verce-vue-test 0.0.80 → 0.0.82

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.
Files changed (26) hide show
  1. package/.feisuan/rules/project_rule.md +1 -3
  2. package/env.d.ts +5 -5
  3. package/package.json +1 -1
  4. package/src/App.vue +48 -36
  5. package/src/components/{ElButtonPro.vue → element-rewrite/ElButtonPro.vue} +1 -1
  6. package/src/components/element-rewrite/ElTablePro.vue +1050 -0
  7. package/src/components/{ElUploadButton.vue → element-rewrite/ElUploadButton.vue} +1 -1
  8. package/src/components/index.ts +10 -10
  9. package/src/router/index.ts +0 -6
  10. package/src/utils/baseHttpClient.ts +15 -7
  11. package/src/views/ForecastInfo/components/FlowInfoPanel.vue +1 -0
  12. package/src/views/ForecastInfo/components/ForecastInfoPanel.vue +1 -0
  13. package/src/views/ForecastInfo/forecast-info.css +8 -0
  14. package/src/views/HomeView.vue +0 -2
  15. package/src/views/rmb-position-estimation/README.md +2 -3
  16. package/src/views/rmb-position-estimation/index.vue +189 -63
  17. package/src/views/rmb-position-forecast/api.ts +180 -0
  18. package/src/views/rmb-position-forecast/index.vue +131 -246
  19. package/src/components/ElTablePro.vue +0 -619
  20. package/src/views/ExecutiveManagementView/components/ExecutiveAccountPanel.vue +0 -492
  21. package/src/views/ExecutiveManagementView/components/ExecutiveReliablePanel.vue +0 -398
  22. package/src/views/ExecutiveManagementView/components/ExecutiveWarningOverview.vue +0 -355
  23. package/src/views/ExecutiveManagementView/components/ExecutiveWarningTablePanel.vue +0 -226
  24. package/src/views/ExecutiveManagementView/index.vue +0 -99
  25. /package/src/components/{ElFormDialog.vue → element-rewrite/ElFormDialog.vue} +0 -0
  26. /package/src/components/{ElInputThousandth.vue → element-rewrite/ElInputThousandth.vue} +0 -0
