Commit db4c878c by 张立顺

fix 自测bug修复

1 parent 51047b64
......@@ -535,6 +535,80 @@ export default {
this.persistClassificationTabByPaneName(this.editableTabsValue)
},
/**
* 虚拟 Tab 下仅当前页挂载 classificationCpt,其它页的勾选不会触发 assign* emit,
* goodsSelectList 等与跨 Tab 禁用不同步。从 goodsTypeGroupRules 全量聚合已选品类/商品/套餐,
* 供「分账品类」下拉的禁用逻辑使用。
*/
rebuildCrossTabGoodsSelectionsFromRules() {
const rules = this.financialObj && this.financialObj.goodsTypeGroupRules
if (!Array.isArray(rules) || !rules.length) {
this.goodsSelectList = []
this.selectUpgradeGoodsList = []
this.selectPackageGoodsList = []
return
}
const hashG = {}
const hashU = {}
const hashP = {}
const goodsAgg = []
const upgradeAgg = []
const packageAgg = []
const pushG = (item) => {
if (!item || item.goodsType == null) return
const k = item.goodsType
if (!hashG[k]) {
hashG[k] = true
goodsAgg.push(deepClone(item))
}
}
const pushU = (item) => {
if (!item || item.upgradeGoodsId == null) return
const k = item.upgradeGoodsId
if (!hashU[k]) {
hashU[k] = true
upgradeAgg.push(deepClone(item))
}
}
const pushP = (item) => {
if (!item || item.packageCode == null) return
const k = item.packageCode
if (!hashP[k]) {
hashP[k] = true
packageAgg.push(deepClone(item))
}
}
for (let i = 0; i < rules.length; i++) {
const rule = rules[i]
if (!rule || typeof rule !== "object") continue
let g = Array.isArray(rule.goodsTypes) ? rule.goodsTypes : []
let u = Array.isArray(rule.upgradeGoods) ? rule.upgradeGoods : []
let pRaw = rule.packageGoods
let pList = []
if (Array.isArray(pRaw)) pList = pRaw
else if (pRaw && typeof pRaw === "object") pList = [pRaw]
const rel = rule.goodsTypeGroupRelations
if (
Array.isArray(rel) &&
rel.length &&
!g.length &&
!u.length &&
!pList.length
) {
const inferred = rel[0] && rel[0].categoryType
const ct = inferred != null ? inferred : rule.categoryType
if (ct === 2) u = rel
else if (ct === 3) pList = rel
else g = rel
}
g.forEach(pushG)
u.forEach(pushU)
pList.forEach(pushP)
}
this.goodsSelectList = goodsAgg
this.selectUpgradeGoodsList = upgradeAgg
this.selectPackageGoodsList = packageAgg
},
/**
* 判断 goodsTypeGroupRules 中单条规则是否像「已落库/接口回显」的完整数据(而非新增 tab 的空壳)。
* 用于编辑态下:非激活 tab 无法走子组件 handleConfirm,但 testFlag 可能仍为 N(未做分账测试等),
* 此时仍需允许用 financialObj 缓存提交,否则会出现「页面上已回显完整规则却提示请完善分账规则」。
......@@ -834,6 +908,7 @@ export default {
this.editableTabsValue = this.editableTabs[0].name
this.currentIndex = this.editableTabsValue
}
this.rebuildCrossTabGoodsSelectionsFromRules()
resolve()
})
.catch(() => {
......@@ -1199,6 +1274,7 @@ export default {
await this.$nextTick()
}
this.rebuildCrossTabGoodsSelectionsFromRules()
resolve(goodsTypeGroupRules)
} catch (e) {
reject(e)
......@@ -1441,6 +1517,7 @@ export default {
.then(() => this.$nextTick())
.then(() => {
this.persistClassificationTabByPaneName(oldName)
this.rebuildCrossTabGoodsSelectionsFromRules()
finish()
})
}
......@@ -1543,19 +1620,13 @@ export default {
const packageArr = []
this.editableTabs = []
// console.log(goodsTypeGroupRules, "goodsTypeGroupRules")
const childParams = goodsTypeGroupRules.splice(tabIndex, 1)
goodsTypeGroupRules.splice(tabIndex, 1)
// console.log(goodsTypeGroupRules, this.financialObj, "goodsTypeGroupRules")
// console.log(childParams, "packageArr")
// return
this.$nextTick(() => {
// const { autoFlag } = this.financialObj
this.$set(this.financialObj, "goodsTypeGroupRules", goodsTypeGroupRules)
this.deleteSelectGoodsTypeList(childParams[0].goodsTypes)
this.deleteSelectUpgradeGoodsList(
childParams[0].goodsTypeGroupRelations
)
this.deleteSelectPackageGoodsList(childParams[0].packageGoods)
goodsTypeGroupRules &&
goodsTypeGroupRules.forEach((item, index) => {
this.editableTabs[index] = {
......@@ -1615,6 +1686,7 @@ export default {
// 获取商品
this.getSelectingList(upgradeArr)
this.getSelectingListPackage(packageArr)
this.rebuildCrossTabGoodsSelectionsFromRules()
// this.$forceUpdate()
this.$message({
type: "success",
......
......@@ -59,6 +59,12 @@
</template>
<script>
/**
* 商户对账编辑页(merchantCheck)
* 后续优化要点(对应规划 A 段):sceneLabel 计算属性、productType 浅监听、allSettled 并行加载、
* 费用类别 Promise.all、getAllReconciliationParams 免克隆 Tab 元数据、persist 单次深拷贝合并、
* uniqueBy 去重、errorIndex + focusTabByErrorIndex、子组件见 merchantStep/components/classificationCpt.vue(B 段)。
*/
import { deepClone } from "@/common/util"
import { sceneList } from "@/common/constants"
import {
......@@ -155,7 +161,8 @@ export default {
},
created() {
this.getRowItem()
this.getQueryFeeCategoryByType() // 获取费用类别
// A4:异步方法,不 await,与 mounted 数据加载并行;内部已 try/catch 三路费用接口
void this.getQueryFeeCategoryByType()
},
async mounted() {
this.addContactgetReconciliationHistoryRecordApi()
......@@ -226,6 +233,82 @@ export default {
this.persistClassificationTabByPaneName(this.editableTabsValue)
},
/**
* 虚拟 Tab 下仅当前页挂载 classificationCpt,其它页的勾选不会触发 assign* emit,
* goodsSelectList 等与跨 Tab 禁用不同步。从 goodsTypeGroupReconciliationRules 聚合已选品类/商品/套餐
* (对账侧品类存在 goodsTypeGroupRelations,须按 categoryType 取值,避免与 upgradeGoods 重复计数)。
*/
rebuildCrossTabGoodsSelectionsFromRules() {
const rules = this.goodsTypeGroupReconciliationRules
if (!Array.isArray(rules) || !rules.length) {
this.goodsSelectList = []
this.selectUpgradeGoodsList = []
this.selectPackageGoodsList = []
return
}
const goodsAgg = []
const upgradeAgg = []
const packageAgg = []
const pushG = (item) => {
if (!item || item.goodsType == null) return
goodsAgg.push(deepClone(item))
}
const pushU = (item) => {
if (!item || item.upgradeGoodsId == null) return
upgradeAgg.push(deepClone(item))
}
const pushP = (item) => {
if (!item || item.packageCode == null) return
packageAgg.push(deepClone(item))
}
for (let i = 0; i < rules.length; i++) {
const rule = rules[i]
if (!rule || typeof rule !== "object") continue
const ct = rule.categoryType
const rel = Array.isArray(rule.goodsTypeGroupRelations)
? rule.goodsTypeGroupRelations
: []
const ug = Array.isArray(rule.upgradeGoods) ? rule.upgradeGoods : []
const pRaw = rule.packageGoods
const pg = Array.isArray(pRaw)
? pRaw
: pRaw && typeof pRaw === "object"
? [pRaw]
: []
const gt = Array.isArray(rule.goodsTypes) ? rule.goodsTypes : []
if (ct === 1) {
;(rel.length ? rel : gt).forEach(pushG)
} else if (ct === 2) {
;(ug.length ? ug : rel).forEach(pushU)
} else if (ct === 3) {
;(pg.length ? pg : rel).forEach(pushP)
} else {
if (ug.length) ug.forEach(pushU)
else if (pg.length) pg.forEach(pushP)
else if (rel.length) {
const inf = rel[0] && rel[0].categoryType
if (inf === 2) rel.forEach(pushU)
else if (inf === 3) rel.forEach(pushP)
else rel.forEach(pushG)
} else if (gt.length) {
gt.forEach(pushG)
}
}
}
this.goodsSelectList = uniqueBy(goodsAgg, (x) => x.goodsType)
this.selectUpgradeGoodsList = uniqueBy(
upgradeAgg,
(x) => x && x.upgradeGoodsId
)
this.selectPackageGoodsList = uniqueBy(
packageAgg,
(x) => x && x.packageCode
)
},
/**
* 嘀加商品来源 + 特殊品类(groupType===2):缓存里可能仅有 goodsTypes/upgradeGoods/packageGoods,
* 没有 goodsTypeGroupRelations;非激活 Tab 走缓存提交时补齐,与财务分账页 fillDjGoodsTypeGroupRelations 一致。
*/
......@@ -398,6 +481,7 @@ export default {
await this.$nextTick()
}
this.rebuildCrossTabGoodsSelectionsFromRules()
return goodsTypeGroupRules
},
// 是否在选择时添加 %号
......@@ -512,7 +596,8 @@ export default {
})
.then((res) => {
this.allPages = res.pages
const resArr = res.list.reduce((arr, val) => {
// A3:list / upgradeGoodsList 缺省时兜底,避免单条脏数据打断整页
const resArr = (res.list || []).reduce((arr, val) => {
;(val.upgradeGoodsList || []).forEach((el) => {
const item = {}
const { upgradeGoodsName, id, commodityCode } = el
......@@ -586,6 +671,7 @@ export default {
.then(() => this.$nextTick())
.then(() => {
this.persistClassificationTabByPaneName(oldName)
this.rebuildCrossTabGoodsSelectionsFromRules()
finish()
})
}
......@@ -670,14 +756,10 @@ export default {
const upgradeArr = []
const packageArr = []
this.editableTabs = []
const childParams = goodsTypeGroupRules.splice(removeIdx, 1)
goodsTypeGroupRules.splice(removeIdx, 1)
// this.$set(this.goodsTypeGroupReconciliationRules, goodsTypeGroupRules)
this.$nextTick(() => {
this.goodsTypeGroupReconciliationRules = goodsTypeGroupRules
const removed = childParams[0] || {}
this.deleteSelectGoodsList(removed.goodsTypeGroupRelations)
this.deleteSelectUpgradeGoodsList(removed.upgradeGoods)
this.deleteSelectPackageGoodsList(removed.packageGoods)
const typeList = goodsTypeGroupRules
const newLen = typeList.length
......@@ -698,6 +780,7 @@ export default {
})
this.getSelectingList(upgradeArr)
this.getSelectingListPackage(packageArr)
this.rebuildCrossTabGoodsSelectionsFromRules()
// this.queryFeeCategoryByTypeFlow = deepClone(this.queryFeeCategoryByTypeFlow)
this.$message({
type: "success",
......@@ -815,9 +898,11 @@ export default {
this.getSelectingList(upgradeArr)
this.getSelectingListPackage(packageArr)
}
this.rebuildCrossTabGoodsSelectionsFromRules()
} else {
this.getSelectingList()
this.getSelectingListPackage()
this.rebuildCrossTabGoodsSelectionsFromRules()
}
},
checkParamsType(array) {
......
/**
* B4(长期):与 financialRules 等页的同类归一逻辑可逐步迁入本目录或 merchant/shared,避免多处拷贝。
*/
import { deepClone } from "@/common/util"
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!