@94ai/nf-table 100.1.9 → 100.1.15
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 +136 -136
- package/lib/nf-column-check-dialog.vue.d.ts +28 -19
- package/lib/nf-column-check-drawer.vue.d.ts +37 -29
- package/lib/nf-table.cjs.js +182 -108
- package/lib/nf-table.esm-bundler.js +183 -109
- package/lib/nf-table.vue.d.ts +50 -50
- package/package/index.ts +0 -7
- package/package/nf-column-check-dialog.vue +31 -10
- package/package/nf-column-check-drawer.vue +10 -5
- package/package/nf-table.vue +85 -57
- package/package.json +8 -8
package/lib/nf-table.vue.d.ts
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
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<{
|
|
4
|
-
background: {
|
|
5
|
-
type: import("vue-demi").PropType<string>;
|
|
6
|
-
default: undefined;
|
|
7
|
-
};
|
|
8
|
-
columns: {
|
|
9
|
-
type: import("vue-demi").PropType<any>;
|
|
10
|
-
default: () => never[];
|
|
11
|
-
};
|
|
12
4
|
data: {
|
|
13
5
|
type: import("vue-demi").PropType<Record<string, any>[]>;
|
|
14
6
|
default: () => never[];
|
|
15
7
|
};
|
|
16
|
-
|
|
8
|
+
columnEdit: {
|
|
9
|
+
type: import("vue-demi").PropType<boolean>;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
12
|
+
operationPropKey: {
|
|
17
13
|
type: import("vue-demi").PropType<string>;
|
|
18
14
|
default: string;
|
|
19
15
|
};
|
|
20
|
-
|
|
21
|
-
type: import("vue-demi").PropType<string
|
|
22
|
-
default:
|
|
16
|
+
storageKey: {
|
|
17
|
+
type: import("vue-demi").PropType<string>;
|
|
18
|
+
default: string;
|
|
23
19
|
};
|
|
24
20
|
fullscreen: {
|
|
25
21
|
type: import("vue-demi").PropType<boolean>;
|
|
@@ -37,14 +33,22 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
37
33
|
type: import("vue-demi").PropType<string>;
|
|
38
34
|
default: undefined;
|
|
39
35
|
};
|
|
40
|
-
|
|
36
|
+
background: {
|
|
41
37
|
type: import("vue-demi").PropType<string>;
|
|
42
|
-
default:
|
|
38
|
+
default: undefined;
|
|
43
39
|
};
|
|
44
|
-
|
|
40
|
+
columns: {
|
|
41
|
+
type: import("vue-demi").PropType<any>;
|
|
42
|
+
default: () => never[];
|
|
43
|
+
};
|
|
44
|
+
selectEmptyWarningTips: {
|
|
45
45
|
type: import("vue-demi").PropType<string>;
|
|
46
46
|
default: string;
|
|
47
47
|
};
|
|
48
|
+
showColumn: {
|
|
49
|
+
type: import("vue-demi").PropType<string[]>;
|
|
50
|
+
default: undefined;
|
|
51
|
+
};
|
|
48
52
|
searchFormAttrs: {
|
|
49
53
|
type: import("vue-demi").PropType<NfSearchFormAttributes>;
|
|
50
54
|
default: () => {};
|
|
@@ -77,10 +81,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
77
81
|
type: import("vue-demi").PropType<boolean>;
|
|
78
82
|
default: boolean;
|
|
79
83
|
};
|
|
80
|
-
columnEdit: {
|
|
81
|
-
type: import("vue-demi").PropType<boolean>;
|
|
82
|
-
default: boolean;
|
|
83
|
-
};
|
|
84
84
|
columnPosition: {
|
|
85
85
|
type: import("vue-demi").PropType<"embed" | "free">;
|
|
86
86
|
default: string;
|
|
@@ -320,7 +320,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
320
320
|
resizable?: boolean | undefined;
|
|
321
321
|
formatter?: Function | undefined;
|
|
322
322
|
'show-overflow-tooltip'?: boolean | undefined;
|
|
323
|
-
align?: "
|
|
323
|
+
align?: "center" | "left" | "right" | undefined;
|
|
324
324
|
'class-name'?: string | undefined;
|
|
325
325
|
'label-class-name'?: string | undefined;
|
|
326
326
|
selectable?: Function | undefined;
|
|
@@ -329,38 +329,34 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
329
329
|
text?: string | number | undefined;
|
|
330
330
|
value?: string | number | undefined;
|
|
331
331
|
}[] | undefined;
|
|
332
|
-
'filter-placement'?: "
|
|
332
|
+
'filter-placement'?: "top" | "bottom" | "left" | "right" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end" | undefined;
|
|
333
333
|
'filter-multiple'?: boolean | undefined;
|
|
334
334
|
'filter-method'?: Function | undefined;
|
|
335
335
|
'filtered-value'?: string[] | undefined;
|
|
336
336
|
} | undefined;
|
|
337
337
|
}[]>;
|
|
338
|
-
syncLocalShowColumnToCookies: () => void
|
|
339
|
-
syncCookiesToLocalShowColumn: () => void
|
|
340
|
-
syncCookiesToTableColumn: (readCached?: boolean) => void
|
|
338
|
+
syncLocalShowColumnToCookies: () => Promise<void>;
|
|
339
|
+
syncCookiesToLocalShowColumn: () => Promise<void>;
|
|
340
|
+
syncCookiesToTableColumn: (readCached?: boolean) => Promise<void>;
|
|
341
341
|
}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
|
|
342
342
|
fieldsChange: (event: string[]) => void;
|
|
343
343
|
"update:showColumn": (event: string[] | undefined) => void;
|
|
344
344
|
}, string, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
345
|
-
background: {
|
|
346
|
-
type: import("vue-demi").PropType<string>;
|
|
347
|
-
default: undefined;
|
|
348
|
-
};
|
|
349
|
-
columns: {
|
|
350
|
-
type: import("vue-demi").PropType<any>;
|
|
351
|
-
default: () => never[];
|
|
352
|
-
};
|
|
353
345
|
data: {
|
|
354
346
|
type: import("vue-demi").PropType<Record<string, any>[]>;
|
|
355
347
|
default: () => never[];
|
|
356
348
|
};
|
|
357
|
-
|
|
349
|
+
columnEdit: {
|
|
350
|
+
type: import("vue-demi").PropType<boolean>;
|
|
351
|
+
default: boolean;
|
|
352
|
+
};
|
|
353
|
+
operationPropKey: {
|
|
358
354
|
type: import("vue-demi").PropType<string>;
|
|
359
355
|
default: string;
|
|
360
356
|
};
|
|
361
|
-
|
|
362
|
-
type: import("vue-demi").PropType<string
|
|
363
|
-
default:
|
|
357
|
+
storageKey: {
|
|
358
|
+
type: import("vue-demi").PropType<string>;
|
|
359
|
+
default: string;
|
|
364
360
|
};
|
|
365
361
|
fullscreen: {
|
|
366
362
|
type: import("vue-demi").PropType<boolean>;
|
|
@@ -378,14 +374,22 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
378
374
|
type: import("vue-demi").PropType<string>;
|
|
379
375
|
default: undefined;
|
|
380
376
|
};
|
|
381
|
-
|
|
377
|
+
background: {
|
|
382
378
|
type: import("vue-demi").PropType<string>;
|
|
383
|
-
default:
|
|
379
|
+
default: undefined;
|
|
384
380
|
};
|
|
385
|
-
|
|
381
|
+
columns: {
|
|
382
|
+
type: import("vue-demi").PropType<any>;
|
|
383
|
+
default: () => never[];
|
|
384
|
+
};
|
|
385
|
+
selectEmptyWarningTips: {
|
|
386
386
|
type: import("vue-demi").PropType<string>;
|
|
387
387
|
default: string;
|
|
388
388
|
};
|
|
389
|
+
showColumn: {
|
|
390
|
+
type: import("vue-demi").PropType<string[]>;
|
|
391
|
+
default: undefined;
|
|
392
|
+
};
|
|
389
393
|
searchFormAttrs: {
|
|
390
394
|
type: import("vue-demi").PropType<NfSearchFormAttributes>;
|
|
391
395
|
default: () => {};
|
|
@@ -418,10 +422,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
418
422
|
type: import("vue-demi").PropType<boolean>;
|
|
419
423
|
default: boolean;
|
|
420
424
|
};
|
|
421
|
-
columnEdit: {
|
|
422
|
-
type: import("vue-demi").PropType<boolean>;
|
|
423
|
-
default: boolean;
|
|
424
|
-
};
|
|
425
425
|
columnPosition: {
|
|
426
426
|
type: import("vue-demi").PropType<"embed" | "free">;
|
|
427
427
|
default: string;
|
|
@@ -605,17 +605,18 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
605
605
|
default: boolean;
|
|
606
606
|
};
|
|
607
607
|
}>>, {
|
|
608
|
-
background: string;
|
|
609
|
-
columns: NfTableColumnAttributes[] | any;
|
|
610
608
|
data: Record<string, any>[];
|
|
609
|
+
columnEdit: boolean;
|
|
610
|
+
operationPropKey: string;
|
|
611
611
|
storageKey: string;
|
|
612
|
-
showColumn: string[];
|
|
613
612
|
fullscreen: boolean;
|
|
614
613
|
customClass: string;
|
|
615
614
|
body: boolean;
|
|
616
615
|
text: string;
|
|
616
|
+
background: string;
|
|
617
|
+
columns: NfTableColumnAttributes[] | any;
|
|
617
618
|
selectEmptyWarningTips: string;
|
|
618
|
-
|
|
619
|
+
showColumn: string[];
|
|
619
620
|
searchFormAttrs: NfSearchFormAttributes;
|
|
620
621
|
searchFormEvents: Partial<Record<NfSearchFormEventKey, Function>>;
|
|
621
622
|
tableAttrs: ElTableAttributes;
|
|
@@ -624,7 +625,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
624
625
|
pageEvents: Partial<Record<ElPaginationEventKey, Function>>;
|
|
625
626
|
actionBarOptList: NfTableActionBtnAttributes[];
|
|
626
627
|
calHeight: boolean;
|
|
627
|
-
columnEdit: boolean;
|
|
628
628
|
columnPosition: 'free' | 'embed';
|
|
629
629
|
checkMode: 'dialog' | 'drawer';
|
|
630
630
|
priority: 'cached' | 'value';
|
|
@@ -745,7 +745,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
745
745
|
resizable?: boolean | undefined;
|
|
746
746
|
formatter?: Function | undefined;
|
|
747
747
|
'show-overflow-tooltip'?: boolean | undefined;
|
|
748
|
-
align?: "
|
|
748
|
+
align?: "center" | "left" | "right" | undefined;
|
|
749
749
|
'class-name'?: string | undefined;
|
|
750
750
|
'label-class-name'?: string | undefined;
|
|
751
751
|
selectable?: Function | undefined;
|
|
@@ -754,7 +754,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
754
754
|
text?: string | number | undefined;
|
|
755
755
|
value?: string | number | undefined;
|
|
756
756
|
}[] | undefined;
|
|
757
|
-
'filter-placement'?: "
|
|
757
|
+
'filter-placement'?: "top" | "bottom" | "left" | "right" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end" | undefined;
|
|
758
758
|
'filter-multiple'?: boolean | undefined;
|
|
759
759
|
'filter-method'?: Function | undefined;
|
|
760
760
|
'filtered-value'?: string[] | undefined;
|
package/package/index.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import NfTable from './nf-table.vue'
|
|
2
2
|
import { Vue2, PluginObject } from 'vue-demi'
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import VueCookies from 'vue-cookies'
|
|
5
3
|
import NfMessage from '@94ai/nf-message'
|
|
6
4
|
|
|
7
5
|
NfTable.install = (app: typeof Vue2) => {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
if (!app.$cookies) {
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
app.use(VueCookies)
|
|
12
|
-
}
|
|
13
6
|
// @ts-ignore
|
|
14
7
|
if (!app.$openMessage) {
|
|
15
8
|
// @ts-ignore
|
|
@@ -25,7 +25,14 @@
|
|
|
25
25
|
<div class="nf-table-nf-column-check-dialog-check-content">
|
|
26
26
|
<div v-for="(item,index) in fields" :key="index" class="nf-check-item">
|
|
27
27
|
<div class="nf-check-title">{{ item.name }}</div>
|
|
28
|
-
<el-checkbox
|
|
28
|
+
<el-checkbox
|
|
29
|
+
v-for="obj in item.list"
|
|
30
|
+
:key="obj.prop"
|
|
31
|
+
v-model="tableData[obj.prop]"
|
|
32
|
+
class="nf-check-box"
|
|
33
|
+
:label="obj.prop"
|
|
34
|
+
:disabled="unChangedColumn.includes(obj.prop)"
|
|
35
|
+
>{{ obj.label }}</el-checkbox>
|
|
29
36
|
</div>
|
|
30
37
|
</div>
|
|
31
38
|
<slot slot="footer" name="footer">
|
|
@@ -53,9 +60,14 @@ import {
|
|
|
53
60
|
onMounted,
|
|
54
61
|
ref
|
|
55
62
|
} from 'vue-demi'
|
|
56
|
-
import {
|
|
63
|
+
import { set as cachedSet } from 'idb-keyval'
|
|
57
64
|
|
|
58
65
|
const props = withDefaults(defineProps<{
|
|
66
|
+
/**
|
|
67
|
+
* 列编辑显示开关
|
|
68
|
+
*/
|
|
69
|
+
columnEdit?: boolean,
|
|
70
|
+
operationPropKey?: string
|
|
59
71
|
storageKey?: string
|
|
60
72
|
show?: boolean,
|
|
61
73
|
title?: string,
|
|
@@ -63,7 +75,6 @@ const props = withDefaults(defineProps<{
|
|
|
63
75
|
confirmText?: string
|
|
64
76
|
cancelText?: string
|
|
65
77
|
tableColumns?: Record<string, any>[],
|
|
66
|
-
showColumn?: string[]
|
|
67
78
|
modalAppendToBody?: boolean,
|
|
68
79
|
modal?: boolean,
|
|
69
80
|
fullscreen?: boolean,
|
|
@@ -78,6 +89,8 @@ const props = withDefaults(defineProps<{
|
|
|
78
89
|
center?: boolean,
|
|
79
90
|
destroyOnClose?: boolean,
|
|
80
91
|
}>(), {
|
|
92
|
+
columnEdit: false,
|
|
93
|
+
operationPropKey: 'operation',
|
|
81
94
|
storageKey: 'nf-table-columns-cached-key',
|
|
82
95
|
show: false,
|
|
83
96
|
width: '600px',
|
|
@@ -85,7 +98,6 @@ const props = withDefaults(defineProps<{
|
|
|
85
98
|
cancelText: '取 消',
|
|
86
99
|
confirmText: '保 存',
|
|
87
100
|
tableColumns: () => [],
|
|
88
|
-
showColumn: undefined,
|
|
89
101
|
modalAppendToBody: true,
|
|
90
102
|
modal: true,
|
|
91
103
|
fullscreen: false,
|
|
@@ -111,7 +123,8 @@ const emit = defineEmits<{
|
|
|
111
123
|
const instance = getCurrentInstance()?.proxy
|
|
112
124
|
|
|
113
125
|
const tableData = ref<Record<string, any>>({})
|
|
114
|
-
|
|
126
|
+
// 不可操作列
|
|
127
|
+
const unChangedColumn = ref<string[]>([])
|
|
115
128
|
|
|
116
129
|
const visible = computed({
|
|
117
130
|
get() {
|
|
@@ -124,7 +137,7 @@ const visible = computed({
|
|
|
124
137
|
|
|
125
138
|
const fields = computed(() => {
|
|
126
139
|
const obj: Record<string, any> = {}
|
|
127
|
-
|
|
140
|
+
props.tableColumns.filter(item => !item.destory).map(item => {
|
|
128
141
|
if (!item.type) {
|
|
129
142
|
const key = item.category || '基础字段'
|
|
130
143
|
if (!obj[key]) {
|
|
@@ -143,7 +156,7 @@ const fields = computed(() => {
|
|
|
143
156
|
return fields
|
|
144
157
|
})
|
|
145
158
|
|
|
146
|
-
const submit = ()
|
|
159
|
+
const submit = async () => {
|
|
147
160
|
visible.value = false
|
|
148
161
|
const columnState = {}
|
|
149
162
|
props.tableColumns.map((i, index) => {
|
|
@@ -154,17 +167,25 @@ const submit = () =>{
|
|
|
154
167
|
index
|
|
155
168
|
}
|
|
156
169
|
})
|
|
157
|
-
instance?.$cookies?.remove(props.storageKey)
|
|
158
|
-
instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1, '/xxxx/xxxx/xxxx')
|
|
159
170
|
emit('save', tableData.value)
|
|
171
|
+
if (props.columnEdit) {
|
|
172
|
+
await cachedSet(props.storageKey, columnState)
|
|
173
|
+
}
|
|
160
174
|
}
|
|
161
175
|
|
|
162
176
|
const addInitValue = () => {
|
|
163
177
|
const obj: Record<string, any> = {}
|
|
164
178
|
props.tableColumns.forEach(v => {
|
|
165
|
-
obj[v.prop] =
|
|
179
|
+
obj[v.prop] = !v.initHidden
|
|
166
180
|
})
|
|
167
181
|
tableData.value = obj
|
|
182
|
+
|
|
183
|
+
if (props.tableColumns.findIndex((item) => !!item.type) > -1) {
|
|
184
|
+
unChangedColumn.value.push('selection')
|
|
185
|
+
}
|
|
186
|
+
if (props.tableColumns.findIndex((item) => (item.prop || item.attr?.prop) === props.operationPropKey) > -1) {
|
|
187
|
+
unChangedColumn.value.push(props.operationPropKey)
|
|
188
|
+
}
|
|
168
189
|
}
|
|
169
190
|
|
|
170
191
|
onMounted(() => {
|
|
@@ -137,10 +137,9 @@ import {
|
|
|
137
137
|
computed,
|
|
138
138
|
onBeforeMount,
|
|
139
139
|
getCurrentInstance,
|
|
140
|
-
PropType,
|
|
141
|
-
onMounted
|
|
142
140
|
} from 'vue-demi'
|
|
143
141
|
import { deepClone } from '@94ai/common-utils'
|
|
142
|
+
import { set as cachedSet } from 'idb-keyval'
|
|
144
143
|
|
|
145
144
|
const instance = getCurrentInstance()?.proxy
|
|
146
145
|
|
|
@@ -151,6 +150,10 @@ const props = withDefaults(defineProps<{
|
|
|
151
150
|
tableColumns?: Record<string, any>[],
|
|
152
151
|
storageKey?: string
|
|
153
152
|
operationPropKey?: string
|
|
153
|
+
/**
|
|
154
|
+
* 列编辑显示开关
|
|
155
|
+
*/
|
|
156
|
+
columnEdit?: boolean,
|
|
154
157
|
searchPlaceholder?: string
|
|
155
158
|
fixedLeftDesc?: string
|
|
156
159
|
clearDesc?: string
|
|
@@ -158,6 +161,7 @@ const props = withDefaults(defineProps<{
|
|
|
158
161
|
getCheckedLengthDesc?: Function
|
|
159
162
|
getAllCheckDesc?: Function
|
|
160
163
|
}>(), {
|
|
164
|
+
columnEdit: false,
|
|
161
165
|
selectEmptyWarningTips: '请选择至少一个选项',
|
|
162
166
|
tableColumns: () => [],
|
|
163
167
|
storageKey: 'nf-table-columns-cached-key',
|
|
@@ -350,7 +354,7 @@ const handleFixed = (v, prop) => {
|
|
|
350
354
|
/**
|
|
351
355
|
* 确定
|
|
352
356
|
*/
|
|
353
|
-
const syncTableColumnsToCookies = () => {
|
|
357
|
+
const syncTableColumnsToCookies = async () => {
|
|
354
358
|
const newTableColumns = [...fixedColumn.value, ...unFixedColumn.value]
|
|
355
359
|
if (newTableColumns.filter(item => !item.type && item.prop !== props.operationPropKey && !item.initHidden).length === 0) {
|
|
356
360
|
// @ts-ignore
|
|
@@ -380,8 +384,9 @@ const syncTableColumnsToCookies = () => {
|
|
|
380
384
|
}
|
|
381
385
|
obj[i.prop] = !columnState[i.prop].initHidden
|
|
382
386
|
})
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
if (props.columnEdit) {
|
|
388
|
+
await cachedSet(props.storageKey, columnState)
|
|
389
|
+
}
|
|
385
390
|
return obj
|
|
386
391
|
}
|
|
387
392
|
|
package/package/nf-table.vue
CHANGED
|
@@ -468,7 +468,7 @@
|
|
|
468
468
|
v-if="nfColumCheckDialogVisible && checkMode === 'dialog'"
|
|
469
469
|
:show.sync="nfColumCheckDialogVisible"
|
|
470
470
|
:table-columns="columns"
|
|
471
|
-
:
|
|
471
|
+
:column-edit="columnEdit"
|
|
472
472
|
:storage-key="storageKey"
|
|
473
473
|
@save="fieldsConfirm"
|
|
474
474
|
:title="columnCheckTitle"
|
|
@@ -489,6 +489,7 @@
|
|
|
489
489
|
:center="columnCheckCenter"
|
|
490
490
|
:destroy-on-close="columnCheckDestroyOnClose"
|
|
491
491
|
ref="columnCheckDialog"
|
|
492
|
+
:operation-prop-key="operationPropKey"
|
|
492
493
|
>
|
|
493
494
|
<slot slot="tableColumnEditDialogTitle" name="title"></slot>
|
|
494
495
|
<slot slot="tableColumnEditDialogFooter" name="footer"></slot>
|
|
@@ -515,6 +516,7 @@
|
|
|
515
516
|
:fixed-left-desc="columnCheckFixedLeftDesc"
|
|
516
517
|
:clear-desc="columnCheckClearDesc"
|
|
517
518
|
:no-fixed-desc="columnCheckNoFixedDesc"
|
|
519
|
+
:column-edit="columnEdit"
|
|
518
520
|
:get-checked-length-desc="columnCheckGetCheckedLengthDesc"
|
|
519
521
|
:get-all-check-desc="columnCheckGetAllCheckDesc"
|
|
520
522
|
:operation-prop-key="operationPropKey"
|
|
@@ -547,7 +549,8 @@ import {
|
|
|
547
549
|
onMounted,
|
|
548
550
|
onBeforeMount,
|
|
549
551
|
ref,
|
|
550
|
-
watch
|
|
552
|
+
watch,
|
|
553
|
+
set
|
|
551
554
|
} from 'vue-demi'
|
|
552
555
|
import {
|
|
553
556
|
NfTableColumnAttributes,
|
|
@@ -561,6 +564,7 @@ import {
|
|
|
561
564
|
NfTableActionBtnAttributes
|
|
562
565
|
} from './types'
|
|
563
566
|
import { ITabItem } from '@94ai/nf-drawer/lib/types'
|
|
567
|
+
import { set as cachedSet, get as cachedGet, del } from 'idb-keyval'
|
|
564
568
|
|
|
565
569
|
const props = withDefaults(defineProps<{
|
|
566
570
|
data?: Record<string, any>[],
|
|
@@ -812,7 +816,9 @@ const initLocalShow = () => {
|
|
|
812
816
|
}
|
|
813
817
|
return !item.initHidden
|
|
814
818
|
}).map(item => item.prop! || item.attr?.prop!)
|
|
815
|
-
|
|
819
|
+
nextTick(() => {
|
|
820
|
+
props.columns._skip = false
|
|
821
|
+
})
|
|
816
822
|
if (result.length) {
|
|
817
823
|
return result
|
|
818
824
|
}
|
|
@@ -825,7 +831,7 @@ watch(() => localShowColumn.value?.length, () => {
|
|
|
825
831
|
immediate: true
|
|
826
832
|
})
|
|
827
833
|
|
|
828
|
-
const syncLocalShowColumnToCookies = () => {
|
|
834
|
+
const syncLocalShowColumnToCookies = async () => {
|
|
829
835
|
if (props.columnEdit) {
|
|
830
836
|
const columnState = {}
|
|
831
837
|
props.columns.map((i, index) => {
|
|
@@ -837,8 +843,7 @@ const syncLocalShowColumnToCookies = () => {
|
|
|
837
843
|
index
|
|
838
844
|
}
|
|
839
845
|
})
|
|
840
|
-
|
|
841
|
-
instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1, '/xxxx/xxxx/xxxx')
|
|
846
|
+
await cachedSet(props.storageKey, columnState)
|
|
842
847
|
}
|
|
843
848
|
}
|
|
844
849
|
|
|
@@ -852,40 +857,56 @@ const syncShowItemToInitHidden = () => {
|
|
|
852
857
|
item.initHidden = true
|
|
853
858
|
}
|
|
854
859
|
})
|
|
855
|
-
|
|
860
|
+
nextTick(() => {
|
|
861
|
+
props.columns._skip = false
|
|
862
|
+
})
|
|
856
863
|
}
|
|
857
|
-
const syncCookiesToLocalShowColumn = () => {
|
|
864
|
+
const syncCookiesToLocalShowColumn = async () => {
|
|
858
865
|
if (props.columnEdit) {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
if (
|
|
862
|
-
columnState
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
866
|
+
try {
|
|
867
|
+
let columnState: string | NfTableColumnAttributes | undefined = await cachedGet(props.storageKey)
|
|
868
|
+
if (columnState) {
|
|
869
|
+
if (typeof columnState === 'string') {
|
|
870
|
+
columnState = JSON.parse(columnState)
|
|
871
|
+
}
|
|
872
|
+
const showColumnItems: string[] = []
|
|
873
|
+
for (const key in columnState as NfTableColumnAttributes) {
|
|
874
|
+
if (!columnState![key].initHidden) {
|
|
875
|
+
showColumnItems.push(columnState![key].prop)
|
|
876
|
+
}
|
|
868
877
|
}
|
|
878
|
+
localShowColumn.value = showColumnItems
|
|
879
|
+
syncShowItemToInitHidden()
|
|
869
880
|
}
|
|
870
|
-
|
|
871
|
-
|
|
881
|
+
} catch (e) {
|
|
882
|
+
console.log(e)
|
|
872
883
|
}
|
|
873
884
|
}
|
|
874
885
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
886
|
+
|
|
887
|
+
const initCachedData = async () => {
|
|
888
|
+
if (props.columnEdit) {
|
|
889
|
+
// 同步缓存参数
|
|
890
|
+
try {
|
|
891
|
+
const cached = await cachedGet(props.storageKey)
|
|
892
|
+
const cachedPriority = props.priority === 'cached'
|
|
893
|
+
if (cachedPriority ? cached : localShowColumn.value?.length) {
|
|
894
|
+
cachedPriority ? await syncCookiesToLocalShowColumn() : await syncLocalShowColumnToCookies()
|
|
895
|
+
} else if (cachedPriority ? localShowColumn.value?.length : cached) {
|
|
896
|
+
cachedPriority ? await syncLocalShowColumnToCookies() : await syncCookiesToLocalShowColumn()
|
|
897
|
+
}
|
|
898
|
+
} catch (e) {
|
|
899
|
+
console.log(e)
|
|
900
|
+
await del(props.storageKey)
|
|
901
|
+
}
|
|
883
902
|
}
|
|
884
903
|
}
|
|
885
904
|
|
|
905
|
+
initCachedData()
|
|
906
|
+
|
|
886
907
|
const tableColumns = ref<NfTableColumnAttributes[]>([])
|
|
887
908
|
const elTableRefKey = ref(Date.now())
|
|
888
|
-
const syncCookiesToTableColumn = (readCached = true) => {
|
|
909
|
+
const syncCookiesToTableColumn = async (readCached = true) => {
|
|
889
910
|
props.columns._skip = true
|
|
890
911
|
const columns = props.columns!.map((item, index) => {
|
|
891
912
|
const len = item.label?.length || 0
|
|
@@ -913,30 +934,39 @@ const syncCookiesToTableColumn = (readCached = true) => {
|
|
|
913
934
|
delete item.attr.prop
|
|
914
935
|
delete item.attr.label
|
|
915
936
|
item._index = index
|
|
937
|
+
set(item, 'initHidden', item.initHidden)
|
|
938
|
+
set(item, 'destory', item.destory)
|
|
916
939
|
item.__index = index
|
|
917
940
|
return item
|
|
918
941
|
})
|
|
919
942
|
if (readCached && props.columnEdit) {
|
|
920
943
|
// 读取缓存 Column 配置
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
944
|
+
try {
|
|
945
|
+
let columnState: string | NfTableColumnAttributes | undefined = await cachedGet(props.storageKey)
|
|
946
|
+
props.columns._skip = true
|
|
947
|
+
if (columnState) {
|
|
948
|
+
if (typeof columnState === 'string') {
|
|
949
|
+
columnState = JSON.parse(columnState)
|
|
950
|
+
}
|
|
951
|
+
for (const key in columnState as NfTableColumnAttributes) {
|
|
952
|
+
const state = columnState![key]
|
|
953
|
+
columns.every(i => {
|
|
954
|
+
if (i.prop === key) {
|
|
955
|
+
i.initHidden = state.initHidden
|
|
956
|
+
i.attr ? i.attr['fixed'] = state.fixed : i.attr = { fixed: state.fixed }
|
|
957
|
+
i._index = state.index
|
|
958
|
+
return false
|
|
959
|
+
}
|
|
960
|
+
return true
|
|
961
|
+
})
|
|
962
|
+
}
|
|
937
963
|
}
|
|
964
|
+
} catch (e) {
|
|
965
|
+
console.log(e)
|
|
966
|
+
await del(props.storageKey)
|
|
938
967
|
}
|
|
939
968
|
}
|
|
969
|
+
await nextTick()
|
|
940
970
|
props.columns._skip = true
|
|
941
971
|
tableColumns.value = columns.sort((a, b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0)
|
|
942
972
|
elTableRefKey.value = Date.now()
|
|
@@ -947,11 +977,12 @@ syncCookiesToTableColumn()
|
|
|
947
977
|
onBeforeMount(() => {
|
|
948
978
|
watch(() => {
|
|
949
979
|
return props.columns
|
|
950
|
-
}, () => {
|
|
980
|
+
}, async () => {
|
|
951
981
|
if (props.columns._skip) {
|
|
952
982
|
return
|
|
953
983
|
}
|
|
954
|
-
|
|
984
|
+
localShowColumn.value = initLocalShow()
|
|
985
|
+
await syncCookiesToTableColumn(false)
|
|
955
986
|
}, {
|
|
956
987
|
deep: true
|
|
957
988
|
})
|
|
@@ -1016,10 +1047,7 @@ const isShow = (row: Record<string, any>) => {
|
|
|
1016
1047
|
if (row.type) {
|
|
1017
1048
|
return true
|
|
1018
1049
|
}
|
|
1019
|
-
|
|
1020
|
-
return !row.initHidden && !row.destory
|
|
1021
|
-
}
|
|
1022
|
-
return localShowColumn.value.includes(row.prop) && !row.initHidden && !row.destory
|
|
1050
|
+
return !row.initHidden && !row.destory
|
|
1023
1051
|
}
|
|
1024
1052
|
|
|
1025
1053
|
const resetNfSearchFormModel = () => {
|
|
@@ -1089,10 +1117,10 @@ const columnCheckConfirmFeedback = (value: Record<string, any>) => {
|
|
|
1089
1117
|
* 弹框确定
|
|
1090
1118
|
* @param { Object } value
|
|
1091
1119
|
*/
|
|
1092
|
-
const fieldsConfirm = (value) => {
|
|
1120
|
+
const fieldsConfirm = async (value) => {
|
|
1093
1121
|
columnCheckConfirmFeedback(value)
|
|
1094
|
-
syncCookiesToLocalShowColumn()
|
|
1095
|
-
syncCookiesToTableColumn()
|
|
1122
|
+
await syncCookiesToLocalShowColumn()
|
|
1123
|
+
await syncCookiesToTableColumn()
|
|
1096
1124
|
emit('fieldsChange', localShowColumn.value)
|
|
1097
1125
|
}
|
|
1098
1126
|
/**
|
|
@@ -1100,12 +1128,12 @@ const fieldsConfirm = (value) => {
|
|
|
1100
1128
|
* @param { Function } cb
|
|
1101
1129
|
* @param { Function } error
|
|
1102
1130
|
*/
|
|
1103
|
-
const columnCheckConfirm = (cb, error) => {
|
|
1131
|
+
const columnCheckConfirm = async (cb, error) => {
|
|
1104
1132
|
try {
|
|
1105
|
-
const value = columnCheckDrawer.value.syncTableColumnsToCookies()
|
|
1133
|
+
const value = await columnCheckDrawer.value.syncTableColumnsToCookies()
|
|
1106
1134
|
columnCheckConfirmFeedback(value)
|
|
1107
|
-
syncCookiesToLocalShowColumn()
|
|
1108
|
-
syncCookiesToTableColumn()
|
|
1135
|
+
await syncCookiesToLocalShowColumn()
|
|
1136
|
+
await syncCookiesToTableColumn()
|
|
1109
1137
|
emit('fieldsChange', localShowColumn.value)
|
|
1110
1138
|
cb()
|
|
1111
1139
|
} catch (e) {
|