@94ai/nf-table 8.3.4 → 8.3.7

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.
@@ -5358,7 +5358,7 @@ __sfc_main$1.setup = (__props, __ctx) => {
5358
5358
  updateColumn();
5359
5359
  if (currentTable.value.every((i) => !i.initHidden)) {
5360
5360
  showColumn.value = currentTable.value.map((i) => i.prop);
5361
- checkedCount.value = list.length;
5361
+ checkedCount.value = list.map((item) => item.prop || item.type);
5362
5362
  checkAll2.value = true;
5363
5363
  isIndeterminate.value = false;
5364
5364
  }
@@ -5385,7 +5385,10 @@ __sfc_main$1.setup = (__props, __ctx) => {
5385
5385
  }
5386
5386
  fields.value = items;
5387
5387
  };
5388
- const checkedCount = ref(0);
5388
+ const checkedCount = ref([]);
5389
+ const showCheckCount = computed(() => {
5390
+ return checkedCount.value.filter((item) => !(item === "selection" || item === props.operationPropKey)).length;
5391
+ });
5389
5392
  const updateColumn = () => {
5390
5393
  fixedColumn.value = [];
5391
5394
  unFixedColumn.value = [];
@@ -5425,14 +5428,14 @@ __sfc_main$1.setup = (__props, __ctx) => {
5425
5428
  const updateCheckStatus = () => {
5426
5429
  showColumn.value = currentTable.value.filter((i) => !i.initHidden).map((item) => item.prop);
5427
5430
  if (columnName.value && fields.value.length) {
5428
- checkedCount.value = searchValue.filter((i) => !i.initHidden).length;
5429
- checkAll2.value = checkedCount.value === searchValue.length;
5430
- isIndeterminate.value = checkedCount.value > 0 && checkedCount.value < searchValue.length;
5431
+ checkedCount.value = searchValue.filter((i) => !i.initHidden).map((item) => item.prop || item.type);
5432
+ checkAll2.value = checkedCount.value.length === searchValue.length;
5433
+ isIndeterminate.value = checkedCount.value.length > 0 && checkedCount.value.length < searchValue.length;
5431
5434
  return;
5432
5435
  }
5433
- checkedCount.value = showColumn.value.length;
5434
- checkAll2.value = checkedCount.value === currentTable.value.length;
5435
- isIndeterminate.value = checkedCount.value > 0 && checkedCount.value < currentTable.value.length;
5436
+ checkedCount.value = showColumn.value;
5437
+ checkAll2.value = checkedCount.value.length === currentTable.value.length;
5438
+ isIndeterminate.value = checkedCount.value.length > 0 && checkedCount.value.length < currentTable.value.length;
5436
5439
  };
5437
5440
  const columnName = ref("");
5438
5441
  let searchValue = [];
@@ -5617,7 +5620,7 @@ __sfc_main$1.setup = (__props, __ctx) => {
5617
5620
  fixedColumn,
5618
5621
  unFixedColumn,
5619
5622
  fields,
5620
- checkedCount,
5623
+ showCheckCount,
5621
5624
  columnName,
5622
5625
  handleSearch,
5623
5626
  checkAll: checkAll2,
@@ -5694,7 +5697,7 @@ var _sfc_render$2 = function render2() {
5694
5697
  },
5695
5698
  expression: "checkAll"
5696
5699
  }
5697
- }, [_vm._v(_vm._s(_vm.getAllCheckDesc(_vm.checkedCount)))]) : _vm._e()], 1), _c("div", {
5700
+ }, [_vm._v(_vm._s(_vm.getAllCheckDesc(_vm.showCheckCount)))]) : _vm._e()], 1), _c("div", {
5698
5701
  staticClass: "nf-select-column"
5699
5702
  }, _vm._l(_vm.fields, function(item, index2) {
5700
5703
  return _c("div", {
@@ -9403,6 +9406,24 @@ __sfc_main.props = {
9403
9406
  required: false,
9404
9407
  type: Object,
9405
9408
  default: () => ({})
9409
+ },
9410
+ dragIndicatorPaddingLeft: {
9411
+ key: "dragIndicatorPaddingLeft",
9412
+ required: false,
9413
+ type: Number,
9414
+ default: 120
9415
+ },
9416
+ dragIndicatorPaddingRight: {
9417
+ key: "dragIndicatorPaddingRight",
9418
+ required: false,
9419
+ type: Number,
9420
+ default: 120
9421
+ },
9422
+ fixedRightDragEnabled: {
9423
+ key: "fixedRightDragEnabled",
9424
+ required: false,
9425
+ type: Boolean,
9426
+ default: false
9406
9427
  }
9407
9428
  };
9408
9429
  __sfc_main.setup = (__props, __ctx) => {
@@ -9971,6 +9992,199 @@ __sfc_main.setup = (__props, __ctx) => {
9971
9992
  resizeTable();
9972
9993
  await ((_b = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b.call(_a2, newWidth, oldWidth, column, event));
9973
9994
  };
9995
+ let opFixedRightCleanup = null;
9996
+ const initOpFixedRightResizer = async () => {
9997
+ var _a2, _b, _c;
9998
+ await nextTick();
9999
+ opFixedRightCleanup == null ? void 0 : opFixedRightCleanup();
10000
+ opFixedRightCleanup = null;
10001
+ if (!props.fixedRightDragEnabled)
10002
+ return;
10003
+ const tableEl = (_a2 = elTableRef.value) == null ? void 0 : _a2.$el;
10004
+ if (!tableEl)
10005
+ return;
10006
+ const visibleColumns = tableColumns.value.filter((col) => isShow(col));
10007
+ const opCol = visibleColumns.find((col) => {
10008
+ var _a3;
10009
+ return (col.prop || ((_a3 = col.attr) == null ? void 0 : _a3.prop)) === props.operationPropKey;
10010
+ });
10011
+ if (!opCol || ((_b = opCol == null ? void 0 : opCol.attr) == null ? void 0 : _b.fixed) !== "right")
10012
+ return;
10013
+ const fixedRightHeader = tableEl.querySelector(".el-table__fixed-right .el-table__fixed-header-wrapper thead tr");
10014
+ if (!fixedRightHeader)
10015
+ return;
10016
+ const fixedIndex = visibleColumns.findIndex((col) => {
10017
+ var _a3;
10018
+ return ((_a3 = col == null ? void 0 : col.attr) == null ? void 0 : _a3.fixed) === "right";
10019
+ });
10020
+ if (fixedIndex < 0)
10021
+ return;
10022
+ const th = fixedRightHeader.querySelectorAll("th")[fixedIndex];
10023
+ if (!th)
10024
+ return;
10025
+ const fixedRightRoot = tableEl.querySelector(".el-table__fixed-right");
10026
+ if (!fixedRightRoot)
10027
+ return;
10028
+ const oldOverlay = fixedRightRoot.querySelector('[data-nf-fixed-right-overlay="true"]');
10029
+ if (oldOverlay)
10030
+ oldOverlay.remove();
10031
+ const overlay = document.createElement("div");
10032
+ overlay.setAttribute("data-nf-fixed-right-overlay", "true");
10033
+ overlay.style.position = "relative";
10034
+ overlay.style.width = "100%";
10035
+ overlay.style.height = "100%";
10036
+ overlay.style.pointerEvents = "none";
10037
+ overlay.style.zIndex = "30";
10038
+ fixedRightRoot.appendChild(overlay);
10039
+ const mainHeader = tableEl.querySelector(".el-table__header-wrapper thead tr");
10040
+ const cleanupHideAfter = [];
10041
+ const hideNativeAfter = (el) => {
10042
+ if (!el)
10043
+ return;
10044
+ el.classList.add("nf-table-hide-after");
10045
+ cleanupHideAfter.push(el);
10046
+ };
10047
+ const lastNormalIndex = fixedIndex - 1;
10048
+ if (mainHeader) {
10049
+ const mainThs = mainHeader.querySelectorAll("th");
10050
+ if (lastNormalIndex >= 0 && lastNormalIndex < mainThs.length) {
10051
+ hideNativeAfter(mainThs[lastNormalIndex]);
10052
+ }
10053
+ }
10054
+ hideNativeAfter(th);
10055
+ const handle = document.createElement("div");
10056
+ handle.setAttribute("data-nf-fixed-op-resizer", "true");
10057
+ handle.style.position = "absolute";
10058
+ handle.style.left = "-8px";
10059
+ handle.style.top = "0";
10060
+ handle.style.bottom = "0";
10061
+ handle.style.width = "16px";
10062
+ handle.style.cursor = "col-resize";
10063
+ handle.style.zIndex = "10";
10064
+ handle.style.background = "transparent";
10065
+ handle.style.pointerEvents = "auto";
10066
+ overlay.appendChild(handle);
10067
+ let indicatorLine = null;
10068
+ const columnProp = opCol.prop || ((_c = opCol.attr) == null ? void 0 : _c.prop);
10069
+ const createIndicatorLine = (rect) => {
10070
+ const line = document.createElement("div");
10071
+ line.id = "nf-fixed-right-indicator-line";
10072
+ const tableRect = rect || tableEl.getBoundingClientRect();
10073
+ line.style.cssText = `
10074
+ position: fixed;
10075
+ top: ${tableRect.top}px;
10076
+ left: 0;
10077
+ height: ${tableRect.height}px;
10078
+ width: 2px;
10079
+ background: #409EFF;
10080
+ z-index: 10000;
10081
+ pointer-events: none;
10082
+ display: none;
10083
+ transform: translateX(0px);
10084
+ will-change: transform;
10085
+ `;
10086
+ document.body.appendChild(line);
10087
+ return line;
10088
+ };
10089
+ let pending = false;
10090
+ let cachedRect = null;
10091
+ const onPointerMove = (e) => {
10092
+ e.preventDefault();
10093
+ if (!cachedRect)
10094
+ cachedRect = tableEl.getBoundingClientRect();
10095
+ const tableRect = cachedRect;
10096
+ const leftBound = tableRect.left + (props.dragIndicatorPaddingLeft || 0);
10097
+ const rightBound = tableRect.right - (props.dragIndicatorPaddingRight || 0);
10098
+ let dragX = e.clientX;
10099
+ if (dragX < leftBound)
10100
+ dragX = leftBound;
10101
+ if (dragX > rightBound)
10102
+ dragX = rightBound;
10103
+ if (indicatorLine) {
10104
+ if (!pending) {
10105
+ pending = true;
10106
+ requestAnimationFrame(() => {
10107
+ indicatorLine.style.display = "block";
10108
+ indicatorLine.style.transform = `translateX(${dragX}px)`;
10109
+ pending = false;
10110
+ });
10111
+ }
10112
+ }
10113
+ };
10114
+ const onPointerUp = async (e) => {
10115
+ document.removeEventListener("pointermove", onPointerMove);
10116
+ document.removeEventListener("pointerup", onPointerUp);
10117
+ const dragMask = document.getElementById("nf-fixed-right-drag-mask");
10118
+ dragMask && dragMask.remove();
10119
+ if (indicatorLine) {
10120
+ indicatorLine.remove();
10121
+ indicatorLine = null;
10122
+ }
10123
+ try {
10124
+ handle.releasePointerCapture && handle.releasePointerCapture(e.pointerId);
10125
+ } catch {
10126
+ }
10127
+ try {
10128
+ const tableRect = cachedRect || tableEl.getBoundingClientRect();
10129
+ cachedRect = null;
10130
+ const leftBound = tableRect.left + (props.dragIndicatorPaddingLeft || 0);
10131
+ const rightBound = tableRect.right - (props.dragIndicatorPaddingRight || 0);
10132
+ const clampX = Math.min(Math.max(e.clientX, leftBound), rightBound);
10133
+ const rawWidth = tableRect.right - clampX;
10134
+ const minWidth = getMinWidth(opCol);
10135
+ const finalWidthNum = Math.max(rawWidth, minWidth);
10136
+ if (props.dragCached && columnProp) {
10137
+ const columnCachedData = await CachedManager.asyncCachedGet(`${cStorageKey.value}$drag-column-width`) || {};
10138
+ columnCachedData[columnProp] = finalWidthNum;
10139
+ await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, columnCachedData);
10140
+ }
10141
+ const oldWidth = th.getBoundingClientRect().width;
10142
+ emit("fixedColumnDragEnd", {
10143
+ width: finalWidthNum,
10144
+ oldWidth,
10145
+ prop: columnProp,
10146
+ column: opCol,
10147
+ nativeEvent: e
10148
+ });
10149
+ } catch (error) {
10150
+ console.error("更新列宽失败:", error);
10151
+ }
10152
+ };
10153
+ const onPointerDown = (e) => {
10154
+ e.preventDefault();
10155
+ indicatorLine = createIndicatorLine();
10156
+ const mask = document.createElement("div");
10157
+ mask.id = "nf-fixed-right-drag-mask";
10158
+ mask.style.cssText = "position:fixed;inset:0;cursor:col-resize;z-index:9999;";
10159
+ document.body.appendChild(mask);
10160
+ try {
10161
+ handle.setPointerCapture && handle.setPointerCapture(e.pointerId);
10162
+ } catch {
10163
+ }
10164
+ document.addEventListener("pointermove", onPointerMove, {
10165
+ passive: false
10166
+ });
10167
+ document.addEventListener("pointerup", onPointerUp);
10168
+ };
10169
+ handle.addEventListener("pointerdown", onPointerDown);
10170
+ opFixedRightCleanup = () => {
10171
+ try {
10172
+ handle.removeEventListener("pointerdown", onPointerDown);
10173
+ handle.remove();
10174
+ cleanupHideAfter.forEach((el) => el.classList.remove("nf-table-hide-after"));
10175
+ } catch {
10176
+ }
10177
+ };
10178
+ };
10179
+ watch(() => {
10180
+ var _a2;
10181
+ return [tableColumns.value.length, (_a2 = localShowColumn.value) == null ? void 0 : _a2.length, elTableRefKey.value];
10182
+ }, () => {
10183
+ initOpFixedRightResizer();
10184
+ });
10185
+ watch(() => props.fixedRightDragEnabled, () => {
10186
+ initOpFixedRightResizer();
10187
+ });
9974
10188
  async function clearDragCached() {
9975
10189
  await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, null);
9976
10190
  }
@@ -10099,6 +10313,7 @@ __sfc_main.setup = (__props, __ctx) => {
10099
10313
  });
10100
10314
  if (cInitSearchApi.value)
10101
10315
  onNfSearchFormSearch();
10316
+ initOpFixedRightResizer();
10102
10317
  });
10103
10318
  const nfTableBorder = window.nfTableBorder;
10104
10319
  const nfSearchFormModel = computed({
@@ -79,6 +79,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
79
79
  virtualized?: boolean | undefined;
80
80
  virtualTableData?: Record<string, any>[] | undefined;
81
81
  virtualProps?: Record<string, any> | undefined;
82
+ dragIndicatorPaddingLeft?: number | undefined;
83
+ dragIndicatorPaddingRight?: number | undefined;
84
+ fixedRightDragEnabled?: boolean | undefined;
82
85
  }>, {
83
86
  viewIdentity: string;
84
87
  dragCached: boolean;
@@ -156,6 +159,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
156
159
  virtualized: boolean;
157
160
  virtualTableData: () => never[];
158
161
  virtualProps: () => {};
162
+ dragIndicatorPaddingLeft: number;
163
+ dragIndicatorPaddingRight: number;
164
+ fixedRightDragEnabled: boolean;
159
165
  }>, {
160
166
  clearFilter: () => void;
161
167
  sort: (prop: any, order: any) => void;
@@ -262,6 +268,13 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
262
268
  data: Record<string, any>;
263
269
  callback: Function;
264
270
  }) => void;
271
+ fixedColumnDragEnd: (event: {
272
+ width: number;
273
+ oldWidth: number;
274
+ prop?: string | undefined;
275
+ column?: any;
276
+ nativeEvent?: Event | undefined;
277
+ }) => void;
265
278
  }, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
