From f87ac6149c04411d2b1ef4e46c76b2d7b6a96af7 Mon Sep 17 00:00:00 2001 From: 86156 <823267011@qq.com> Date: Mon, 23 Mar 2026 15:39:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E9=80=9F=E6=8E=92=E6=9F=A5=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=AD=97=E6=AE=B5=E4=B8=8E=E5=89=8D=E7=AB=AF=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- klp-ui/src/views/aps/quickSheetPreview.vue | 98 +++++++++++++++++++--- 1 file changed, 86 insertions(+), 12 deletions(-) diff --git a/klp-ui/src/views/aps/quickSheetPreview.vue b/klp-ui/src/views/aps/quickSheetPreview.vue index 145b10c9..78c42db5 100644 --- a/klp-ui/src/views/aps/quickSheetPreview.vue +++ b/klp-ui/src/views/aps/quickSheetPreview.vue @@ -66,17 +66,36 @@ :visible.sync="columnSettingVisible" direction="rtl" size="55%" - append-to-body> + append-to-body + @open="resetColumnDraft">
恢复默认 + 重置 + 保存 +
+ +
+
固定列(最多5列)
+ +
+ + {{ item.label }} + 移除 +
+
+
+ +
+
其他列
+ +
+ + {{ item.label }} + 加入固定 +
+
- -
- - {{ item.label }} -
-
@@ -107,7 +126,9 @@ export default { pageSize: 25 }, columnSettingVisible: false, - columnSettingList: [] + columnSettingList: [], + fixedColumnList: [], + normalColumnList: [] } }, computed: { @@ -138,6 +159,9 @@ export default { const rest = base.filter(c => !selectedSet.has(c.prop)) return [...selected, ...rest] }, + fixedProps() { + return (this.columnSettingList || []).filter(i => i.visible && i.fixed).map(i => i.prop).slice(0, 5) + }, filteredRows() { const [startAfter, endBefore] = this.filter.range || [] const lineName = (this.filter.lineName || '').trim() @@ -179,7 +203,7 @@ export default { initColumnSettings() { const key = this.getColumnSettingKey() const stored = localStorage.getItem(key) - const base = this.flatColumns.map(col => ({ prop: col.prop, label: col.label, visible: true })) + const base = this.flatColumns.map((col, idx) => ({ prop: col.prop, label: col.label, visible: true, fixed: idx < 5 })) if (!stored) { this.columnSettingList = base return @@ -199,24 +223,63 @@ export default { const extras = base.filter(i => !savedProps.includes(i.prop)) this.columnSettingList = [...parsed.filter(i => base.some(b => b.prop === i.prop)).map(i => { const match = base.find(b => b.prop === i.prop) - return { ...match, visible: i.visible !== false } + return { ...match, visible: i.visible !== false, fixed: i.fixed === true } }), ...extras] + this.resetColumnDraft() } catch (e) { this.columnSettingList = base + this.resetColumnDraft() } }, + resetColumnDraft() { + const fixed = (this.columnSettingList || []).filter(i => i.visible && i.fixed).slice(0, 5) + const normal = (this.columnSettingList || []).filter(i => !i.fixed || !i.visible) + this.fixedColumnList = fixed.map(i => ({ ...i, visible: true, fixed: true })) + this.normalColumnList = normal.map(i => ({ ...i, visible: true, fixed: false })) + }, + saveColumnSettings() { + const fixed = (this.fixedColumnList || []).map(i => ({ ...i, visible: true, fixed: true })) + const normal = (this.normalColumnList || []).map(i => ({ ...i, fixed: false })) + this.columnSettingList = [...fixed, ...normal] + this.persistColumnSettings() + this.columnSettingVisible = false + this.pager.pageNum = 1 + this.loadRows().finally(() => { + this.$nextTick(() => { + this.$refs.quickSheetPreviewTable && this.$refs.quickSheetPreviewTable.doLayout && this.$refs.quickSheetPreviewTable.doLayout() + }) + }) + }, + addToFixed(prop) { + if ((this.fixedColumnList || []).length >= 5) { + this.$message.warning('固定列最多5列') + return + } + const idx = (this.normalColumnList || []).findIndex(i => i.prop === prop) + if (idx < 0) return + const item = this.normalColumnList.splice(idx, 1)[0] + this.fixedColumnList.push({ ...item, fixed: true, visible: true }) + }, + removeFromFixed(prop) { + const idx = (this.fixedColumnList || []).findIndex(i => i.prop === prop) + if (idx < 0) return + const item = this.fixedColumnList.splice(idx, 1)[0] + this.normalColumnList.push({ ...item, fixed: false, visible: true }) + }, persistColumnSettings() { const key = this.getColumnSettingKey() const payload = (this.columnSettingList || []).map(item => ({ prop: item.prop, label: item.label, - visible: item.visible !== false + visible: item.visible !== false, + fixed: item.fixed === true })) localStorage.setItem(key, JSON.stringify(payload)) }, restoreDefaultColumns() { - const base = this.flatColumns.map(col => ({ prop: col.prop, label: col.label, visible: true })) + const base = this.flatColumns.map((col, idx) => ({ prop: col.prop, label: col.label, visible: true, fixed: idx < 5 })) this.columnSettingList = base + this.resetColumnDraft() this.persistColumnSettings() }, getColumnSettingKey() { @@ -324,6 +387,17 @@ export default { justify-content: flex-end; } +.col-section { + margin-bottom: 12px; +} + +.col-section-title { + font-size: 13px; + font-weight: 600; + color: #303133; + margin-bottom: 8px; +} + .col-setting-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));