update at 2026-02-13 23:17:10
This commit is contained in:
@@ -232,6 +232,41 @@ function buildColumnSelectedMap(indices) {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为三组列选择 UI 构造可直接渲染的数据,避免模板层做复杂表达式计算。
|
||||
*/
|
||||
function buildColumnRenderRows(headers, sourceDataColumn, sourceDescMap, targetDescMap) {
|
||||
const normalizedHeaders = Array.isArray(headers) ? headers : [];
|
||||
const sourceRows = [];
|
||||
const sourceDescRows = [];
|
||||
const targetDescRows = [];
|
||||
|
||||
normalizedHeaders.forEach((header, index) => {
|
||||
const label = String(header || '');
|
||||
sourceRows.push({
|
||||
index,
|
||||
label,
|
||||
selected: sourceDataColumn === index
|
||||
});
|
||||
sourceDescRows.push({
|
||||
index,
|
||||
label,
|
||||
checked: !!(sourceDescMap && sourceDescMap[index])
|
||||
});
|
||||
targetDescRows.push({
|
||||
index,
|
||||
label,
|
||||
checked: !!(targetDescMap && targetDescMap[index])
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
sourceDataRows: sourceRows,
|
||||
sourceDescRows,
|
||||
targetDescRows
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一错误文案:
|
||||
* - xlsx 解析能力缺失时,固定提示用户去“构建 npm”
|
||||
@@ -543,6 +578,9 @@ Page({
|
||||
targetDescriptionColumns: [],
|
||||
sourceDescSelectedMap: {},
|
||||
targetDescSelectedMap: {},
|
||||
sourceDataRows: [],
|
||||
sourceDescRows: [],
|
||||
targetDescRows: [],
|
||||
sectionVisibleSourceData: true,
|
||||
sectionVisibleSourceDesc: true,
|
||||
sectionVisibleTargetDesc: true,
|
||||
@@ -965,7 +1003,13 @@ Page({
|
||||
sourceDescriptionColumns,
|
||||
targetDescriptionColumns,
|
||||
sourceDescSelectedMap: buildColumnSelectedMap(sourceDescriptionColumns),
|
||||
targetDescSelectedMap: buildColumnSelectedMap(targetDescriptionColumns)
|
||||
targetDescSelectedMap: buildColumnSelectedMap(targetDescriptionColumns),
|
||||
...buildColumnRenderRows(
|
||||
headers.length > 0 ? headers : [],
|
||||
sourceDataColumn,
|
||||
buildColumnSelectedMap(sourceDescriptionColumns),
|
||||
buildColumnSelectedMap(targetDescriptionColumns)
|
||||
)
|
||||
},
|
||||
() => {
|
||||
this.rebuildSankey();
|
||||
@@ -975,9 +1019,16 @@ Page({
|
||||
|
||||
onSelectSourceData(e) {
|
||||
const index = Number(e.currentTarget.dataset.index);
|
||||
const safeSourceDataColumn = Number.isNaN(index) ? null : index;
|
||||
this.setData(
|
||||
{
|
||||
sourceDataColumn: Number.isNaN(index) ? null : index
|
||||
sourceDataColumn: safeSourceDataColumn,
|
||||
...buildColumnRenderRows(
|
||||
this.data.columnHeaders || [],
|
||||
safeSourceDataColumn,
|
||||
this.data.sourceDescSelectedMap || {},
|
||||
this.data.targetDescSelectedMap || {}
|
||||
)
|
||||
},
|
||||
() => {
|
||||
this.rebuildSankey();
|
||||
@@ -995,10 +1046,17 @@ Page({
|
||||
const next = exists
|
||||
? current.filter((item) => item !== index)
|
||||
: normalizeColumnIndexArray(current.concat(index));
|
||||
const nextSourceDescSelectedMap = buildColumnSelectedMap(next);
|
||||
this.setData(
|
||||
{
|
||||
sourceDescriptionColumns: next,
|
||||
sourceDescSelectedMap: buildColumnSelectedMap(next)
|
||||
sourceDescSelectedMap: nextSourceDescSelectedMap,
|
||||
...buildColumnRenderRows(
|
||||
this.data.columnHeaders || [],
|
||||
this.data.sourceDataColumn,
|
||||
nextSourceDescSelectedMap,
|
||||
this.data.targetDescSelectedMap || {}
|
||||
)
|
||||
},
|
||||
() => {
|
||||
this.rebuildSankey();
|
||||
@@ -1016,10 +1074,17 @@ Page({
|
||||
const next = exists
|
||||
? current.filter((item) => item !== index)
|
||||
: normalizeColumnIndexArray(current.concat(index));
|
||||
const nextTargetDescSelectedMap = buildColumnSelectedMap(next);
|
||||
this.setData(
|
||||
{
|
||||
targetDescriptionColumns: next,
|
||||
targetDescSelectedMap: buildColumnSelectedMap(next)
|
||||
targetDescSelectedMap: nextTargetDescSelectedMap,
|
||||
...buildColumnRenderRows(
|
||||
this.data.columnHeaders || [],
|
||||
this.data.sourceDataColumn,
|
||||
this.data.sourceDescSelectedMap || {},
|
||||
nextTargetDescSelectedMap
|
||||
)
|
||||
},
|
||||
() => {
|
||||
this.rebuildSankey();
|
||||
|
||||
Reference in New Issue
Block a user