266
279
  viewIdentity?: string | undefined;
267
280
  data?: Record<string, any>[] | undefined;
@@ -341,6 +354,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
341
354
  virtualized?: boolean | undefined;
342
355
  virtualTableData?: Record<string, any>[] | undefined;
343
356
  virtualProps?: Record<string, any> | undefined;
357
+ dragIndicatorPaddingLeft?: number | undefined;
358
+ dragIndicatorPaddingRight?: number | undefined;
359
+ fixedRightDragEnabled?: boolean | undefined;
344
360
  }>, {
345
361
  viewIdentity: string;
346
362
  dragCached: boolean;
@@ -418,6 +434,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
418
434
  virtualized: boolean;
419
435
  virtualTableData: () => never[];
420
436
  virtualProps: () => {};
437
+ dragIndicatorPaddingLeft: number;
438
+ dragIndicatorPaddingRight: number;
439
+ fixedRightDragEnabled: boolean;
421
440
  }>>>, {
422
441
  background: string;
423
442
  columns: NfTableColumnAttributes[] | any;
@@ -495,6 +514,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
495
514
  virtualized: boolean;
496
515
  virtualTableData: Record<string, any>[];
497
516
  virtualProps: Record<string, any>;
517
+ dragIndicatorPaddingLeft: number;
518
+ dragIndicatorPaddingRight: number;
519
+ fixedRightDragEnabled: boolean;
498
520
  }>, Partial<Record<any, (_: {
499
521
  slot: any;
500
522
  }) => any>> & Partial<Record<any, (_: {
@@ -17,7 +17,7 @@
17
17
  v-model="checkAll"
18
18
  :indeterminate="isIndeterminate"
19
19
  @change="handleCheckAllChange"
20
- >{{ getAllCheckDesc(checkedCount) }}</el-checkbox>
20
+ >{{ getAllCheckDesc(showCheckCount) }}</el-checkbox>
21
21
  </div>
22
22
  <div class="nf-select-column">
23
23
  <div v-for="(item,index) in fields" :key="index + item.name" class="nf-column-category">
@@ -214,7 +214,7 @@ onBeforeMount(() => {
214
214
  updateColumn()
215
215
  if (currentTable.value.every(i => !i.initHidden)) {
216
216
  showColumn.value = currentTable.value.map(i => i.prop)
217
- checkedCount.value = list.length
217
+ checkedCount.value = list.map(item => item.prop || item.type)
218
218
  checkAll.value = true
219
219
  isIndeterminate.value = false
220
220
  }
@@ -260,7 +260,11 @@ const setFields = async(tableColumns) => {
260
260
  /**
261
261
  * 更新已选列表
262
262
  */
263
- const checkedCount = ref(0) // 勾选的数量
263
+ const checkedCount = ref<string[]>([]) // 勾选的prop
264
+
265
+ const showCheckCount = computed(() => {
266
+ return checkedCount.value.filter(item => !(item === 'selection' || item === props.operationPropKey)).length
267
+ })
264
268
  const updateColumn = () => {
265
269
  fixedColumn.value = []
266
270
  unFixedColumn.value = []
@@ -307,14 +311,14 @@ const updateCheckStatus = () => {
307
311
  // [全选 checkbox] 展示状态
308
312
  if (columnName.value && fields.value.length) {
309
313
  // 搜索时
310
- checkedCount.value = searchValue.filter(i => !i.initHidden).length
311
- checkAll.value = checkedCount.value === searchValue.length
312
- isIndeterminate.value = checkedCount.value > 0 && checkedCount.value < searchValue.length
314
+ checkedCount.value = searchValue.filter(i => !i.initHidden).map(item => item.prop || item.type)
315
+ checkAll.value = checkedCount.value.length === searchValue.length
316
+ isIndeterminate.value = checkedCount.value.length > 0 && checkedCount.value.length < searchValue.length
313
317
  return
314
318
  }
315
- checkedCount.value = showColumn.value.length
316
- checkAll.value = checkedCount.value === currentTable.value.length
317
- isIndeterminate.value = checkedCount.value > 0 && checkedCount.value < currentTable.value.length
319
+ checkedCount.value = showColumn.value
320
+ checkAll.value = checkedCount.value.length === currentTable.value.length
321
+ isIndeterminate.value = checkedCount.value.length > 0 && checkedCount.value.length < currentTable.value.length
318
322
  }
319
323
 
320
324
  /**