Commit 7223c705 by 前端

解决sop旧数据展示问题

1 parent ae0e3ce7
......@@ -62,7 +62,7 @@
</glsx-combi-form>
</div>
</div>
<div class="container edit-container">
<div class="container edit-container" v-loading="marketingEventLoading">
<div class="edit-title flex" style="align-items: center">
<p>营销事件设置</p>
<el-tooltip :disabled="!(!editForm.customerInfoList.length || !editForm.sopName)" effect="dark"
......@@ -81,7 +81,8 @@
<div v-show="editForm.eventList.length" class="event-box">
<div class="event-item" v-for="(item, index) in editForm.eventList" :key="index">
<div class="flex-default event-title">
<p :class="{'m-r-10':true,'editFlag':!item.eventStartDate}">{{ item.eventStartDate ? item.eventStartDate : '请点击“编辑”完善事件的营销时间' }}</p>
<p :class="{'m-r-10':true,'editFlag':!item.eventStartDate}">
{{ item.eventStartDate ? item.eventStartDate : '请点击“编辑”完善事件的营销时间' }}</p>
<p class="m-r-20">{{ item.eventTime }}</p>
<p class="m-r-20" v-show="item.repeatFlag == 'Y' && item.repeatMode == 1">每天重复循环至</p>
<p class="m-r-20" v-show="item.repeatFlag == 'Y' && item.repeatMode == 2">每周{{
......@@ -113,12 +114,13 @@
<div class="welcome-activity-box">
<div class="welcome-activity-icon">
<img src="@/assets/welcomeWord/pdf_r.png"
v-if="obj.attContent && !JSON.parse(obj.attContent).isFile"/>
v-if="obj.attContent && !backupContentJson(obj.attContent).isFile"/>
<img src="@/assets/welcomeWord/text.png"
v-if="obj.attContent && JSON.parse(obj.attContent).isFile"/>
v-if="obj.attContent && backupContentJson(obj.attContent).isFile"/>
</div>
<div class="welcome-activity-desc">
<div class="model-item-title">{{ JSON.parse(obj.attContent).fileName }}</div>
<div class="model-item-title">{{ backupContentJson(obj.attContent).fileName }}</div>
</div>
</div>
</div>
......@@ -241,6 +243,7 @@ export default {
size: 'small',
title: '基本信息',
url: url,
marketingEventLoading: false,
editChildRef: 'editChildRef',
editStatus: false,
editDisabled: false,
......@@ -390,7 +393,14 @@ export default {
confName: '微信朋友圈'
}
]
}
},
// 素材活动集合
materialGroupSet: [],
equityCardCollection: [],
equityPackageCollection: [],
mallCouponCollection: [],
seckillActivitySet: []
}
},
......@@ -423,17 +433,60 @@ export default {
},
mounted() {
async mounted() {
this.setMinHeight('.sop-base-info')
// this.routeInfo.addOrEdit == 'edit'
await this.getTheMaterialActivityCollection()
if (['edit', 'copy', 'look'].includes(this.routeInfo.addOrEdit)) {
this.getInfo()
} else if (this.routeInfo.info) {
this.setCustomer()
}
},
methods: {
async getTheMaterialActivityCollection() {
await this.$apis.welcomeword.getMaterialListApi({
pageNum: 1,
pageSize: 100000,
merchant: this.$globalState.session.merchantId,
status: 0
}).then(res =>
this.materialGroupSet = res.data
)
},
async getEachActivity(interfaceName) {
let params = {
pageNum: 1,
pageSize: 100000,
}
// 权益卡
if (interfaceName == 'merchant') {
params.tryAble = 1
params.merchantId = this.$globalState.session.merchantId
}
if (interfaceName == 'getActivity') {
params.currentPage = 1
}
await this.$apis.welcomeword[interfaceName](params).then(res => {
switch (interfaceName) {
case 'merchant':
this.equityCardCollection = res
break;
case 'getPackage':
this.equityPackageCollection = res.list
break;
case 'getMerchant':
this.mallCouponCollection = res.list
break;
case 'getActivity':
this.seckillActivitySet = res.list
}
})
},
tramWord(val) {
let htm = val.replace(
/\[([\u4E00-\u9FA56]{1,4}|OK|NO|666)]/gi,
......@@ -566,13 +619,147 @@ export default {
}
},
async processOldSOPData(list, index) {
for (let i = 0; i < list['eventList'].length; i++) {
let item = list.eventList[i]
if (!item.backupContent) {
this.marketingEventLoading = true
let backUpContent = []
// 文本
backUpContent.push({attType: 1, attContent: item.eventContent})
// 图片
if (item.additionalType == 5 && item.objectType == 11) {
let imgResourceList = item.object && item.object.result.map(img => img.content)
imgResourceList.forEach(resource => {
backUpContent.push({attType: 2, attContent: resource})
})
}
// 视频
if (item.additionalType == 5 && item.objectType == 12) {
let videoResourceList = item.object && item.object.result.map(img => img.content)
backUpContent.push({attType: 3, attContent: videoResourceList})
}
// 活动-权益卡试用
if (item.additionalType == 2 && item.objectType == 6) {
await this.getEachActivity('merchant')
let activity = this.equityCardCollection && this.equityCardCollection.filter(it => it.equityClassId == item.objectId)
let {effectivedDay, equityClassId, effectiveType, equityName, freeDay} = activity[0]
backUpContent.push({
attType: 7,
attContent: {
marketingId: equityClassId,
marketingType: effectiveType,
marketingName: equityName,
marketingContent: {
equityName,
effectivedDay,
effectiveType,
freeDay,
selectType: 'card',
}
}
})
}
// 活动-权益套餐
if (item.additionalType == 2 && item.objectType == 7) {
await this.getEachActivity('getPackage')
let getPackage = this.equityPackageCollection && this.equityPackageCollection.filter(it => it.id == item.objectId)
let {id, packagePrice, packageName} = getPackage[0]
backUpContent.push({
attType: 7,
attContent: {
marketingId: id,
// marketingType: effectiveType,
marketingName: packageName,
marketingContent: {
packageName,
packagePrice,
selectType: 'package',
}
}
})
}
// 活动-商城券
if (item.additionalType == 3 && item.objectType == 5) {
await this.getEachActivity('getMerchant')
let coupon = this.mallCouponCollection && this.mallCouponCollection.filter(it => it.id == item.objectId)
let {id, couponName, effectiveType, residueAmount} = coupon[0]
backUpContent.push({
attType: 7,
attContent: {
marketingId: id,
marketingType: effectiveType,
marketingName: couponName,
marketingContent: {
couponName,
effectiveType,
residueAmount,
selectType: 'coupon',
}
}
})
}
// 活动-秒杀活动
if (item.additionalType == 2 && item.objectType == 8) {
await this.getEachActivity('getActivity')
let activity = this.seckillActivitySet && this.seckillActivitySet.filter(it => it.id == item.objectId)
let {id, activityName, startTime, endTime} = activity[0]
backUpContent.push({
attType: 7,
attContent: {
marketingId: id,
// marketingType: effectiveType,
marketingName: activityName,
marketingContent: {
activityName,
endTime,
startTime,
selectType: 'activity',
}
}
})
}
// 素材
if (item.additionalType == 1 && item.objectType == 10) {
let material = this.materialGroupSet && this.materialGroupSet.filter(it => it.id == item.objectId)
let {id, materialContentRpcResponse} = material[0]
let detail = {
'fileName': materialContentRpcResponse.materialName,
'objectId': id,
'isFile': decodeURIComponent(materialContentRpcResponse.materialUrl),
}
backUpContent.push({
attType: 6,
attContent: JSON.stringify(detail)
})
}
list.eventList[i].backupContent = backUpContent
}
}
return list
},
getInfo() {
this.$apis.sop.getSopInfoDetailApi({sopId: this.routeInfo.id}).then(res => {
this.$apis.sop.getSopInfoDetailApi({sopId: this.routeInfo.id}).then(async res => {
if (this.routeInfo.addOrEdit == 'copy') {
res.eventList && res.eventList.map(item => {
item.eventStartDate = ''
item.eventTime = ''
})
// 判断有没有旧数据
await this.processOldSOPData(res).then(res => {
this.marketingEventLoading = false
})
this.editForm.eventList = res.eventList
} else {
this.editForm = res
......@@ -1416,7 +1603,8 @@ export default {
margin-top: 8px;
display: inline-block
}
.editFlag{
.editFlag {
color: #f56c6c;
font-size: 12px;
}
......
......@@ -126,7 +126,6 @@ export default {
})
item.attContent = htm
} else if (item.attType != 2 && item.attType != 3 && item.attType != 7) {
// console.log(item.attContent, JSON.parse(item.attContent).fileName)
item.attContent = JSON.parse(item.attContent)
}
})
......@@ -134,7 +133,6 @@ export default {
},
previewVal: {
handler(val) {
console.log(val)
this.previewList = utils.deepClone(val).filter(item => item.attContent)
},
deep: true
......
......@@ -594,7 +594,6 @@ export default {
setTimeout(() => {
this.previewList = JSON.parse(JSON.stringify(this.previewList))
})
},
},
......@@ -608,6 +607,7 @@ export default {
},
mounted() {
Object.assign(this.editForm, this.eventObj.info)
this.getStaffTypeList()
this.$nextTick(() => {
......@@ -722,13 +722,12 @@ export default {
let backupContent = typeof (this.editForm.backupContent) == 'string' ? JSON.parse(this.editForm.backupContent) : this.editForm.backupContent
if (backupContent) {
const previewList = backupContent.map(item => {
// JSON.parse(item.attContent)
if (item.attType == 7) item.attContent = typeof (item.attContent) == 'string' ? JSON.parse(item.attContent) : item.attContent
return item
})
this.$refs.welcome.updateList(previewList)
} else if (this.editForm.object && this.editForm.object.length != 0) {
const previewList = JSON.parse(this.editForm.backupContent).map(item => {
const previewList = JSON.parse(backupContent).map(item => {
if (item.attType == 7) item.attContent = typeof (item.attContent) == 'string' ? JSON.parse(item.attContent) : item.attContent
return item
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!