Commit fbdd12b2 by chenwq

sop编辑-基本信息

1 parent a7d0f9ab
...@@ -28,6 +28,12 @@ module.exports = { ...@@ -28,6 +28,12 @@ module.exports = {
// 返回数据类型 // 返回数据类型
responseType: 'json' responseType: 'json'
}, },
request2: {
timeout: 180000,
baseURL: 'http://ismv.branch.glsx.com.cn',
responseType: 'json',
withCredentials: true
},
sign: { sign: {
appKey: '48e5e13229b82c1b4e6e8c96151f0637', appKey: '48e5e13229b82c1b4e6e8c96151f0637',
v: '1.0.0', v: '1.0.0',
......
<!-- 编辑sop -->
<template> <template>
<div class="edit-gift marketing p-t-20 edit-box"> <div>
<div class="container edit-container"> <base-info v-show="activeName == 'baseInfo'" :routeInfo="routeInfo"></base-info>
<p class="edit-title">{{ title }}</p> <edit-event v-show="activeName == 'editEvent'"></edit-event>
<glsx-combi-form class="edit-form-container m-r-20" ref="editFormRef" :isEdit="isEdit" :labelWidth="labelWidth" defaultWidth="320px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"></glsx-combi-form>
</div>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
</div> </div>
</template> </template>
<script> <script>
import baseInfo from './editSop/baseInfo'
import editEvent from './editSop/editEvent'
export default { export default {
name: 'editGift', name: 'editSop',
data() { data() {
return { return {
size: 'small', activeName: 'baseInfo',
title: '新增信息',
titleObj: {
add: '新增信息',
edit: '编辑信息'
},
footerLeft: '0',
footerWidth: '0',
editChildRef: 'editChildRef',
routeInfo: { routeInfo: {
// add-新增;edit-编辑;look-查看 // add-新增;edit-编辑;look-查看
addOrEdit: 'add', addOrEdit: 'add',
id: '' id: ''
},
editStatus: false,
labelWidth: '144px',
editForm: {
zoneName: '',
zoneImg: '',
merchantList: []
},
editRule: {
zoneName: [{ required: true, message: '请输入sop名称', trigger: 'change' }],
zoneImg: [{ required: true, message: '请选择sop图片', trigger: 'change' }],
merchantList: [{ required: true, message: '请选择门店', trigger: 'change' }]
},
isEdit: true,
editFormData: [
{
label: 'sop名称',
name: 'zoneName',
type: 'input',
maxlength: 20
},
{
label: 'sop图片',
name: 'zoneImg',
type: 'upload',
limitSize: 10,
maxPhotoNum: 1,
handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result
const base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
this.$apis.common.uploadImgApi({ file: base64, fileType: 'image' }).then(res => {
this.editForm[targetItem.name] = res
this.$refs.editFormRef.$refs[this.editChildRef].validateField(targetItem.name)
})
}
} }
]
} }
}, },
watch: { components: {
editForm: { baseInfo,
handler(val) { editEvent
this.editStatus = true
},
deep: true
}
}, },
mounted() { mounted() {
this.footerLeft = document.querySelector('.base-container-right').offsetLeft
this.footerWidth = document.documentElement.clientWidth - this.footerLeft
this.routeInfo = this.$route.query this.routeInfo = this.$route.query
console.log(this.routeInfo.addOrEdit)
this.title = this.titleObj[this.routeInfo.addOrEdit]
this.routeInfo.addOrEdit != 'add' ? this.getInfo() : ''
}, },
methods: { methods: {}
getInfo() {
// this.$apis.zoneList.getZoneInfoApi({ id: this.routeInfo.id }).then(res => {
// this.editForm.zoneName = res.zoneName
// this.editForm.zoneImg = res.zoneImg
// this.editForm.merchantList = res.merchantRefList
// this.editForm.merchantList.forEach(item => {
// item.merchantNo = item.merchantId
// })
// this.$nextTick(() => {
// this.editStatus = false
// })
// })
},
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var params = this.$common.utils.deepClone(this.editForm)
if (this.routeInfo.addOrEdit == 'edit') {
params.id = this.routeInfo.id
}
params.merchantList = []
this.editForm.merchantList.forEach(item => {
params.merchantList.push({
merchantId: item.merchantNo,
merchantName: item.merchantName,
merchantAccountLevel: item.merchantAccountLevel
})
})
// console.log(params)
this.$apis.zoneList.insertZoneApi(params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.cancelJump()
}
})
}
})
},
cancelJump() {
this.$router.push({
path: '/sop/index'
})
},
handleCancel() {
if (this.editStatus) {
this.$confirm('当前有内容信息未保存,是否继续返回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.cancelJump()
})
.catch(() => { })
} else {
this.cancelJump()
}
}
}
} }
</script> </script>
<style scoped>
.marketing.edit-gift .select-merchant { <style lang="scss">
/* width: calc(98% - 140px); */
width: 98%;
}
</style> </style>
<!-- 编辑sop -->
<template> <template>
<div></div> <div class="edit-gift marketing p-t-20 edit-box">
<div class="container edit-container">
<p class="edit-title">{{ title }}</p>
<glsx-combi-form class="edit-form-container m-r-20" ref="editFormRef" :isEdit="isEdit" :labelWidth="labelWidth" defaultWidth="320px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<div slot="customerList">
<el-button class="default-blue-btn" :size="size" @click="handleSelectCustomer">选择客户</el-button>
<el-button :size="size" @click="handleResetCostomer">重置客户</el-button>
<!-- <div v-show="editForm.customerList.length != 0" :key="key" class="el-input-tag input-tag-wrapper">
<span v-for="(tag, idx) in tagging" :key="idx">
<el-tag v-for="(tagItem, idx1) in tag.labelList" :key="idx1" :size="size" type="info" closable :disable-transitions="false" @close="removeTag(tag, idx1, idx)">{{ tagItem.name }}</el-tag>
</span>
</div> -->
</div>
</glsx-combi-form>
</div>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
<SelectLabel ref="selectLabel" @tagSelected="handleSelect" :dialogVisible="isTagVisible"></SelectLabel>
</div>
</template> </template>
<script> <script>
import SelectLabel from './components/selectLabel.vue'
export default { export default {
name: 'baseInfo', name: 'baseInfo',
data() { data() {
return {} return {
size: 'small',
title: '基本信息',
// titleObj: {
// add: '新增信息',
// edit: '编辑信息'
// },
footerLeft: '0',
footerWidth: '0',
editChildRef: 'editChildRef',
editStatus: false,
labelWidth: '144px',
// 标签弹窗
isTagVisible: false,
tagging: [],
editForm: {
sopName: '',
sopTime: '2022-01-01',
// tagging: [],
customerList: [],
customerIds: []
}, },
mounted() { }, editRule: {
methods: {} sopName: [{ required: true, message: '请输入sop名称', trigger: 'change' }],
sopTime: [{ required: true, message: '请选择营销时间', trigger: 'change' }],
customerList: [{ required: true, message: '请选择营销对象', trigger: 'change' }],
},
isEdit: true,
editFormData: [
{
label: 'sop名称',
name: 'sopName',
type: 'input',
maxlength: 20
},
{
label: '营销时间',
name: 'sopTime',
type: 'showTxt'
},
{
label: '营销对象',
name: 'customerList',
addHtml: 'customerList'
}
]
}
},
components: {
SelectLabel
},
props: {
routeInfo: {
type: Object,
default: () => {
return {
// add-新增;edit-编辑;look-查看
addOrEdit: 'add',
id: ''
}
}
}
},
watch: {
editForm: {
handler(val) {
this.editStatus = true
},
deep: true
}
},
mounted() {
this.footerLeft = document.querySelector('.base-container-right').offsetLeft
this.footerWidth = document.documentElement.clientWidth - this.footerLeft
console.log(this.routeInfo.addOrEdit)
this.routeInfo.addOrEdit != 'add' ? this.getInfo() : ''
},
methods: {
getInfo() {
// this.$apis.zoneList.getZoneInfoApi({ id: this.routeInfo.id }).then(res => {
// this.editForm.sopName = res.sopName
// this.$nextTick(() => {
// this.editStatus = false
// })
// })
},
// 选择标签
handleSelect(val) {
this.isUpdate = true
this.tagging = val
let arr = []
this.tagging.forEach(item => {
item.labelList.forEach(tag => {
arr.push({
groupId: item.labelGroup.id,
groupName: item.labelGroup.name,
labelId: tag.id,
labelName: tag.name,
groupType: item.labelType
})
})
})
this.taggingList = arr
console.log(this.taggingList)
// this.taggingList = val
console.log(val, '1')
console.log(this.tagging, '2')
},
handleSelectCustomer() {
this.isTagVisible = !this.isTagVisible
this.$refs.selectLabel.init(this.tagging)
console.log(this.isTagVisible)
},
handleResetCostomer() { },
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var params = this.$common.utils.deepClone(this.editForm)
if (this.routeInfo.addOrEdit == 'edit') {
params.id = this.routeInfo.id
}
// console.log(params)
this.$apis.zoneList.insertZoneApi(params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.cancelJump()
}
})
}
})
},
cancelJump() {
this.$router.push({
path: '/sop/index'
})
},
handleCancel() {
if (this.editStatus) {
this.$confirm('当前有内容信息未保存,是否继续返回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.cancelJump()
})
.catch(() => { })
} else {
this.cancelJump()
}
}
}
} }
</script> </script>
<style scoped>
<style> .marketing.edit-gift .select-merchant {
/* width: calc(98% - 140px); */
width: 98%;
}
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!