Commit 835f1ce6 by 张立顺

feat 功能联调修复

1 parent 9920fffc
...@@ -201,7 +201,7 @@ async function main() { ...@@ -201,7 +201,7 @@ async function main() {
- [ ] 编写/补全 `src/api/adapters/{feature}/` adapters - [ ] 编写/补全 `src/api/adapters/{feature}/` adapters
- [ ] `src/api/*.js` 接入 request + adapter - [ ] `src/api/*.js` 接入 request + adapter
- [ ] Mock 数据对齐 Swagger 字段 - [ ] Mock 数据对齐 Swagger 字段
- [ ] `.env.development`:`VUE_APP_USE_DEVELOP_AXIOS=true`,确认未设置 feature mock 开关(或 `VUE_APP_*_MOCK` 非 `true`) - [ ] `.env.development`:默认不开启 `VUE_APP_USE_DEVELOP_AXIOS`(配置中心成功则用返回配置);确认未设置 feature mock 开关(或 `VUE_APP_*_MOCK` 非 `true`)
- [ ] `npm run rop:contract:check` 契约基线通过 - [ ] `npm run rop:contract:check` 契约基线通过
- [ ] `npm run api:smoke:journal`(或对应冒烟脚本)通过 - [ ] `npm run api:smoke:journal`(或对应冒烟脚本)通过
- [ ] 浏览器登录验证页面 - [ ] 浏览器登录验证页面
...@@ -254,7 +254,7 @@ async function main() { ...@@ -254,7 +254,7 @@ async function main() {
- [ ] adapter 单测通过(至少覆盖请求映射 + 行映射) - [ ] adapter 单测通过(至少覆盖请求映射 + 行映射)
- [ ] `npm run rop:contract:check` 通过 - [ ] `npm run rop:contract:check` 通过
- [ ] `npm run api:smoke:{feature}` 或 `npm run rop:verify` exit 0 - [ ] `npm run api:smoke:{feature}` 或 `npm run rop:verify` exit 0
- [ ] `.env.development` 已设 `VUE_APP_USE_DEVELOP_AXIOS=true`,未误开 feature mock(`VUE_APP_*_MOCK=true`) - [ ] `.env.development` 未误开 `VUE_APP_USE_DEVELOP_AXIOS=true`(除非个人本地需强制 dev 网关),未误开 feature mock(`VUE_APP_*_MOCK=true`)
- [ ] 浏览器页面可访问(需账号具备对应菜单权限) - [ ] 浏览器页面可访问(需账号具备对应菜单权限)
- [ ] 脚手架未误覆盖已有 adapter(默认 skip;必要时才用 `--force`) - [ ] 脚手架未误覆盖已有 adapter(默认 skip;必要时才用 `--force`)
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
VUE_APP_REPO=http://192.168.3.171:7300/mock/5be17454f31545347559d499/config VUE_APP_REPO=http://192.168.3.171:7300/mock/5be17454f31545347559d499/config
# 配置中心地址继承 .env 中的 VUE_APP_CONFIG_CENTER_URL(config-center-backend) # 配置中心地址继承 .env 中的 VUE_APP_CONFIG_CENTER_URL(config-center-backend)
# 配置中心不可用时,main.js 会回退到 src/common/baseConfig.develop.json # 配置中心成功时直接使用返回的环境配置(测试/正式);不可用时回退 baseConfig.develop.json
# 使用 develop 环境完整配置(含 axios.appkey/secret/baseURL) # 若需强制本地 dev 网关,在 .env.development.local 设 VUE_APP_USE_DEVELOP_AXIOS=true
VUE_APP_USE_DEVELOP_AXIOS=true
# 门店工作汇报:默认走真实 dailyReport 接口;本地需 Mock 时设 VUE_APP_JOURNAL_MOCK=true # 门店工作汇报:默认走真实 dailyReport 接口;本地需 Mock 时设 VUE_APP_JOURNAL_MOCK=true
/**
* 本地验证:洽谈明细 subform v2 格式归一化与回显
* 运行: node scripts/verify-journal-subform-echo.mjs
*/
const EMPTY_TEXT = "—";
function getSubformTemplate(field = {}) {
const children = field.children;
if (Array.isArray(children) && children.length) {
return Array.isArray(children[0]) ? children[0] : children;
}
if (Array.isArray(field.origin_children) && field.origin_children.length) {
return field.origin_children;
}
return [];
}
function extractSubformRowData(rowEntry, subformKey) {
if (!rowEntry || typeof rowEntry !== "object") {
return {};
}
if (subformKey && rowEntry[subformKey] && typeof rowEntry[subformKey] === "object") {
return rowEntry[subformKey];
}
return rowEntry;
}
function hasSubformRowData(value) {
if (!Array.isArray(value) || !value.length) {
return false;
}
return value.some((row) => Array.isArray(row) && row.length);
}
function normalizeSubformField(field = {}) {
if (field.type !== "subform") {
return field;
}
const template = getSubformTemplate(field);
let value = field.value;
if (!hasSubformRowData(value) && Array.isArray(field.childrenValue) && field.childrenValue.length) {
value = field.childrenValue.map((rowEntry) => {
const rowData = extractSubformRowData(rowEntry, field.key);
return template.map((col) => ({
...col,
value: rowData[col.key],
}));
});
}
return {
...field,
children: template.length ? [ template ] : field.children,
value,
};
}
function isLabelValueObject(raw) {
return raw != null && typeof raw === "object" && !Array.isArray(raw) && "text" in raw;
}
function formatCarBrandValue(raw) {
if (raw == null || raw === "") {
return EMPTY_TEXT;
}
if (typeof raw === "object") {
if (raw.displayText) {
return raw.displayText;
}
const parts = [
raw.vehicleBrandName,
raw.vehicleSubBrandName,
raw.vehicleSeriesName,
raw.vehicleShapeName,
].filter((part) => part != null && part !== "");
return parts.length ? parts.join(" / ") : EMPTY_TEXT;
}
return String(raw);
}
function resolveLabelValueRaw(raw, type) {
if (!isLabelValueObject(raw)) {
return raw;
}
if (raw.text != null && raw.text !== "") {
return raw.text;
}
if (type === "carBrandSelect" && raw.value != null) {
return formatCarBrandValue(raw.value);
}
if (raw.value != null && raw.value !== "") {
return raw.value;
}
return raw;
}
function formatEchoValue(field = {}) {
const { type } = field;
const raw = field.value;
if (raw == null || raw === "") {
return EMPTY_TEXT;
}
if (type === "select" || type === "radio") {
const displayRaw = resolveLabelValueRaw(raw, type);
if (displayRaw !== raw) {
return String(displayRaw);
}
return String(raw);
}
if (type === "carBrandSelect") {
const displayRaw = resolveLabelValueRaw(raw, type);
if (displayRaw !== raw) {
return String(displayRaw);
}
return formatCarBrandValue(raw);
}
if (type === "numberInput") {
const unit = field.unit ? String(field.unit) : "";
return `${raw}${unit}`;
}
return String(raw);
}
function buildSubformTable(field = {}) {
const template = getSubformTemplate(field);
const rowFieldsList = Array.isArray(field.value) ? field.value : [];
const rows = rowFieldsList.map((rowFields) => {
const row = {};
const cells = Array.isArray(rowFields) ? rowFields : [];
cells.forEach((cell) => {
if (cell?.key) {
row[cell.key] = formatEchoValue(cell);
}
});
return row;
});
return { columns: template, rows };
}
const subform = normalizeSubformField({
label: "洽谈明细 (轻改)",
key: "F3-4",
type: "subform",
origin_children: [
{ label: "洽谈日期", key: "F3-4-1", type: "date" },
{ label: "驻店人员", key: "F3-4-2", type: "select" },
{ label: "销售/交付/SA", key: "F3-4-4", type: "select" },
{ label: "车型配置", key: "F3-4-7", type: "carBrandSelect" },
{ label: "窗膜金额", key: "F3-4-13", type: "numberInput", unit: "元" },
],
childrenValue: [
{
"F3-4": {
"F3-4-1": "2026-07-20",
"F3-4-2": { text: "小王", value: "staff-id" },
"F3-4-4": { text: "7Na", value: "sa-id" },
"F3-4-7": {
text: "鸿蒙智行-AITO 问界-问界M7",
value: { vehicleBrandName: "鸿蒙智行" },
},
"F3-4-13": 1,
},
},
],
});
const table = buildSubformTable(subform);
const row = table.rows[0] || {};
const checks = [
[ "children columns", subform.children?.[0]?.length, 5 ],
[ "value rows", subform.value?.length, 1 ],
[ "F3-4-1", row["F3-4-1"], "2026-07-20" ],
[ "F3-4-2", row["F3-4-2"], "小王" ],
[ "F3-4-4", row["F3-4-4"], "7Na" ],
[ "F3-4-7", row["F3-4-7"], "鸿蒙智行-AITO 问界-问界M7" ],
[ "F3-4-13", row["F3-4-13"], "1元" ],
];
let failed = false;
checks.forEach(([ label, actual, expected ]) => {
const ok = actual === expected;
console.log(`${ok ? "OK" : "FAIL"} ${label}:`, actual);
if (!ok) {
failed = true;
}
});
process.exit(failed ? 1 : 0);
function tryParseJson(raw) {
if (typeof raw !== "string" || !raw.trim()) {
return null;
}
try {
return JSON.parse(raw);
} catch (error) {
return null;
}
}
/**
* 解析配置中心响应:支持 { code, data } 包装或直接返回配置体
* @param {*} response
* @returns {object|null}
*/
export function parseConfigCenterResponse(response) {
if (!response || typeof response !== "object") {
return null;
}
let payload = response;
if (response.code == "200" && response.data) {
payload = typeof response.data === "string"
? tryParseJson(response.data)
: response.data;
}
if (
payload
&& typeof payload === "object"
&& payload.axios?.baseURL
&& payload.axios?.appkey
) {
return payload;
}
return null;
}
export function mergeConfigTarget(target, source) {
if (!target || !source || typeof source !== "object") {
return target;
}
Object.keys(target).forEach((key) => {
delete target[key];
});
return Object.assign(target, source);
}
...@@ -4,6 +4,38 @@ const https = require("https"); ...@@ -4,6 +4,38 @@ const https = require("https");
const path = require("path"); const path = require("path");
const { getAxiosConfigKey } = require("./resolveApiName"); const { getAxiosConfigKey } = require("./resolveApiName");
function tryParseJson(raw) {
if (typeof raw !== "string" || !raw.trim()) {
return null;
}
try {
return JSON.parse(raw);
} catch (error) {
return null;
}
}
function parseConfigCenterResponse(response) {
if (!response || typeof response !== "object") {
return null;
}
let payload = response;
if (response.code == "200" && response.data) {
payload = typeof response.data === "string"
? tryParseJson(response.data)
: response.data;
}
if (
payload
&& typeof payload === "object"
&& payload.axios?.baseURL
&& payload.axios?.appkey
) {
return payload;
}
return null;
}
const DEFAULT_CONFIG_URL = process.env.VUE_APP_CONFIG_CENTER_URL const DEFAULT_CONFIG_URL = process.env.VUE_APP_CONFIG_CENTER_URL
|| "https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-system-config"; || "https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-system-config";
...@@ -64,7 +96,7 @@ async function loadAxiosConfig(options) { ...@@ -64,7 +96,7 @@ async function loadAxiosConfig(options) {
let baseConfig = null; let baseConfig = null;
try { try {
const response = await fetchJson(configUrl); const response = await fetchJson(configUrl);
baseConfig = response.code == "200" ? response.data : response; baseConfig = parseConfigCenterResponse(response);
} catch (error) { } catch (error) {
// 回退 develop 本地配置 // 回退 develop 本地配置
} }
......
...@@ -9,6 +9,10 @@ import VueLazyload from "vue-lazyload"; ...@@ -9,6 +9,10 @@ import VueLazyload from "vue-lazyload";
import { config } from "@/common/baseConfig"; import { config } from "@/common/baseConfig";
import developConfig from "@/common/baseConfig.develop.json"; import developConfig from "@/common/baseConfig.develop.json";
import {
mergeConfigTarget,
parseConfigCenterResponse,
} from "@/common/parseConfigCenterResponse";
import { installVueMapApi } from "@/common/installVueMapApi"; import { installVueMapApi } from "@/common/installVueMapApi";
import notice from "@/common/notice"; import notice from "@/common/notice";
import util from "@/libs/util.js"; import util from "@/libs/util.js";
...@@ -115,6 +119,7 @@ Vue.directive("preventReClick", { ...@@ -115,6 +119,7 @@ Vue.directive("preventReClick", {
}, },
}); });
let baseConfig = config; let baseConfig = config;
let configCenterLoaded = false;
// 如果要改地址, 优先去 .env.development 中配置 // 如果要改地址, 优先去 .env.development 中配置
// 如果要创建自己的配置 可以 创建.env.development.local 文件. 该文件已被 git忽略, 不会上传, 优先级比.env.development更高, 满足本地开发的需求. // 如果要创建自己的配置 可以 创建.env.development.local 文件. 该文件已被 git忽略, 不会上传, 优先级比.env.development更高, 满足本地开发的需求.
...@@ -148,15 +153,20 @@ fetch(configCenterUrl) ...@@ -148,15 +153,20 @@ fetch(configCenterUrl)
}, },
) )
.then((response) => { .then((response) => {
const { code, data } = response; console.log("response", response?.code, response);
console.log("response", code, response); const parsed = parseConfigCenterResponse(response);
if (code == "200") { if (parsed) {
console.log(data); configCenterLoaded = true;
baseConfig = data; mergeConfigTarget(baseConfig, parsed);
// console.log("baseConfig", baseConfig) console.log("config center loaded", baseConfig.env, baseConfig.axios?.baseURL);
// window.$fetchConfig = data
} else { } else {
baseConfig = response; const { code } = response || {};
if (code == "200") {
console.log(response?.data);
}
if (response && typeof response === "object") {
mergeConfigTarget(baseConfig, response);
}
window.$fetchConfig = response; window.$fetchConfig = response;
console.log(response); console.log(response);
window.$gscApi = new Request({ window.$gscApi = new Request({
...@@ -186,11 +196,10 @@ fetch(configCenterUrl) ...@@ -186,11 +196,10 @@ fetch(configCenterUrl)
init(); init();
}); });
function applyDevelopAxiosConfig() { function applyDevelopAxiosConfig() {
if ( if (configCenterLoaded && process.env.VUE_APP_USE_DEVELOP_AXIOS !== "true") {
process.env.NODE_ENV === "development" return;
&& process.env.VUE_APP_USE_DEVELOP_AXIOS === "true" }
&& developConfig?.axios if (process.env.NODE_ENV === "development" && developConfig?.axios) {
) {
baseConfig.axios = { baseConfig.axios = {
...baseConfig.axios, ...baseConfig.axios,
...developConfig.axios, ...developConfig.axios,
...@@ -198,6 +207,7 @@ function applyDevelopAxiosConfig() { ...@@ -198,6 +207,7 @@ function applyDevelopAxiosConfig() {
if (developConfig.env) { if (developConfig.env) {
baseConfig.env = developConfig.env; baseConfig.env = developConfig.env;
} }
console.log("develop axios fallback", baseConfig.env, baseConfig.axios?.baseURL);
} }
} }
......
...@@ -78,7 +78,7 @@ export const TABLE_COLUMNS_MAP = { ...@@ -78,7 +78,7 @@ export const TABLE_COLUMNS_MAP = {
staffDaily: [ staffDaily: [
{ label: "驻店人员", prop: "staffName", minWidth: "100px", showOverFlow: true }, { label: "驻店人员", prop: "staffName", minWidth: "100px", showOverFlow: true },
bizTypeColumn, bizTypeColumn,
{ label: "所属门店", prop: "merchantName", minWidth: "160px", showOverFlow: true, align: "left" }, { label: "所属门店", prop: "merchantName", minWidth: "160px", showOverFlow: true, align: "center" },
createEmptyTextColumn("今日出勤", "attendanceStatus", { width: "100px" }), createEmptyTextColumn("今日出勤", "attendanceStatus", { width: "100px" }),
createDateTimeColumn("最近保存时间", "lastSaveTime"), createDateTimeColumn("最近保存时间", "lastSaveTime"),
], ],
...@@ -88,7 +88,7 @@ export const TABLE_COLUMNS_MAP = { ...@@ -88,7 +88,7 @@ export const TABLE_COLUMNS_MAP = {
prop: "merchantName", prop: "merchantName",
minWidth: "160px", minWidth: "160px",
showOverFlow: true, showOverFlow: true,
align: "left", align: "center",
}, },
bizTypeColumn, bizTypeColumn,
{ {
...@@ -108,7 +108,7 @@ export const TABLE_COLUMNS_MAP = { ...@@ -108,7 +108,7 @@ export const TABLE_COLUMNS_MAP = {
negotiation: [ negotiation: [
{ label: "驻店人员", prop: "staffName", minWidth: "100px", showOverFlow: true }, { label: "驻店人员", prop: "staffName", minWidth: "100px", showOverFlow: true },
bizTypeColumn, bizTypeColumn,
{ label: "所属门店", prop: "merchantName", minWidth: "160px", showOverFlow: true, align: "left" }, { label: "所属门店", prop: "merchantName", minWidth: "160px", showOverFlow: true, align: "center" },
createDateTimeColumn("最近保存时间", "lastSaveTime"), createDateTimeColumn("最近保存时间", "lastSaveTime"),
], ],
}; };
......
...@@ -158,4 +158,73 @@ export function buildJournalDetailJsonContent() { ...@@ -158,4 +158,73 @@ export function buildJournalDetailJsonContent() {
return JSON.stringify(JOURNAL_DETAIL_ECHO_FORM_LIST); return JSON.stringify(JOURNAL_DETAIL_ECHO_FORM_LIST);
} }
const negotiationOriginChildren = [
{ label: "洽谈日期", sortNum: "60", key: "F3-4-1", type: "date", required: true },
{ label: "驻店人员", sortNum: "61", key: "F3-4-2", type: "select", required: true, options: [], optionsKey: "storeStaffList" },
{ label: "部门", sortNum: "62", key: "F3-4-3", type: "select", required: true, options: [ { label: "交付部", value: "交付部" } ] },
{ label: "销售/交付/SA", sortNum: "63", key: "F3-4-4", type: "select", required: true, options: [], optionsKey: "4sStaffList" },
{ label: "客户名称", sortNum: "64", key: "F3-4-5", type: "input", required: true },
{ label: "客户手机号", sortNum: "65", key: "F3-4-6", type: "phoneInput", required: true },
{ label: "车型配置", sortNum: "66", key: "F3-4-7", type: "carBrandSelect", required: true },
{ label: "车架号", sortNum: "67", key: "F3-4-8", type: "input", required: true },
{ label: "销售赠送", sortNum: "68", key: "F3-4-9", type: "numberInput", required: true },
{ label: "客户来源", sortNum: "69", key: "F3-4-10", type: "radio", required: true, options: [ { label: "商超", value: "商超" } ] },
{ label: "是否有效", sortNum: "70", key: "F3-4-11", type: "radio", required: true, options: [ { label: "是", value: "是" } ] },
{ label: "是否升级", sortNum: "71", key: "F3-4-12", type: "radio", required: true, options: [ { label: "是", value: "是" } ] },
{ label: "窗膜金额", sortNum: "72", key: "F3-4-13", type: "numberInput", required: true, unit: "元" },
{ label: "车衣金额", sortNum: "73", key: "F3-4-14", type: "numberInput", required: true, unit: "元" },
{ label: "精品金额", sortNum: "74", key: "F3-4-15", type: "numberInput", required: true, unit: "元" },
{ label: "升级金额", sortNum: "75", key: "F3-4-16", type: "numberInput", required: true, unit: "元" },
{ label: "备注", sortNum: "76", key: "F3-4-17", type: "textarea", required: false },
];
export const NEGOTIATION_SUBFORM_V2_FORM_LIST = [
{
label: "洽谈明细 (轻改)",
sortNum: "59",
key: "F3-4",
type: "subform",
origin_children: negotiationOriginChildren,
childrenValue: [
{
"F3-4": {
"F3-4-1": "2026-07-20",
"F3-4-2": { text: "小王", value: "0a522331c33744a881313e746cc688b1" },
"F3-4-3": "交付部",
"F3-4-4": { text: "7Na", value: "c8335e0f0da84021999edac6254a3dc1" },
"F3-4-5": "1",
"F3-4-6": "15817666666",
"F3-4-7": {
text: "鸿蒙智行-AITO 问界-问界M7-2026款 纯电 Ultra四驱版 5座",
value: {
vehicleBrandId: 2978,
vehicleBrandName: "鸿蒙智行",
vehicleSubBrandId: 3454,
vehicleSubBrandName: "AITO 问界",
vehicleSeriesId: 1149147,
vehicleSeriesName: "问界M7",
vehicleShapeId: 452204,
vehicleShapeName: "2026款 纯电 Ultra四驱版 5座",
},
},
"F3-4-8": "666666666666666666",
"F3-4-9": 222,
"F3-4-10": "商超",
"F3-4-11": "是",
"F3-4-12": "是",
"F3-4-13": 1,
"F3-4-14": 2,
"F3-4-15": 3,
"F3-4-16": 4,
"F3-4-17": "444",
},
},
],
},
];
export function buildNegotiationDetailJsonContent() {
return JSON.stringify(NEGOTIATION_SUBFORM_V2_FORM_LIST);
}
export default JOURNAL_DETAIL_ECHO_FORM_LIST; export default JOURNAL_DETAIL_ECHO_FORM_LIST;
...@@ -44,6 +44,60 @@ function mergeSchemaWithFieldDataList(schemaList = [], fieldDataList = []) { ...@@ -44,6 +44,60 @@ function mergeSchemaWithFieldDataList(schemaList = [], fieldDataList = []) {
})); }));
} }
function getSubformTemplate(field = {}) {
const children = field.children;
if (Array.isArray(children) && children.length) {
return Array.isArray(children[0]) ? children[0] : children;
}
if (Array.isArray(field.origin_children) && field.origin_children.length) {
return field.origin_children;
}
return [];
}
function extractSubformRowData(rowEntry, subformKey) {
if (!rowEntry || typeof rowEntry !== "object") {
return {};
}
if (subformKey && rowEntry[subformKey] && typeof rowEntry[subformKey] === "object") {
return rowEntry[subformKey];
}
return rowEntry;
}
function hasSubformRowData(value) {
if (!Array.isArray(value) || !value.length) {
return false;
}
return value.some((row) => Array.isArray(row) && row.length);
}
function normalizeSubformField(field = {}) {
if (field.type !== "subform") {
return field;
}
const template = getSubformTemplate(field);
let value = field.value;
if (!hasSubformRowData(value) && Array.isArray(field.childrenValue) && field.childrenValue.length) {
value = field.childrenValue.map((rowEntry) => {
const rowData = extractSubformRowData(rowEntry, field.key);
return template.map((col) => ({
...col,
value: rowData[col.key],
}));
});
}
return {
...field,
children: template.length ? [ template ] : field.children,
value,
};
}
function normalizeFormList(formList = []) {
return formList.map((field) => normalizeSubformField(field));
}
/** /**
* 解析详情为 formList:jsonContent 优先,兜底 schema + fieldDataList * 解析详情为 formList:jsonContent 优先,兜底 schema + fieldDataList
*/ */
...@@ -52,7 +106,7 @@ export function parseFormList(detail = {}) { ...@@ -52,7 +106,7 @@ export function parseFormList(detail = {}) {
if (!formList.length && detail.schema?.list?.length) { if (!formList.length && detail.schema?.list?.length) {
formList = mergeSchemaWithFieldDataList(detail.schema.list, detail.fieldDataList || []); formList = mergeSchemaWithFieldDataList(detail.schema.list, detail.fieldDataList || []);
} }
return sortBySortNum(formList); return sortBySortNum(normalizeFormList(formList));
} }
function findOptionLabel(options = [], value) { function findOptionLabel(options = [], value) {
...@@ -82,6 +136,26 @@ function formatCarBrandValue(raw) { ...@@ -82,6 +136,26 @@ function formatCarBrandValue(raw) {
return String(raw); return String(raw);
} }
function isLabelValueObject(raw) {
return raw != null && typeof raw === "object" && !Array.isArray(raw) && "text" in raw;
}
function resolveLabelValueRaw(raw, type) {
if (!isLabelValueObject(raw)) {
return raw;
}
if (raw.text != null && raw.text !== "") {
return raw.text;
}
if (type === "carBrandSelect" && raw.value != null) {
return formatCarBrandValue(raw.value);
}
if (raw.value != null && raw.value !== "") {
return raw.value;
}
return raw;
}
/** /**
* 字段值格式化为只读展示文案 * 字段值格式化为只读展示文案
*/ */
...@@ -94,15 +168,31 @@ export function formatEchoValue(field = {}) { ...@@ -94,15 +168,31 @@ export function formatEchoValue(field = {}) {
switch (type) { switch (type) {
case "radio": case "radio":
case "select": case "select": {
const displayRaw = resolveLabelValueRaw(raw, type);
if (displayRaw !== raw) {
return String(displayRaw);
}
return findOptionLabel(options, raw) || String(raw); return findOptionLabel(options, raw) || String(raw);
}
case "multipleSelect": { case "multipleSelect": {
const list = Array.isArray(raw) ? raw : [raw]; const list = Array.isArray(raw) ? raw : [ raw ];
const labels = list.map((item) => findOptionLabel(options, item) || String(item)).filter(Boolean); const labels = list.map((item) => {
const displayItem = resolveLabelValueRaw(item, "select");
if (displayItem !== item) {
return String(displayItem);
}
return findOptionLabel(options, item) || String(item);
}).filter(Boolean);
return labels.length ? labels.join(",") : EMPTY_TEXT; return labels.length ? labels.join(",") : EMPTY_TEXT;
} }
case "carBrandSelect": case "carBrandSelect": {
const displayRaw = resolveLabelValueRaw(raw, type);
if (displayRaw !== raw) {
return String(displayRaw);
}
return formatCarBrandValue(raw); return formatCarBrandValue(raw);
}
case "numberInput": { case "numberInput": {
const unit = field.unit ? String(field.unit) : ""; const unit = field.unit ? String(field.unit) : "";
return `${raw}${unit}`; return `${raw}${unit}`;
...@@ -189,7 +279,7 @@ export function buildEchoBlocks(formList = []) { ...@@ -189,7 +279,7 @@ export function buildEchoBlocks(formList = []) {
* 子表单 → el-table 列与行(children[0] 为列模板,value 为行数据) * 子表单 → el-table 列与行(children[0] 为列模板,value 为行数据)
*/ */
export function buildSubformTable(field = {}) { export function buildSubformTable(field = {}) {
const template = Array.isArray(field.children?.[0]) ? field.children[0] : []; const template = getSubformTemplate(field);
const rowFieldsList = Array.isArray(field.value) ? field.value : []; const rowFieldsList = Array.isArray(field.value) ? field.value : [];
const columns = template.map((col) => ({ const columns = template.map((col) => ({
......
...@@ -16,8 +16,11 @@ export function getStaticGroupChildren(field = {}) { ...@@ -16,8 +16,11 @@ export function getStaticGroupChildren(field = {}) {
export function getSubformRowTemplate(field = {}) { export function getSubformRowTemplate(field = {}) {
const children = field.children; const children = field.children;
if (!Array.isArray(children) || !children.length) { if (Array.isArray(children) && children.length) {
return []; return Array.isArray(children[0]) ? children[0] : children;
} }
return Array.isArray(children[0]) ? children[0] : children; if (Array.isArray(field.origin_children) && field.origin_children.length) {
return field.origin_children;
}
return [];
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!