@94ai/nf-search-form 3.2.48 → 3.2.51

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,10 +1,22 @@
1
1
  import { NfSearchFormItemOption } from './types';
2
2
  import { ITabItem } from '@94ai/nf-drawer/lib/types';
3
3
  declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineComponent<{
4
+ columns: {
5
+ type: import("vue-demi").PropType<number>;
6
+ default: undefined;
7
+ };
8
+ top: {
9
+ type: import("vue-demi").PropType<string>;
10
+ default: string;
11
+ };
4
12
  storageKey: {
5
13
  type: import("vue-demi").PropType<string>;
6
14
  default: string;
7
15
  };
16
+ columnEdit: {
17
+ type: import("vue-demi").PropType<boolean>;
18
+ default: boolean;
19
+ };
8
20
  modalAppendToBody: {
9
21
  type: import("vue-demi").PropType<boolean>;
10
22
  default: boolean;
@@ -17,10 +29,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
17
29
  type: import("vue-demi").PropType<boolean>;
18
30
  default: boolean;
19
31
  };
20
- top: {
21
- type: import("vue-demi").PropType<string>;
22
- default: string;
23
- };
24
32
  appendToBody: {
25
33
  type: import("vue-demi").PropType<boolean>;
26
34
  default: boolean;
@@ -77,6 +85,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
77
85
  type: import("vue-demi").PropType<Record<string, any>>;
78
86
  default: undefined;
79
87
  };
88
+ inline: {
89
+ type: import("vue-demi").PropType<boolean>;
90
+ default: boolean;
91
+ };
80
92
  upIcon: {
81
93
  type: import("vue-demi").PropType<string>;
82
94
  default: string;
@@ -85,10 +97,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
85
97
  type: import("vue-demi").PropType<string>;
86
98
  default: string;
87
99
  };
88
- columns: {
89
- type: import("vue-demi").PropType<number>;
90
- default: undefined;
91
- };
92
100
  showBtn: {
93
101
  type: import("vue-demi").PropType<boolean>;
94
102
  default: boolean;
@@ -155,16 +163,12 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
155
163
  type: import("vue-demi").PropType<"right" | "left" | "top">;
156
164
  default: string;
157
165
  };
158
- inline: {
159
- type: import("vue-demi").PropType<boolean>;
160
- default: boolean;
161
- };
162
166
  btnBoxLabel: {
163
167
  type: import("vue-demi").PropType<string>;
164
168
  default: string;
165
169
  };
166
170
  btnModel: {
167
- type: import("vue-demi").PropType<"block" | "inline">;
171
+ type: import("vue-demi").PropType<"inline" | "block">;
168
172
  default: string;
169
173
  };
170
174
  labelWidth: {
@@ -179,10 +183,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
179
183
  type: import("vue-demi").PropType<boolean>;
180
184
  default: boolean;
181
185
  };
182
- columnEdit: {
183
- type: import("vue-demi").PropType<boolean>;
184
- default: boolean;
185
- };
186
186
  showItems: {
187
187
  type: import("vue-demi").PropType<string[]>;
188
188
  default: () => never[];
@@ -281,7 +281,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
281
281
  type: import("vue-demi").PropType<string>;
282
282
  };
283
283
  btnItems: {
284
- type: import("vue-demi").PropType<"" | string[] | "search" | "reset" | "export">;
284
+ type: import("vue-demi").PropType<"" | string[] | "search" | "export" | "reset">;
285
285
  default: () => "";
286
286
  };
287
287
  reverseBtnSlot: {
@@ -408,10 +408,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
408
408
  }, {
409
409
  localShowItems: import("vue-demi").Ref<string[]>;
410
410
  syncLocalShowColumnToCookies: () => void;
411
- syncCookiesToLocalShowColumn: () => void;
411
+ syncCookiesToLocalShowColumn: () => Promise<void>;
412
412
  syncShowItemToInitHidden: () => void;
413
413
  hiddenNfSearchFormItemOptionField: (prop: any) => Promise<void>;
414
- refreshNfSearchFormModel: () => Promise<void>;
414
+ refreshNfSearchFormModel: (outEmit?: boolean, init?: boolean) => void;
415
415
  renderSearchFormItemOptions: import("vue-demi").Ref<{
416
416
  key?: string | undefined;
417
417
  _index?: number | undefined;
@@ -471,7 +471,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
471
471
  columnCheckDialog: import("vue-demi").Ref<any>;
472
472
  columnCheckDrawer: import("vue-demi").Ref<any>;
473
473
  configNfSearchItemVisibleDialog: import("vue-demi").Ref<boolean>;
474
- syncCookiesToSearchFormItemOptions: (readCached?: boolean) => void;
474
+ syncCookiesToSearchFormItemOptions: (readCached?: boolean) => Promise<void>;
475
475
  onResize: (params?: Record<string, any>) => Promise<void>;
476
476
  visibleChange: () => void;
477
477
  }, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
@@ -483,10 +483,22 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
483
483
  isCollapseChange: (event: boolean) => void;
484
484
  "update:showItems": (event: string[] | undefined) => void;
485
485
  }, string, Readonly<import("vue-demi").ExtractPropTypes<{
486
+ columns: {
487
+ type: import("vue-demi").PropType<number>;
488
+ default: undefined;
489
+ };
490
+ top: {
491
+ type: import("vue-demi").PropType<string>;
492
+ default: string;
493
+ };
486
494
  storageKey: {
487
495
  type: import("vue-demi").PropType<string>;
488
496
  default: string;
489
497
  };
498
+ columnEdit: {
499
+ type: import("vue-demi").PropType<boolean>;
500
+ default: boolean;
501
+ };
490
502
  modalAppendToBody: {
491
503
  type: import("vue-demi").PropType<boolean>;
492
504
  default: boolean;
@@ -499,10 +511,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
499
511
  type: import("vue-demi").PropType<boolean>;
500
512
  default: boolean;
501
513
  };
502
- top: {
503
- type: import("vue-demi").PropType<string>;
504
- default: string;
505
- };
506
514
  appendToBody: {
507
515
  type: import("vue-demi").PropType<boolean>;
508
516
  default: boolean;
@@ -559,6 +567,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
559
567
  type: import("vue-demi").PropType<Record<string, any>>;
560
568
  default: undefined;
561
569
  };
570
+ inline: {
571
+ type: import("vue-demi").PropType<boolean>;
572
+ default: boolean;
573
+ };
562
574
  upIcon: {
563
575
  type: import("vue-demi").PropType<string>;
564
576
  default: string;
@@ -567,10 +579,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
567
579
  type: import("vue-demi").PropType<string>;
568
580
  default: string;
569
581
  };
570
- columns: {
571
- type: import("vue-demi").PropType<number>;
572
- default: undefined;
573
- };
574
582
  showBtn: {
575
583
  type: import("vue-demi").PropType<boolean>;
576
584
  default: boolean;
@@ -637,16 +645,12 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
637
645
  type: import("vue-demi").PropType<"right" | "left" | "top">;
638
646
  default: string;
639
647
  };
640
- inline: {
641
- type: import("vue-demi").PropType<boolean>;
642
- default: boolean;
643
- };
644
648
  btnBoxLabel: {
645
649
  type: import("vue-demi").PropType<string>;
646
650
  default: string;
647
651
  };
648
652
  btnModel: {
649
- type: import("vue-demi").PropType<"block" | "inline">;
653
+ type: import("vue-demi").PropType<"inline" | "block">;
650
654
  default: string;
651
655
  };
652
656
  labelWidth: {
@@ -661,10 +665,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
661
665
  type: import("vue-demi").PropType<boolean>;
662
666
  default: boolean;
663
667
  };
664
- columnEdit: {
665
- type: import("vue-demi").PropType<boolean>;
666
- default: boolean;
667
- };
668
668
  showItems: {
669
669
  type: import("vue-demi").PropType<string[]>;
670
670
  default: () => never[];
@@ -763,7 +763,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
763
763
  type: import("vue-demi").PropType<string>;
764
764
  };
765
765
  btnItems: {
766
- type: import("vue-demi").PropType<"" | string[] | "search" | "reset" | "export">;
766
+ type: import("vue-demi").PropType<"" | string[] | "search" | "export" | "reset">;
767
767
  default: () => "";
768
768
  };
769
769
  reverseBtnSlot: {
@@ -888,11 +888,13 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
888
888
  default: string;
889
889
  };
890
890
  }>>, {
891
+ columns: number;
892
+ top: string;
891
893
  storageKey: string;
894
+ columnEdit: boolean;
892
895
  modalAppendToBody: boolean;
893
896
  modal: boolean;
894
897
  fullscreen: boolean;
895
- top: string;
896
898
  appendToBody: boolean;
897
899
  lockScroll: boolean;
898
900
  customClass: string;
@@ -907,9 +909,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
907
909
  disabled: boolean;
908
910
  itemWidth: number;
909
911
  rules: Record<string, any>;
912
+ inline: boolean;
910
913
  upIcon: string;
911
914
  downIcon: string;
912
- columns: number;
913
915
  showBtn: boolean;
914
916
  isCollapse: boolean;
915
917
  expandBtnType: string;
@@ -925,13 +927,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
925
927
  statusIcon: boolean;
926
928
  validateOnRuleChange: boolean;
927
929
  labelPosition: 'top' | 'right' | 'left';
928
- inline: boolean;
929
930
  btnBoxLabel: string;
930
931
  btnModel: 'inline' | 'block';
931
932
  labelWidth: number;
932
933
  formOptions: NfSearchFormItemOption[] | any;
933
934
  closable: boolean;
934
- columnEdit: boolean;
935
935
  showItems: string[];
936
936
  priority: 'cached' | 'value';
937
937
  checkMode: 'dialog' | 'drawer';
package/package/index.ts CHANGED
@@ -1,14 +1,8 @@
1
1
  import NfSearchForm from './nf-search-form.vue'
2
2
  import { Vue2, PluginObject } from 'vue-demi'
3
3
  import NfMessage from '@94ai/nf-message'
4
- import VueCookies from 'vue-cookies'
5
4
 
6
5
  NfSearchForm.install = (app: typeof Vue2) => {
7
- // @ts-ignore
8
- if (!app.$cookies) {
9
- // @ts-ignore
10
- app.use(VueCookies)
11
- }
12
6
  // @ts-ignore
13
7
  if (!app.$openMessage) {
14
8
  // @ts-ignore
@@ -55,17 +55,21 @@ import {
55
55
  onMounted,
56
56
  ref
57
57
  } from 'vue-demi'
58
- import { NfSearchFormItemOption } from 'packages/nf-search-form/lib/types'
58
+ import { NfSearchFormItemOption } from './types'
59
+ import { CachedManager } from '@94ai/common-utils'
59
60
 
60
61
  const props = withDefaults(defineProps<{
61
62
  storageKey?: string
63
+ /**
64
+ * 列编辑,是否显示按钮配置表单项显示
65
+ */
66
+ columnEdit?: boolean,
62
67
  show?: boolean,
63
68
  title?: string,
64
69
  width?: string,
65
70
  confirmText?: string
66
71
  cancelText?: string
67
72
  tableColumns?: NfSearchFormItemOption[],
68
- showColumns?: string[],
69
73
  modalAppendToBody?: boolean,
70
74
  modal?: boolean,
71
75
  fullscreen?: boolean,
@@ -80,6 +84,7 @@ const props = withDefaults(defineProps<{
80
84
  center?: boolean,
81
85
  destroyOnClose?: boolean,
82
86
  }>(), {
87
+ columnEdit: false,
83
88
  storageKey: 'nf-table-columns-cached-key',
84
89
  show: false,
85
90
  width: '600',
@@ -87,7 +92,6 @@ const props = withDefaults(defineProps<{
87
92
  cancelText: '取 消',
88
93
  confirmText: '保 存',
89
94
  tableColumns: () => [],
90
- showColumns: () => [],
91
95
  modalAppendToBody: true,
92
96
  modal: true,
93
97
  fullscreen: false,
@@ -125,7 +129,7 @@ const visible = computed({
125
129
  */
126
130
  const fields = computed(() => {
127
131
  const obj: Record<string, any> = {}
128
- props.tableColumns.map(item => {
132
+ props.tableColumns.filter(item => !item.destory).map(item => {
129
133
  const key = item.category || '基础查询框'
130
134
  if (!obj[key]) {
131
135
  obj[key] = []
@@ -160,16 +164,16 @@ const submit = () => {
160
164
  index
161
165
  }
162
166
  })
163
-
164
- instance?.$cookies?.remove(props.storageKey)
165
- instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1, '/xxxx/xxxx/xxxx')
166
167
  emit('save', tableData.value)
168
+ if (props.columnEdit) {
169
+ CachedManager.syncCachedSet(props.storageKey, columnState)
170
+ }
167
171
  }
168
172
 
169
173
  const addInitValue = () => {
170
174
  const obj: Record<string, any> = {}
171
175
  props.tableColumns.forEach(v => {
172
- obj[v.prop!] = props.showColumns?.length ? props.showColumns.includes(v.prop!) : true
176
+ obj[v.prop!] = !v.initHidden
173
177
  })
174
178
  tableData.value = obj
175
179
  }
@@ -138,10 +138,9 @@ import {
138
138
  computed,
139
139
  onBeforeMount,
140
140
  getCurrentInstance,
141
- PropType,
142
- onMounted
143
141
  } from 'vue-demi'
144
- import { deepClone } from './tools'
142
+ import { deepClone } from '@94ai/common-utils'
143
+ import { CachedManager } from '@94ai/common-utils'
145
144
 
146
145
  const instance = getCurrentInstance()?.proxy
147
146
 
@@ -157,6 +156,10 @@ const props = withDefaults(defineProps<{
157
156
  noFixedDesc?: string
158
157
  getCheckedLengthDesc?: Function
159
158
  getAllCheckDesc?: Function
159
+ /**
160
+ * 列编辑,是否显示按钮配置表单项显示
161
+ */
162
+ columnEdit?: boolean,
160
163
  }>(), {
161
164
  selectEmptyWarningTips: '请选择至少一个选项',
162
165
  tableColumns: () => [],
@@ -166,7 +169,8 @@ const props = withDefaults(defineProps<{
166
169
  clearDesc: '清除',
167
170
  noFixedDesc: '不固定',
168
171
  getCheckedLengthDesc: (length) => '已选(' + length + ')',
169
- getAllCheckDesc: (length) => '全选(' + length + ')'
172
+ getAllCheckDesc: (length) => '全选(' + length + ')',
173
+ columnEdit: false
170
174
  })
171
175
 
172
176
  // 获取当前缓存中的动态数据列
@@ -182,6 +186,7 @@ const unFixedColumn = ref<Record<string, any>[]>([])
182
186
 
183
187
 
184
188
  onBeforeMount(() => {
189
+ // 混合缓存后数据
185
190
  currentTable.value = deepClone(props.tableColumns.filter(item => !item.destory)).sort((a,b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0) as Record<string, any>[]
186
191
  // 兼容处理
187
192
  currentTable.value.map(i => {
@@ -189,6 +194,7 @@ onBeforeMount(() => {
189
194
  i.attr = {}
190
195
  }
191
196
  })
197
+ // 原始数据
192
198
  const list = props.tableColumns.filter(item => !item.destory)
193
199
  // 可选列表 → 字段区分
194
200
  setFields(list)
@@ -345,26 +351,27 @@ const syncTableColumnsToCookies = () => {
345
351
  const newTableColumns = [...fixedColumn.value, ...unFixedColumn.value]
346
352
  if (newTableColumns.filter(item => !item.initHidden).length === 0) {
347
353
  // @ts-ignore
348
- instance?.$openMessage.warning({
354
+ instance?.$openMessage?.warning({
349
355
  message: props.selectEmptyWarningTips,
350
356
  duration: 2000,
351
357
  })
352
358
  throw new Error(props.selectEmptyWarningTips)
353
359
  }
354
- const columnState = {}
355
- const obj: Record<string, any> = {}
356
- newTableColumns.map((i, index) => {
357
- columnState[i.prop] = {
358
- initHidden: i.initHidden || false,
359
- fixed: i.attr?.fixed || false,
360
- prop: i.prop,
361
- index
360
+ const columnState = {}
361
+ const obj: Record<string, any> = {}
362
+ newTableColumns.map((i, index) => {
363
+ columnState[i.prop] = {
364
+ initHidden: i.initHidden || false,
365
+ fixed: i.attr?.fixed || false,
366
+ prop: i.prop,
367
+ index
368
+ }
369
+ obj[i.prop] = !columnState[i.prop].initHidden
370
+ })
371
+ if (props.columnEdit) {
372
+ CachedManager.syncCachedSet(props.storageKey, columnState)
362
373
  }
363
- obj[i.prop] = !columnState[i.prop].initHidden
364
- })
365
- instance?.$cookies?.remove(props.storageKey)
366
- instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1, '/xxxx/xxxx/xxxx')
367
- return obj
374
+ return obj
368
375
  }
369
376
 
370
377
  /**
@@ -188,7 +188,7 @@ import {
188
188
  getCurrentInstance
189
189
  } from 'vue-demi'
190
190
  import { NfSearchFormItemOption } from '@94ai/nf-search-form/lib/types'
191
- import { createUniqueString } from './tools'
191
+ import { createUniqueString } from '@94ai/common-utils'
192
192
 
193
193
  const emit = defineEmits<{
194
194
  (e: 'input', event: any): void