Commit dc13cea0 by chenwq Committed by 杨北旺

编辑sop-添加事件

1 parent f7f33727
<!-- 编辑sop --> <!-- 编辑sop -->
<template> <template>
<div class="sop-base-info marketing p-t-20 edit-box"> <div class="marketing p-t-20 edit-box">
<div class="container edit-container"> <div class="sop-base-info" v-show="activeName == 'baseInfo'">
<div class="container m-b-20">
<p class="edit-title">{{ title }}</p> <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"> <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"> <div slot="customerList">
...@@ -19,6 +20,19 @@ ...@@ -19,6 +20,19 @@
</div> </div>
</glsx-combi-form> </glsx-combi-form>
</div> </div>
<div class="container edit-container">
<div class="edit-title flex" style="align-items: center;">
<p>营销事件设置</p>
<el-button class="m-r-20" :size="size" type="primary" @click="handleEventEdit('add')">添加事件</el-button>
</div>
<div v-show="!editForm.eventList.length" class="event-empty">
<img class="empty-img" :src="url" />
<p class="empty-txt">暂无营销事件</p>
</div>
<div v-show="editForm.eventList.length"></div>
</div>
</div>
<edit-event v-show="activeName == 'editEvent'"></edit-event>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }"> <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="primary" @click="handleConfirm">确定</el-button> <el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button> <el-button type="default" @click="handleCancel">取消</el-button>
...@@ -28,13 +42,17 @@ ...@@ -28,13 +42,17 @@
</template> </template>
<script> <script>
import url from "@/assets/empty.png"
import SelectLabel from './components/selectLabel.vue' import SelectLabel from './components/selectLabel.vue'
import editEvent from './editEvent'
export default { export default {
name: 'baseInfo', name: 'baseInfo',
data() { data() {
return { return {
size: 'small', size: 'small',
title: '基本信息', title: '基本信息',
url: url,
activeName: 'baseInfo',
// titleObj: { // titleObj: {
// add: '新增信息', // add: '新增信息',
// edit: '编辑信息' // edit: '编辑信息'
...@@ -57,7 +75,8 @@ export default { ...@@ -57,7 +75,8 @@ export default {
sopTime: '2022-01-01', sopTime: '2022-01-01',
// tagging: [], // tagging: [],
customerList: [], customerList: [],
customerIds: [] customerIds: [],
eventList: []
}, },
editRule: { editRule: {
sopName: [{ required: true, message: '请输入sop名称', trigger: 'change' }], sopName: [{ required: true, message: '请输入sop名称', trigger: 'change' }],
...@@ -87,7 +106,8 @@ export default { ...@@ -87,7 +106,8 @@ export default {
}, },
components: { components: {
SelectLabel SelectLabel,
editEvent
}, },
props: { props: {
...@@ -171,6 +191,10 @@ export default { ...@@ -171,6 +191,10 @@ export default {
this.$refs.editFormRef.$refs[this.editChildRef].validateField('customerList') this.$refs.editFormRef.$refs[this.editChildRef].validateField('customerList')
}, },
handleEventEdit(addOrEdit, row) {
this.activeName = 'editEvent'
},
handleConfirm() { handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => { this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) { if (valid) {
...@@ -196,7 +220,12 @@ export default { ...@@ -196,7 +220,12 @@ export default {
path: '/sop/index' path: '/sop/index'
}) })
}, },
handleCancel() { handleCancel() {
if (this.activeName == 'editEvent') {
this.activeName = 'baseInfo'
return false
}
if (this.editStatus) { if (this.editStatus) {
this.$confirm('当前有内容信息未保存,是否继续返回?', '提示', { this.$confirm('当前有内容信息未保存,是否继续返回?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
...@@ -251,5 +280,17 @@ export default { ...@@ -251,5 +280,17 @@ export default {
} }
} }
} }
.event-empty {
height: 234px;
text-align: center;
.empty-img {
margin: 80px 0 12px;
}
.empty-txt {
color: #000000;
font-size: 14px;
opacity: 0.65;
}
}
} }
</style> </style>
<!-- 编辑sop - 添加事件 -->
<template>
<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"></glsx-combi-form>
</div>
</template>
<script>
export default {
name: 'editGift',
data() {
return {
size: 'small',
title: '新增信息',
titleObj: {
add: '新增信息',
edit: '编辑信息'
},
footerLeft: '0',
footerWidth: '0',
editChildRef: 'editChildRef',
routeInfo: {
// add-新增;edit-编辑;look-查看
addOrEdit: 'add',
id: ''
},
editStatus: false,
labelWidth: '144px',
editForm: {
// 专区类型(1发现频道,2商城专区)
zoneType: '2',
zoneName: '',
zoneImg: '',
merchantList: []
},
editRule: {
zoneName: [{ required: true, message: '请输入专区名称', trigger: 'change' }],
zoneImg: [{ required: true, message: '请选择专区图片', trigger: 'change' }],
merchantList: [{ required: true, message: '请选择门店', trigger: 'change' }]
},
isEdit: true,
editFormData: [
{
label: '专区名称',
name: 'zoneName',
type: 'input',
maxlength: 20
},
{
label: '专区图片',
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: {
editForm: {
handler(val) {
this.editStatus = true
},
deep: true
}
},
mounted() {
this.footerLeft = document.querySelector('.base-container-right').offsetLeft
this.footerWidth = document.documentElement.clientWidth - this.footerLeft
this.routeInfo = this.$route.query
console.log(this.routeInfo.addOrEdit)
this.title = this.titleObj[this.routeInfo.addOrEdit]
this.routeInfo.addOrEdit != 'add' ? this.getInfo() : ''
},
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 = []
// 专区类型(1发现频道,2商城专区)
params.zoneType = '2'
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: '/giftBag/index'
// })
},
handleCancel() {
if (this.editStatus) {
this.$confirm('当前有内容信息未保存,是否继续返回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.cancelJump()
})
.catch(() => { })
} else {
this.cancelJump()
}
}
}
}
</script>
<style scoped>
.marketing.edit-gift .select-merchant {
/* width: calc(98% - 140px); */
width: 98%;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!