@94ai/nf-table 3.2.48 → 3.2.49

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.
@@ -1,17 +1,29 @@
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
+ };
4
12
  data: {
5
13
  type: import("vue-demi").PropType<Record<string, any>[]>;
6
14
  default: () => never[];
7
15
  };
8
- storageKey: {
16
+ columnEdit: {
17
+ type: import("vue-demi").PropType<boolean>;
18
+ default: boolean;
19
+ };
20
+ operationPropKey: {
9
21
  type: import("vue-demi").PropType<string>;
10
22
  default: string;
11
23
  };
12
- showColumn: {
13
- type: import("vue-demi").PropType<string[]>;
14
- default: undefined;
24
+ storageKey: {
25
+ type: import("vue-demi").PropType<string>;
26
+ default: string;
15
27
  };
16
28
  fullscreen: {
17
29
  type: import("vue-demi").PropType<boolean>;
@@ -33,13 +45,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
33
45
  type: import("vue-demi").PropType<string>;
34
46
  default: string;
35
47
  };
36
- operationPropKey: {
37
- type: import("vue-demi").PropType<string>;
38
- default: string;
39
- };
40
- columns: {
41
- type: import("vue-demi").PropType<any>;
42
- default: () => never[];
48
+ showColumn: {
49
+ type: import("vue-demi").PropType<string[]>;
50
+ default: undefined;
43
51
  };
44
52
  searchFormAttrs: {
45
53
  type: import("vue-demi").PropType<NfSearchFormAttributes>;
@@ -73,10 +81,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
73
81
  type: import("vue-demi").PropType<boolean>;
74
82
  default: boolean;
75
83
  };
76
- columnEdit: {
77
- type: import("vue-demi").PropType<boolean>;
78
- default: boolean;
79
- };
80
84
  columnPosition: {
81
85
  type: import("vue-demi").PropType<"embed" | "free">;
82
86
  default: string;
@@ -255,10 +259,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
255
259
  type: import("vue-demi").PropType<string>;
256
260
  default: undefined;
257
261
  };
258
- background: {
259
- type: import("vue-demi").PropType<string>;
260
- default: undefined;
261
- };
262
262
  alwaysShowPage: {
263
263
  type: import("vue-demi").PropType<boolean>;
264
264
  default: boolean;
@@ -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?: "center" | "left" | "right" | undefined;
323
+ align?: "left" | "right" | "center" | undefined;
324
324
  'class-name'?: string | undefined;
325
325
  'label-class-name'?: string | undefined;
326
326
  selectable?: Function | undefined;
@@ -329,30 +329,42 @@ 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'?: "top" | "left" | "right" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end" | undefined;
332
+ 'filter-placement'?: "bottom" | "left" | "right" | "top" | "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
338
  syncLocalShowColumnToCookies: () => void;
339
- syncCookiesToLocalShowColumn: () => void;
340
- syncCookiesToTableColumn: (readCached?: boolean) => 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
+ };
345
353
  data: {
346
354
  type: import("vue-demi").PropType<Record<string, any>[]>;
347
355
  default: () => never[];
348
356
  };
349
- storageKey: {
357
+ columnEdit: {
358
+ type: import("vue-demi").PropType<boolean>;
359
+ default: boolean;
360
+ };
361
+ operationPropKey: {
350
362
  type: import("vue-demi").PropType<string>;
351
363
  default: string;
352
364
  };
353
- showColumn: {
354
- type: import("vue-demi").PropType<string[]>;
355
- default: undefined;
365
+ storageKey: {
366
+ type: import("vue-demi").PropType<string>;
367
+ default: string;
356
368
  };
357
369
  fullscreen: {
358
370
  type: import("vue-demi").PropType<boolean>;
@@ -374,13 +386,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
374
386
  type: import("vue-demi").PropType<string>;
375
387
  default: string;
376
388
  };
377
- operationPropKey: {
378
- type: import("vue-demi").PropType<string>;
379
- default: string;
380
- };
381
- columns: {
382
- type: import("vue-demi").PropType<any>;
383
- default: () => never[];
389
+ showColumn: {
390
+ type: import("vue-demi").PropType<string[]>;
391
+ default: undefined;
384
392
  };
385
393
  searchFormAttrs: {
386
394
  type: import("vue-demi").PropType<NfSearchFormAttributes>;
@@ -414,10 +422,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
414
422
  type: import("vue-demi").PropType<boolean>;
415
423
  default: boolean;
416
424
  };
417
- columnEdit: {
418
- type: import("vue-demi").PropType<boolean>;
419
- default: boolean;
420
- };
421
425
  columnPosition: {
422
426
  type: import("vue-demi").PropType<"embed" | "free">;
423
427
  default: string;
@@ -596,25 +600,23 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
596
600
  type: import("vue-demi").PropType<string>;
597
601
  default: undefined;
598
602
  };
599
- background: {
600
- type: import("vue-demi").PropType<string>;
601
- default: undefined;
602
- };
603
603
  alwaysShowPage: {
604
604
  type: import("vue-demi").PropType<boolean>;
605
605
  default: boolean;
606
606
  };
607
607
  }>>, {
608
+ background: string;
609
+ columns: NfTableColumnAttributes[] | any;
608
610
  data: Record<string, any>[];
611
+ columnEdit: boolean;
612
+ operationPropKey: string;
609
613
  storageKey: string;
610
- showColumn: string[];
611
614
  fullscreen: boolean;
612
615
  customClass: string;
613
616
  body: boolean;
614
617
  text: string;
615
618
  selectEmptyWarningTips: string;
616
- operationPropKey: string;
617
- columns: NfTableColumnAttributes[] | any;
619
+ showColumn: string[];
618
620
  searchFormAttrs: NfSearchFormAttributes;
619
621
  searchFormEvents: Partial<Record<NfSearchFormEventKey, Function>>;
620
622
  tableAttrs: ElTableAttributes;
@@ -623,7 +625,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
623
625
  pageEvents: Partial<Record<ElPaginationEventKey, Function>>;
624
626
  actionBarOptList: NfTableActionBtnAttributes[];
625
627
  calHeight: boolean;
626
- columnEdit: boolean;
627
628
  columnPosition: 'free' | 'embed';
628
629
  checkMode: 'dialog' | 'drawer';
629
630
  priority: 'cached' | 'value';
@@ -667,7 +668,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
667
668
  target: HTMLElement;
668
669
  lock: boolean;
669
670
  spinner: string;
670
- background: string;
671
671
  alwaysShowPage: boolean;
672
672
  }>, Partial<Record<any, (_: {
673
673
  slot: any;
@@ -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?: "center" | "left" | "right" | undefined;
748
+ align?: "left" | "right" | "center" | 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'?: "top" | "left" | "right" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end" | undefined;
757
+ 'filter-placement'?: "bottom" | "left" | "right" | "top" | "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 v-for="obj in item.list" :key="obj.prop" v-model="tableData[obj.prop]" class="nf-check-box" :label="obj.prop">{{ obj.label }}</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 { deepClone } from 'packages/nf-table/lib/utils'
63
+ import { CachedManager } from '@94ai/common-utils'
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
- deepClone(props.tableColumns).sort((a,b) => a.__index! - b.__index! < 0 ? -1 : a.__index! - b.__index! > 0 ? 1 : 0).map(item => {
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 = () => {
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
+ CachedManager.syncCachedSet(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] = props.showColumn?.length ? (props.showColumn || []).includes(v.prop) : true
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
- import { deepClone } from './utils'
141
+ import { deepClone } from '@94ai/common-utils'
142
+ import { CachedManager } from '@94ai/common-utils'
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',
@@ -354,7 +358,7 @@ const syncTableColumnsToCookies = () => {
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
357
- instance?.$openMessage.warning({
361
+ instance?.$openMessage?.warning({
358
362
  message: props.selectEmptyWarningTips,
359
363
  duration: 2000,
360
364
  })
@@ -380,8 +384,9 @@ const syncTableColumnsToCookies = () => {
380
384
  }
381
385
  obj[i.prop] = !columnState[i.prop].initHidden
382
386
  })
383
- instance?.$cookies?.remove(props.storageKey)
384
- instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1, '/xxxx/xxxx/xxxx')
387
+ if (props.columnEdit) {
388
+ CachedManager.syncCachedSet(props.storageKey, columnState)
389
+ }
385
390
  return obj
386
391
  }
387
392