@94ai/nf-table 8.3.1 → 8.3.6
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/lib/index.d.ts +26 -0
- package/lib/nf-column-check-drawer.vue.d.ts +1 -1
- package/lib/nf-table.cjs.js +99 -20
- package/lib/nf-table.esm-bundler.js +99 -20
- package/lib/nf-table.vue.d.ts +5 -0
- package/package/nf-column-check-drawer.vue +13 -9
- package/package/nf-table.vue +86 -10
- package/package.json +9 -9
package/lib/index.d.ts
CHANGED
|
@@ -48,6 +48,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
48
48
|
type: import("vue-demi").PropType<string[]>;
|
|
49
49
|
default: undefined;
|
|
50
50
|
};
|
|
51
|
+
viewIdentity: {
|
|
52
|
+
type: import("vue-demi").PropType<string>;
|
|
53
|
+
default: string;
|
|
54
|
+
};
|
|
51
55
|
searchFormAttrs: {
|
|
52
56
|
type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
|
|
53
57
|
default: () => {};
|
|
@@ -355,6 +359,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
355
359
|
type: import("vue-demi").PropType<string[]>;
|
|
356
360
|
default: undefined;
|
|
357
361
|
};
|
|
362
|
+
viewIdentity: {
|
|
363
|
+
type: import("vue-demi").PropType<string>;
|
|
364
|
+
default: string;
|
|
365
|
+
};
|
|
358
366
|
searchFormAttrs: {
|
|
359
367
|
type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
|
|
360
368
|
default: () => {};
|
|
@@ -633,6 +641,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
633
641
|
text: string;
|
|
634
642
|
selectEmptyWarningTips: string;
|
|
635
643
|
showColumn: string[];
|
|
644
|
+
viewIdentity: string;
|
|
636
645
|
searchFormAttrs: import("./types").NfSearchFormAttributes;
|
|
637
646
|
searchFormEvents: Partial<Record<import("./types").NfSearchFormEventKey, Function>>;
|
|
638
647
|
tableAttrs: import("./types").ElTableAttributes;
|
|
@@ -745,6 +754,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
745
754
|
type: import("vue-demi").PropType<string[]>;
|
|
746
755
|
default: undefined;
|
|
747
756
|
};
|
|
757
|
+
viewIdentity: {
|
|
758
|
+
type: import("vue-demi").PropType<string>;
|
|
759
|
+
default: string;
|
|
760
|
+
};
|
|
748
761
|
searchFormAttrs: {
|
|
749
762
|
type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
|
|
750
763
|
default: () => {};
|
|
@@ -1151,6 +1164,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
1151
1164
|
type: import("vue-demi").PropType<string[]>;
|
|
1152
1165
|
default: undefined;
|
|
1153
1166
|
};
|
|
1167
|
+
viewIdentity: {
|
|
1168
|
+
type: import("vue-demi").PropType<string>;
|
|
1169
|
+
default: string;
|
|
1170
|
+
};
|
|
1154
1171
|
searchFormAttrs: {
|
|
1155
1172
|
type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
|
|
1156
1173
|
default: () => {};
|
|
@@ -1458,6 +1475,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
1458
1475
|
type: import("vue-demi").PropType<string[]>;
|
|
1459
1476
|
default: undefined;
|
|
1460
1477
|
};
|
|
1478
|
+
viewIdentity: {
|
|
1479
|
+
type: import("vue-demi").PropType<string>;
|
|
1480
|
+
default: string;
|
|
1481
|
+
};
|
|
1461
1482
|
searchFormAttrs: {
|
|
1462
1483
|
type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
|
|
1463
1484
|
default: () => {};
|
|
@@ -1835,6 +1856,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
1835
1856
|
text: string;
|
|
1836
1857
|
selectEmptyWarningTips: string;
|
|
1837
1858
|
showColumn: string[];
|
|
1859
|
+
viewIdentity: string;
|
|
1838
1860
|
searchFormAttrs: import("./types").NfSearchFormAttributes;
|
|
1839
1861
|
searchFormEvents: Partial<Record<import("./types").NfSearchFormEventKey, Function>>;
|
|
1840
1862
|
tableAttrs: import("./types").ElTableAttributes;
|
|
@@ -1948,6 +1970,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
1948
1970
|
type: import("vue-demi").PropType<string[]>;
|
|
1949
1971
|
default: undefined;
|
|
1950
1972
|
};
|
|
1973
|
+
viewIdentity: {
|
|
1974
|
+
type: import("vue-demi").PropType<string>;
|
|
1975
|
+
default: string;
|
|
1976
|
+
};
|
|
1951
1977
|
searchFormAttrs: {
|
|
1952
1978
|
type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
|
|
1953
1979
|
default: () => {};
|
|
@@ -38,7 +38,7 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
|
|
|
38
38
|
isIndeterminate: import("vue-demi").Ref<boolean>;
|
|
39
39
|
columnName: import("vue-demi").Ref<string>;
|
|
40
40
|
searchValue: Record<string, any>[];
|
|
41
|
-
checkedCount: import("vue-demi").Ref<
|
|
41
|
+
checkedCount: import("vue-demi").Ref<string[]>;
|
|
42
42
|
fields: import("vue-demi").Ref<{
|
|
43
43
|
name: string;
|
|
44
44
|
list: Record<string, any>[];
|
package/lib/nf-table.cjs.js
CHANGED
|
@@ -5360,7 +5360,7 @@ __sfc_main$1.setup = (__props, __ctx) => {
|
|
|
5360
5360
|
updateColumn();
|
|
5361
5361
|
if (currentTable.value.every((i) => !i.initHidden)) {
|
|
5362
5362
|
showColumn.value = currentTable.value.map((i) => i.prop);
|
|
5363
|
-
checkedCount.value = list.
|
|
5363
|
+
checkedCount.value = list.map((item) => item.prop || item.type);
|
|
5364
5364
|
checkAll2.value = true;
|
|
5365
5365
|
isIndeterminate.value = false;
|
|
5366
5366
|
}
|
|
@@ -5387,7 +5387,10 @@ __sfc_main$1.setup = (__props, __ctx) => {
|
|
|
5387
5387
|
}
|
|
5388
5388
|
fields.value = items;
|
|
5389
5389
|
};
|
|
5390
|
-
const checkedCount = vueDemi.ref(
|
|
5390
|
+
const checkedCount = vueDemi.ref([]);
|
|
5391
|
+
const showCheckCount = vueDemi.computed(() => {
|
|
5392
|
+
return checkedCount.value.filter((item) => !(item === "selection" || item === props.operationPropKey)).length;
|
|
5393
|
+
});
|
|
5391
5394
|
const updateColumn = () => {
|
|
5392
5395
|
fixedColumn.value = [];
|
|
5393
5396
|
unFixedColumn.value = [];
|
|
@@ -5427,14 +5430,14 @@ __sfc_main$1.setup = (__props, __ctx) => {
|
|
|
5427
5430
|
const updateCheckStatus = () => {
|
|
5428
5431
|
showColumn.value = currentTable.value.filter((i) => !i.initHidden).map((item) => item.prop);
|
|
5429
5432
|
if (columnName.value && fields.value.length) {
|
|
5430
|
-
checkedCount.value = searchValue.filter((i) => !i.initHidden).
|
|
5431
|
-
checkAll2.value = checkedCount.value === searchValue.length;
|
|
5432
|
-
isIndeterminate.value = checkedCount.value > 0 && checkedCount.value < searchValue.length;
|
|
5433
|
+
checkedCount.value = searchValue.filter((i) => !i.initHidden).map((item) => item.prop || item.type);
|
|
5434
|
+
checkAll2.value = checkedCount.value.length === searchValue.length;
|
|
5435
|
+
isIndeterminate.value = checkedCount.value.length > 0 && checkedCount.value.length < searchValue.length;
|
|
5433
5436
|
return;
|
|
5434
5437
|
}
|
|
5435
|
-
checkedCount.value = showColumn.value
|
|
5436
|
-
checkAll2.value = checkedCount.value === currentTable.value.length;
|
|
5437
|
-
isIndeterminate.value = checkedCount.value > 0 && checkedCount.value < currentTable.value.length;
|
|
5438
|
+
checkedCount.value = showColumn.value;
|
|
5439
|
+
checkAll2.value = checkedCount.value.length === currentTable.value.length;
|
|
5440
|
+
isIndeterminate.value = checkedCount.value.length > 0 && checkedCount.value.length < currentTable.value.length;
|
|
5438
5441
|
};
|
|
5439
5442
|
const columnName = vueDemi.ref("");
|
|
5440
5443
|
let searchValue = [];
|
|
@@ -5619,7 +5622,7 @@ __sfc_main$1.setup = (__props, __ctx) => {
|
|
|
5619
5622
|
fixedColumn,
|
|
5620
5623
|
unFixedColumn,
|
|
5621
5624
|
fields,
|
|
5622
|
-
|
|
5625
|
+
showCheckCount,
|
|
5623
5626
|
columnName,
|
|
5624
5627
|
handleSearch,
|
|
5625
5628
|
checkAll: checkAll2,
|
|
@@ -5696,7 +5699,7 @@ var _sfc_render$2 = function render2() {
|
|
|
5696
5699
|
},
|
|
5697
5700
|
expression: "checkAll"
|
|
5698
5701
|
}
|
|
5699
|
-
}, [_vm._v(_vm._s(_vm.getAllCheckDesc(_vm.
|
|
5702
|
+
}, [_vm._v(_vm._s(_vm.getAllCheckDesc(_vm.showCheckCount)))]) : _vm._e()], 1), _c("div", {
|
|
5700
5703
|
staticClass: "nf-select-column"
|
|
5701
5704
|
}, _vm._l(_vm.fields, function(item, index2) {
|
|
5702
5705
|
return _c("div", {
|
|
@@ -8940,6 +8943,12 @@ const __sfc_main = vueDemi.defineComponent({
|
|
|
8940
8943
|
name: "nf-table"
|
|
8941
8944
|
});
|
|
8942
8945
|
__sfc_main.props = {
|
|
8946
|
+
viewIdentity: {
|
|
8947
|
+
key: "viewIdentity",
|
|
8948
|
+
required: false,
|
|
8949
|
+
type: String,
|
|
8950
|
+
default: ""
|
|
8951
|
+
},
|
|
8943
8952
|
data: {
|
|
8944
8953
|
key: "data",
|
|
8945
8954
|
required: false,
|
|
@@ -9405,6 +9414,17 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9405
9414
|
var _a;
|
|
9406
9415
|
const props = __props;
|
|
9407
9416
|
const emit = __ctx.emit;
|
|
9417
|
+
const processedColumns = vueDemi.computed(() => {
|
|
9418
|
+
var _a2;
|
|
9419
|
+
const viewField = window.viewField;
|
|
9420
|
+
if (props.viewIdentity && viewField) {
|
|
9421
|
+
const showList = (_a2 = viewField.find((item) => item.viewIdentity === props.viewIdentity)) == null ? void 0 : _a2.fieldList;
|
|
9422
|
+
if (showList == null ? void 0 : showList.length) {
|
|
9423
|
+
return props.columns.filter((item) => showList.includes(item.prop) || item.prop === props.operationPropKey || item.type === "selection" || item.type === "index" || item.type === "expand");
|
|
9424
|
+
}
|
|
9425
|
+
}
|
|
9426
|
+
return props.columns;
|
|
9427
|
+
});
|
|
9408
9428
|
const getOperationListLocal = (column, scope) => {
|
|
9409
9429
|
if (typeof column.operationList === "function") {
|
|
9410
9430
|
return column.operationList(scope);
|
|
@@ -9438,7 +9458,61 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9438
9458
|
const preSearchFormData = vueDemi.ref({});
|
|
9439
9459
|
const cPageChangeSearchApi = vueDemi.ref(props.pageChangeSearchApi ?? props.setEasyConf);
|
|
9440
9460
|
const cInitSearchApi = vueDemi.ref(props.initSearchApi ?? props.setEasyConf);
|
|
9441
|
-
const cStorageKey = vueDemi.
|
|
9461
|
+
const cStorageKey = vueDemi.computed(() => {
|
|
9462
|
+
const key = props.storageKey || `nf-table-columns-cached-key-${routeName.value}`;
|
|
9463
|
+
const userId = window.userId;
|
|
9464
|
+
if (props.viewIdentity && userId) {
|
|
9465
|
+
return userId + "-" + key;
|
|
9466
|
+
}
|
|
9467
|
+
return key;
|
|
9468
|
+
});
|
|
9469
|
+
const cStorageKeyViewIdentity = vueDemi.computed(() => {
|
|
9470
|
+
return "nf-table-view-identity";
|
|
9471
|
+
});
|
|
9472
|
+
const checkViewIdentityChange = async () => {
|
|
9473
|
+
const userId = window.userId;
|
|
9474
|
+
const viewField = window.viewField;
|
|
9475
|
+
if (props.viewIdentity && userId && viewField) {
|
|
9476
|
+
let viewIdentity = commonUtils.CachedManager.syncCachedGet(cStorageKeyViewIdentity.value);
|
|
9477
|
+
if (!viewIdentity) {
|
|
9478
|
+
viewIdentity = await commonUtils.CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value);
|
|
9479
|
+
}
|
|
9480
|
+
if (!viewIdentity) {
|
|
9481
|
+
await commonUtils.CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField);
|
|
9482
|
+
} else {
|
|
9483
|
+
const newViewIdentity = viewField.find((item) => item.viewIdentity === props.viewIdentity);
|
|
9484
|
+
const oldViewIdentity = viewIdentity.find((item) => item.viewIdentity === props.viewIdentity);
|
|
9485
|
+
if (newViewIdentity && !oldViewIdentity || !newViewIdentity && oldViewIdentity) {
|
|
9486
|
+
await clearColumnEditCached();
|
|
9487
|
+
await clearDragCached();
|
|
9488
|
+
} else if (newViewIdentity && oldViewIdentity) {
|
|
9489
|
+
let change = false;
|
|
9490
|
+
newViewIdentity.fieldList.every((item) => {
|
|
9491
|
+
if (!oldViewIdentity.fieldList.includes(item)) {
|
|
9492
|
+
change = true;
|
|
9493
|
+
return;
|
|
9494
|
+
}
|
|
9495
|
+
return true;
|
|
9496
|
+
});
|
|
9497
|
+
if (!change) {
|
|
9498
|
+
oldViewIdentity.fieldList.every((item) => {
|
|
9499
|
+
if (!newViewIdentity.fieldList.includes(item)) {
|
|
9500
|
+
change = true;
|
|
9501
|
+
return;
|
|
9502
|
+
}
|
|
9503
|
+
return true;
|
|
9504
|
+
});
|
|
9505
|
+
}
|
|
9506
|
+
if (change) {
|
|
9507
|
+
await clearColumnEditCached();
|
|
9508
|
+
await clearDragCached();
|
|
9509
|
+
oldViewIdentity.fieldList = newViewIdentity.fieldList;
|
|
9510
|
+
await commonUtils.CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity);
|
|
9511
|
+
}
|
|
9512
|
+
}
|
|
9513
|
+
}
|
|
9514
|
+
}
|
|
9515
|
+
};
|
|
9442
9516
|
const cPageAttrs = vueDemi.reactive({
|
|
9443
9517
|
// 页码,没有props时 & 允许分页时;默认 = 1
|
|
9444
9518
|
"current-page": props.pageAttrs["current-page"] || (props.alwaysShowPage ? 1 : void 0),
|
|
@@ -9512,7 +9586,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9512
9586
|
if (!init) {
|
|
9513
9587
|
props.columns._skip = true;
|
|
9514
9588
|
}
|
|
9515
|
-
const result =
|
|
9589
|
+
const result = processedColumns.value.filter((item) => {
|
|
9516
9590
|
var _a2, _b;
|
|
9517
9591
|
const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
|
|
9518
9592
|
if ((_b = props.showColumn) == null ? void 0 : _b.includes(prop)) {
|
|
@@ -9531,7 +9605,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9531
9605
|
if (result.length) {
|
|
9532
9606
|
return result;
|
|
9533
9607
|
}
|
|
9534
|
-
return
|
|
9608
|
+
return processedColumns.value.map((item) => {
|
|
9535
9609
|
var _a2;
|
|
9536
9610
|
return item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
|
|
9537
9611
|
});
|
|
@@ -9548,7 +9622,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9548
9622
|
const syncLocalShowColumnToCookies = () => {
|
|
9549
9623
|
if (props.columnEdit) {
|
|
9550
9624
|
const columnState = {};
|
|
9551
|
-
|
|
9625
|
+
processedColumns.value.map((i, index2) => {
|
|
9552
9626
|
var _a2, _b;
|
|
9553
9627
|
const prop = i.prop || ((_a2 = i.attr) == null ? void 0 : _a2.prop);
|
|
9554
9628
|
columnState[prop] = {
|
|
@@ -9563,7 +9637,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9563
9637
|
};
|
|
9564
9638
|
const syncShowItemToInitHidden = () => {
|
|
9565
9639
|
props.columns._skip = true;
|
|
9566
|
-
|
|
9640
|
+
processedColumns.value.forEach((item) => {
|
|
9567
9641
|
var _a2, _b;
|
|
9568
9642
|
const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
|
|
9569
9643
|
if ((_b = localShowColumn.value) == null ? void 0 : _b.includes(prop)) {
|
|
@@ -9579,6 +9653,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9579
9653
|
const syncCookiesToLocalShowColumn = async () => {
|
|
9580
9654
|
if (props.columnEdit) {
|
|
9581
9655
|
try {
|
|
9656
|
+
await checkViewIdentityChange();
|
|
9582
9657
|
let columnState = commonUtils.CachedManager.syncCachedGet(cStorageKey.value);
|
|
9583
9658
|
if (!columnState) {
|
|
9584
9659
|
columnState = await commonUtils.CachedManager.asyncCachedGet(cStorageKey.value);
|
|
@@ -9605,6 +9680,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9605
9680
|
var _a2, _b;
|
|
9606
9681
|
if (props.columnEdit) {
|
|
9607
9682
|
try {
|
|
9683
|
+
await checkViewIdentityChange();
|
|
9608
9684
|
let cached = commonUtils.CachedManager.syncCachedGet(cStorageKey.value);
|
|
9609
9685
|
if (!cached) {
|
|
9610
9686
|
cached = await commonUtils.CachedManager.asyncCachedGet(cStorageKey.value);
|
|
@@ -9643,7 +9719,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9643
9719
|
const elTableRefKey = vueDemi.ref(Date.now());
|
|
9644
9720
|
const syncCookiesToTableColumn = async (readCached = true) => {
|
|
9645
9721
|
props.columns._skip = true;
|
|
9646
|
-
const columns =
|
|
9722
|
+
const columns = processedColumns.value.map((item, index2) => {
|
|
9647
9723
|
var _a2;
|
|
9648
9724
|
const attr = item.attr || {};
|
|
9649
9725
|
if (!attr["min-width"] && item.label) {
|
|
@@ -9686,6 +9762,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9686
9762
|
});
|
|
9687
9763
|
if (readCached && props.columnEdit) {
|
|
9688
9764
|
try {
|
|
9765
|
+
await checkViewIdentityChange();
|
|
9689
9766
|
let columnState = commonUtils.CachedManager.syncCachedGet(cStorageKey.value);
|
|
9690
9767
|
if (!columnState) {
|
|
9691
9768
|
columnState = await commonUtils.CachedManager.asyncCachedGet(cStorageKey.value);
|
|
@@ -9756,6 +9833,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9756
9833
|
columnEdit: true
|
|
9757
9834
|
} : {},
|
|
9758
9835
|
storageKey: props.searchFormStorageKey,
|
|
9836
|
+
viewIdentity: props.viewIdentity,
|
|
9759
9837
|
...props.searchFormAttrs
|
|
9760
9838
|
};
|
|
9761
9839
|
return obj;
|
|
@@ -9974,8 +10052,8 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9974
10052
|
};
|
|
9975
10053
|
const resizeTable = () => {
|
|
9976
10054
|
if (props.detectResize) {
|
|
9977
|
-
const hasLeftFixed =
|
|
9978
|
-
const hasRightFixed =
|
|
10055
|
+
const hasLeftFixed = processedColumns.value.find((item) => item.attr.fixed === "left" || item.attr.fixed === true);
|
|
10056
|
+
const hasRightFixed = processedColumns.value.find((item) => item.attr.fixed === "right");
|
|
9979
10057
|
if (!hasLeftFixed && !hasRightFixed) {
|
|
9980
10058
|
return;
|
|
9981
10059
|
}
|
|
@@ -10040,6 +10118,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
10040
10118
|
});
|
|
10041
10119
|
return Object.assign({
|
|
10042
10120
|
resolveValue: commonUtils.resolveValue,
|
|
10121
|
+
processedColumns,
|
|
10043
10122
|
getOperationListLocal,
|
|
10044
10123
|
eventsOperationListBtns,
|
|
10045
10124
|
elTableRef,
|
|
@@ -10999,7 +11078,7 @@ var _sfc_render = function render4() {
|
|
|
10999
11078
|
"cancel-text": _vm.columnCheckCancelButtonText,
|
|
11000
11079
|
"basic-field-desc": _vm.columnCheckBasicFieldDesc,
|
|
11001
11080
|
"show": _vm.nfColumCheckDialogVisible,
|
|
11002
|
-
"table-columns": _vm.
|
|
11081
|
+
"table-columns": _vm.processedColumns,
|
|
11003
11082
|
"column-edit": _vm.columnEdit,
|
|
11004
11083
|
"storage-key": _vm.cStorageKey,
|
|
11005
11084
|
"width": _vm.columnCheckWidth,
|
|
@@ -11066,7 +11145,7 @@ var _sfc_render = function render4() {
|
|
|
11066
11145
|
"column-edit": _vm.columnEdit,
|
|
11067
11146
|
"operation-prop-key": _vm.operationPropKey,
|
|
11068
11147
|
"storage-key": _vm.cStorageKey,
|
|
11069
|
-
"table-columns": _vm.
|
|
11148
|
+
"table-columns": _vm.processedColumns
|
|
11070
11149
|
}
|
|
11071
11150
|
})], 2) : _vm._e()], 2);
|
|
11072
11151
|
};
|
|
@@ -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.
|
|
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(
|
|
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).
|
|
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
|
|
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
|
-
|
|
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.
|
|
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", {
|
|
@@ -8938,6 +8941,12 @@ const __sfc_main = defineComponent({
|
|
|
8938
8941
|
name: "nf-table"
|
|
8939
8942
|
});
|
|
8940
8943
|
__sfc_main.props = {
|
|
8944
|
+
viewIdentity: {
|
|
8945
|
+
key: "viewIdentity",
|
|
8946
|
+
required: false,
|
|
8947
|
+
type: String,
|
|
8948
|
+
default: ""
|
|
8949
|
+
},
|
|
8941
8950
|
data: {
|
|
8942
8951
|
key: "data",
|
|
8943
8952
|
required: false,
|
|
@@ -9403,6 +9412,17 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9403
9412
|
var _a;
|
|
9404
9413
|
const props = __props;
|
|
9405
9414
|
const emit = __ctx.emit;
|
|
9415
|
+
const processedColumns = computed(() => {
|
|
9416
|
+
var _a2;
|
|
9417
|
+
const viewField = window.viewField;
|
|
9418
|
+
if (props.viewIdentity && viewField) {
|
|
9419
|
+
const showList = (_a2 = viewField.find((item) => item.viewIdentity === props.viewIdentity)) == null ? void 0 : _a2.fieldList;
|
|
9420
|
+
if (showList == null ? void 0 : showList.length) {
|
|
9421
|
+
return props.columns.filter((item) => showList.includes(item.prop) || item.prop === props.operationPropKey || item.type === "selection" || item.type === "index" || item.type === "expand");
|
|
9422
|
+
}
|
|
9423
|
+
}
|
|
9424
|
+
return props.columns;
|
|
9425
|
+
});
|
|
9406
9426
|
const getOperationListLocal = (column, scope) => {
|
|
9407
9427
|
if (typeof column.operationList === "function") {
|
|
9408
9428
|
return column.operationList(scope);
|
|
@@ -9436,7 +9456,61 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9436
9456
|
const preSearchFormData = ref({});
|
|
9437
9457
|
const cPageChangeSearchApi = ref(props.pageChangeSearchApi ?? props.setEasyConf);
|
|
9438
9458
|
const cInitSearchApi = ref(props.initSearchApi ?? props.setEasyConf);
|
|
9439
|
-
const cStorageKey =
|
|
9459
|
+
const cStorageKey = computed(() => {
|
|
9460
|
+
const key = props.storageKey || `nf-table-columns-cached-key-${routeName.value}`;
|
|
9461
|
+
const userId = window.userId;
|
|
9462
|
+
if (props.viewIdentity && userId) {
|
|
9463
|
+
return userId + "-" + key;
|
|
9464
|
+
}
|
|
9465
|
+
return key;
|
|
9466
|
+
});
|
|
9467
|
+
const cStorageKeyViewIdentity = computed(() => {
|
|
9468
|
+
return "nf-table-view-identity";
|
|
9469
|
+
});
|
|
9470
|
+
const checkViewIdentityChange = async () => {
|
|
9471
|
+
const userId = window.userId;
|
|
9472
|
+
const viewField = window.viewField;
|
|
9473
|
+
if (props.viewIdentity && userId && viewField) {
|
|
9474
|
+
let viewIdentity = CachedManager.syncCachedGet(cStorageKeyViewIdentity.value);
|
|
9475
|
+
if (!viewIdentity) {
|
|
9476
|
+
viewIdentity = await CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value);
|
|
9477
|
+
}
|
|
9478
|
+
if (!viewIdentity) {
|
|
9479
|
+
await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField);
|
|
9480
|
+
} else {
|
|
9481
|
+
const newViewIdentity = viewField.find((item) => item.viewIdentity === props.viewIdentity);
|
|
9482
|
+
const oldViewIdentity = viewIdentity.find((item) => item.viewIdentity === props.viewIdentity);
|
|
9483
|
+
if (newViewIdentity && !oldViewIdentity || !newViewIdentity && oldViewIdentity) {
|
|
9484
|
+
await clearColumnEditCached();
|
|
9485
|
+
await clearDragCached();
|
|
9486
|
+
} else if (newViewIdentity && oldViewIdentity) {
|
|
9487
|
+
let change = false;
|
|
9488
|
+
newViewIdentity.fieldList.every((item) => {
|
|
9489
|
+
if (!oldViewIdentity.fieldList.includes(item)) {
|
|
9490
|
+
change = true;
|
|
9491
|
+
return;
|
|
9492
|
+
}
|
|
9493
|
+
return true;
|
|
9494
|
+
});
|
|
9495
|
+
if (!change) {
|
|
9496
|
+
oldViewIdentity.fieldList.every((item) => {
|
|
9497
|
+
if (!newViewIdentity.fieldList.includes(item)) {
|
|
9498
|
+
change = true;
|
|
9499
|
+
return;
|
|
9500
|
+
}
|
|
9501
|
+
return true;
|
|
9502
|
+
});
|
|
9503
|
+
}
|
|
9504
|
+
if (change) {
|
|
9505
|
+
await clearColumnEditCached();
|
|
9506
|
+
await clearDragCached();
|
|
9507
|
+
oldViewIdentity.fieldList = newViewIdentity.fieldList;
|
|
9508
|
+
await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity);
|
|
9509
|
+
}
|
|
9510
|
+
}
|
|
9511
|
+
}
|
|
9512
|
+
}
|
|
9513
|
+
};
|
|
9440
9514
|
const cPageAttrs = reactive({
|
|
9441
9515
|
// 页码,没有props时 & 允许分页时;默认 = 1
|
|
9442
9516
|
"current-page": props.pageAttrs["current-page"] || (props.alwaysShowPage ? 1 : void 0),
|
|
@@ -9510,7 +9584,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9510
9584
|
if (!init) {
|
|
9511
9585
|
props.columns._skip = true;
|
|
9512
9586
|
}
|
|
9513
|
-
const result =
|
|
9587
|
+
const result = processedColumns.value.filter((item) => {
|
|
9514
9588
|
var _a2, _b;
|
|
9515
9589
|
const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
|
|
9516
9590
|
if ((_b = props.showColumn) == null ? void 0 : _b.includes(prop)) {
|
|
@@ -9529,7 +9603,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9529
9603
|
if (result.length) {
|
|
9530
9604
|
return result;
|
|
9531
9605
|
}
|
|
9532
|
-
return
|
|
9606
|
+
return processedColumns.value.map((item) => {
|
|
9533
9607
|
var _a2;
|
|
9534
9608
|
return item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
|
|
9535
9609
|
});
|
|
@@ -9546,7 +9620,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9546
9620
|
const syncLocalShowColumnToCookies = () => {
|
|
9547
9621
|
if (props.columnEdit) {
|
|
9548
9622
|
const columnState = {};
|
|
9549
|
-
|
|
9623
|
+
processedColumns.value.map((i, index2) => {
|
|
9550
9624
|
var _a2, _b;
|
|
9551
9625
|
const prop = i.prop || ((_a2 = i.attr) == null ? void 0 : _a2.prop);
|
|
9552
9626
|
columnState[prop] = {
|
|
@@ -9561,7 +9635,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9561
9635
|
};
|
|
9562
9636
|
const syncShowItemToInitHidden = () => {
|
|
9563
9637
|
props.columns._skip = true;
|
|
9564
|
-
|
|
9638
|
+
processedColumns.value.forEach((item) => {
|
|
9565
9639
|
var _a2, _b;
|
|
9566
9640
|
const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
|
|
9567
9641
|
if ((_b = localShowColumn.value) == null ? void 0 : _b.includes(prop)) {
|
|
@@ -9577,6 +9651,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9577
9651
|
const syncCookiesToLocalShowColumn = async () => {
|
|
9578
9652
|
if (props.columnEdit) {
|
|
9579
9653
|
try {
|
|
9654
|
+
await checkViewIdentityChange();
|
|
9580
9655
|
let columnState = CachedManager.syncCachedGet(cStorageKey.value);
|
|
9581
9656
|
if (!columnState) {
|
|
9582
9657
|
columnState = await CachedManager.asyncCachedGet(cStorageKey.value);
|
|
@@ -9603,6 +9678,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9603
9678
|
var _a2, _b;
|
|
9604
9679
|
if (props.columnEdit) {
|
|
9605
9680
|
try {
|
|
9681
|
+
await checkViewIdentityChange();
|
|
9606
9682
|
let cached = CachedManager.syncCachedGet(cStorageKey.value);
|
|
9607
9683
|
if (!cached) {
|
|
9608
9684
|
cached = await CachedManager.asyncCachedGet(cStorageKey.value);
|
|
@@ -9641,7 +9717,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9641
9717
|
const elTableRefKey = ref(Date.now());
|
|
9642
9718
|
const syncCookiesToTableColumn = async (readCached = true) => {
|
|
9643
9719
|
props.columns._skip = true;
|
|
9644
|
-
const columns =
|
|
9720
|
+
const columns = processedColumns.value.map((item, index2) => {
|
|
9645
9721
|
var _a2;
|
|
9646
9722
|
const attr = item.attr || {};
|
|
9647
9723
|
if (!attr["min-width"] && item.label) {
|
|
@@ -9684,6 +9760,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9684
9760
|
});
|
|
9685
9761
|
if (readCached && props.columnEdit) {
|
|
9686
9762
|
try {
|
|
9763
|
+
await checkViewIdentityChange();
|
|
9687
9764
|
let columnState = CachedManager.syncCachedGet(cStorageKey.value);
|
|
9688
9765
|
if (!columnState) {
|
|
9689
9766
|
columnState = await CachedManager.asyncCachedGet(cStorageKey.value);
|
|
@@ -9754,6 +9831,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9754
9831
|
columnEdit: true
|
|
9755
9832
|
} : {},
|
|
9756
9833
|
storageKey: props.searchFormStorageKey,
|
|
9834
|
+
viewIdentity: props.viewIdentity,
|
|
9757
9835
|
...props.searchFormAttrs
|
|
9758
9836
|
};
|
|
9759
9837
|
return obj;
|
|
@@ -9972,8 +10050,8 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9972
10050
|
};
|
|
9973
10051
|
const resizeTable = () => {
|
|
9974
10052
|
if (props.detectResize) {
|
|
9975
|
-
const hasLeftFixed =
|
|
9976
|
-
const hasRightFixed =
|
|
10053
|
+
const hasLeftFixed = processedColumns.value.find((item) => item.attr.fixed === "left" || item.attr.fixed === true);
|
|
10054
|
+
const hasRightFixed = processedColumns.value.find((item) => item.attr.fixed === "right");
|
|
9977
10055
|
if (!hasLeftFixed && !hasRightFixed) {
|
|
9978
10056
|
return;
|
|
9979
10057
|
}
|
|
@@ -10038,6 +10116,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
10038
10116
|
});
|
|
10039
10117
|
return Object.assign({
|
|
10040
10118
|
resolveValue,
|
|
10119
|
+
processedColumns,
|
|
10041
10120
|
getOperationListLocal,
|
|
10042
10121
|
eventsOperationListBtns,
|
|
10043
10122
|
elTableRef,
|
|
@@ -10997,7 +11076,7 @@ var _sfc_render = function render4() {
|
|
|
10997
11076
|
"cancel-text": _vm.columnCheckCancelButtonText,
|
|
10998
11077
|
"basic-field-desc": _vm.columnCheckBasicFieldDesc,
|
|
10999
11078
|
"show": _vm.nfColumCheckDialogVisible,
|
|
11000
|
-
"table-columns": _vm.
|
|
11079
|
+
"table-columns": _vm.processedColumns,
|
|
11001
11080
|
"column-edit": _vm.columnEdit,
|
|
11002
11081
|
"storage-key": _vm.cStorageKey,
|
|
11003
11082
|
"width": _vm.columnCheckWidth,
|
|
@@ -11064,7 +11143,7 @@ var _sfc_render = function render4() {
|
|
|
11064
11143
|
"column-edit": _vm.columnEdit,
|
|
11065
11144
|
"operation-prop-key": _vm.operationPropKey,
|
|
11066
11145
|
"storage-key": _vm.cStorageKey,
|
|
11067
|
-
"table-columns": _vm.
|
|
11146
|
+
"table-columns": _vm.processedColumns
|
|
11068
11147
|
}
|
|
11069
11148
|
})], 2) : _vm._e()], 2);
|
|
11070
11149
|
};
|
package/lib/nf-table.vue.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NfTableColumnAttributes, ElTableAttributes, ElTableEventKey, ElPaginationEventKey, ElPaginationAttributes, NfSearchFormAttributes, NfSearchFormEventKey, NfTableActionBtnAttributes } from './types';
|
|
2
2
|
import { ITabItem } from '@94ai/nf-drawer/lib/types';
|
|
3
3
|
declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
viewIdentity?: string | undefined;
|
|
4
5
|
data?: Record<string, any>[] | undefined;
|
|
5
6
|
columns?: NfTableColumnAttributes[] | any;
|
|
6
7
|
searchFormAttrs?: NfSearchFormAttributes | undefined;
|
|
@@ -79,6 +80,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
79
80
|
virtualTableData?: Record<string, any>[] | undefined;
|
|
80
81
|
virtualProps?: Record<string, any> | undefined;
|
|
81
82
|
}>, {
|
|
83
|
+
viewIdentity: string;
|
|
82
84
|
dragCached: boolean;
|
|
83
85
|
emptyImageSize: number;
|
|
84
86
|
emptyText: string;
|
|
@@ -261,6 +263,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
261
263
|
callback: Function;
|
|
262
264
|
}) => void;
|
|
263
265
|
}, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
266
|
+
viewIdentity?: string | undefined;
|
|
264
267
|
data?: Record<string, any>[] | undefined;
|
|
265
268
|
columns?: NfTableColumnAttributes[] | any;
|
|
266
269
|
searchFormAttrs?: NfSearchFormAttributes | undefined;
|
|
@@ -339,6 +342,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
339
342
|
virtualTableData?: Record<string, any>[] | undefined;
|
|
340
343
|
virtualProps?: Record<string, any> | undefined;
|
|
341
344
|
}>, {
|
|
345
|
+
viewIdentity: string;
|
|
342
346
|
dragCached: boolean;
|
|
343
347
|
emptyImageSize: number;
|
|
344
348
|
emptyText: string;
|
|
@@ -427,6 +431,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
427
431
|
text: string;
|
|
428
432
|
selectEmptyWarningTips: string;
|
|
429
433
|
showColumn: string[];
|
|
434
|
+
viewIdentity: string;
|
|
430
435
|
searchFormAttrs: NfSearchFormAttributes;
|
|
431
436
|
searchFormEvents: Partial<Record<NfSearchFormEventKey, Function>>;
|
|
432
437
|
tableAttrs: ElTableAttributes;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
v-model="checkAll"
|
|
18
18
|
:indeterminate="isIndeterminate"
|
|
19
19
|
@change="handleCheckAllChange"
|
|
20
|
-
>{{ getAllCheckDesc(
|
|
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.
|
|
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(
|
|
263
|
+
const checkedCount = ref<string[]>([]) // 勾选的
|
|
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).
|
|
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
|
|
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
|
/**
|
package/package/nf-table.vue
CHANGED
|
@@ -691,7 +691,7 @@
|
|
|
691
691
|
:basic-field-desc="columnCheckBasicFieldDesc"
|
|
692
692
|
|
|
693
693
|
:show.sync="nfColumCheckDialogVisible"
|
|
694
|
-
:table-columns="
|
|
694
|
+
:table-columns="processedColumns"
|
|
695
695
|
:column-edit="columnEdit"
|
|
696
696
|
:storage-key="cStorageKey"
|
|
697
697
|
:width="columnCheckWidth"
|
|
@@ -750,7 +750,7 @@
|
|
|
750
750
|
:column-edit="columnEdit"
|
|
751
751
|
:operation-prop-key="operationPropKey"
|
|
752
752
|
:storage-key="cStorageKey"
|
|
753
|
-
:table-columns="
|
|
753
|
+
:table-columns="processedColumns"
|
|
754
754
|
/>
|
|
755
755
|
</nf-drawer>
|
|
756
756
|
</div>
|
|
@@ -797,6 +797,7 @@ import { useRoute } from 'vue-router/composables'
|
|
|
797
797
|
import VirtualScroll, { VirtualColumn } from 'el-table-virtual-scroll'
|
|
798
798
|
|
|
799
799
|
const props = withDefaults(defineProps<{
|
|
800
|
+
viewIdentity?: string,
|
|
800
801
|
data?: Record<string, any>[],
|
|
801
802
|
columns?: NfTableColumnAttributes[] | any,
|
|
802
803
|
searchFormAttrs?: NfSearchFormAttributes,
|
|
@@ -916,6 +917,7 @@ const props = withDefaults(defineProps<{
|
|
|
916
917
|
virtualTableData?: Record<string, any>[],
|
|
917
918
|
virtualProps?: Record<string, any>,
|
|
918
919
|
}>(), {
|
|
920
|
+
viewIdentity: '',
|
|
919
921
|
dragCached: true,
|
|
920
922
|
emptyImageSize: 145,
|
|
921
923
|
emptyText: '',
|
|
@@ -999,6 +1001,18 @@ const emit = defineEmits<{
|
|
|
999
1001
|
(e: 'searchApi', event: { data: Record<string, any>, callback: Function}): void
|
|
1000
1002
|
}>()
|
|
1001
1003
|
|
|
1004
|
+
const processedColumns = computed(() => {
|
|
1005
|
+
const viewField = (window as any).viewField
|
|
1006
|
+
if (props.viewIdentity && viewField) {
|
|
1007
|
+
const showList = viewField.find(item => item.viewIdentity === props.viewIdentity)?.fieldList
|
|
1008
|
+
if (showList?.length) {
|
|
1009
|
+
return props.columns.filter(item => showList.includes(item.prop) || item.prop === props.operationPropKey || item.type === 'selection' || item.type === 'index' || item.type === 'expand')
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
return props.columns
|
|
1013
|
+
})
|
|
1014
|
+
|
|
1015
|
+
|
|
1002
1016
|
const getOperationListLocal = (column, scope) => {
|
|
1003
1017
|
if (typeof column.operationList === 'function') {
|
|
1004
1018
|
return column.operationList(scope)
|
|
@@ -1033,7 +1047,65 @@ const nfColumCheckDialogVisible = ref(false)
|
|
|
1033
1047
|
const preSearchFormData = ref({})
|
|
1034
1048
|
const cPageChangeSearchApi = ref(props.pageChangeSearchApi ?? props.setEasyConf)
|
|
1035
1049
|
const cInitSearchApi = ref(props.initSearchApi ?? props.setEasyConf)
|
|
1036
|
-
|
|
1050
|
+
|
|
1051
|
+
const cStorageKey = computed(() => {
|
|
1052
|
+
const key = props.storageKey || `nf-table-columns-cached-key-${routeName.value}`
|
|
1053
|
+
const userId = (window as any).userId
|
|
1054
|
+
if (props.viewIdentity && userId) {
|
|
1055
|
+
return userId + '-' + key
|
|
1056
|
+
}
|
|
1057
|
+
return key
|
|
1058
|
+
})
|
|
1059
|
+
|
|
1060
|
+
const cStorageKeyViewIdentity = computed(() => {
|
|
1061
|
+
return 'nf-table-view-identity'
|
|
1062
|
+
})
|
|
1063
|
+
|
|
1064
|
+
const checkViewIdentityChange = async () => {
|
|
1065
|
+
const userId = (window as any).userId
|
|
1066
|
+
const viewField = (window as any).viewField
|
|
1067
|
+
if (props.viewIdentity && userId && viewField) {
|
|
1068
|
+
let viewIdentity = CachedManager.syncCachedGet(cStorageKeyViewIdentity.value)
|
|
1069
|
+
if (!viewIdentity) {
|
|
1070
|
+
viewIdentity = await CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value)
|
|
1071
|
+
}
|
|
1072
|
+
if (!viewIdentity) {
|
|
1073
|
+
await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField)
|
|
1074
|
+
} else {
|
|
1075
|
+
const newViewIdentity = viewField.find(item => item.viewIdentity === props.viewIdentity)
|
|
1076
|
+
const oldViewIdentity = viewIdentity.find(item => item.viewIdentity === props.viewIdentity)
|
|
1077
|
+
if ((newViewIdentity && !oldViewIdentity) || (!newViewIdentity && oldViewIdentity)) {
|
|
1078
|
+
await clearColumnEditCached()
|
|
1079
|
+
await clearDragCached()
|
|
1080
|
+
} else if (newViewIdentity && oldViewIdentity) {
|
|
1081
|
+
let change = false
|
|
1082
|
+
newViewIdentity.fieldList.every(item => {
|
|
1083
|
+
if (!oldViewIdentity.fieldList.includes(item)) {
|
|
1084
|
+
change = true
|
|
1085
|
+
return
|
|
1086
|
+
}
|
|
1087
|
+
return true
|
|
1088
|
+
})
|
|
1089
|
+
if (!change) {
|
|
1090
|
+
oldViewIdentity.fieldList.every(item => {
|
|
1091
|
+
if (!newViewIdentity.fieldList.includes(item)) {
|
|
1092
|
+
change = true
|
|
1093
|
+
return
|
|
1094
|
+
}
|
|
1095
|
+
return true
|
|
1096
|
+
})
|
|
1097
|
+
}
|
|
1098
|
+
if (change) {
|
|
1099
|
+
await clearColumnEditCached()
|
|
1100
|
+
await clearDragCached()
|
|
1101
|
+
oldViewIdentity.fieldList = newViewIdentity.fieldList
|
|
1102
|
+
await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity)
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1037
1109
|
const cPageAttrs = reactive({
|
|
1038
1110
|
// 页码,没有props时 & 允许分页时;默认 = 1
|
|
1039
1111
|
'current-page': props.pageAttrs['current-page'] || (props.alwaysShowPage ? 1 : undefined),
|
|
@@ -1119,7 +1191,7 @@ const initLocalShow = (init = false) => {
|
|
|
1119
1191
|
if (!init) {
|
|
1120
1192
|
props.columns._skip = true
|
|
1121
1193
|
}
|
|
1122
|
-
const result =
|
|
1194
|
+
const result = processedColumns.value.filter(item => {
|
|
1123
1195
|
const prop = item.prop || item.attr?.prop
|
|
1124
1196
|
if (props.showColumn?.includes(prop!)) {
|
|
1125
1197
|
item.initHidden = false
|
|
@@ -1134,7 +1206,7 @@ const initLocalShow = (init = false) => {
|
|
|
1134
1206
|
if (result.length) {
|
|
1135
1207
|
return result
|
|
1136
1208
|
}
|
|
1137
|
-
return
|
|
1209
|
+
return processedColumns.value.map(item => item.prop! || item.attr?.prop!)
|
|
1138
1210
|
}
|
|
1139
1211
|
const localShowColumn = ref<string[]>(initLocalShow(true))
|
|
1140
1212
|
watch(() => localShowColumn.value?.length, () => {
|
|
@@ -1146,7 +1218,7 @@ watch(() => localShowColumn.value?.length, () => {
|
|
|
1146
1218
|
const syncLocalShowColumnToCookies = () => {
|
|
1147
1219
|
if (props.columnEdit) {
|
|
1148
1220
|
const columnState = {}
|
|
1149
|
-
|
|
1221
|
+
processedColumns.value.map((i, index) => {
|
|
1150
1222
|
const prop = i.prop || i.attr?.prop
|
|
1151
1223
|
columnState[prop!] = {
|
|
1152
1224
|
initHidden: i.initHidden || false,
|
|
@@ -1161,7 +1233,7 @@ const syncLocalShowColumnToCookies = () => {
|
|
|
1161
1233
|
|
|
1162
1234
|
const syncShowItemToInitHidden = () => {
|
|
1163
1235
|
props.columns._skip = true
|
|
1164
|
-
|
|
1236
|
+
processedColumns.value.forEach(item => {
|
|
1165
1237
|
const prop = item.prop || item.attr?.prop
|
|
1166
1238
|
if (localShowColumn.value?.includes(prop!)) {
|
|
1167
1239
|
item.initHidden = false
|
|
@@ -1176,6 +1248,7 @@ const syncShowItemToInitHidden = () => {
|
|
|
1176
1248
|
const syncCookiesToLocalShowColumn = async () => {
|
|
1177
1249
|
if (props.columnEdit) {
|
|
1178
1250
|
try {
|
|
1251
|
+
await checkViewIdentityChange()
|
|
1179
1252
|
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
|
|
1180
1253
|
if (!columnState) {
|
|
1181
1254
|
columnState = await CachedManager.asyncCachedGet(cStorageKey.value)
|
|
@@ -1203,6 +1276,7 @@ const initCachedData = async () => {
|
|
|
1203
1276
|
if (props.columnEdit) {
|
|
1204
1277
|
// 同步缓存参数
|
|
1205
1278
|
try {
|
|
1279
|
+
await checkViewIdentityChange()
|
|
1206
1280
|
let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
|
|
1207
1281
|
if (!cached) {
|
|
1208
1282
|
cached = await CachedManager.asyncCachedGet(cStorageKey.value)
|
|
@@ -1243,7 +1317,7 @@ const tableColumns = ref<NfTableColumnAttributes[]>([])
|
|
|
1243
1317
|
const elTableRefKey = ref(Date.now())
|
|
1244
1318
|
const syncCookiesToTableColumn = async (readCached = true) => {
|
|
1245
1319
|
props.columns._skip = true
|
|
1246
|
-
const columns =
|
|
1320
|
+
const columns = processedColumns.value!.map((item, index) => {
|
|
1247
1321
|
const attr = (item.attr || {}) as ElTableColumnAttributes
|
|
1248
1322
|
// 区分中文、数字、其他字符
|
|
1249
1323
|
if (!attr['min-width'] && item.label) {
|
|
@@ -1288,6 +1362,7 @@ const syncCookiesToTableColumn = async (readCached = true) => {
|
|
|
1288
1362
|
if (readCached && props.columnEdit) {
|
|
1289
1363
|
// 读取缓存 Column 配置
|
|
1290
1364
|
try {
|
|
1365
|
+
await checkViewIdentityChange()
|
|
1291
1366
|
let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
|
|
1292
1367
|
if (!columnState) {
|
|
1293
1368
|
columnState = await CachedManager.asyncCachedGet(cStorageKey.value)
|
|
@@ -1359,6 +1434,7 @@ const searchFormAttrer = computed(() => {
|
|
|
1359
1434
|
columnEdit: true
|
|
1360
1435
|
} : {}),
|
|
1361
1436
|
storageKey: props.searchFormStorageKey,
|
|
1437
|
+
viewIdentity: props.viewIdentity,
|
|
1362
1438
|
...props.searchFormAttrs
|
|
1363
1439
|
}
|
|
1364
1440
|
return obj
|
|
@@ -1598,8 +1674,8 @@ const searchApi = async (formData = {}, refresh = false) => {
|
|
|
1598
1674
|
// 调整table固定列高度
|
|
1599
1675
|
const resizeTable = () => {
|
|
1600
1676
|
if (props.detectResize) {
|
|
1601
|
-
const hasLeftFixed =
|
|
1602
|
-
const hasRightFixed =
|
|
1677
|
+
const hasLeftFixed = processedColumns.value.find(item => item.attr.fixed === 'left' || item.attr.fixed === true)
|
|
1678
|
+
const hasRightFixed = processedColumns.value.find(item => item.attr.fixed === 'right')
|
|
1603
1679
|
if (!hasLeftFixed && !hasRightFixed) {
|
|
1604
1680
|
return
|
|
1605
1681
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-table",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.6",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "zoujiahe <zoujiahe@94ai.com>",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@94ai/common-utils": "^8.3.
|
|
18
|
-
"@94ai/nf-button": "^8.3.
|
|
19
|
-
"@94ai/nf-drawer": "^8.3.
|
|
20
|
-
"@94ai/nf-message": "^8.3.
|
|
21
|
-
"@94ai/nf-search-form": "^8.3.
|
|
22
|
-
"@94ai/nf-tag": "^8.3.
|
|
23
|
-
"@94ai/nf-theme-chalk": "^8.3.
|
|
17
|
+
"@94ai/common-utils": "^8.3.6",
|
|
18
|
+
"@94ai/nf-button": "^8.3.6",
|
|
19
|
+
"@94ai/nf-drawer": "^8.3.6",
|
|
20
|
+
"@94ai/nf-message": "^8.3.6",
|
|
21
|
+
"@94ai/nf-search-form": "^8.3.6",
|
|
22
|
+
"@94ai/nf-tag": "^8.3.6",
|
|
23
|
+
"@94ai/nf-theme-chalk": "^8.3.6",
|
|
24
24
|
"idb-keyval": "^6.2.1",
|
|
25
25
|
"vue-demi": "^0.14.5",
|
|
26
26
|
"vue-router": "3.6.4",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"types": "lib/index.d.ts",
|
|
40
40
|
"main": "lib/nf-table.cjs.js",
|
|
41
41
|
"module": "lib/nf-table.esm-bundler.js",
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "1ddd91dce7a3ef5d1f3f923ca0997cdd4e023d7a"
|
|
43
43
|
}
|