@@ -0,0 +1,1050 @@
1
+ <script setup lang="ts" name="ElTablePro">
2
+ /**
3
+ * ElTablePro 组件
4
+ * 基于 Element Plus 的增强表格组件,支持列配置、本地存储和分页功能
5
+ */
6
+ import {
7
+ computed,
8
+ nextTick,
9
+ ref,
10
+ useAttrs,
11
+ useId,
12
+ useSlots,
13
+ watch,
14
+ cloneVNode,
15
+ Fragment,
16
+ type VNode
17
+ } from "vue"
18
+ import { useRoute } from "vue-router"
19
+
20
+ // 组件配置选项
21
+ // defineOptions({
22
+ // name: "ElTablePro",
23
+ // inheritAttrs: false
24
+ // })
25
+
26
+ /**
27
+ * Props 定义
28
+ */
29
+ const props = withDefaults(
30
+ defineProps<{
31
+ // 表格数据源
32
+ data: any[]
33
+ // 行唯一标识字段
34
+ rowKey?: string
35
+ // 多表格区分 key(用于本地存储)
36
+ tableKey?: string
37
+ // 完全自定义缓存 key,优先级最高
38
+ columnStorageKey?: string
39
+ // 是否开启列配置功能
40
+ columnConfig?: boolean
41
+ // 是否持久化列配置到本地存储
42
+ columnStorage?: boolean
43
+ // 是否显示分页
44
+ pagination?: boolean
45
+ // 总记录数
46
+ total?: number
47
+ // 当前页码
48
+ page?: number
49
+ // 每页条数
50
+ pageSize?: number
51
+ // 可选每页条数列表
52
+ pageSizes?: number[]
53
+ // 分页组件布局
54
+ layout?: string
55
+ barJustifyContent?: string
56
+ colBtnSize?: "" | "small" | "large" | "default" | undefined
57
+ // 外部递增该值时,清空表格内部保留的勾选状态
58
+ selectionResetKey?: string | number
59
+ }>(),
60
+ {
61
+ columnConfig: true,
62
+ columnStorage: true,
63
+ pagination: true,
64
+ page: 1,
65
+ pageSize: 10,
66
+ pageSizes: () => [10, 20, 50, 100],
67
+ layout: "total, sizes, prev, pager, next, jumper",
68
+ colBtnSize: ""
69
+ }
70
+ )
71
+
72
+ /**
73
+ * 事件定义
74
+ */
75
+ const emit = defineEmits<{
76
+ // 更新页码
77
+ "update:page": [value: number]
78
+ // 更新每页条数
79
+ "update:pageSize": [value: number]
80
+ // 分页变化
81
+ "pagination-change": [value: { page: number; pageSize: number }]
82
+ }>()
83
+
84
+ /**
85
+ * 依赖注入
86
+ */
87
+ const route = useRoute()
88
+ const attrs = useAttrs()
89
+ const slots = useSlots()
90
+ const columnOrderTipId = useId()
91
+
92
+ /**
93
+ * 响应式状态
94
+ */
95
+ // 列配置弹窗可见性
96
+ const dialogVisible = ref(false)
97
+ const tableRef = ref<{ clearSelection: () => void } | null>(null)
98
+
99
+ // 列选项类型定义
100
+ type ColumnOption = {
101
+ key: string // 列唯一标识
102
+ label: string // 列显示名称
103
+ visible: boolean // 是否可见
104
+ disabled: boolean // 是否禁用选择
105
+ orderLocked: boolean // 是否锁定列顺序
106
+ vnode: VNode // 列的 VNode 节点
107
+ }
108
+
109
+ type DropPlacement = "before" | "after"
110
+ const lockedColumnTypes = new Set(["selection", "index", "expand"])
111
+
112
+ /** Vue 模板中的无值属性可能表现为空字符串,需要按已启用处理。 */
113
+ const isColumnPropEnabled = (value: unknown) => value === "" || Boolean(value)
114
+
115
+ // 列选项列表
116
+ const columnOptions = ref<ColumnOption[]>([])
117
+
118
+ // 弹窗中的临时列选项(确认后才应用)
119
+ const pendingColumnOptions = ref<ColumnOption[]>([])
120
+
121
+ // 列排序拖拽状态
122
+ const draggedColumnKey = ref<string | null>(null)
123
+ const dragOverColumnKey = ref<string | null>(null)
124
+ const dropPlacement = ref<DropPlacement | null>(null)
125
+ const columnOrderAnnouncement = ref("")
126
+
127
+ watch(
128
+ () => props.selectionResetKey,
129
+ async (value, oldValue) => {
130
+ if (value === oldValue) return
131
+ await nextTick()
132
+ tableRef.value?.clearSelection()
133
+ }
134
+ )
135
+
136
+ /**
137
+ * 计算属性
138
+ */
139
+
140
+ // 本地存储的 key(根据路由路径和表格 key 生成)
141
+ const storageKey = computed(() => {
142
+ // 优先使用自定义的存储 key
143
+ if (props.columnStorageKey) {
144
+ return props.columnStorageKey
145
+ }
146
+ // 如果指定了表格 key,添加到存储 key 中
147
+ if (props.tableKey) {
148
+ return `el-table-plus:${route.path}:${props.tableKey}`
149
+ }
150
+ // 默认使用路由路径作为存储 key
151
+ return `el-table-plus:${route.path}`
152
+ })
153
+
154
+ // 当前页码(双向绑定)
155
+ const currentPage = computed({
156
+ get: () => props.page,
157
+ set: (value) => {
158
+ emit("update:page", value)
159
+ emit("pagination-change", {
160
+ page: value,
161
+ pageSize: props.pageSize
162
+ })
163
+ }
164
+ })
165
+
166
+ // 当前每页条数(双向绑定)
167
+ const currentPageSize = computed({
168
+ get: () => props.pageSize,
169
+ set: (value) => {
170
+ emit("update:pageSize", value)
171
+ emit("update:page", 1)
172
+ emit("pagination-change", {
173
+ page: 1,
174
+ pageSize: value
175
+ })
176
+ }
177
+ })
178
+
179
+ // 是否全选(弹窗中的临时状态)
180
+ const isAllSelected = computed({
181
+ get: () => {
182
+ const selectable = pendingColumnOptions.value.filter((col) => !col.disabled)
183
+ return selectable.length > 0 && selectable.every((col) => col.visible)
184
+ },
185
+ set: (value) => {
186
+ pendingColumnOptions.value.forEach((col) => {
187
+ if (!col.disabled) {
188
+ col.visible = value
189
+ }
190
+ })
191
+ }
192
+ })
193
+
194
+ const pendingVisibleColumnCount = computed(
195
+ () => pendingColumnOptions.value.filter((column) => column.visible).length
196
+ )
197
+
198
+ /**
199
+ * 方法定义
200
+ */
201
+
202
+ /**
203
+ * 获取列的唯一标识
204
+ * @param vnode - 列的 VNode 节点
205
+ * @param index - 索引位置
206
+ * @returns 列的唯一标识
207
+ */
208
+ const getColumnKey = (vnode: VNode, index: number) => {
209
+ const columnProps = vnode.props as Record<string, any> | null
210
+
211
+ return (
212
+ columnProps?.columnKey ||
213
+ columnProps?.prop ||
214
+ columnProps?.label ||
215
+ columnProps?.type ||
216
+ `column_${index}`
217
+ )
218
+ }
219
+
220
+ /**
221
+ * 获取列的显示标签
222
+ * @param vnode - 列的 VNode 节点
223
+ * @param index - 索引位置
224
+ * @returns 列的显示标签
225
+ */
226
+ const getColumnLabel = (vnode: VNode, index: number) => {
227
+ const columnProps = vnode.props as Record<string, any> | null
228
+
229
+ return (
230
+ columnProps?.label ||
231
+ columnProps?.prop ||
232
+ columnProps?.type ||
233
+ `列 ${index + 1}`
234
+ )
235
+ }
236
+
237
+ /**
238
+ * 从本地存储恢复列配置
239
+ */
240
+ const restoreColumnConfig = () => {
241
+ // 如果未开启本地存储,直接返回
242
+ if (!props.columnStorage) return
243
+
244
+ // 从 localStorage 获取缓存的列配置
245
+ const cache = localStorage.getItem(storageKey.value)
246
+ if (!cache) return
247
+
248
+ try {
249
+ // 解析缓存数据
250
+ const cacheColumns = JSON.parse(cache) as Array<{
251
+ key: string
252
+ visible: boolean
253
+ }>
254
+ if (!Array.isArray(cacheColumns)) {
255
+ throw new Error("Invalid column cache")
256
+ }
257
+
258
+ const cacheByKey = new Map(cacheColumns.map((column) => [column.key, column]))
259
+ const cacheOrder = new Map(cacheColumns.map((column, index) => [column.key, index]))
260
+
261
+ // 先恢复显隐状态;禁用显隐的列始终使用组件声明配置
262
+ columnOptions.value.forEach((column) => {
263
+ if (column.disabled) return
264
+ const match = cacheByKey.get(column.key)
265
+ if (match && typeof match.visible === "boolean") {
266
+ column.visible = match.visible
267
+ }
268
+ })
269
+
270
+ // 固定列作为分隔点,只恢复各可移动区间内的顺序
271
+ const restoredColumns: ColumnOption[] = []
272
+ let movableColumns: ColumnOption[] = []
273
+ const flushMovableColumns = () => {
274
+ movableColumns.sort((left, right) => {
275
+ const leftOrder = cacheOrder.get(left.key)
276
+ const rightOrder = cacheOrder.get(right.key)
277
+ if (leftOrder === undefined && rightOrder === undefined) return 0
278
+ if (leftOrder === undefined) return 1
279
+ if (rightOrder === undefined) return -1
280
+ return leftOrder - rightOrder
281
+ })
282
+ restoredColumns.push(...movableColumns)
283
+ movableColumns = []
284
+ }
285
+
286
+ columnOptions.value.forEach((column) => {
287
+ if (column.orderLocked) {
288
+ flushMovableColumns()
289
+ restoredColumns.push(column)
290
+ return
291
+ }
292
+ movableColumns.push(column)
293
+ })
294
+ flushMovableColumns()
295
+ columnOptions.value = restoredColumns
296
+ } catch {
297
+ // 解析失败时清除缓存
298
+ localStorage.removeItem(storageKey.value)
299
+ }
300
+ }
301
+
302
+ /**
303
+ * 保存列配置到本地存储
304
+ */
305
+ const saveColumnConfig = () => {
306
+ // 如果未开启本地存储,直接返回
307
+ if (!props.columnStorage) return
308
+
309
+ // 构建需要缓存的数据结构
310
+ const cacheColumns = columnOptions.value.map((column) => ({
311
+ key: column.key,
312
+ visible: column.visible
313
+ }))
314
+
315
+ // 保存到 localStorage
316
+ localStorage.setItem(storageKey.value, JSON.stringify(cacheColumns))
317
+ }
318
+
319
+ /**
320
+ * 判断某列是否可以向相邻方向移动
321
+ */
322
+ const canMovePendingColumn = (index: number, direction: -1 | 1) => {
323
+ const column = pendingColumnOptions.value[index]
324
+ const targetColumn = pendingColumnOptions.value[index + direction]
325
+ return Boolean(column && targetColumn && !column.orderLocked && !targetColumn.orderLocked)
326
+ }
327
+
328
+ /**
329
+ * 使用按钮或键盘调整列顺序
330
+ */
331
+ const movePendingColumn = (columnKey: string, direction: -1 | 1) => {
332
+ const currentIndex = pendingColumnOptions.value.findIndex((column) => column.key === columnKey)
333
+ if (!canMovePendingColumn(currentIndex, direction)) return
334
+
335
+ const targetIndex = currentIndex + direction
336
+ const nextColumns = [...pendingColumnOptions.value]
337
+ const currentColumn = nextColumns[currentIndex]
338
+ const targetColumn = nextColumns[targetIndex]
339
+ if (!currentColumn || !targetColumn) return
340
+
341
+ nextColumns[currentIndex] = targetColumn
342
+ nextColumns[targetIndex] = currentColumn
343
+ pendingColumnOptions.value = nextColumns
344
+ columnOrderAnnouncement.value = `${currentColumn.label}已移动到第 ${targetIndex + 1} 位`
345
+ }
346
+
347
+ /**
348
+ * 判断拖拽是否会跨越锁定列
349
+ */
350
+ const canDropColumn = (sourceIndex: number, targetIndex: number) => {
351
+ if (sourceIndex < 0 || targetIndex < 0 || sourceIndex === targetIndex) return false
352
+ const startIndex = Math.min(sourceIndex, targetIndex)
353
+ const endIndex = Math.max(sourceIndex, targetIndex)
354
+ return !pendingColumnOptions.value
355
+ .slice(startIndex, endIndex + 1)
356
+ .some((column) => column.orderLocked)
357
+ }
358
+
359
+ const resetColumnDragState = () => {
360
+ draggedColumnKey.value = null
361
+ dragOverColumnKey.value = null
362
+ dropPlacement.value = null
363
+ }
364
+
365
+ const handleColumnDragStart = (event: DragEvent, column: ColumnOption) => {
366
+ if (column.orderLocked) {
367
+ event.preventDefault()
368
+ return
369
+ }
370
+
371
+ draggedColumnKey.value = column.key
372
+ if (event.dataTransfer) {
373
+ event.dataTransfer.effectAllowed = "move"
374
+ event.dataTransfer.setData("text/plain", column.key)
375
+ const dragItem = (event.currentTarget as HTMLElement | null)?.closest<HTMLElement>(
376
+ ".el-table-plus__column-grid-item"
377
+ )
378
+ if (dragItem) {
379
+ event.dataTransfer.setDragImage(dragItem, 24, 24)
380
+ }
381
+ }
382
+ }
383
+
384
+ const handleColumnDragOver = (event: DragEvent, targetColumn: ColumnOption) => {
385
+ const sourceIndex = pendingColumnOptions.value.findIndex(
386
+ (column) => column.key === draggedColumnKey.value
387
+ )
388
+ const targetIndex = pendingColumnOptions.value.findIndex(
389
+ (column) => column.key === targetColumn.key
390
+ )
391
+ if (!canDropColumn(sourceIndex, targetIndex)) {
392
+ dragOverColumnKey.value = null
393
+ dropPlacement.value = null
394
+ return
395
+ }
396
+
397
+ event.preventDefault()
398
+ if (event.dataTransfer) {
399
+ event.dataTransfer.dropEffect = "move"
400
+ }
401
+
402
+ const targetElement = event.currentTarget as HTMLElement
403
+ const targetRect = targetElement.getBoundingClientRect()
404
+ dragOverColumnKey.value = targetColumn.key
405
+ dropPlacement.value = event.clientY < targetRect.top + targetRect.height / 2 ? "before" : "after"
406
+ }
407
+
408
+ const handleColumnDrop = (event: DragEvent, targetColumn: ColumnOption) => {
409
+ event.preventDefault()
410
+ const sourceIndex = pendingColumnOptions.value.findIndex(
411
+ (column) => column.key === draggedColumnKey.value
412
+ )
413
+ const targetIndex = pendingColumnOptions.value.findIndex(
414
+ (column) => column.key === targetColumn.key
415
+ )
416
+ if (!canDropColumn(sourceIndex, targetIndex)) {
417
+ resetColumnDragState()
418
+ return
419
+ }
420
+
421
+ let insertIndex = targetIndex + (dropPlacement.value === "after" ? 1 : 0)
422
+ if (sourceIndex < insertIndex) {
423
+ insertIndex -= 1
424
+ }
425
+ if (insertIndex === sourceIndex) {
426
+ resetColumnDragState()
427
+ return
428
+ }
429
+
430
+ const nextColumns = [...pendingColumnOptions.value]
431
+ const [movedColumn] = nextColumns.splice(sourceIndex, 1)
432
+ if (!movedColumn) {
433
+ resetColumnDragState()
434
+ return
435
+ }
436
+
437
+ nextColumns.splice(insertIndex, 0, movedColumn)
438
+ pendingColumnOptions.value = nextColumns
439
+ columnOrderAnnouncement.value = `${movedColumn.label}已移动到第 ${insertIndex + 1} 位`
440
+ resetColumnDragState()
441
+ }
442
+
443
+ /**
444
+ * 打开列配置弹窗
445
+ */
446
+ const openColumnConfigDialog = () => {
447
+ pendingColumnOptions.value = columnOptions.value.map((col) => ({ ...col }))
448
+ columnOrderAnnouncement.value = ""
449
+ resetColumnDragState()
450
+ dialogVisible.value = true
451
+ }
452
+
453
+ /**
454
+ * 确认列配置
455
+ */
456
+ const confirmColumnConfig = () => {
457
+ columnOptions.value = pendingColumnOptions.value.map((column) => ({ ...column }))
458
+ saveColumnConfig()
459
+ dialogVisible.value = false
460
+ }
461
+
462
+ /**
463
+ * 取消列配置
464
+ */
465
+ const cancelColumnConfig = () => {
466
+ resetColumnDragState()
467
+ dialogVisible.value = false
468
+ }
469
+
470
+ /**
471
+ * 初始化列配置
472
+ */
473
+ const initColumns = () => {
474
+ const rawChildren = slots.default?.() || []
475
+
476
+ const flattenVNodes = (vnodes: VNode[]): VNode[] => {
477
+ const result: VNode[] = []
478
+ for (const vnode of vnodes) {
479
+ if (vnode.type === Fragment && Array.isArray(vnode.children)) {
480
+ result.push(...flattenVNodes(vnode.children as VNode[]))
481
+ } else {
482
+ result.push(vnode)
483
+ }
484
+ }
485
+ return result
486
+ }
487
+
488
+ const children = flattenVNodes(rawChildren)
489
+
490
+ columnOptions.value = children.map((vnode, index) => {
491
+ const columnProps = vnode.props as Record<string, any> | null
492
+ const disabled = isColumnPropEnabled(columnProps?.disabled)
493
+ const fixed = isColumnPropEnabled(columnProps?.fixed)
494
+ return {
495
+ key: getColumnKey(vnode, index),
496
+ label: getColumnLabel(vnode, index),
497
+ visible: columnProps?.visible ?? true,
498
+ disabled,
499
+ orderLocked: Boolean(
500
+ disabled ||
501
+ fixed ||
502
+ lockedColumnTypes.has(columnProps?.type)
503
+ ),
504
+ vnode
505
+ }
506
+ })
507
+
508
+ restoreColumnConfig()
509
+ }
510
+
511
+ /**
512
+ * 获取可见的列(用于渲染)
513
+ */
514
+ const visibleColumns = computed(() => {
515
+ return columnOptions.value
516
+ .filter((column) => column.visible)
517
+ .map((column) => ({
518
+ key: column.key,
519
+ vnode: cloneVNode(column.vnode, { key: column.key })
520
+ }))
521
+ })
522
+
523
+ // 初始化列配置
524
+ initColumns()
525
+ </script>
526
+
527
+ <template>
528
+ <div class="el-table-plus">
529
+ <!-- 工具栏 -->
530
+ <div
531
+ v-if="columnConfig"
532
+ class="el-table-plus__toolbar"
533
+ :style="`justify-content:${barJustifyContent}`"
534
+ >
535
+ <div class="el-table-plus__toolbar-left">
536
+ <slot name="toolbar" />
537
+ </div>
538
+
539
+ <div class="el-table-plus__toolbar-right">
540
+ <slot name="toolbar-right" />
541
+ <el-button
542
+ @click="openColumnConfigDialog"
543
+ icon="Setting"
544
+ :size="colBtnSize"
545
+ >
546
+ 列配置
547
+ </el-button>
548
+ </div>
549
+ </div>
550
+
551
+ <!-- 表格主体 -->
552
+ <el-table
553
+ ref="tableRef"
554
+ v-bind="{
555
+ ...attrs,
556
+ style: undefined // 明确排除 style
557
+ }"
558
+ :data="data"
559
+ :row-key="rowKey"
560
+ >
561
+ <component
562
+ :is="column.vnode"
563
+ v-for="column in visibleColumns"
564
+ :key="column.key"
565
+ />
566
+ </el-table>
567
+
568
+ <!-- 分页组件 -->
569
+ <div v-if="pagination" class="el-table-plus__pagination">
570
+ <el-pagination
571
+ v-model:current-page="currentPage"
572
+ v-model:page-size="currentPageSize"
573
+ :total="total || data.length"
574
+ :page-sizes="pageSizes"
575
+ :layout="layout"
576
+ background
577
+ :small="colBtnSize === 'small'"
578
+ />
579
+ </div>
580
+
581
+ <!-- 列配置弹窗 -->
582
+ <el-dialog
583
+ v-model="dialogVisible"
584
+ title="表格列配置"
585
+ width="min(640px, calc(100vw - 32px))"
586
+ :close-on-click-modal="false"
587
+ @closed="resetColumnDragState"
588
+ >
589
+ <!-- 弹窗提示文字 -->
590
+ <p :id="columnOrderTipId" class="el-table-plus__dialog-tip">
591
+ <span>勾选需要显示的列,拖动手柄或使用方向按钮调整顺序</span>
592
+
593
+ <el-popover placement="right" :width="400" trigger="hover">
594
+ <template #reference>
595
+ <el-icon class="icon"><QuestionFilled></QuestionFilled></el-icon>
596
+ </template>
597
+ <div>
598
+ <p style="font-weight: bold; margin-bottom: 5px">提示</p>
599
+ <p style="margin: 5px 0; line-height: 1.4">
600
+ 1.列的显示状态和排列顺序只对当前浏览器生效(和登录账户无关)。
601
+ </p>
602
+ <p style="margin: 5px 0; line-height: 1.4">
603
+ 2.清除浏览器缓存后,列配置会恢复到默认。
604
+ </p>
605
+ <p style="margin: 5px 0; line-height: 1.4">
606
+ 3.切换账号,不会重置列配置
607
+ </p>
608
+ </div>
609
+ </el-popover>
610
+ </p>
611
+
612
+ <!-- 列配置内容 -->
613
+ <div class="el-table-plus__column-config">
614
+ <!-- 全选行 -->
615
+ <div class="el-table-plus__column-select-all">
616
+ <el-checkbox v-model="isAllSelected"> 全选 </el-checkbox>
617
+ <span class="el-table-plus__column-count">
618
+ 已显示 {{ pendingVisibleColumnCount }}/{{ pendingColumnOptions.length }} 列
619
+ </span>
620
+ </div>
621
+
622
+ <!-- 分隔线 -->
623
+ <div class="el-table-plus__column-divider"></div>
624
+
625
+ <!-- 可排序列选项列表 -->
626
+ <div class="el-table-plus__column-grid">
627
+ <div
628
+ v-for="(column, index) in pendingColumnOptions"
629
+ :key="column.key"
630
+ class="el-table-plus__column-grid-item"
631
+ :class="{
632
+ 'is-dragging': draggedColumnKey === column.key,
633
+ 'is-drop-before': dragOverColumnKey === column.key && dropPlacement === 'before',
634
+ 'is-drop-after': dragOverColumnKey === column.key && dropPlacement === 'after',
635
+ 'is-order-locked': column.orderLocked
636
+ }"
637
+ @dragover="handleColumnDragOver($event, column)"
638
+ @drop="handleColumnDrop($event, column)"
639
+ >
640
+ <span
641
+ class="el-table-plus__drag-handle"
642
+ :class="{ 'is-disabled': column.orderLocked }"
643
+ :draggable="!column.orderLocked"
644
+ :role="column.orderLocked ? undefined : 'spinbutton'"
645
+ :tabindex="column.orderLocked ? -1 : 0"
646
+ :aria-label="column.orderLocked ? undefined : `调整${column.label}的顺序`"
647
+ :aria-describedby="column.orderLocked ? undefined : columnOrderTipId"
648
+ :aria-valuemin="column.orderLocked ? undefined : 1"
649
+ :aria-valuemax="column.orderLocked ? undefined : pendingColumnOptions.length"
650
+ :aria-valuenow="column.orderLocked ? undefined : index + 1"
651
+ :aria-valuetext="column.orderLocked ? undefined : `第 ${index + 1} 位`"
652
+ :title="column.orderLocked ? '该列顺序已固定' : '拖动或使用上下方向键调整顺序'"
653
+ @dragstart="handleColumnDragStart($event, column)"
654
+ @dragend="resetColumnDragState"
655
+ @keydown.up.prevent="movePendingColumn(column.key, -1)"
656
+ @keydown.down.prevent="movePendingColumn(column.key, 1)"
657
+ >
658
+ <span class="el-table-plus__drag-dots" aria-hidden="true"></span>
659
+ </span>
660
+ <span class="el-table-plus__column-order" aria-hidden="true">
661
+ {{ String(index + 1).padStart(2, "0") }}
662
+ </span>
663
+ <el-checkbox
664
+ v-model="column.visible"
665
+ class="el-table-plus__column-checkbox"
666
+ :disabled="column.disabled"
667
+ >
668
+ {{ column.label }}
669
+ </el-checkbox>
670
+ <span v-if="column.orderLocked" class="el-table-plus__column-lock">
671
+ 固定顺序
672
+ </span>
673
+ <div v-else class="el-table-plus__column-move-actions">
674
+ <button
675
+ type="button"
676
+ class="el-table-plus__move-button"
677
+ :disabled="!canMovePendingColumn(index, -1)"
678
+ :aria-label="`上移${column.label}`"
679
+ :title="`上移${column.label}`"
680
+ @click="movePendingColumn(column.key, -1)"
681
+ >
682
+ <span aria-hidden="true">↑</span>
683
+ </button>
684
+ <button
685
+ type="button"
686
+ class="el-table-plus__move-button"
687
+ :disabled="!canMovePendingColumn(index, 1)"
688
+ :aria-label="`下移${column.label}`"
689
+ :title="`下移${column.label}`"
690
+ @click="movePendingColumn(column.key, 1)"
691
+ >
692
+ <span aria-hidden="true">↓</span>
693
+ </button>
694
+ </div>
695
+ </div>
696
+ </div>
697
+ <p class="el-table-plus__sr-only" aria-live="polite">
698
+ {{ columnOrderAnnouncement }}
699
+ </p>
700
+ </div>
701
+
702
+ <!-- 弹窗底部按钮 -->
703
+ <template #footer>
704
+ <div class="el-table-plus__dialog-footer">
705
+ <el-button @click="cancelColumnConfig"> 取消 </el-button>
706
+
707
+ <el-button type="primary" @click="confirmColumnConfig">
708
+ 确认
709
+ </el-button>
710
+ </div>
711
+ </template>
712
+ </el-dialog>
713
+ </div>
714
+ </template>
715
+
716
+ <style scoped lang="scss">
717
+ /**
718
+ * 主容器样式
719
+ */
720
+ .el-table-plus {
721
+ width: 100%;
722
+ }
723
+
724
+ /**
725
+ * 工具栏样式
726
+ */
727
+ .el-table-plus__toolbar {
728
+ display: flex;
729
+ align-items: center;
730
+ justify-content: space-between;
731
+ margin-bottom: 12px;
732
+ }
733
+ .el-table-plus__toolbar-left {
734
+ width: 100%;
735
+ }
736
+
737
+ .el-table-plus__toolbar-left,
738
+ .el-table-plus__toolbar-right {
739
+ display: flex;
740
+ align-items: center;
741
+ gap: 8px;
742
+ }
743
+
744
+ /**
745
+ * 分页组件样式
746
+ */
747
+ .el-table-plus__pagination {
748
+ display: flex;
749
+ justify-content: flex-end;
750
+ margin-top: 10px;
751
+ }
752
+
753
+ /**
754
+ * 弹窗提示文字样式
755
+ */
756
+ .el-table-plus__dialog-tip {
757
+ font-size: 14px;
758
+ color: #909399;
759
+ margin-bottom: 16px;
760
+ margin-top: 8px;
761
+ display: flex;
762
+ align-items: center;
763
+ line-height: 1.5;
764
+ .icon {
765
+ margin-left: 10px;
766
+ cursor: pointer;
767
+ flex: none;
768
+ }
769
+ }
770
+
771
+ /**
772
+ * 列配置容器样式
773
+ */
774
+ .el-table-plus__column-config {
775
+ border: 1px solid #e4e7ed;
776
+ border-radius: 10px;
777
+ padding: 12px;
778
+ background: #f7f9fc;
779
+ }
780
+
781
+ /**
782
+ * 全选行样式
783
+ */
784
+ .el-table-plus__column-select-all {
785
+ display: flex;
786
+ align-items: center;
787
+ justify-content: space-between;
788
+ gap: 16px;
789
+ padding: 4px 4px 8px;
790
+ }
791
+
792
+ .el-table-plus__column-count {
793
+ font-size: 12px;
794
+ color: #909399;
795
+ font-variant-numeric: tabular-nums;
796
+ }
797
+
798
+ /**
799
+ * 分隔线样式
800
+ */
801
+ .el-table-plus__column-divider {
802
+ height: 1px;
803
+ background-color: #e4e7ed;
804
+ margin: 4px 0 8px;
805
+ }
806
+
807
+ /**
808
+ * 列选项网格布局样式
809
+ */
810
+ .el-table-plus__column-grid {
811
+ display: flex;
812
+ flex-direction: column;
813
+ gap: 6px;
814
+ max-height: min(48vh, 420px);
815
+ overflow-y: auto;
816
+ overscroll-behavior: contain;
817
+ padding: 4px;
818
+ scrollbar-gutter: stable;
819
+ }
820
+
821
+ /**
822
+ * 网格项样式
823
+ */
824
+ .el-table-plus__column-grid-item {
825
+ position: relative;
826
+ display: grid;
827
+ grid-template-columns: 24px 34px minmax(0, 1fr) auto;
828
+ align-items: center;
829
+ gap: 8px;
830
+ min-height: 44px;
831
+ padding: 6px 8px;
832
+ border: 1px solid #e4e7ed;
833
+ border-radius: 8px;
834
+ background: #ffffff;
835
+ transition:
836
+ border-color 160ms ease,
837
+ box-shadow 160ms ease,
838
+ background-color 160ms ease,
839
+ opacity 160ms ease;
840
+ }
841
+
842
+ .el-table-plus__column-grid-item:hover {
843
+ border-color: #c6e2ff;
844
+ box-shadow: 0 3px 12px rgb(31 45 61 / 7%);
845
+ }
846
+
847
+ .el-table-plus__column-grid-item.is-order-locked {
848
+ background: #fafafa;
849
+ }
850
+
851
+ .el-table-plus__column-grid-item.is-dragging {
852
+ opacity: 0.42;
853
+ box-shadow: none;
854
+ }
855
+
856
+ .el-table-plus__column-grid-item.is-drop-before::before,
857
+ .el-table-plus__column-grid-item.is-drop-after::after {
858
+ position: absolute;
859
+ right: 4px;
860
+ left: 4px;
861
+ z-index: 2;
862
+ height: 2px;
863
+ border-radius: 999px;
864
+ background: var(--el-color-primary, #409eff);
865
+ box-shadow: 0 0 0 2px rgb(64 158 255 / 12%);
866
+ content: "";
867
+ }
868
+
869
+ .el-table-plus__column-grid-item.is-drop-before::before {
870
+ top: -5px;
871
+ }
872
+
873
+ .el-table-plus__column-grid-item.is-drop-after::after {
874
+ bottom: -5px;
875
+ }
876
+
877
+ .el-table-plus__drag-handle {
878
+ display: inline-flex;
879
+ width: 24px;
880
+ height: 28px;
881
+ align-items: center;
882
+ justify-content: center;
883
+ border-radius: 6px;
884
+ cursor: grab;
885
+ user-select: none;
886
+ }
887
+
888
+ .el-table-plus__drag-handle:hover {
889
+ background: #ecf5ff;
890
+ }
891
+
892
+ .el-table-plus__drag-handle:active {
893
+ cursor: grabbing;
894
+ }
895
+
896
+ .el-table-plus__drag-handle:focus-visible {
897
+ outline: 2px solid var(--el-color-primary, #409eff);
898
+ outline-offset: 1px;
899
+ }
900
+
901
+ .el-table-plus__drag-handle.is-disabled {
902
+ cursor: not-allowed;
903
+ opacity: 0.35;
904
+ }
905
+
906
+ .el-table-plus__drag-handle.is-disabled:hover {
907
+ background: transparent;
908
+ }
909
+
910
+ .el-table-plus__drag-dots {
911
+ width: 12px;
912
+ height: 18px;
913
+ background-image: radial-gradient(circle, #909399 1.2px, transparent 1.3px);
914
+ background-position: center;
915
+ background-size: 5px 5px;
916
+ }
917
+
918
+ .el-table-plus__column-order {
919
+ color: #a8abb2;
920
+ font-size: 12px;
921
+ font-variant-numeric: tabular-nums;
922
+ letter-spacing: 0.04em;
923
+ }
924
+
925
+ .el-table-plus__column-checkbox {
926
+ min-width: 0;
927
+ margin-right: 0;
928
+ }
929
+
930
+ .el-table-plus__column-checkbox :deep(.el-checkbox__label) {
931
+ overflow: hidden;
932
+ text-overflow: ellipsis;
933
+ white-space: nowrap;
934
+ }
935
+
936
+ .el-table-plus__column-lock {
937
+ padding: 3px 8px;
938
+ border: 1px solid #e4e7ed;
939
+ border-radius: 999px;
940
+ color: #909399;
941
+ background: #f4f4f5;
942
+ font-size: 11px;
943
+ line-height: 1.4;
944
+ white-space: nowrap;
945
+ }
946
+
947
+ .el-table-plus__column-move-actions {
948
+ display: inline-flex;
949
+ gap: 4px;
950
+ }
951
+
952
+ .el-table-plus__move-button {
953
+ display: inline-flex;
954
+ width: 28px;
955
+ height: 28px;
956
+ align-items: center;
957
+ justify-content: center;
958
+ padding: 0;
959
+ border: 1px solid #dcdfe6;
960
+ border-radius: 6px;
961
+ color: #606266;
962
+ background: #ffffff;
963
+ font: inherit;
964
+ cursor: pointer;
965
+ transition:
966
+ color 150ms ease,
967
+ border-color 150ms ease,
968
+ background-color 150ms ease;
969
+ }
970
+
971
+ .el-table-plus__move-button:hover:not(:disabled) {
972
+ border-color: #79bbff;
973
+ color: var(--el-color-primary, #409eff);
974
+ background: #ecf5ff;
975
+ }
976
+
977
+ .el-table-plus__move-button:focus-visible {
978
+ outline: 2px solid var(--el-color-primary, #409eff);
979
+ outline-offset: 1px;
980
+ }
981
+
982
+ .el-table-plus__move-button:disabled {
983
+ color: #c0c4cc;
984
+ background: #f5f7fa;
985
+ cursor: not-allowed;
986
+ }
987
+
988
+ .el-table-plus__sr-only {
989
+ position: absolute;
990
+ width: 1px;
991
+ height: 1px;
992
+ padding: 0;
993
+ margin: -1px;
994
+ overflow: hidden;
995
+ clip: rect(0, 0, 0, 0);
996
+ white-space: nowrap;
997
+ border: 0;
998
+ }
999
+
1000
+ @media (max-width: 520px) {
1001
+ .el-table-plus__column-grid-item {
1002
+ grid-template-columns: 24px minmax(0, 1fr) auto;
1003
+ }
1004
+
1005
+ .el-table-plus__column-order {
1006
+ display: none;
1007
+ }
1008
+
1009
+ .el-table-plus__column-lock {
1010
+ padding-inline: 6px;
1011
+ }
1012
+ }
1013
+
1014
+ /**
1015
+ * 弹窗底部按钮容器样式
1016
+ */
1017
+ .el-table-plus__dialog-footer {
1018
+ display: flex;
1019
+ justify-content: flex-end;
1020
+ gap: 12px;
1021
+ }
1022
+
1023
+ /**
1024
+ * 弹窗底部取消按钮样式
1025
+ */
1026
+ .el-table-plus__dialog-footer .el-button:first-child {
1027
+ background-color: #f5f7fa;
1028
+ color: #606266;
1029
+ border-color: #d9d9d9;
1030
+ }
1031
+
1032
+ .el-table-plus__dialog-footer .el-button:first-child:hover {
1033
+ background-color: #e4e7ed;
1034
+ border-color: #c0c4cc;
1035
+ }
1036
+
1037
+ /**
1038
+ * 弹窗底部确认按钮样式
1039
+ */
1040
+ .el-table-plus__dialog-footer .el-button--primary {
1041
+ background-color: #1890ff;
1042
+ border-color: #1890ff;
1043
+ color: #ffffff;
1044
+ }
1045
+
1046
+ .el-table-plus__dialog-footer .el-button--primary:hover {
1047
+ background-color: #40a9ff;
1048
+ border-color: #40a9ff;
1049
+ }
1050
+ </style>