Commit 98c6630a by 张立顺

fix bug

1 parent 4cea7c0d
......@@ -66,6 +66,19 @@ const DEFAULT_MERCHANT_MODEL_LIST = [
const ACCOUNT_LEVEL_LABELS = ["工厂", "省代", "市代", "门店"];
/**
* 上级商户分页 merchants.api.open.findMerchantListByPage 筛选用的 accounttypeId(数组元素)
* 与业务约定:4S店=2,园区店=6,服务商=7(按字典 dictLabel 映射)
*/
const PARENT_MERCHANT_LIST_ACCOUNTTYPE_ID_BY_LABEL = {
"4S店": 2,
"园区店": 6,
"服务商": 7,
};
/** 上级商户列表接口筛选:仅这几种 accounttypeId */
const PARENT_MERCHANT_LIST_ACCOUNTTYPE_IDS = new Set([2, 6, 7]);
/** 与货架 AddMerchant 一致的表单结构;用于客户管理「信息核验」弹窗 */
export function createEmptyMerchantVerifyEditData() {
return {
......@@ -699,6 +712,45 @@ export default {
this.get4sAndServiceMerchantList("store");
}
},
/** 上级商户下拉请求:与本弹窗可选商户类型一致的 accounttypeId 数组 */
getParentMerchantListAccounttypeIds() {
const list = this.baseData.merchantTypeList || [];
const ids = list
.map((row) => {
const n = parseInt(String(row.confId), 10);
if (
!Number.isNaN(n) &&
PARENT_MERCHANT_LIST_ACCOUNTTYPE_IDS.has(n)
) {
return n;
}
const label = String(row.confLabel ?? "").trim();
const byLabel =
PARENT_MERCHANT_LIST_ACCOUNTTYPE_ID_BY_LABEL[label];
if (byLabel != null) return Number(byLabel);
// dictLabel 与约定字面不一致时(含空格、后缀等)
if (
label.includes("园区店") &&
!label.includes("虚拟")
) {
return 6;
}
if (/4\s*[Ss]店/.test(label)) return 2;
if (label.includes("服务商")) return 7;
return null;
})
.filter((id) => id != null);
const unique = [...new Set(ids)];
if (unique.length) return unique;
const sel = parseInt(String(this.editData.accounttypeId), 10);
if (
!Number.isNaN(sel) &&
PARENT_MERCHANT_LIST_ACCOUNTTYPE_IDS.has(sel)
) {
return [sel];
}
return [2, 6, 7];
},
get4sAndServiceMerchantList(searchIndex) {
this.merchantLoading = true;
return new Promise((resolve) => {
......@@ -708,6 +760,7 @@ export default {
pageSize: 50,
merchantModel: this.editData.merchantModel,
accountLevelUpdate: this.editData.merchantAccountLevel,
accounttypeId: this.getParentMerchantListAccounttypeIds(),
})
.then((res) => {
res?.data?.forEach((val) => {
......@@ -737,11 +790,14 @@ export default {
: ["4S店", "园区店", "服务商"];
this.baseData.merchantTypeList = [];
labelOrder.forEach((item) => {
const obj = res.find((k) => k.dictLabel == item);
const want = String(item ?? "").trim();
const obj = res.find(
(k) => String(k.dictLabel ?? "").trim() === want
);
if (obj) {
this.baseData.merchantTypeList.push({
confId: obj.dictValue,
confLabel: obj.dictLabel,
confLabel: String(obj.dictLabel ?? "").trim(),
});
}
});
......
......@@ -61,6 +61,51 @@ function numOrNull(v) {
return Number.isNaN(n) ? null : n;
}
/**
* 详情 queryMerchantDetail.merchantInfo 中与「经营信息区块」一致的字段(与 buildBusinessForm 同源字段名)
*/
const MERCHANT_INFO_BUSINESS_NATIVE_SCALAR_KEYS = [
"deliveryCount",
"customerTouchRate",
"personnelCost",
"rentCost",
"depreciationCost",
"otherCost",
"storeProfitPerCar",
];
/** 从详情 merchantInfo 拾起经营信息标量,保持接口原始类型(不强制 Number) */
function pickMerchantInfoBusinessNativeScalars(mi) {
if (!mi || typeof mi !== "object") return {};
const out = {};
for (const k of MERCHANT_INFO_BUSINESS_NATIVE_SCALAR_KEYS) {
if (Object.prototype.hasOwnProperty.call(mi, k)) {
out[k] = mi[k];
}
}
if (
!Object.prototype.hasOwnProperty.call(out, "depreciationCost") &&
Object.prototype.hasOwnProperty.call(mi, "depreciation")
) {
out.depreciationCost = mi.depreciation;
}
return out;
}
/** 详情原值 + 表单编辑值(后者覆盖);用于经营信息按详情字段名回传 */
function mergeBusinessScalarsWithDetailNative(mi, businessForm) {
return {
...pickMerchantInfoBusinessNativeScalars(mi),
...(businessForm && typeof businessForm === "object" ? businessForm : {}),
};
}
/** 空串转 null,其余保持原样(与详情/表单原生值一致,不整型化) */
function detailScalarSubmitValue(v) {
if (v === "" || v === undefined) return null;
return v;
}
function mapProductDetailBusinessRow(pd) {
const row = {
productType: pd.productType,
......@@ -133,8 +178,11 @@ export function buildMerchantOnShelfOpenPayload(options) {
: null;
const yqName = traffic.yqMerchantName || mi.parkingStoreName || "";
const biz = businessForm || {};
const { djGrossProfit, djGpr, estimatedRevenue } = computeDjMetrics(biz, productDetailsForSubmit);
const bizMerged = mergeBusinessScalarsWithDetailNative(mi, businessForm);
const { djGrossProfit, djGpr, estimatedRevenue } = computeDjMetrics(
bizMerged,
productDetailsForSubmit,
);
const parentSvcId = mi.parentServiceMerchantId;
const trafficPartyBusinessData = {
......@@ -156,16 +204,17 @@ export function buildMerchantOnShelfOpenPayload(options) {
signingEntityName: traffic.signingEntity || "",
businessMode: traffic.businessMode != null ? Number(traffic.businessMode) : null,
operationMode: traffic.operationMode != null ? Number(traffic.operationMode) : null,
storeProfitPerCar: numOrNull(biz.storeProfitPerCar),
// 经营信息:与详情 merchantInfo 字段名一致;标量为详情原生 + 表单覆盖;产值/毛利/毛利率与页面对齐由销售品类计算
deliveryCount: detailScalarSubmitValue(bizMerged.deliveryCount),
customerTouchRate: detailScalarSubmitValue(bizMerged.customerTouchRate),
personnelCost: detailScalarSubmitValue(bizMerged.personnelCost),
rentCost: detailScalarSubmitValue(bizMerged.rentCost),
depreciationCost: detailScalarSubmitValue(bizMerged.depreciationCost),
otherCost: detailScalarSubmitValue(bizMerged.otherCost),
storeProfitPerCar: detailScalarSubmitValue(bizMerged.storeProfitPerCar),
estimatedRevenue,
djGrossProfit,
djGpr,
deliveryCount: numOrNull(biz.deliveryCount),
customerTouchRate: numOrNull(biz.customerTouchRate),
personnelCost: numOrNull(biz.personnelCost),
rentCost: numOrNull(biz.rentCost),
estimatedRevenue: numOrNull(estimatedRevenue),
depreciation: numOrNull(biz.depreciationCost),
otherCost: numOrNull(biz.otherCost),
areaOpId: joinMultiId(traffic, "areaOpIdList", "areaOpId"),
onlineOpId: joinMultiId(traffic, "onlineOpIdList", "onlineOpId"),
regionSupervisorId: joinMultiId(traffic, "regionSupervisorIdList", "regionSupervisorId"),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!