vue2-client 1.15.12 → 1.15.14

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.
@@ -25,7 +25,7 @@ export default {
25
25
  data () {
26
26
  return {
27
27
  // 查询配置文件名
28
- queryParamsName: 'ApplyTransactionCRUD',
28
+ queryParamsName: 'ceshiCRUD',
29
29
  // 新增表单固定值
30
30
  fixedAddForm: {},
31
31
  // 是否显示详情抽屉
@@ -6,7 +6,9 @@
6
6
  width="60vw"
7
7
  @ok="printGen"
8
8
  @cancel="cancel"
9
- style="min-width: 800px">
9
+ style="min-width: 800px"
10
+ z-index="1009"
11
+ >
10
12
  <a-skeleton v-if="!loaded" active/>
11
13
  <div
12
14
  style="display: flex;justify-content: center;"
@@ -19,6 +19,7 @@
19
19
  :setScrollYHeight="tableContext.setScrollYHeight"
20
20
  :selectRowMode="tableContext.selectRowMode"
21
21
  :size="tableContext.tableSize"
22
+ :components="components"
22
23
  @beforeDataChange="beforeDataChange"
23
24
  @expand="onExpand"
24
25
  @rowClick="handleRowClick"
@@ -154,6 +155,7 @@
154
155
  :setScrollYHeight="tableContext.setScrollYHeight"
155
156
  :selectRowMode="tableContext.selectRowMode"
156
157
  :size="tableContext.tableSize"
158
+ :components="components"
157
159
  @rowClick="handleRowClick"
158
160
  @beforeDataChange="beforeDataChange"
159
161
  >
@@ -269,6 +271,7 @@ import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormIte
269
271
  import CustomFuncCel from '@vue2-client/base-client/components/common/XTable/CustomFuncCel.vue'
270
272
  import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
271
273
  import XRate from '@vue2-client/base-client/components/common/XRate/index.vue'
274
+ import VueDraggableResizable from 'vue-draggable-resizable'
272
275
 
273
276
  export default {
274
277
  name: 'XTableWrapper',
@@ -278,7 +281,15 @@ export default {
278
281
  XBadge,
279
282
  XFormItem,
280
283
  XRate,
281
- CustomFuncCel
284
+ CustomFuncCel,
285
+ VueDraggableResizable
286
+ },
287
+ data () {
288
+ return {
289
+ isDragging: false, // 添加拖拽状态标记
290
+ // eslint-disable-next-line vue/no-reserved-keys
291
+ _rafId: null // 添加requestAnimationFrame ID标记
292
+ }
282
293
  },
283
294
  computed: {
284
295
  localDataSource () {
@@ -290,6 +301,114 @@ export default {
290
301
  },
291
302
  realTableColumns () {
292
303
  return this.tableContext.tableColumns.filter(item => item.slotType !== 'action' || !this.disableAction)
304
+ },
305
+ components () {
306
+ return {
307
+ header: {
308
+ cell: (h, props, children) => {
309
+ const { key, ...restProps } = props
310
+ // 此处的this.realTableColumns 是定义的table的表头属性变量
311
+ const col = this.realTableColumns.find((col) => {
312
+ const k = col.dataIndex || col.key
313
+ return k === key
314
+ })
315
+ if (!col || !col.width) {
316
+ return h('th', { ...restProps }, [...children])
317
+ }
318
+
319
+ // 创建一个防止点击排序的容器
320
+ const preventSortProps = {
321
+ style: {
322
+ position: 'absolute',
323
+ right: 0,
324
+ top: 0,
325
+ width: '20px',
326
+ height: '100%',
327
+ zIndex: 10
328
+ },
329
+ on: {
330
+ mousedown: (e) => {
331
+ e.stopPropagation()
332
+ e.preventDefault()
333
+ this.isDragging = true
334
+ }
335
+ }
336
+ }
337
+
338
+ const dragProps = {
339
+ key: col.dataIndex || col.key,
340
+ class: 'table-draggable-handle',
341
+ attrs: {
342
+ w: 10,
343
+ x: col.width,
344
+ z: 1,
345
+ axis: 'x',
346
+ draggable: true,
347
+ resizable: false,
348
+ },
349
+ on: {
350
+ dragging: (x, y) => {
351
+ // 使用requestAnimationFrame优化性能,减少卡顿
352
+ if (!this._rafId) {
353
+ this._rafId = requestAnimationFrame(() => {
354
+ col.width = Math.max(x, 50) // 设置最小列宽为50px
355
+ this.isDragging = true // 设置拖拽状态
356
+ this._rafId = null
357
+ })
358
+ }
359
+ },
360
+ mousedown: (e) => {
361
+ // 阻止事件冒泡,防止触发排序
362
+ e.stopPropagation()
363
+ e.preventDefault()
364
+ this.isDragging = true // 设置拖拽状态
365
+ },
366
+ dragstop: () => {
367
+ // 清除可能存在的动画帧请求
368
+ if (this._rafId) {
369
+ cancelAnimationFrame(this._rafId)
370
+ this._rafId = null
371
+ }
372
+
373
+ // 拖拽结束时,延迟重置拖拽状态,以防止排序被触发
374
+ setTimeout(() => {
375
+ this.isDragging = false
376
+ }, 100)
377
+ }
378
+ },
379
+ nativeOn: {
380
+ mousedown: (e) => {
381
+ e.stopPropagation()
382
+ e.preventDefault()
383
+ this.isDragging = true // 设置拖拽状态
384
+ }
385
+ }
386
+ }
387
+
388
+ const preventSort = h('div', preventSortProps)
389
+ const drag = h('vue-draggable-resizable', { ...dragProps })
390
+
391
+ // 修改th的点击事件,在拖拽状态下阻止排序
392
+ const newRestProps = { ...restProps }
393
+ const originalClick = newRestProps.on && newRestProps.on.click
394
+ if (originalClick) {
395
+ newRestProps.on = {
396
+ ...newRestProps.on,
397
+ click: (e) => {
398
+ if (this.isDragging) {
399
+ e.stopPropagation()
400
+ e.preventDefault()
401
+ return
402
+ }
403
+ originalClick(e)
404
+ }
405
+ }
406
+ }
407
+
408
+ return h('th', { ...newRestProps, class: 'resize-table-th' }, [...children, preventSort, drag])
409
+ },
410
+ }
411
+ }
293
412
  }
294
413
  },
295
414
  props: {
@@ -412,6 +531,52 @@ export default {
412
531
  }
413
532
  return false
414
533
  },
534
+ handleResizeColumn (w, col) {
535
+ col.width = w
536
+ }
415
537
  }
416
538
  }
417
539
  </script>
540
+
541
+ <style>
542
+ .table-draggable-handle {
543
+ height: 100% !important;
544
+ left: auto !important;
545
+ right: -10px;
546
+ cursor: col-resize;
547
+ touch-action: none;
548
+ border: none;
549
+ position: absolute;
550
+ transform: none !important;
551
+ bottom: 0;
552
+ width: 20px !important;
553
+ }
554
+
555
+ .table-draggable-handle::after {
556
+ content: "";
557
+ position: absolute;
558
+ top: 50%;
559
+ height: 20px;
560
+ width: 1px;
561
+ background-color: #d9d9d9;
562
+ transition: background-color 0.2s;
563
+ transform: translateY(-50%);
564
+ right: 9px;
565
+ }
566
+
567
+ .table-draggable-handle:hover::after {
568
+ background-color: #1890ff;
569
+ }
570
+
571
+ .table-draggable-handle:active::after {
572
+ background-color: #096dd9;
573
+ }
574
+
575
+ .resize-table-th {
576
+ position: relative;
577
+ }
578
+
579
+ .resize-table-th:hover .table-draggable-handle::after {
580
+ background-color: rgba(24, 144, 255, 0.5);
581
+ }
582
+ </style>