n20-common-lib 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}}</el-checkbox>
|
|
29
29
|
</div>
|
|
30
30
|
</div>
|
|
31
|
-
<div class="flex-item p-r" style="height:
|
|
31
|
+
<div class="flex-item p-r" style="height: 80%; overflow: auto">
|
|
32
32
|
<!-- :value 需包含 static 列的 label,使其显示为选中状态 -->
|
|
33
33
|
<el-checkbox-group :value="checkedLabelValues" @change="handleCheckedChange">
|
|
34
34
|
<template v-if="!columnsGroups">
|
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
@resize="sizeSet"
|
|
303
303
|
@toggle-expand="toggleExpand"
|
|
304
304
|
@toggle-operate-fixed="handleToggleOperateFixed"
|
|
305
|
-
@visible-column="
|
|
305
|
+
@visible-column="handleVisibleColumn"
|
|
306
306
|
/>
|
|
307
307
|
<!-- 操作列的悬浮按钮组 -->
|
|
308
308
|
<transition name="hover-btns-fade">
|
|
@@ -680,6 +680,10 @@ export default {
|
|
|
680
680
|
}
|
|
681
681
|
},
|
|
682
682
|
methods: {
|
|
683
|
+
handleVisibleColumn() {
|
|
684
|
+
this.isExport = false
|
|
685
|
+
this.dialogVisible = !this.dialogVisible
|
|
686
|
+
},
|
|
683
687
|
openExportColumn() {
|
|
684
688
|
this.dialogVisible = true
|
|
685
689
|
this.isExport = true
|
|
@@ -718,13 +722,45 @@ export default {
|
|
|
718
722
|
},
|
|
719
723
|
async getColumns() {
|
|
720
724
|
try {
|
|
721
|
-
const columns = await this.$refs
|
|
722
|
-
|
|
725
|
+
const columns = await this.$refs?.showColumn?.getColumns(this.pageId)
|
|
726
|
+
|
|
727
|
+
if (columns?.length) {
|
|
728
|
+
this.checkColumns = columns
|
|
729
|
+
// 将 remote: true 的远程列同步写入 this.columns,保持位置一致
|
|
730
|
+
this.syncRemoteColumns(columns)
|
|
731
|
+
} else {
|
|
732
|
+
this.checkColumns = this.filterDefaultHidden(this.columns)
|
|
733
|
+
}
|
|
723
734
|
} catch (err) {
|
|
724
735
|
// API 请求失败时回退到过滤后的 columns prop
|
|
725
736
|
this.checkColumns = this.filterDefaultHidden(this.columns)
|
|
726
737
|
}
|
|
727
738
|
},
|
|
739
|
+
// 供组件外部调用,刷新表头数据(重新请求 getColumns 并同步远程列)
|
|
740
|
+
async refreshColumns() {
|
|
741
|
+
if (this.showColumn && this.pageId) {
|
|
742
|
+
await this.getColumns()
|
|
743
|
+
// 强制重建 vxe-table,确保列变更后视图正确刷新
|
|
744
|
+
this.colsKey++
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
// 将 API 返回中标记 remote: true 的列同步到 this.columns,保持对应位置一致
|
|
748
|
+
syncRemoteColumns(apiColumns) {
|
|
749
|
+
apiColumns.forEach((apiCol, index) => {
|
|
750
|
+
if (!apiCol.remote) return
|
|
751
|
+
// 按 prop 或 labelKey 匹配 this.columns 中是否已存在
|
|
752
|
+
const matchKey = apiCol.prop ? 'prop' : this.labelKey
|
|
753
|
+
const existingIdx = this.columns.findIndex((c) => c[matchKey] === apiCol[matchKey])
|
|
754
|
+
if (existingIdx !== -1) {
|
|
755
|
+
// 已存在则替换,保持位置以 API 返回为准
|
|
756
|
+
this.$set(this.columns, existingIdx, apiCol)
|
|
757
|
+
} else {
|
|
758
|
+
// 不存在则插入到对应位置(避免 $set 索引超出长度产生稀疏数组)
|
|
759
|
+
const insertIdx = Math.min(index, this.columns.length)
|
|
760
|
+
this.columns.splice(insertIdx, 0, apiCol)
|
|
761
|
+
}
|
|
762
|
+
})
|
|
763
|
+
},
|
|
728
764
|
/**
|
|
729
765
|
* 一键展开/折叠表格树形行(仅处理第一层级数据行)
|
|
730
766
|
* 通过 vxe-table 的 setTreeExpand API 批量设置顶层行的展开状态,
|