Commit 0df3b769 by 张立顺

fix bug

1 parent 92a6b532
import { baseConfig } from "@/main";
import request from "./request"; import request from "./request";
const path = "dj.api."; const path = "dj.api.";
...@@ -168,13 +167,13 @@ export function productUpdate(data) { ...@@ -168,13 +167,13 @@ export function productUpdate(data) {
// 查询接待素材商户配置 // 查询接待素材商户配置
export function materialPage(data) { export function materialPage(data) {
data.method = `dj.api.smartcarlife.recepiton.material.page`; data.method = `dj.api.smartcarlife.recepiton.material.page`;
return request(data, "post", [], { url: baseConfig.axios8.baseURL }); return request(data, "post", [], "", "/rop-dj-car-boutique/router");
} }
// 查询门店接待素材详情 // 查询门店接待素材详情
export function materialDetail(data) { export function materialDetail(data) {
data.method = `dj.api.smartcarlife.recepiton.material.merchant.detail`; data.method = `dj.api.smartcarlife.recepiton.material.merchant.detail`;
return request(data, "post", [], { url: baseConfig.axios8.baseURL }); return request(data, "post", [], "", "/rop-dj-car-boutique/router");
} }
// 获取车系列表 // 获取车系列表
export function listBrandWithSeries(data) { export function listBrandWithSeries(data) {
...@@ -185,7 +184,7 @@ export function listBrandWithSeries(data) { ...@@ -185,7 +184,7 @@ export function listBrandWithSeries(data) {
// 保存更新门店接待素材 // 保存更新门店接待素材
export function recepitonUpdate(data) { export function recepitonUpdate(data) {
data.method = `dj.api.smartcarlife.recepiton.material.merchant.saveOrUpdate`; data.method = `dj.api.smartcarlife.recepiton.material.merchant.saveOrUpdate`;
return request(data, "post", [], { url: baseConfig.axios8.baseURL }); return request(data, "post", [], "", "/rop-dj-car-boutique/router");
} }
// 保存更新门店接待素材 // 保存更新门店接待素材
export function findDictData(data) { export function findDictData(data) {
......
import { baseConfig } from "@/main" import request from "./request";
import request from "./request" const path = "dj.api.inviteRecord.";
const path = "dj.api.inviteRecord." const pathInviteRecord = "dj.api.smartcarlife.inviteRecord.";
const pathInviteRecord = "dj.api.smartcarlife.inviteRecord." const pathDj = "dj.api.smartcarlife.";
const pathDj = "dj.api.smartcarlife."
// 待预约、已预约总数查询 // 待预约、已预约总数查询
export function getTotalCount (data) { export function getTotalCount(data) {
data.method = `${path}count` data.method = `${path}count`;
return request(data) return request(data);
} }
// 待预约、已预约总数查询 // 待预约、已预约总数查询
export function getList (data) { export function getList(data) {
data.method = `${path}search` data.method = `${path}search`;
return request(data) return request(data);
} }
// 预约记录列表查询 // 预约记录列表查询
export function queryInviteRecord (data) { export function queryInviteRecord(data) {
data.method = `${pathInviteRecord}query` data.method = `${pathInviteRecord}query`;
return request(data) return request(data);
} }
// 预约记录总数查询 // 预约记录总数查询
export function inviteRecordCount (data) { export function inviteRecordCount(data) {
data.method = `${pathInviteRecord}count` data.method = `${pathInviteRecord}count`;
return request(data) return request(data);
} }
// 门店下拉列表查询 // 门店下拉列表查询
export function getInviteMerchant (data) { export function getInviteMerchant(data) {
data.method = `${pathInviteRecord}merchant.page` data.method = `${pathInviteRecord}merchant.page`;
return request(data) return request(data);
} }
// 查询1.1场景登录权限下园区店信息 // 查询1.1场景登录权限下园区店信息
export function yqMerchantPage (data) { export function yqMerchantPage(data) {
data.method = `dj.api.sceneMerchantRef.shopMerchant.LoginPermissionYqMerchant.page` data.method = `dj.api.sceneMerchantRef.shopMerchant.LoginPermissionYqMerchant.page`;
return request(data) return request(data);
} }
// 工位设置查询 // 工位设置查询
export function inviteStationSetGet (data) { export function inviteStationSetGet(data) {
data.method = `${pathDj}inviteStationSet.get` data.method = `${pathDj}inviteStationSet.get`;
return request(data) return request(data);
} }
// 获取指定商户指定日期范围的邀约统计 // 获取指定商户指定日期范围的邀约统计
export function inviteStatMerchantList (data) { export function inviteStatMerchantList(data) {
data.method = `dj.api.smartcarlife.inviteStat.merchant.list` data.method = `dj.api.smartcarlife.inviteStat.merchant.list`;
return request(data) return request(data);
} }
// 工位设置修改 // 工位设置修改
export function inviteStationSetUpdate (data) { export function inviteStationSetUpdate(data) {
data.method = `${pathDj}inviteStationSet.update` data.method = `${pathDj}inviteStationSet.update`;
return request(data) return request(data);
} }
// 修改备注 // 修改备注
export function followRecordUpdate (data) { export function followRecordUpdate(data) {
data.method = `${pathInviteRecord}followRecord.update` data.method = `${pathInviteRecord}followRecord.update`;
return request(data) return request(data);
} }
// 修改预约时间 // 修改预约时间
export function dateUpdate (data) { export function dateUpdate(data) {
data.method = `${pathInviteRecord}invite.dateUpdate` data.method = `${pathInviteRecord}invite.dateUpdate`;
return request(data) return request(data);
} }
// 取消预约 // 取消预约
export function cancelInvite (data) { export function cancelInvite(data) {
data.method = `${pathInviteRecord}cancelInvite` data.method = `${pathInviteRecord}cancelInvite`;
return request(data) return request(data);
} }
/** /**
* 跟进记录 * 跟进记录
*/ */
export function followRecordListUpdate (data) {
data.method = 'dj.api.smartcarlife.invite.followRecord.update'
return request(data, "post", [], { url: baseConfig.axios8.baseURL })
}
\ No newline at end of file \ No newline at end of file
export function followRecordListUpdate(data) {
data.method = "dj.api.smartcarlife.invite.followRecord.update";
return request(data, "post", [], "", "boutique");
}
...@@ -1243,40 +1243,57 @@ export default { ...@@ -1243,40 +1243,57 @@ export default {
}, },
}, },
data() { data() {
/** 开启扣除(Y) 时要求比例非空且为合法数字,避免 undefined/null 误判为已填 */
const rateFilled = (v) => {
if (v === null || v === undefined) return false;
const s = String(v).trim();
if (s === "") return false;
return !Number.isNaN(Number(s));
};
let validatorFormGoodsCostConvertRate = (rule, value, callback) => { let validatorFormGoodsCostConvertRate = (rule, value, callback) => {
if (this.classificationObj.goodsCostConvertRate != "" || this.classificationObj.goodsCostFlag == "N") { if (this.classificationObj.goodsCostFlag === "N") {
callback(); callback();
} else { return;
callback(new Error("请输入折算比例"));
} }
rateFilled(this.classificationObj.goodsCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
}; };
let validatorForm1 = (rule, value, callback) => { let validatorForm1 = (rule, value, callback) => {
if (this.classificationObj.virtualAccountCostConvertRate != "" || this.classificationObj.virtualAccountCostFlag == "N") { if (this.classificationObj.virtualAccountCostFlag === "N") {
callback(); callback();
} else { return;
callback(new Error("请输入折算比例"));
} }
rateFilled(this.classificationObj.virtualAccountCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
}; };
let validatorForm2 = (rule, value, callback) => { let validatorForm2 = (rule, value, callback) => {
if (this.classificationObj.recoveryCostConvertRate != "" || this.classificationObj.recoveryCostFlag == "N") { if (this.classificationObj.recoveryCostFlag === "N") {
callback(); callback();
} else { return;
callback(new Error("请输入折算比例"));
} }
rateFilled(this.classificationObj.recoveryCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
}; };
let validatorForm3 = (rule, value, callback) => { let validatorForm3 = (rule, value, callback) => {
if (this.classificationObj.djCostConvertRate != "" || this.classificationObj.djCostFlag == "N") { if (this.classificationObj.djCostFlag === "N") {
callback(); callback();
} else { return;
callback(new Error("请输入折算比例"));
} }
rateFilled(this.classificationObj.djCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
}; };
let validatorForm4 = (rule, value, callback) => { let validatorForm4 = (rule, value, callback) => {
if (this.classificationObj.thirdPartyCostConvertRate != "" || this.classificationObj.thirdPartyCostFlag == "N") { if (this.classificationObj.thirdPartyCostFlag === "N") {
callback(); callback();
} else { return;
callback(new Error("请输入折算比例"));
} }
rateFilled(this.classificationObj.thirdPartyCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
}; };
return { return {
channelSelectDialogVisible: false, channelSelectDialogVisible: false,
...@@ -2166,7 +2183,7 @@ export default { ...@@ -2166,7 +2183,7 @@ export default {
initList() { initList() {
this._suppressSelectionSync = true; this._suppressSelectionSync = true;
try { try {
this.classificationObj.groupType = this.paneIndex ? 1 : 2; this.classificationObj.groupType = this.paneIndex === 0 ? 1 : 2;
// this.goodsTypeGroupRules // this.goodsTypeGroupRules
const expenseCategoryRules const expenseCategoryRules
= deepClone(this.goodsTypeGroupRules.expenseCategoryRules) || []; = deepClone(this.goodsTypeGroupRules.expenseCategoryRules) || [];
...@@ -2701,24 +2718,53 @@ export default { ...@@ -2701,24 +2718,53 @@ export default {
goodsTypeGroupRelations, goodsTypeGroupRelations,
}; };
}, },
async handleConfirm() { handleConfirm() {
return new Promise((resolve, reject) => { return new Promise((resolve) => {
this.$refs.classification.validate(async (valid) => { if (!this.$refs.classification) {
// console.log(valid) resolve(false);
if (valid) { return;
// console.log(this.getParams()) }
const obj = this.getParams(); // 勿用 async 作为 validate 回调:避免与 Element 表单校验时序叠加后下方表单项未标红
const res = await this.$refs.tableAccount.handleConfirm(); this.$refs.classification.validate((valid) => {
const res2 = await this.$refs.tableAccount.handleConfirm2(); if (!valid) {
res && res2 this.$nextTick(() => this.scrollClassificationFirstError());
? resolve({ ...obj, merchantDistributionRules: res, owningMerchantDistributionRules: res2 })
: resolve(false);
} else {
resolve(false); resolve(false);
return;
} }
const obj = this.getParams();
const ta = this.$refs.tableAccount;
if (!ta) {
resolve(false);
return;
}
ta.handleConfirm().then((res) => {
if (!res) {
resolve(false);
return;
}
ta.handleConfirm2().then((res2) => {
if (!res2) {
resolve(false);
return;
}
resolve({
...obj,
merchantDistributionRules: res,
owningMerchantDistributionRules: res2,
});
});
});
}); });
}); });
}, },
scrollClassificationFirstError() {
const form = this.$refs.classification;
if (!form || !form.fields) return;
const first = form.fields.find((f) => f.validateState === 'error');
if (first && first.$el) {
first.$el.scrollIntoView({ block: 'center', behavior: 'smooth' });
}
},
getClassificationParams() { getClassificationParams() {
const obj = this.getParams(); const obj = this.getParams();
const res = this.$refs.tableAccount.getTableAccountParams(); const res = this.$refs.tableAccount.getTableAccountParams();
......
...@@ -335,31 +335,83 @@ export default { ...@@ -335,31 +335,83 @@ export default {
// console.log('validField', validField) // console.log('validField', validField)
this.$refs.divisionRuleRef2.clearValidate(validField) this.$refs.divisionRuleRef2.clearValidate(validField)
}, },
/** validate 通过后兜底:每行须能解析出 merchantId(与快路径 distributionRulesLookComplete 一致) */
distributionRowsHaveMerchantId(rows) {
if (!Array.isArray(rows) || rows.length === 0) return false
return rows.every((r) => {
if (!r || typeof r !== 'object') return false
const mid = r.merchantId
return mid !== '' && mid !== undefined && mid !== null
})
},
/** 选项变更后 id 不在 tableSelectOptions 时 Element 仍可能视为有值;清空以便 required 标红 */
normalizeInvalidDistributionSelection(formObj, radioList, rows) {
radioList.forEach((next, idx) => {
const row = rows[idx]
const bad = !row || row.merchantId === '' || row.merchantId === undefined || row.merchantId === null
if (!bad) return
const key = 'id' + next.expenseCategoryId
const id = formObj[key]
if (id === '' || id === undefined || id === null) return
const merchantObj = this.tableSelectOptions.find(item => item.merchantId == id)
if (!merchantObj) {
this.$set(formObj, key, '')
}
})
},
scrollToFirstError(preferredRefKey) {
const scrollForm = (key) => {
const form = this.$refs[key]
if (!form || !form.fields) return false
const first = form.fields.find(
(f) => f.validateState === 'error' || (f.validateMessage && String(f.validateMessage).length)
)
if (first && first.$el) {
first.$el.scrollIntoView({ block: 'center', behavior: 'smooth' })
return true
}
return false
}
this.$nextTick(() => {
if (preferredRefKey && scrollForm(preferredRefKey)) return
scrollForm('divisionRuleRef2') || scrollForm('divisionRuleRef')
})
},
handleConfirm2() { handleConfirm2() {
// console.log(this.merchantInfo) // console.log(this.merchantInfo)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$refs.divisionRuleRef2.validate(valid => { this.$refs.divisionRuleRef2.validate(valid => {
if (valid) { if (!valid) {
// this.form this.scrollToFirstError('divisionRuleRef2')
const merchantDistributionRules = this.radioList2.reduce((prev, next) => {
const id = this.form2['id' + next.expenseCategoryId]
// console.log(id)
const merchantObj = this.tableSelectOptions.find(item => item.merchantId == id)
// console.log(merchantObj, 'merchantObj')
next = {
...next,
expenseCategoryId: next.expenseCategoryId,
...merchantObj
}
// console.log(next, 'next')
// const name = 'id' + next.id
// prev[name] = this.form[name]
prev.push(next)
return prev
}, [])
resolve(merchantDistributionRules)
} else {
resolve(false) resolve(false)
return
}
const merchantDistributionRules = this.radioList2.reduce((prev, next) => {
const id = this.form2['id' + next.expenseCategoryId]
const merchantObj = this.tableSelectOptions.find(item => item.merchantId == id)
next = {
...next,
expenseCategoryId: next.expenseCategoryId,
...merchantObj
}
prev.push(next)
return prev
}, [])
if (!this.distributionRowsHaveMerchantId(merchantDistributionRules)) {
this.normalizeInvalidDistributionSelection(
this.form2,
this.radioList2,
merchantDistributionRules
)
this.$nextTick(() => {
this.$refs.divisionRuleRef2.validate(() => {
this.scrollToFirstError('divisionRuleRef2')
})
})
this.$message.warning('请完善费用归属设置中的分账方')
resolve(false)
} else {
resolve(merchantDistributionRules)
} }
}) })
} }
...@@ -400,27 +452,37 @@ export default { ...@@ -400,27 +452,37 @@ export default {
// console.log(this.merchantInfo) // console.log(this.merchantInfo)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$refs.divisionRuleRef.validate(valid => { this.$refs.divisionRuleRef.validate(valid => {
if (valid) { if (!valid) {
// this.form this.scrollToFirstError('divisionRuleRef')
const merchantDistributionRules = this.radioList.reduce((prev, next) => { resolve(false)
const id = this.form['id' + next.expenseCategoryId] return
// console.log(id) }
const merchantObj = this.tableSelectOptions.find(item => item.merchantId == id) const merchantDistributionRules = this.radioList.reduce((prev, next) => {
// console.log(merchantObj, 'merchantObj') const id = this.form['id' + next.expenseCategoryId]
next = { const merchantObj = this.tableSelectOptions.find(item => item.merchantId == id)
...next, next = {
expenseCategoryId: next.expenseCategoryId, ...next,
...merchantObj expenseCategoryId: next.expenseCategoryId,
} ...merchantObj
// console.log(next, 'next') }
// const name = 'id' + next.id prev.push(next)
// prev[name] = this.form[name] return prev
prev.push(next) }, [])
return prev if (!this.distributionRowsHaveMerchantId(merchantDistributionRules)) {
}, []) this.normalizeInvalidDistributionSelection(
resolve(merchantDistributionRules) this.form,
} else { this.radioList,
merchantDistributionRules
)
this.$nextTick(() => {
this.$refs.divisionRuleRef.validate(() => {
this.scrollToFirstError('divisionRuleRef')
})
})
this.$message.warning('请完善实际分账设置中的分账方')
resolve(false) resolve(false)
} else {
resolve(merchantDistributionRules)
} }
}) })
} }
......
...@@ -567,6 +567,25 @@ export default { ...@@ -567,6 +567,25 @@ export default {
return false return false
}, },
/** /**
* 缓存快路径专用:分账表须非空且每行带有效 merchantId(含 -1 等合法值),否则须走慢路径做 Element 校验。
*/
distributionRulesLookComplete(rule) {
const md = rule.merchantDistributionRules
const od = rule.owningMerchantDistributionRules
if (!Array.isArray(md) || !Array.isArray(od)) return false
if (md.length === 0 || od.length === 0) return false
const rowOk = (rows) =>
rows.every(
(r) =>
r &&
typeof r === "object" &&
r.merchantId !== "" &&
r.merchantId !== undefined &&
r.merchantId !== null
)
return rowOk(md) && rowOk(od)
},
/**
* 判断是否允许 getGoodsTypeGroupRules 走「缓存快路径」(不切 Tab、不调 handleConfirm)。 * 判断是否允许 getGoodsTypeGroupRules 走「缓存快路径」(不切 Tab、不调 handleConfirm)。
* *
* 背景:虚拟 Tab 下一旦 editableTabsValue 切换到某页,子组件必挂载,原 else 分支里 * 背景:虚拟 Tab 下一旦 editableTabsValue 切换到某页,子组件必挂载,原 else 分支里
...@@ -578,7 +597,8 @@ export default { ...@@ -578,7 +597,8 @@ export default {
if (!rule || typeof rule !== "object") return false if (!rule || typeof rule !== "object") return false
if (!Array.isArray(rule.merchantDistributionRules)) return false if (!Array.isArray(rule.merchantDistributionRules)) return false
if (!Array.isArray(rule.owningMerchantDistributionRules)) return false if (!Array.isArray(rule.owningMerchantDistributionRules)) return false
return this.hasEchoedGoodsTypeGroupRulePayload(rule) if (!this.hasEchoedGoodsTypeGroupRulePayload(rule)) return false
return this.distributionRulesLookComplete(rule)
}, },
/** 为 Tab 补上 revision 字段(getFinancialObj / addTab / removeTab 已初始化为 0,此处兜底)。 */ /** 为 Tab 补上 revision 字段(getFinancialObj / addTab / removeTab 已初始化为 0,此处兜底)。 */
ensureTabRevisionFields(tab) { ensureTabRevisionFields(tab) {
...@@ -1227,7 +1247,8 @@ export default { ...@@ -1227,7 +1247,8 @@ export default {
* *
* 【快路径】当 testFlag=Y、ruleCacheRevision===confirmedRuleCacheRevision 且 canSubmitFromCacheForFastPath * 【快路径】当 testFlag=Y、ruleCacheRevision===confirmedRuleCacheRevision 且 canSubmitFromCacheForFastPath
* 通过时:不对 editableTabsValue 赋该 Tab、不挂载 classificationCpt,直接 deepClone 财务缓存, * 通过时:不对 editableTabsValue 赋该 Tab、不挂载 classificationCpt,直接 deepClone 财务缓存,
* 再 fillDjGoodsTypeGroupRelations。revision 语义见 persistClassificationTabByPaneName / bump / sync。 * 再 fillDjGoodsTypeGroupRelations。特殊品类(groupType===2)永不走快路径,须 handleConfirm。
* revision 语义见 persistClassificationTabByPaneName / bump / sync。
* *
* 【慢路径】否则:持久化当前页 → 切换目标 Tab → 双 nextTick 等待挂载 → handleConfirm 或旧版缓存兜底。 * 【慢路径】否则:持久化当前页 → 切换目标 Tab → 双 nextTick 等待挂载 → handleConfirm 或旧版缓存兜底。
* 成功后 syncTabConfirmedRuleRevisionByIndex,使该 Tab 下次在满足条件时可快走。 * 成功后 syncTabConfirmedRuleRevisionByIndex,使该 Tab 下次在满足条件时可快走。
...@@ -1291,9 +1312,15 @@ export default { ...@@ -1291,9 +1312,15 @@ export default {
const cachedRule = this.financialObj.goodsTypeGroupRules[tabindex] const cachedRule = this.financialObj.goodsTypeGroupRules[tabindex]
this.ensureTabRevisionFields(tab) this.ensureTabRevisionFields(tab)
// 特殊品类(groupType===2)保存前须走慢路径执行 handleConfirm;否则用户未切换 Tab 时仅 deepClone 会跳过整表校验
const isSpecialCategoryRule =
cachedRule &&
typeof cachedRule === "object" &&
Number(cachedRule.groupType) === 2
// 快路径条件集:见本方法文件头 JSDoc;缺一不可,否则必须慢路径以保证与 handleConfirm 等价 // 快路径条件集:见本方法文件头 JSDoc;缺一不可,否则必须慢路径以保证与 handleConfirm 等价
const useFastPath = const useFastPath =
tab && tab &&
!isSpecialCategoryRule &&
tab.testFlag === "Y" && tab.testFlag === "Y" &&
cachedRule && cachedRule &&
typeof cachedRule === "object" && typeof cachedRule === "object" &&
...@@ -1321,21 +1348,16 @@ export default { ...@@ -1321,21 +1348,16 @@ export default {
await this.$nextTick() await this.$nextTick()
} }
this.editableTabsValue = nextName this.editableTabsValue = nextName
await this.$nextTick() // 虚拟 Tab 切换后 ref 可能晚于 nextTick 就绪;若用缓存 deepClone 会跳过 handleConfirm,
await this.$nextTick() // 编辑态下特殊品类等必填未校验也能过(原 allowByTestFlag / allowByEditEcho 回退)。
const MAX_CLASSIFICATION_REF_WAIT = 24
node = this.getClassificationRef(panes[index].name) for (let attempt = 0; attempt < MAX_CLASSIFICATION_REF_WAIT; attempt++) {
if (node) { await this.$nextTick()
node = this.getClassificationRef(panes[index].name)
if (node) break
}
if (node && typeof node.handleConfirm === "function") {
res = await node.handleConfirm() res = await node.handleConfirm()
} else if (cachedRule && typeof cachedRule === "object") {
const allowByTestFlag = tab?.testFlag === "Y"
const allowByEditEcho =
!!this.financialObj?.divisionRuleId &&
this.hasEchoedGoodsTypeGroupRulePayload(cachedRule)
res =
allowByTestFlag || allowByEditEcho
? deepClone(cachedRule)
: false
} else { } else {
res = false res = false
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!