Commit 1620ae95 by 张立顺

feat 功能联调

1 parent b5cccf56
...@@ -272,6 +272,16 @@ export default { ...@@ -272,6 +272,16 @@ export default {
return option?.label || (i.viewKey && this.componentData[i.viewKey]) || value || '-' return option?.label || (i.viewKey && this.componentData[i.viewKey]) || value || '-'
}, },
getMultipleSelectText (i) { getMultipleSelectText (i) {
const nameByListKey = {
areaOpIdList: 'areaOpName',
onlineOpIdList: 'onlineOpName',
regionSupervisorIdList: 'regionSupervisorName',
}
const nameKey = nameByListKey[i.key]
if (this.isViewMode && nameKey) {
const raw = this.componentData[nameKey]
if (raw != null && String(raw).trim() !== '') return String(raw).trim()
}
const values = this.componentData[i.key] const values = this.componentData[i.key]
if (!values || !Array.isArray(values) || values.length === 0 || !i?.options?.length) return '-' if (!values || !Array.isArray(values) || values.length === 0 || !i?.options?.length) return '-'
......
...@@ -75,7 +75,7 @@ import SalesCategory ...@@ -75,7 +75,7 @@ import SalesCategory
from "@/views/salesManagement/availableInStores/tigaListingAndSalesContract/components/StepTwo/components/SalesCategory.vue"; from "@/views/salesManagement/availableInStores/tigaListingAndSalesContract/components/StepTwo/components/SalesCategory.vue";
import { SALES_CATEGORY_RULES } from "@/views/salesManagement/availableInStores/tigaListingAndSalesContract/components/StepTwo/components/constant"; import { SALES_CATEGORY_RULES } from "@/views/salesManagement/availableInStores/tigaListingAndSalesContract/components/StepTwo/components/constant";
import MgBusinessSection from "./MgBusinessSection.vue"; import MgBusinessSection from "./MgBusinessSection.vue";
import { buildTrafficProviderData, buildBusinessForm } from "./merchantDetailMap"; import { buildTrafficProviderData, buildBusinessForm, normalizeBaseSceneListResponse } from "./merchantDetailMap";
import { buildMerchantOnShelfOpenPayload } from "./merchantOnShelfOpenPayload"; import { buildMerchantOnShelfOpenPayload } from "./merchantOnShelfOpenPayload";
export default { export default {
...@@ -164,7 +164,7 @@ export default { ...@@ -164,7 +164,7 @@ export default {
this.loading = true; this.loading = true;
try { try {
const scenes = await getBaseSceneCodeList({}); const scenes = await getBaseSceneCodeList({});
this.baseSceneList = Array.isArray(scenes) ? scenes : []; this.baseSceneList = normalizeBaseSceneListResponse(scenes);
const res = await queryMerchantDetail({ const res = await queryMerchantDetail({
merchantId: this.detailQueryMerchantId, merchantId: this.detailQueryMerchantId,
baseSceneCode: this.detailQueryBaseSceneCode, baseSceneCode: this.detailQueryBaseSceneCode,
......
...@@ -8,12 +8,47 @@ export function joinIds(mi, listKey, strKey) { ...@@ -8,12 +8,47 @@ export function joinIds(mi, listKey, strKey) {
return ""; return "";
} }
/** 场景列表接口可能返回 { list } 或裸数组,统一成数组 */
export function normalizeBaseSceneListResponse(res) {
if (Array.isArray(res)) return res;
if (res && typeof res === "object") {
const inner = res.list ?? res.records ?? res.data ?? res.rows ?? res.scenes;
if (Array.isArray(inner)) return inner;
}
return [];
}
function sceneRowMatchCodes(row) {
if (!row || typeof row !== "object") return [];
const keys = ["baseSceneCode", "sceneCode", "bizSceneCode", "code", "id", "sceneId"];
const out = [];
for (const k of keys) {
const v = row[k];
if (v != null && v !== "") out.push(String(v).trim());
}
return out;
}
/** 历史/详情里可能出现的场景编码字段(仅用于名称反查,不含 scene 大类枚举) */
export function pickSceneLookupCode(mi) {
if (!mi || typeof mi !== "object") return "";
const keys = ["baseSceneCode", "bizBaseSceneCode", "bizSceneCode", "sceneBizCode", "businessSceneCode"];
for (const k of keys) {
const v = mi[k];
if (v != null && v !== "") return v;
}
return "";
}
export function resolveSceneName(code, baseSceneList = []) { export function resolveSceneName(code, baseSceneList = []) {
if (code == null || code === "") return ""; if (code == null || code === "") return "";
const hit = baseSceneList.find( const codeStr = String(code).trim();
x => String(x.baseSceneCode) === String(code), if (!codeStr) return "";
); const hit = baseSceneList.find(row => sceneRowMatchCodes(row).includes(codeStr));
return hit?.name || String(code); if (hit) {
return hit.name ?? hit.sceneName ?? hit.label ?? hit.confLabel ?? codeStr;
}
return codeStr;
} }
export function storeProfitPerCar(mi) { export function storeProfitPerCar(mi) {
...@@ -27,7 +62,7 @@ export function buildTrafficProviderData(mi, baseSceneList = []) { ...@@ -27,7 +62,7 @@ export function buildTrafficProviderData(mi, baseSceneList = []) {
return { return {
trafficPartyName: mi.trafficPartyName || "", trafficPartyName: mi.trafficPartyName || "",
parentName: mi.parentName || mi.parentMerchantName || "", parentName: mi.parentName || mi.parentMerchantName || "",
sceneTypeName: mi.sceneTypeName || mi.baseSceneName || resolveSceneName(mi.baseSceneCode, baseSceneList) || "", sceneTypeName: mi.sceneTypeName || mi.baseSceneName || resolveSceneName(pickSceneLookupCode(mi), baseSceneList) || "",
signingEntityId: mi.signingEntityId != null ? Number(mi.signingEntityId) : null, signingEntityId: mi.signingEntityId != null ? Number(mi.signingEntityId) : null,
signingEntity: mi.signingEntity || mi.signingEntityName || "", signingEntity: mi.signingEntity || mi.signingEntityName || "",
businessMode: mi.businessMode != null ? Number(mi.businessMode) : null, businessMode: mi.businessMode != null ? Number(mi.businessMode) : null,
......
...@@ -47,8 +47,8 @@ ...@@ -47,8 +47,8 @@
<!-- 禁用 --> <!-- 禁用 -->
<auth-button v-if="isRelationEnabled(scope.scope)" slot="auth-button" :data="scope.scope" <auth-button v-if="isRelationEnabled(scope.scope)" slot="auth-button" :data="scope.scope"
:show-btn-ids="['9060305']" /> :show-btn-ids="['9060305']" />
<!-- 启用 --> <!-- 启用:与状态列一致,凡非「判定为启用」即展示(避免仅认 0/'0' 漏掉 false 等) -->
<auth-button v-if="isRelationDisabled(scope.scope)" slot="auth-button" :data="scope.scope" <auth-button v-if="!isRelationEnabled(scope.scope)" slot="auth-button" :data="scope.scope"
:show-btn-ids="['90603019']" /> :show-btn-ids="['90603019']" />
</div> </div>
</template> </template>
...@@ -431,6 +431,7 @@ export default { ...@@ -431,6 +431,7 @@ export default {
}, },
{ {
label: "关联服务商名称", label: "关联服务商名称",
width: "170px",
// prop: "partnerMerchants", // prop: "partnerMerchants",
prop: "serviceList", prop: "serviceList",
html: true, html: true,
...@@ -707,13 +708,13 @@ export default { ...@@ -707,13 +708,13 @@ export default {
return !this.filterEmpty(row.scene) return !this.filterEmpty(row.scene)
|| (row.baseSceneCode != null && row.baseSceneCode !== ""); || (row.baseSceneCode != null && row.baseSceneCode !== "");
}, },
isRelationEnabled(row) { /** 接口是否返回了有效的关联启用状态(0/1);null/undefined/空串视为未返回,勿覆盖父级 0 */
const s = row.status; relationStatusIsExplicit(v) {
return s === undefined || s === null || s === 1 || s === "1"; return v !== undefined && v !== null && v !== "";
}, },
isRelationDisabled(row) { isRelationEnabled(row) {
const s = row.status; const s = row?.status;
return s === 0 || s === "0"; return s === undefined || s === null || s === 1 || s === "1" || s === true;
}, },
formatBusinessSceneName(row) { formatBusinessSceneName(row) {
if (row.baseSceneName) { if (row.baseSceneName) {
...@@ -1225,6 +1226,10 @@ export default { ...@@ -1225,6 +1226,10 @@ export default {
if (rest.channelType !== undefined) { if (rest.channelType !== undefined) {
row.channelType = rest.channelType; row.channelType = rest.channelType;
} }
// newMerchantScene.status 为 null 时不应覆盖外层 status:0,否则会误显为「启用」
if (!this.relationStatusIsExplicit(nms.status) && this.relationStatusIsExplicit(rest.status)) {
row.status = rest.status;
}
} else { } else {
row = { ...item }; row = { ...item };
} }
...@@ -1267,6 +1272,10 @@ export default { ...@@ -1267,6 +1272,10 @@ export default {
if (merged.baseSceneName == null || merged.baseSceneName === "") { if (merged.baseSceneName == null || merged.baseSceneName === "") {
merged.baseSceneName = base.baseSceneName; merged.baseSceneName = base.baseSceneName;
} }
// sceneList 子项 status 为 null 时保留父行 0/1,避免 isRelationEnabled(null) 误判为启用
if (!this.relationStatusIsExplicit(s.status) && this.relationStatusIsExplicit(base.status)) {
merged.status = base.status;
}
prev.push(merged); prev.push(merged);
}); });
} else { } else {
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
import ledgerAccount from './components/ledgerAccount.vue' import ledgerAccount from './components/ledgerAccount.vue'
import reconciliation from './components/reconciliation.vue' import reconciliation from './components/reconciliation.vue'
import MerchantRelationGroundingReadonly from '../merchantGroundingEdit/MerchantRelationGroundingReadonly.vue' import MerchantRelationGroundingReadonly from '../merchantGroundingEdit/MerchantRelationGroundingReadonly.vue'
import { buildTrafficProviderData, buildBusinessForm } from '../merchantGroundingEdit/merchantDetailMap' import { buildTrafficProviderData, buildBusinessForm, normalizeBaseSceneListResponse } from '../merchantGroundingEdit/merchantDetailMap'
import { import {
getDistributeRuleApi, getDistributeRuleApi,
getEffectRuleApi, getEffectRuleApi,
...@@ -136,7 +136,7 @@ export default { ...@@ -136,7 +136,7 @@ export default {
this.relationLoading = true this.relationLoading = true
try { try {
const scenes = await getBaseSceneCodeList({}) const scenes = await getBaseSceneCodeList({})
this.relationBaseSceneList = Array.isArray(scenes) ? scenes : [] this.relationBaseSceneList = normalizeBaseSceneListResponse(scenes)
const res = await queryMerchantDetail({ const res = await queryMerchantDetail({
merchantId: merchantIdNum, merchantId: merchantIdNum,
baseSceneCode: String(baseSceneCode) baseSceneCode: String(baseSceneCode)
......
...@@ -96,7 +96,7 @@ import { getHistoryRecord } from "@api/publicAccount" ...@@ -96,7 +96,7 @@ import { getHistoryRecord } from "@api/publicAccount"
import ledgerAccount from "./components/ledgerAccount.vue" import ledgerAccount from "./components/ledgerAccount.vue"
import reconciliation from "./components/reconciliation.vue" import reconciliation from "./components/reconciliation.vue"
import MerchantRelationGroundingReadonly from '../merchantGroundingEdit/MerchantRelationGroundingReadonly.vue' import MerchantRelationGroundingReadonly from '../merchantGroundingEdit/MerchantRelationGroundingReadonly.vue'
import { buildTrafficProviderData, buildBusinessForm } from '../merchantGroundingEdit/merchantDetailMap' import { buildTrafficProviderData, buildBusinessForm, normalizeBaseSceneListResponse, pickSceneLookupCode } from '../merchantGroundingEdit/merchantDetailMap'
import { import {
getLedgerHistoryRecordApi, getLedgerHistoryRecordApi,
getReconciliationHistoryRecordApi, getReconciliationHistoryRecordApi,
...@@ -313,13 +313,22 @@ export default { ...@@ -313,13 +313,22 @@ export default {
productDetails: [], productDetails: [],
} }
} }
const storeInfo = const nestedRaw =
formItem.merchantStoreInfoHistory != null formItem.merchantStoreInfoHistory != null
? formItem.merchantStoreInfoHistory ? formItem.merchantStoreInfoHistory
: formItem.merchantInfo != null : formItem.merchantInfo != null
? formItem.merchantInfo ? formItem.merchantInfo
: formItem : null
const mi = storeInfo && typeof storeInfo === "object" ? storeInfo : {} /** 顶层与嵌套合并:history 明细里可能没有 baseSceneCode,保留 formItem 上字段 */
const mergedRow =
nestedRaw != null && typeof nestedRaw === "object"
? { ...formItem, ...nestedRaw }
: { ...formItem }
let mi = mergedRow && typeof mergedRow === "object" ? mergedRow : {}
const routeBsc = this.resolveRowBaseSceneCode(this.merchantRow)
if (pickSceneLookupCode(mi) === "" && routeBsc !== "") {
mi = { ...mi, baseSceneCode: routeBsc }
}
let pd = [] let pd = []
if (Array.isArray(formItem.merchantStoreProductDetailHistoryList)) { if (Array.isArray(formItem.merchantStoreProductDetailHistoryList)) {
pd = formItem.merchantStoreProductDetailHistoryList pd = formItem.merchantStoreProductDetailHistoryList
...@@ -342,7 +351,7 @@ export default { ...@@ -342,7 +351,7 @@ export default {
}) })
try { try {
const scenes = await getBaseSceneCodeList({}) const scenes = await getBaseSceneCodeList({})
this.relationSceneList = Array.isArray(scenes) ? scenes : [] this.relationSceneList = normalizeBaseSceneListResponse(scenes)
} catch (e) { } catch (e) {
console.warn(e) console.warn(e)
this.relationSceneList = [] this.relationSceneList = []
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!