Commit 0df3b769 by 张立顺

fix bug

1 parent 92a6b532
import { baseConfig } from "@/main";
import request from "./request";
const path = "dj.api.";
......@@ -168,13 +167,13 @@ export function productUpdate(data) {
// 查询接待素材商户配置
export function materialPage(data) {
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) {
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) {
......@@ -185,7 +184,7 @@ export function listBrandWithSeries(data) {
// 保存更新门店接待素材
export function recepitonUpdate(data) {
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) {
......
import { baseConfig } from "@/main"
import request from "./request"
const path = "dj.api.inviteRecord."
const pathInviteRecord = "dj.api.smartcarlife.inviteRecord."
const pathDj = "dj.api.smartcarlife."
import request from "./request";
const path = "dj.api.inviteRecord.";
const pathInviteRecord = "dj.api.smartcarlife.inviteRecord.";
const pathDj = "dj.api.smartcarlife.";
// 待预约、已预约总数查询
export function getTotalCount (data) {
data.method = `${path}count`
return request(data)
export function getTotalCount(data) {
data.method = `${path}count`;
return request(data);
}
// 待预约、已预约总数查询
export function getList (data) {
data.method = `${path}search`
return request(data)
export function getList(data) {
data.method = `${path}search`;
return request(data);
}
// 预约记录列表查询
export function queryInviteRecord (data) {
data.method = `${pathInviteRecord}query`
return request(data)
export function queryInviteRecord(data) {
data.method = `${pathInviteRecord}query`;
return request(data);
}
// 预约记录总数查询
export function inviteRecordCount (data) {
data.method = `${pathInviteRecord}count`
return request(data)
export function inviteRecordCount(data) {
data.method = `${pathInviteRecord}count`;
return request(data);
}
// 门店下拉列表查询
export function getInviteMerchant (data) {
data.method = `${pathInviteRecord}merchant.page`
return request(data)
export function getInviteMerchant(data) {
data.method = `${pathInviteRecord}merchant.page`;
return request(data);
}
// 查询1.1场景登录权限下园区店信息
export function yqMerchantPage (data) {
data.method = `dj.api.sceneMerchantRef.shopMerchant.LoginPermissionYqMerchant.page`
return request(data)
export function yqMerchantPage(data) {
data.method = `dj.api.sceneMerchantRef.shopMerchant.LoginPermissionYqMerchant.page`;
return request(data);
}
// 工位设置查询
export function inviteStationSetGet (data) {
data.method = `${pathDj}inviteStationSet.get`
return request(data)
export function inviteStationSetGet(data) {
data.method = `${pathDj}inviteStationSet.get`;
return request(data);
}
// 获取指定商户指定日期范围的邀约统计
export function inviteStatMerchantList (data) {
data.method = `dj.api.smartcarlife.inviteStat.merchant.list`
return request(data)
export function inviteStatMerchantList(data) {
data.method = `dj.api.smartcarlife.inviteStat.merchant.list`;
return request(data);
}
// 工位设置修改
export function inviteStationSetUpdate (data) {
data.method = `${pathDj}inviteStationSet.update`
return request(data)
export function inviteStationSetUpdate(data) {
data.method = `${pathDj}inviteStationSet.update`;
return request(data);
}
// 修改备注
export function followRecordUpdate (data) {
data.method = `${pathInviteRecord}followRecord.update`
return request(data)
export function followRecordUpdate(data) {
data.method = `${pathInviteRecord}followRecord.update`;
return request(data);
}
// 修改预约时间
export function dateUpdate (data) {
data.method = `${pathInviteRecord}invite.dateUpdate`
return request(data)
export function dateUpdate(data) {
data.method = `${pathInviteRecord}invite.dateUpdate`;
return request(data);
}
// 取消预约
export function cancelInvite (data) {
data.method = `${pathInviteRecord}cancelInvite`
return request(data)
export function cancelInvite(data) {
data.method = `${pathInviteRecord}cancelInvite`;
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
export function followRecordListUpdate(data) {
data.method = "dj.api.smartcarlife.invite.followRecord.update";
return request(data, "post", [], "", "boutique");
}
......@@ -1243,40 +1243,57 @@ export default {
},
},
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) => {
if (this.classificationObj.goodsCostConvertRate != "" || this.classificationObj.goodsCostFlag == "N") {
if (this.classificationObj.goodsCostFlag === "N") {
callback();
} else {
callback(new Error("请输入折算比例"));
return;
}
rateFilled(this.classificationObj.goodsCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
};
let validatorForm1 = (rule, value, callback) => {
if (this.classificationObj.virtualAccountCostConvertRate != "" || this.classificationObj.virtualAccountCostFlag == "N") {
if (this.classificationObj.virtualAccountCostFlag === "N") {
callback();
} else {
callback(new Error("请输入折算比例"));
return;
}
rateFilled(this.classificationObj.virtualAccountCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
};
let validatorForm2 = (rule, value, callback) => {
if (this.classificationObj.recoveryCostConvertRate != "" || this.classificationObj.recoveryCostFlag == "N") {
if (this.classificationObj.recoveryCostFlag === "N") {
callback();
} else {
callback(new Error("请输入折算比例"));
return;
}
rateFilled(this.classificationObj.recoveryCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
};
let validatorForm3 = (rule, value, callback) => {
if (this.classificationObj.djCostConvertRate != "" || this.classificationObj.djCostFlag == "N") {
if (this.classificationObj.djCostFlag === "N") {
callback();
} else {
callback(new Error("请输入折算比例"));
return;
}
rateFilled(this.classificationObj.djCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
};
let validatorForm4 = (rule, value, callback) => {
if (this.classificationObj.thirdPartyCostConvertRate != "" || this.classificationObj.thirdPartyCostFlag == "N") {
if (this.classificationObj.thirdPartyCostFlag === "N") {
callback();
} else {
callback(new Error("请输入折算比例"));
return;
}
rateFilled(this.classificationObj.thirdPartyCostConvertRate)
? callback()
: callback(new Error("请输入折算比例"));
};
return {
channelSelectDialogVisible: false,
......@@ -2166,7 +2183,7 @@ export default {
initList() {
this._suppressSelectionSync = true;
try {
this.classificationObj.groupType = this.paneIndex ? 1 : 2;
this.classificationObj.groupType = this.paneIndex === 0 ? 1 : 2;
// this.goodsTypeGroupRules
const expenseCategoryRules
= deepClone(this.goodsTypeGroupRules.expenseCategoryRules) || [];
......@@ -2701,24 +2718,53 @@ export default {
goodsTypeGroupRelations,
};
},
async handleConfirm() {
return new Promise((resolve, reject) => {
this.$refs.classification.validate(async (valid) => {
// console.log(valid)
if (valid) {
// console.log(this.getParams())
const obj = this.getParams();
const res = await this.$refs.tableAccount.handleConfirm();
const res2 = await this.$refs.tableAccount.handleConfirm2();
res && res2
? resolve({ ...obj, merchantDistributionRules: res, owningMerchantDistributionRules: res2 })
: resolve(false);
} else {
handleConfirm() {
return new Promise((resolve) => {
if (!this.$refs.classification) {
resolve(false);
return;
}
// 勿用 async 作为 validate 回调:避免与 Element 表单校验时序叠加后下方表单项未标红
this.$refs.classification.validate((valid) => {
if (!valid) {
this.$nextTick(() => this.scrollClassificationFirstError());
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() {
const obj = this.getParams();
const res = this.$refs.tableAccount.getTableAccountParams();
......
......@@ -335,31 +335,83 @@ export default {
// console.log('validField', 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() {
// console.log(this.merchantInfo)
return new Promise((resolve, reject) => {
this.$refs.divisionRuleRef2.validate(valid => {
if (valid) {
// this.form
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 {
if (!valid) {
this.scrollToFirstError('divisionRuleRef2')
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 {
// console.log(this.merchantInfo)
return new Promise((resolve, reject) => {
this.$refs.divisionRuleRef.validate(valid => {
if (valid) {
// this.form
const merchantDistributionRules = this.radioList.reduce((prev, next) => {
const id = this.form['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 {
if (!valid) {
this.scrollToFirstError('divisionRuleRef')
resolve(false)
return
}
const merchantDistributionRules = this.radioList.reduce((prev, next) => {
const id = this.form['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.form,
this.radioList,
merchantDistributionRules
)
this.$nextTick(() => {
this.$refs.divisionRuleRef.validate(() => {
this.scrollToFirstError('divisionRuleRef')
})
})
this.$message.warning('请完善实际分账设置中的分账方')
resolve(false)
} else {
resolve(merchantDistributionRules)
}
})
}
......
......@@ -567,6 +567,25 @@ export default {
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)。
*
* 背景:虚拟 Tab 下一旦 editableTabsValue 切换到某页,子组件必挂载,原 else 分支里
......@@ -578,7 +597,8 @@ export default {
if (!rule || typeof rule !== "object") return false
if (!Array.isArray(rule.merchantDistributionRules)) 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,此处兜底)。 */
ensureTabRevisionFields(tab) {
......@@ -1227,7 +1247,8 @@ export default {
*
* 【快路径】当 testFlag=Y、ruleCacheRevision===confirmedRuleCacheRevision 且 canSubmitFromCacheForFastPath
* 通过时:不对 editableTabsValue 赋该 Tab、不挂载 classificationCpt,直接 deepClone 财务缓存,
* 再 fillDjGoodsTypeGroupRelations。revision 语义见 persistClassificationTabByPaneName / bump / sync。
* 再 fillDjGoodsTypeGroupRelations。特殊品类(groupType===2)永不走快路径,须 handleConfirm。
* revision 语义见 persistClassificationTabByPaneName / bump / sync。
*
* 【慢路径】否则:持久化当前页 → 切换目标 Tab → 双 nextTick 等待挂载 → handleConfirm 或旧版缓存兜底。
* 成功后 syncTabConfirmedRuleRevisionByIndex,使该 Tab 下次在满足条件时可快走。
......@@ -1291,9 +1312,15 @@ export default {
const cachedRule = this.financialObj.goodsTypeGroupRules[tabindex]
this.ensureTabRevisionFields(tab)
// 特殊品类(groupType===2)保存前须走慢路径执行 handleConfirm;否则用户未切换 Tab 时仅 deepClone 会跳过整表校验
const isSpecialCategoryRule =
cachedRule &&
typeof cachedRule === "object" &&
Number(cachedRule.groupType) === 2
// 快路径条件集:见本方法文件头 JSDoc;缺一不可,否则必须慢路径以保证与 handleConfirm 等价
const useFastPath =
tab &&
!isSpecialCategoryRule &&
tab.testFlag === "Y" &&
cachedRule &&
typeof cachedRule === "object" &&
......@@ -1321,21 +1348,16 @@ export default {
await this.$nextTick()
}
this.editableTabsValue = nextName
await this.$nextTick()
await this.$nextTick()
node = this.getClassificationRef(panes[index].name)
if (node) {
// 虚拟 Tab 切换后 ref 可能晚于 nextTick 就绪;若用缓存 deepClone 会跳过 handleConfirm,
// 编辑态下特殊品类等必填未校验也能过(原 allowByTestFlag / allowByEditEcho 回退)。
const MAX_CLASSIFICATION_REF_WAIT = 24
for (let attempt = 0; attempt < MAX_CLASSIFICATION_REF_WAIT; attempt++) {
await this.$nextTick()
node = this.getClassificationRef(panes[index].name)
if (node) break
}
if (node && typeof node.handleConfirm === "function") {
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 {
res = false
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!