Commit d7759e3b by chenwq

fix(validReferralCount): 修复编辑后数据回显问题

- 新增 editCurScene 状态跟踪当前编辑的业务场景
- 修改 defaultFillVal 方法返回空对象而非空数组
- 新增 dealEditedVal 方法处理编辑后的数据合并逻辑
- 提交时记录当前场景,获取详情时仅更新对应场景数据
1 parent 8084b019
......@@ -8,7 +8,12 @@ Page({
data: {
routerParams: {},
detailInfo: {},
loading: false
loading: false,
/** 本次草稿/提交的业务场景
* 1-精品升级(轻改);2-会员权益(广联权益);3-单延保;
* 用于存草稿/提交后,仅更新当前的场景值
*/
editCurScene: null
},
/**
......@@ -28,7 +33,7 @@ Page({
defaultFillVal(data) {
data.sceneTypeEffectiveReferrals.forEach(item => {
// updateFlag 是否可编辑:0-不可编辑,1-可编辑(优先级最高)
// 状态:0-未提交,1-草稿,2-已提交
// status状态:0-未提交,1-草稿,2-已提交
if (item.status == 0 && data.updateFlag == 1) {
if (item.effectiveReferralCountDTOS && item.effectiveReferralCountDTOS.length) {
item.effectiveReferralCountDTOS.forEach(k => {
......@@ -37,23 +42,43 @@ Page({
}
}
})
return data || []
return data || {}
},
dealEditedVal(data) {
let { editCurScene, detailInfo } = this.data
console.log(detailInfo)
// updateFlag 是否可编辑:0-不可编辑,1-可编辑(优先级最高)
// status状态:0-未提交,1-草稿,2-已提交
if (data.updateFlag == 1) {
detailInfo.sceneTypeEffectiveReferrals.forEach((item, idx) => {
let obj = data.sceneTypeEffectiveReferrals.find(k => k.sceneType == item.sceneType)
if(editCurScene == item.sceneType || item.status == 2) {
detailInfo.sceneTypeEffectiveReferrals[idx] = obj
}
})
} else {
detailInfo = data
}
return detailInfo || {}
},
// Simulate fetching data from backend
getDetail() {
let { merchantId, reviewMonth } = this.data.routerParams
let { editCurScene } = this.data
const params = {
merchantId,
reviewMonth
}
api.getReferralDetail(params).then(res => {
let { code, data, message } = res;
console.log(data)
console.log(data, editCurScene)
if (code == 0) {
let list = this.defaultFillVal(data)
let list = editCurScene != null ? this.dealEditedVal(data) : this.defaultFillVal(data)
this.setData({
detailInfo: list
detailInfo: list,
editCurScene: null
})
}
})
......@@ -94,7 +119,8 @@ Page({
console.log(params, 'params---')
wx.$util.showLoading()
this.setData({
loading: true
loading: true,
editCurScene: updatedItem.sceneType || null
})
api.referralSubmit(params).then(res => {
let { code, data, message } = res
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!