Commit edece645 by 张立顺

feat 功能联调

1 parent d3fb5422
...@@ -3,25 +3,29 @@ ...@@ -3,25 +3,29 @@
* 优先使用接口同步后的映射(见 syncStaffSceneLabelList);未加载前使用 LEGACY 兜底。 * 优先使用接口同步后的映射(见 syncStaffSceneLabelList);未加载前使用 LEGACY 兜底。
*/ */
/** @type {Record<number, number>} 冷启动 / 接口未返回前兜底 */ /** baseSceneCode → sceneType,冷启动 / 接口未返回前兜底(一码一型,避免「sceneType 多条共码」反转丢失) */
const LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE = {
100101: 1,
100102: 2,
110101: 2,
110201: 2,
110202: 2,
100103: 3,
120101: 7,
};
/**
* sceneType → 默认 baseSceneCode(与历史 getBaseSceneCodeBySceneType 行为一致:同类型多码时取约定主码)
* 注意:0 与 2 历史上均曾落到 110101,仅作路由/入参默认,细粒度以 baseSceneCode 为准。
*/
const LEGACY_SCENE_TYPE_TO_BASE_SCENE_CODE = { const LEGACY_SCENE_TYPE_TO_BASE_SCENE_CODE = {
0: 110101, 0: 110101,
1: 100101, 1: 100101,
2: 100102,
2: 110202,
2: 110201,
2: 110101, 2: 110101,
3: 100103, 3: 100103,
7: 120101, 7: 120101,
}; };
/** baseSceneCode → scene_type,与 LEGACY 互逆 */
const LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE = Object.fromEntries(
Object.entries(LEGACY_SCENE_TYPE_TO_BASE_SCENE_CODE).map(
([sceneType, code]) => [String(code), Number(sceneType)]
)
);
/** @type {Map<number, number>} sceneType → baseSceneCode(数字),仅 status===1 的接口数据 */ /** @type {Map<number, number>} sceneType → baseSceneCode(数字),仅 status===1 的接口数据 */
let dynamicSceneTypeToBaseSceneCode = new Map(); let dynamicSceneTypeToBaseSceneCode = new Map();
...@@ -86,7 +90,10 @@ export function getSceneTypeByBaseSceneCode(baseSceneCode) { ...@@ -86,7 +90,10 @@ export function getSceneTypeByBaseSceneCode(baseSceneCode) {
return dynamicBaseSceneCodeToSceneType.get(key); return dynamicBaseSceneCodeToSceneType.get(key);
} }
const hit = LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE[key]; const legacyKey = Number.isNaN(n) ? key : n;
const hit =
LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE[legacyKey] ??
LEGACY_BASE_SCENE_CODE_TO_SCENE_TYPE[key];
return hit !== undefined ? hit : NaN; return hit !== undefined ? hit : NaN;
} }
......
...@@ -224,6 +224,7 @@ import financialRulesDetail from "./financialRulesDetail"; ...@@ -224,6 +224,7 @@ import financialRulesDetail from "./financialRulesDetail";
// import _ from "lodash" // import _ from "lodash"
import viewDetail from "./viewDetail"; import viewDetail from "./viewDetail";
import { getSceneTypeByBaseSceneCode } from "@/common/sceneBaseSceneCode"; import { getSceneTypeByBaseSceneCode } from "@/common/sceneBaseSceneCode";
import { normalizeBaseSceneListResponse } from "./merchantGroundingEdit/merchantDetailMap";
export default { export default {
name: "MerchantManage", name: "MerchantManage",
...@@ -608,7 +609,7 @@ export default { ...@@ -608,7 +609,7 @@ export default {
}); });
}, },
}, },
mounted() { async mounted() {
this.userInfo.beSuper this.userInfo.beSuper
&& getParkStore({}).then((res) => { && getParkStore({}).then((res) => {
res.forEach((item) => { res.forEach((item) => {
...@@ -617,7 +618,7 @@ export default { ...@@ -617,7 +618,7 @@ export default {
this.parkServiceList = res; this.parkServiceList = res;
}); });
this.getBaseData(); this.getBaseData();
this.loadBaseSceneFilterOptions(); await this.loadBaseSceneFilterOptions();
this.userTypeList = deepClone(userTypeList).filter( this.userTypeList = deepClone(userTypeList).filter(
item => item.confLabel !== "员工", item => item.confLabel !== "员工",
); );
...@@ -676,7 +677,7 @@ export default { ...@@ -676,7 +677,7 @@ export default {
const merchantId = this.resolveRelationMerchantId(row); const merchantId = this.resolveRelationMerchantId(row);
let scene = Number(row.scene); let scene = Number(row.scene);
if (!Number.isFinite(scene)) { if (!Number.isFinite(scene)) {
scene = getSceneTypeByBaseSceneCode(baseSceneCode); scene = this.resolveSceneTypeByBaseSceneCode(baseSceneCode);
} }
return { return {
merchantId, merchantId,
...@@ -700,6 +701,24 @@ export default { ...@@ -700,6 +701,24 @@ export default {
const c = row.baseSceneCode; const c = row.baseSceneCode;
return c != null && c !== "" ? c : ""; return c != null && c !== "" ? c : "";
}, },
/**
* 列表行 scene 为空时,由 baseSceneCode 推导 scene 大类:
* 先走员工场景映射(getSceneTypeByBaseSceneCode),再用 getBaseSceneCodeList 项上的 sceneType 兜底。
*/
resolveSceneTypeByBaseSceneCode(baseSceneCode) {
if (baseSceneCode == null || baseSceneCode === "") return NaN;
const codeStr = String(baseSceneCode).trim();
if (!codeStr) return NaN;
let st = getSceneTypeByBaseSceneCode(codeStr);
if (Number.isFinite(st)) return st;
const list = this.baseData.baseSceneCodeListForFilter || [];
const hit = list.find(
item => item != null && String(item.baseSceneCode).trim() === codeStr,
);
if (!hit) return NaN;
const fromApi = Number(hit.sceneType);
return Number.isFinite(fromApi) ? fromApi : NaN;
},
/** 二手车收车场景 baseSceneCode=120101,不展示财务/对账 */ /** 二手车收车场景 baseSceneCode=120101,不展示财务/对账 */
isUsedCarCollectionBaseScene(row) { isUsedCarCollectionBaseScene(row) {
return String(this.resolveRowBaseSceneCode(row)) === "120101"; return String(this.resolveRowBaseSceneCode(row)) === "120101";
...@@ -736,8 +755,8 @@ export default { ...@@ -736,8 +755,8 @@ export default {
return ""; return "";
}, },
loadBaseSceneFilterOptions() { loadBaseSceneFilterOptions() {
getBaseSceneCodeList({}).then((res) => { return getBaseSceneCodeList({}).then((res) => {
this.baseData.baseSceneCodeListForFilter = Array.isArray(res) ? res : []; this.baseData.baseSceneCodeListForFilter = normalizeBaseSceneListResponse(res);
this.getOptionsList(); this.getOptionsList();
}); });
}, },
...@@ -1236,7 +1255,7 @@ export default { ...@@ -1236,7 +1255,7 @@ export default {
row = { ...item }; row = { ...item };
} }
if ((row.scene == null || row.scene === "") && row.baseSceneCode != null && row.baseSceneCode !== "") { if ((row.scene == null || row.scene === "") && row.baseSceneCode != null && row.baseSceneCode !== "") {
const st = getSceneTypeByBaseSceneCode(row.baseSceneCode); const st = this.resolveSceneTypeByBaseSceneCode(row.baseSceneCode);
if (Number.isFinite(st)) { if (Number.isFinite(st)) {
row.scene = st; row.scene = st;
} }
...@@ -1285,6 +1304,7 @@ export default { ...@@ -1285,6 +1304,7 @@ export default {
} }
return prev; return prev;
}, []); }, []);
console.log(this.restructureList, 'this.restructureList');
}, },
// 商户关联 // 商户关联
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!