update at 2026-02-13 23:06:13
This commit is contained in:
@@ -221,6 +221,17 @@ function normalizeColumnIndexArray(indices) {
|
||||
.sort((a, b) => a - b);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将列索引数组转换为布尔映射,供 WXML 直接按下标判断选中态。
|
||||
*/
|
||||
function buildColumnSelectedMap(indices) {
|
||||
const map = {};
|
||||
normalizeColumnIndexArray(indices).forEach((index) => {
|
||||
map[index] = true;
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一错误文案:
|
||||
* - xlsx 解析能力缺失时,固定提示用户去“构建 npm”
|
||||
@@ -530,6 +541,8 @@ Page({
|
||||
sourceDataColumn: null,
|
||||
sourceDescriptionColumns: [],
|
||||
targetDescriptionColumns: [],
|
||||
sourceDescSelectedMap: {},
|
||||
targetDescSelectedMap: {},
|
||||
sectionVisibleSourceData: true,
|
||||
sectionVisibleSourceDesc: true,
|
||||
sectionVisibleTargetDesc: true,
|
||||
@@ -950,7 +963,9 @@ Page({
|
||||
tableRows: rows,
|
||||
sourceDataColumn,
|
||||
sourceDescriptionColumns,
|
||||
targetDescriptionColumns
|
||||
targetDescriptionColumns,
|
||||
sourceDescSelectedMap: buildColumnSelectedMap(sourceDescriptionColumns),
|
||||
targetDescSelectedMap: buildColumnSelectedMap(targetDescriptionColumns)
|
||||
},
|
||||
() => {
|
||||
this.rebuildSankey();
|
||||
@@ -982,7 +997,8 @@ Page({
|
||||
: normalizeColumnIndexArray(current.concat(index));
|
||||
this.setData(
|
||||
{
|
||||
sourceDescriptionColumns: next
|
||||
sourceDescriptionColumns: next,
|
||||
sourceDescSelectedMap: buildColumnSelectedMap(next)
|
||||
},
|
||||
() => {
|
||||
this.rebuildSankey();
|
||||
@@ -1002,7 +1018,8 @@ Page({
|
||||
: normalizeColumnIndexArray(current.concat(index));
|
||||
this.setData(
|
||||
{
|
||||
targetDescriptionColumns: next
|
||||
targetDescriptionColumns: next,
|
||||
targetDescSelectedMap: buildColumnSelectedMap(next)
|
||||
},
|
||||
() => {
|
||||
this.rebuildSankey();
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
<image src="../../assets/icons/description.svg" mode="aspectFit" />
|
||||
<text class="label">{{item}}</text>
|
||||
<image
|
||||
src="{{(sourceDescriptionColumns.indexOf(index) > -1 || sourceDescriptionColumns.indexOf(index + '') > -1) ? '../../assets/icons/checkbox.svg' : '../../assets/icons/checkbox-no.svg'}}"
|
||||
src="{{sourceDescSelectedMap[index] ? '../../assets/icons/checkbox.svg' : '../../assets/icons/checkbox-no.svg'}}"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
@@ -155,7 +155,7 @@
|
||||
<image src="../../assets/icons/description.svg" mode="aspectFit" />
|
||||
<text class="label">{{item}}</text>
|
||||
<image
|
||||
src="{{(targetDescriptionColumns.indexOf(index) > -1 || targetDescriptionColumns.indexOf(index + '') > -1) ? '../../assets/icons/checkbox.svg' : '../../assets/icons/checkbox-no.svg'}}"
|
||||
src="{{targetDescSelectedMap[index] ? '../../assets/icons/checkbox.svg' : '../../assets/icons/checkbox-no.svg'}}"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user