@94ai/nf-search-form 8.0.5 → 8.0.12

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,112 +1,112 @@
1
- import { NfSearchFormItemOption } from '@94ai/nf-search-form/lib/types';
2
- declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
- value?: any;
4
- itemOptions?: NfSearchFormItemOption | undefined;
5
- itemWidth?: number | undefined;
6
- nfSearchFormModel?: Record<string, any> | undefined;
7
- }>, {
8
- value: undefined;
9
- itemOptions: () => {};
10
- itemWidth: number;
11
- nfSearchFormModel: () => {};
12
- }>, {}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
13
- input: (event: any) => void;
14
- "update:value": (event: any) => void;
15
- handleChangeProps: (event: string[]) => void;
16
- }, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
17
- value?: any;
18
- itemOptions?: NfSearchFormItemOption | undefined;
19
- itemWidth?: number | undefined;
20
- nfSearchFormModel?: Record<string, any> | undefined;
21
- }>, {
22
- value: undefined;
23
- itemOptions: () => {};
24
- itemWidth: number;
25
- nfSearchFormModel: () => {};
26
- }>>>, {
27
- value: any;
28
- itemOptions: NfSearchFormItemOption;
29
- itemWidth: number;
30
- nfSearchFormModel: Record<string, any>;
31
- }>, Partial<Record<string, (_: {}) => any>> & Partial<Record<string, (_: {
32
- slot: string;
33
- }) => any>> & Partial<Record<string, (_: {
34
- slot: string;
35
- }) => any>> & Partial<Record<string, (_: {
36
- slot: string;
37
- }) => any>> & Partial<Record<string, (_: {
38
- slot: string;
39
- }) => any>> & Partial<Record<string, (_: {
40
- slot: string;
41
- }) => any>> & Partial<Record<string, (_: {
42
- slot: string;
43
- }) => any>> & Partial<Record<string, (_: {
44
- slot: string;
45
- }) => any>> & Partial<Record<string, (_: {
46
- slot: string;
47
- }) => any>> & Partial<Record<string, (_: {
48
- slot: string;
49
- }) => any>> & Partial<Record<string, (_: {
50
- slot: string;
51
- }) => any>> & Partial<Record<string, (_: {
52
- slot: string;
53
- }) => any>> & Partial<Record<string, (_: {
54
- slot: string;
55
- }) => any>> & Partial<Record<string, (_: {
56
- slot: string;
57
- }) => any>> & Partial<Record<string, (_: {
58
- slot: string;
59
- }) => any>> & Partial<Record<string, (_: {
60
- slot: string;
61
- }) => any>> & Partial<Record<string, (_: {
62
- slot: string;
63
- }) => any>> & Partial<Record<string, (_: {
64
- slot: string;
65
- }) => any>> & Partial<Record<string, (_: {
66
- slot: string;
67
- }) => any>> & Partial<Record<string, (_: {
68
- slot: string;
69
- }) => any>> & Partial<Record<string, (_: {
70
- slot: string;
71
- }) => any>> & Partial<Record<string, (_: {
72
- slot: string;
73
- }) => any>> & Partial<Record<string, (_: {
74
- slot: string;
75
- }) => any>> & Partial<Record<string, (_: {
76
- slot: string;
77
- }) => any>> & Partial<Record<string, (_: {
78
- slot: string;
79
- }) => any>> & Partial<Record<string, (_: {
80
- slot: string;
81
- }) => any>> & Partial<Record<string, (_: {
82
- slot: string;
83
- }) => any>> & Partial<Record<string, (_: {
84
- slot: string;
85
- }) => any>> & Partial<Record<string, (_: {
86
- slot: string;
87
- }) => any>> & Partial<Record<string, (_: {
88
- slot: string;
89
- }) => any>> & Partial<Record<string, (_: {}) => any>>>;
90
- export default _default;
91
- declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
92
- declare type __VLS_TypePropsToRuntimeProps<T> = {
93
- [K in keyof T]-?: {} extends Pick<T, K> ? {
94
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
95
- } : {
96
- type: import('vue').PropType<T[K]>;
97
- required: true;
98
- };
99
- };
100
- declare type __VLS_WithDefaults<P, D> = {
101
- [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
102
- default: D[K];
103
- }> : P[K];
104
- };
105
- declare type __VLS_Prettify<T> = {
106
- [K in keyof T]: T[K];
107
- } & {};
108
- declare type __VLS_WithTemplateSlots<T, S> = T & {
109
- new (): {
110
- $scopedSlots: S;
111
- };
112
- };
1
+ import { NfSearchFormItemOption } from '@94ai/nf-search-form/lib/types';
2
+ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
+ value?: any;
4
+ itemOptions?: NfSearchFormItemOption | undefined;
5
+ itemWidth?: number | undefined;
6
+ nfSearchFormModel?: Record<string, any> | undefined;
7
+ }>, {
8
+ value: undefined;
9
+ itemOptions: () => {};
10
+ itemWidth: number;
11
+ nfSearchFormModel: () => {};
12
+ }>, {}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
13
+ input: (event: any) => void;
14
+ "update:value": (event: any) => void;
15
+ handleChangeProps: (event: string[]) => void;
16
+ }, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
17
+ value?: any;
18
+ itemOptions?: NfSearchFormItemOption | undefined;
19
+ itemWidth?: number | undefined;
20
+ nfSearchFormModel?: Record<string, any> | undefined;
21
+ }>, {
22
+ value: undefined;
23
+ itemOptions: () => {};
24
+ itemWidth: number;
25
+ nfSearchFormModel: () => {};
26
+ }>>>, {
27
+ value: any;
28
+ itemOptions: NfSearchFormItemOption;
29
+ itemWidth: number;
30
+ nfSearchFormModel: Record<string, any>;
31
+ }>, Partial<Record<string, (_: {}) => any>> & Partial<Record<string, (_: {
32
+ slot: string;
33
+ }) => any>> & Partial<Record<string, (_: {
34
+ slot: string;
35
+ }) => any>> & Partial<Record<string, (_: {
36
+ slot: string;
37
+ }) => any>> & Partial<Record<string, (_: {
38
+ slot: string;
39
+ }) => any>> & Partial<Record<string, (_: {
40
+ slot: string;
41
+ }) => any>> & Partial<Record<string, (_: {
42
+ slot: string;
43
+ }) => any>> & Partial<Record<string, (_: {
44
+ slot: string;
45
+ }) => any>> & Partial<Record<string, (_: {
46
+ slot: string;
47
+ }) => any>> & Partial<Record<string, (_: {
48
+ slot: string;
49
+ }) => any>> & Partial<Record<string, (_: {
50
+ slot: string;
51
+ }) => any>> & Partial<Record<string, (_: {
52
+ slot: string;
53
+ }) => any>> & Partial<Record<string, (_: {
54
+ slot: string;
55
+ }) => any>> & Partial<Record<string, (_: {
56
+ slot: string;
57
+ }) => any>> & Partial<Record<string, (_: {
58
+ slot: string;
59
+ }) => any>> & Partial<Record<string, (_: {
60
+ slot: string;
61
+ }) => any>> & Partial<Record<string, (_: {
62
+ slot: string;
63
+ }) => any>> & Partial<Record<string, (_: {
64
+ slot: string;
65
+ }) => any>> & Partial<Record<string, (_: {
66
+ slot: string;
67
+ }) => any>> & Partial<Record<string, (_: {
68
+ slot: string;
69
+ }) => any>> & Partial<Record<string, (_: {
70
+ slot: string;
71
+ }) => any>> & Partial<Record<string, (_: {
72
+ slot: string;
73
+ }) => any>> & Partial<Record<string, (_: {
74
+ slot: string;
75
+ }) => any>> & Partial<Record<string, (_: {
76
+ slot: string;
77
+ }) => any>> & Partial<Record<string, (_: {
78
+ slot: string;
79
+ }) => any>> & Partial<Record<string, (_: {
80
+ slot: string;
81
+ }) => any>> & Partial<Record<string, (_: {
82
+ slot: string;
83
+ }) => any>> & Partial<Record<string, (_: {
84
+ slot: string;
85
+ }) => any>> & Partial<Record<string, (_: {
86
+ slot: string;
87
+ }) => any>> & Partial<Record<string, (_: {
88
+ slot: string;
89
+ }) => any>> & Partial<Record<string, (_: {}) => any>>>;
90
+ export default _default;
91
+ declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
92
+ declare type __VLS_TypePropsToRuntimeProps<T> = {
93
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
94
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
95
+ } : {
96
+ type: import('vue').PropType<T[K]>;
97
+ required: true;
98
+ };
99
+ };
100
+ declare type __VLS_WithDefaults<P, D> = {
101
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
102
+ default: D[K];
103
+ }> : P[K];
104
+ };
105
+ declare type __VLS_Prettify<T> = {
106
+ [K in keyof T]: T[K];
107
+ } & {};
108
+ declare type __VLS_WithTemplateSlots<T, S> = T & {
109
+ new (): {
110
+ $scopedSlots: S;
111
+ };
112
+ };
@@ -6398,9 +6398,9 @@ __sfc_main$1.setup = (__props, __ctx) => {
6398
6398
  const fixedIndex = fixedColumn.value.findIndex((item) => item.prop === column.prop);
6399
6399
  if (unFixedIndex === -1 && fixedIndex === -1) {
6400
6400
  if (append) {
6401
- unFixedColumn.value.push(column);
6401
+ (column.attr.fixed ? fixedColumn.value : unFixedColumn.value).push(column);
6402
6402
  } else {
6403
- unFixedColumn.value.unshift(column);
6403
+ (column.attr.fixed ? fixedColumn.value : unFixedColumn.value).unshift(column);
6404
6404
  }
6405
6405
  }
6406
6406
  };
@@ -6434,8 +6434,8 @@ __sfc_main$1.setup = (__props, __ctx) => {
6434
6434
  if (v) {
6435
6435
  let flag = false;
6436
6436
  if (columnName.value && fields.value.length) {
6437
- if (searchValue.length && currentTable.value.length && searchValue.length === currentTable.value.length) {
6438
- if (!unFixedColumn.value.length && !fixedColumn.value.length) {
6437
+ if (!unFixedColumn.value.length && !fixedColumn.value.length) {
6438
+ if (searchValue.length && currentTable.value.length && searchValue.length === currentTable.value.length) {
6439
6439
  flag = true;
6440
6440
  }
6441
6441
  }
@@ -6450,7 +6450,11 @@ __sfc_main$1.setup = (__props, __ctx) => {
6450
6450
  const item = currentTable.value.find((item2) => item2.prop === column.prop);
6451
6451
  if (item) {
6452
6452
  item.initHidden = false;
6453
- newColumns.push(item);
6453
+ const cloneItem = commonUtils.deepClone(item);
6454
+ if (!cloneItem.attr) {
6455
+ cloneItem.attr = {};
6456
+ }
6457
+ newColumns.push(cloneItem);
6454
6458
  }
6455
6459
  });
6456
6460
  currentTable.value = newColumns;
@@ -6468,24 +6472,24 @@ __sfc_main$1.setup = (__props, __ctx) => {
6468
6472
  }
6469
6473
  if (columnName.value && fields.value.length) {
6470
6474
  searchValue.map((item) => {
6471
- if (v) {
6472
- insertColumn(item, true);
6473
- } else {
6474
- pullAwayColumn(item);
6475
- }
6476
6475
  if (!unChangedColumn.value.includes(item.prop)) {
6476
+ if (v) {
6477
+ insertColumn(item, true);
6478
+ } else {
6479
+ pullAwayColumn(item);
6480
+ }
6477
6481
  item.initHidden = !v;
6478
6482
  v ? "" : item.attr.fixed = false;
6479
6483
  }
6480
6484
  });
6481
6485
  } else {
6482
6486
  currentTable.value.map((item) => {
6483
- if (v) {
6484
- insertColumn(item, true);
6485
- } else {
6486
- pullAwayColumn(item);
6487
- }
6488
6487
  if (!unChangedColumn.value.includes(item.prop)) {
6488
+ if (v) {
6489
+ insertColumn(item, true);
6490
+ } else {
6491
+ pullAwayColumn(item);
6492
+ }
6489
6493
  item.initHidden = !v;
6490
6494
  v ? "" : item.attr.fixed = false;
6491
6495
  }
@@ -6897,6 +6901,12 @@ __sfc_main.props = {
6897
6901
  type: String,
6898
6902
  default: "收起"
6899
6903
  },
6904
+ requiredValidate: {
6905
+ key: "requiredValidate",
6906
+ required: false,
6907
+ type: Boolean,
6908
+ default: false
6909
+ },
6900
6910
  rules: {
6901
6911
  key: "rules",
6902
6912
  required: false,
@@ -7691,7 +7701,7 @@ __sfc_main.setup = (__props, __ctx) => {
7691
7701
  item._index = index2;
7692
7702
  item.__index = index2;
7693
7703
  vue.set(item, "initHidden", !!item.initHidden);
7694
- vue.set(item, "destory", !!item.destory);
7704
+ vue.set(item, "destory", item.destory);
7695
7705
  if (!item.options)
7696
7706
  vue.set(item, "options", []);
7697
7707
  return item;
@@ -7710,11 +7720,10 @@ __sfc_main.setup = (__props, __ctx) => {
7710
7720
  };
7711
7721
  syncCookiesToSearchFormItemOptions();
7712
7722
  const itemIsShow = (item) => {
7713
- var _a2;
7714
- return !item.initHidden && !item.destory && (commonUtils.validate.isFunction(item.show) ? (_a2 = item == null ? void 0 : item.show) == null ? void 0 : _a2.call(item, nfSearchFormModel.value) : true);
7723
+ return !item.initHidden && !commonUtils.resolveValue(item.destory, nfSearchFormModel.value) && commonUtils.resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7715
7724
  };
7716
7725
  const btnIsShow = (item) => {
7717
- return item.show ? item.show(nfSearchFormModel.value) : true;
7726
+ return commonUtils.resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7718
7727
  };
7719
7728
  vueDemi.watch(() => nfSearchFormModel.value, () => {
7720
7729
  emit("onChange", nfSearchFormModel.value);
@@ -7745,7 +7754,7 @@ __sfc_main.setup = (__props, __ctx) => {
7745
7754
  formsInit();
7746
7755
  });
7747
7756
  const refreshNfSearchFormModel = () => {
7748
- props.formOptions.filter((item) => !item.destory).forEach((v) => {
7757
+ props.formOptions.filter((item) => !commonUtils.resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7749
7758
  if (!localShowItems.value.includes(v.prop)) {
7750
7759
  commonUtils.mapDispose.setValue(nfSearchFormModel.value, v.key, void 0);
7751
7760
  } else if (nfSearchFormModel.value[v.prop] === void 0) {
@@ -7756,7 +7765,7 @@ __sfc_main.setup = (__props, __ctx) => {
7756
7765
  const formsInit = () => {
7757
7766
  getChangePropKeys();
7758
7767
  props.formOptions.forEach((item) => {
7759
- if (item.destory || !localShowItems.value.includes(item.prop))
7768
+ if (commonUtils.resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop))
7760
7769
  return;
7761
7770
  setDefaultVal(item, true);
7762
7771
  triggerGetOptions(item);
@@ -7833,6 +7842,9 @@ __sfc_main.setup = (__props, __ctx) => {
7833
7842
  };
7834
7843
  const onNfSearchFormValidate = (callback) => {
7835
7844
  nfSearchFormRef.value.validate((valid) => {
7845
+ if (props.requiredValidate && !valid) {
7846
+ return;
7847
+ }
7836
7848
  callback == null ? void 0 : callback(valid);
7837
7849
  });
7838
7850
  };
@@ -7943,6 +7955,7 @@ __sfc_main.setup = (__props, __ctx) => {
7943
7955
  return data;
7944
7956
  };
7945
7957
  return Object.assign({
7958
+ resolveValue: commonUtils.resolveValue,
7946
7959
  defaultButtonSlot,
7947
7960
  nfSearchFormRef,
7948
7961
  columnCheckNfDrawer,
@@ -8073,6 +8086,7 @@ var _sfc_render = function render6() {
8073
8086
  "size": _vm.size,
8074
8087
  "disabled": _vm.disabled,
8075
8088
  "rules": _vm.rules,
8089
+ "requiredValidate": _vm.requiredValidate,
8076
8090
  "label-suffix": _vm.labelSuffix,
8077
8091
  "hide-required-asterisk": _vm.hideRequiredAsterisk,
8078
8092
  "show-message": _vm.showMessage,
@@ -8114,7 +8128,7 @@ var _sfc_render = function render6() {
8114
8128
  "label-width": item.labelWidth
8115
8129
  }
8116
8130
  }, [_vm._t(item.labelSlot, function() {
8117
- return [_vm._v(" " + _vm._s(item.label ? item.isShowColon ? item.label + ":" : item.label : "") + " ")];
8131
+ return [_vm._v(" " + _vm._s(_vm.resolveValue(item.label, _vm.nfSearchFormModel) ? item.isShowColon ? _vm.resolveValue(item.label, _vm.nfSearchFormModel) + ":" : _vm.resolveValue(item.label, _vm.nfSearchFormModel) : "") + " ")];
8118
8132
  }, {
8119
8133
  "slot": "label"
8120
8134
  }), _c("search-form-item", {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, ref, getCurrentInstance, computed, watch, onBeforeMount, onMounted, nextTick, onBeforeUnmount } from "vue-demi";
2
2
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
3
- import { createUniqueString, CachedManager, deepClone, validate, mapDispose } from "@94ai/common-utils";
3
+ import { createUniqueString, CachedManager, deepClone, validate, resolveValue, mapDispose } from "@94ai/common-utils";
4
4
  import ResizeObserver from "resize-observer-polyfill";
5
5
  import { getCurrentInstance as getCurrentInstance$1, effectScope, shallowReactive, set } from "vue";
6
6
  import { throttle as throttle$1 } from "lodash-es";
@@ -6396,9 +6396,9 @@ __sfc_main$1.setup = (__props, __ctx) => {
6396
6396
  const fixedIndex = fixedColumn.value.findIndex((item) => item.prop === column.prop);
6397
6397
  if (unFixedIndex === -1 && fixedIndex === -1) {
6398
6398
  if (append) {
6399
- unFixedColumn.value.push(column);
6399
+ (column.attr.fixed ? fixedColumn.value : unFixedColumn.value).push(column);
6400
6400
  } else {
6401
- unFixedColumn.value.unshift(column);
6401
+ (column.attr.fixed ? fixedColumn.value : unFixedColumn.value).unshift(column);
6402
6402
  }
6403
6403
  }
6404
6404
  };
@@ -6432,8 +6432,8 @@ __sfc_main$1.setup = (__props, __ctx) => {
6432
6432
  if (v) {
6433
6433
  let flag = false;
6434
6434
  if (columnName.value && fields.value.length) {
6435
- if (searchValue.length && currentTable.value.length && searchValue.length === currentTable.value.length) {
6436
- if (!unFixedColumn.value.length && !fixedColumn.value.length) {
6435
+ if (!unFixedColumn.value.length && !fixedColumn.value.length) {
6436
+ if (searchValue.length && currentTable.value.length && searchValue.length === currentTable.value.length) {
6437
6437
  flag = true;
6438
6438
  }
6439
6439
  }
@@ -6448,7 +6448,11 @@ __sfc_main$1.setup = (__props, __ctx) => {
6448
6448
  const item = currentTable.value.find((item2) => item2.prop === column.prop);
6449
6449
  if (item) {
6450
6450
  item.initHidden = false;
6451
- newColumns.push(item);
6451
+ const cloneItem = deepClone(item);
6452
+ if (!cloneItem.attr) {
6453
+ cloneItem.attr = {};
6454
+ }
6455
+ newColumns.push(cloneItem);
6452
6456
  }
6453
6457
  });
6454
6458
  currentTable.value = newColumns;
@@ -6466,24 +6470,24 @@ __sfc_main$1.setup = (__props, __ctx) => {
6466
6470
  }
6467
6471
  if (columnName.value && fields.value.length) {
6468
6472
  searchValue.map((item) => {
6469
- if (v) {
6470
- insertColumn(item, true);
6471
- } else {
6472
- pullAwayColumn(item);
6473
- }
6474
6473
  if (!unChangedColumn.value.includes(item.prop)) {
6474
+ if (v) {
6475
+ insertColumn(item, true);
6476
+ } else {
6477
+ pullAwayColumn(item);
6478
+ }
6475
6479
  item.initHidden = !v;
6476
6480
  v ? "" : item.attr.fixed = false;
6477
6481
  }
6478
6482
  });
6479
6483
  } else {
6480
6484
  currentTable.value.map((item) => {
6481
- if (v) {
6482
- insertColumn(item, true);
6483
- } else {
6484
- pullAwayColumn(item);
6485
- }
6486
6485
  if (!unChangedColumn.value.includes(item.prop)) {
6486
+ if (v) {
6487
+ insertColumn(item, true);
6488
+ } else {
6489
+ pullAwayColumn(item);
6490
+ }
6487
6491
  item.initHidden = !v;
6488
6492
  v ? "" : item.attr.fixed = false;
6489
6493
  }
@@ -6895,6 +6899,12 @@ __sfc_main.props = {
6895
6899
  type: String,
6896
6900
  default: "收起"
6897
6901
  },
6902
+ requiredValidate: {
6903
+ key: "requiredValidate",
6904
+ required: false,
6905
+ type: Boolean,
6906
+ default: false
6907
+ },
6898
6908
  rules: {
6899
6909
  key: "rules",
6900
6910
  required: false,
@@ -7689,7 +7699,7 @@ __sfc_main.setup = (__props, __ctx) => {
7689
7699
  item._index = index2;
7690
7700
  item.__index = index2;
7691
7701
  set(item, "initHidden", !!item.initHidden);
7692
- set(item, "destory", !!item.destory);
7702
+ set(item, "destory", item.destory);
7693
7703
  if (!item.options)
7694
7704
  set(item, "options", []);
7695
7705
  return item;
@@ -7708,11 +7718,10 @@ __sfc_main.setup = (__props, __ctx) => {
7708
7718
  };
7709
7719
  syncCookiesToSearchFormItemOptions();
7710
7720
  const itemIsShow = (item) => {
7711
- var _a2;
7712
- return !item.initHidden && !item.destory && (validate.isFunction(item.show) ? (_a2 = item == null ? void 0 : item.show) == null ? void 0 : _a2.call(item, nfSearchFormModel.value) : true);
7721
+ return !item.initHidden && !resolveValue(item.destory, nfSearchFormModel.value) && resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7713
7722
  };
7714
7723
  const btnIsShow = (item) => {
7715
- return item.show ? item.show(nfSearchFormModel.value) : true;
7724
+ return resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7716
7725
  };
7717
7726
  watch(() => nfSearchFormModel.value, () => {
7718
7727
  emit("onChange", nfSearchFormModel.value);
@@ -7743,7 +7752,7 @@ __sfc_main.setup = (__props, __ctx) => {
7743
7752
  formsInit();
7744
7753
  });
7745
7754
  const refreshNfSearchFormModel = () => {
7746
- props.formOptions.filter((item) => !item.destory).forEach((v) => {
7755
+ props.formOptions.filter((item) => !resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7747
7756
  if (!localShowItems.value.includes(v.prop)) {
7748
7757
  mapDispose.setValue(nfSearchFormModel.value, v.key, void 0);
7749
7758
  } else if (nfSearchFormModel.value[v.prop] === void 0) {
@@ -7754,7 +7763,7 @@ __sfc_main.setup = (__props, __ctx) => {
7754
7763
  const formsInit = () => {
7755
7764
  getChangePropKeys();
7756
7765
  props.formOptions.forEach((item) => {
7757
- if (item.destory || !localShowItems.value.includes(item.prop))
7766
+ if (resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop))
7758
7767
  return;
7759
7768
  setDefaultVal(item, true);
7760
7769
  triggerGetOptions(item);
@@ -7831,6 +7840,9 @@ __sfc_main.setup = (__props, __ctx) => {
7831
7840
  };
7832
7841
  const onNfSearchFormValidate = (callback) => {
7833
7842
  nfSearchFormRef.value.validate((valid) => {
7843
+ if (props.requiredValidate && !valid) {
7844
+ return;
7845
+ }
7834
7846
  callback == null ? void 0 : callback(valid);
7835
7847
  });
7836
7848
  };
@@ -7941,6 +7953,7 @@ __sfc_main.setup = (__props, __ctx) => {
7941
7953
  return data;
7942
7954
  };
7943
7955
  return Object.assign({
7956
+ resolveValue,
7944
7957
  defaultButtonSlot,
7945
7958
  nfSearchFormRef,
7946
7959
  columnCheckNfDrawer,
@@ -8071,6 +8084,7 @@ var _sfc_render = function render6() {
8071
8084
  "size": _vm.size,
8072
8085
  "disabled": _vm.disabled,
8073
8086
  "rules": _vm.rules,
8087
+ "requiredValidate": _vm.requiredValidate,
8074
8088
  "label-suffix": _vm.labelSuffix,
8075
8089
  "hide-required-asterisk": _vm.hideRequiredAsterisk,
8076
8090
  "show-message": _vm.showMessage,
@@ -8112,7 +8126,7 @@ var _sfc_render = function render6() {
8112
8126
  "label-width": item.labelWidth
8113
8127
  }
8114
8128
  }, [_vm._t(item.labelSlot, function() {
8115
- return [_vm._v(" " + _vm._s(item.label ? item.isShowColon ? item.label + ":" : item.label : "") + " ")];
8129
+ return [_vm._v(" " + _vm._s(_vm.resolveValue(item.label, _vm.nfSearchFormModel) ? item.isShowColon ? _vm.resolveValue(item.label, _vm.nfSearchFormModel) + ":" : _vm.resolveValue(item.label, _vm.nfSearchFormModel) : "") + " ")];
8116
8130
  }, {
8117
8131
  "slot": "label"
8118
8132
  }), _c("search-form-item", {
@@ -1 +1 @@
1
-
1
+
@@ -1 +1 @@
1
-
1
+
package/lib/types.d.ts CHANGED
@@ -1,70 +1,70 @@
1
- interface IExchangeKey {
2
- type: number;
3
- value?: any;
4
- }
5
- export declare type NfSearchFormItemOption = {
6
- key?: string;
7
- _index?: number;
8
- __index?: number;
9
- initHidden?: boolean;
10
- destory?: boolean;
11
- label?: string;
12
- addLabel?: string;
13
- prop?: string;
14
- width?: string;
15
- isShowColon?: boolean;
16
- hidden?: boolean;
17
- required?: boolean;
18
- rules?: Record<string, any>;
19
- size?: 'medium' | 'small' | 'mini';
20
- labelWidth?: string;
21
- 'is-range'?: boolean;
22
- showMessage?: boolean;
23
- inlineMessage?: boolean;
24
- getOptions?: (callback: (options: any[]) => void, formData: Record<string, any>) => void;
25
- changeProps?: string[];
26
- show?: (formData: Record<string, any>) => boolean;
27
- exchangeKey?: IExchangeKey;
28
- category?: string;
29
- initValue?: any;
30
- slot?: string;
31
- labelSlot?: string;
32
- inputSlot?: {
33
- prepend?: string;
34
- append?: string;
35
- suffix?: string;
36
- prefix?: string;
37
- doublePrepend?: string;
38
- doubleAppend?: string;
39
- doubleSuffix?: string;
40
- doublePrefix?: string;
41
- doubleSegment?: string;
42
- };
43
- class?: string;
44
- tooltip?: {
45
- slot: string;
46
- };
47
- type?: 'monthrange' | 'datetimerange' | 'daterange' | 'yearrange' | 'halfyearrange' | 'quarterrange' | 'date' | 'month' | 'week' | 'dates';
48
- element?: 'el-input' | 'el-select' | 'custom-select' | 'ai-select' | 'ai-custom-select' | 'nf-lazy-select' | 'el-input-number' | 'el-date-picker' | 'el-cascader' | 'el-time-select' | 'el-time-picker' | 'number-range' | 'nf-date-picker' | 'nf-timezone-picker' | 'nf-quarter-picker' | 'nf-half-year-picker' | 'nf-double-year' | 'nf-double-week' | 'nf-double-half-year' | 'nf-double-quarter' | 'nf-transfer-select';
49
- events?: Record<string, Function>;
50
- placeholder?: string;
51
- virtualList?: boolean;
52
- 'controls-position'?: 'right' | 'left';
53
- clearable?: boolean;
54
- startPlaceholder?: string;
55
- rangeSeparator?: string;
56
- endPlaceholder?: string;
57
- defaultTime?: string[];
58
- options?: {
59
- label: string;
60
- value: string | number;
61
- }[];
62
- 'picker-options'?: {
63
- start: string;
64
- step: string;
65
- end: string;
66
- };
67
- valueFormat?: string;
68
- min?: 0;
69
- };
70
- export {};
1
+ interface IExchangeKey {
2
+ type: number;
3
+ value?: any;
4
+ }
5
+ export declare type NfSearchFormItemOption = {
6
+ key?: string;
7
+ _index?: number;
8
+ __index?: number;
9
+ initHidden?: boolean;
10
+ destory?: boolean | ((any: any) => boolean);
11
+ label?: string | ((any: any) => string);
12
+ addLabel?: string;
13
+ prop?: string;
14
+ width?: string;
15
+ isShowColon?: boolean;
16
+ hidden?: boolean;
17
+ required?: boolean;
18
+ rules?: Record<string, any>;
19
+ size?: 'medium' | 'small' | 'mini';
20
+ labelWidth?: string;
21
+ 'is-range'?: boolean;
22
+ showMessage?: boolean;
23
+ inlineMessage?: boolean;
24
+ getOptions?: (callback: (options: any[]) => void, formData: Record<string, any>) => void;
25
+ changeProps?: string[];
26
+ show?: (formData: Record<string, any>) => boolean;
27
+ exchangeKey?: IExchangeKey;
28
+ category?: string;
29
+ initValue?: any;
30
+ slot?: string;
31
+ labelSlot?: string;
32
+ inputSlot?: {
33
+ prepend?: string;
34
+ append?: string;
35
+ suffix?: string;
36
+ prefix?: string;
37
+ doublePrepend?: string;
38
+ doubleAppend?: string;
39
+ doubleSuffix?: string;
40
+ doublePrefix?: string;
41
+ doubleSegment?: string;
42
+ };
43
+ class?: string;
44
+ tooltip?: {
45
+ slot: string;
46
+ };
47
+ type?: 'monthrange' | 'datetimerange' | 'daterange' | 'yearrange' | 'halfyearrange' | 'quarterrange' | 'date' | 'month' | 'week' | 'dates';
48
+ element?: 'el-input' | 'el-select' | 'custom-select' | 'ai-select' | 'ai-custom-select' | 'nf-lazy-select' | 'el-input-number' | 'el-date-picker' | 'el-cascader' | 'el-time-select' | 'el-time-picker' | 'number-range' | 'nf-date-picker' | 'nf-timezone-picker' | 'nf-quarter-picker' | 'nf-half-year-picker' | 'nf-double-year' | 'nf-double-week' | 'nf-double-half-year' | 'nf-double-quarter' | 'nf-transfer-select';
49
+ events?: Record<string, Function>;
50
+ placeholder?: string;
51
+ virtualList?: boolean;
52
+ 'controls-position'?: 'right' | 'left';
53
+ clearable?: boolean;
54
+ startPlaceholder?: string;
55
+ rangeSeparator?: string;
56
+ endPlaceholder?: string;
57
+ defaultTime?: string[];
58
+ options?: {
59
+ label: string;
60
+ value: string | number;
61
+ }[];
62
+ 'picker-options'?: {
63
+ start: string;
64
+ step: string;
65
+ end: string;
66
+ };
67
+ valueFormat?: string;
68
+ min?: 0;
69
+ };
70
+ export {};
@@ -274,9 +274,9 @@ const insertColumn = (column, append = false) => {
274
274
  const fixedIndex = fixedColumn.value.findIndex(item => item.prop === column.prop)
275
275
  if (unFixedIndex === -1 && fixedIndex === -1) {
276
276
  if (append) {
277
- unFixedColumn.value.push(column)
277
+ (column.attr.fixed ? fixedColumn.value : unFixedColumn.value).push(column)
278
278
  } else {
279
- unFixedColumn.value.unshift(column)
279
+ (column.attr.fixed ? fixedColumn.value : unFixedColumn.value).unshift(column)
280
280
  }
281
281
  }
282
282
  }
@@ -323,8 +323,8 @@ const handleCheckAllChange = (v) => {
323
323
  if (v) { // 全选前为空,全选还原成最原始默认的顺序
324
324
  let flag = false
325
325
  if (columnName.value && fields.value.length) { // 搜索时,全选
326
- if (searchValue.length && currentTable.value.length && searchValue.length === currentTable.value.length) {
327
- if (!unFixedColumn.value.length && !fixedColumn.value.length) {
326
+ if (!unFixedColumn.value.length && !fixedColumn.value.length) {
327
+ if (searchValue.length && currentTable.value.length && searchValue.length === currentTable.value.length) {
328
328
  flag = true
329
329
  }
330
330
  }
@@ -339,7 +339,11 @@ const handleCheckAllChange = (v) => {
339
339
  const item = currentTable.value.find(item => item.prop === column.prop)
340
340
  if (item) {
341
341
  item.initHidden = false
342
- newColumns.push(item)
342
+ const cloneItem = deepClone(item)
343
+ if (!cloneItem.attr) {
344
+ cloneItem.attr = {}
345
+ }
346
+ newColumns.push(cloneItem)
343
347
  }
344
348
  })
345
349
  currentTable.value = newColumns
@@ -358,12 +362,12 @@ const handleCheckAllChange = (v) => {
358
362
  // 搜索时,全选
359
363
  if (columnName.value && fields.value.length) {
360
364
  searchValue.map(item => {
361
- if (v) { // 追加
362
- insertColumn(item, true)
363
- } else {
364
- pullAwayColumn(item)
365
- }
366
365
  if (!unChangedColumn.value.includes(item.prop)) {
366
+ if (v) { // 追加
367
+ insertColumn(item, true)
368
+ } else {
369
+ pullAwayColumn(item)
370
+ }
367
371
  item.initHidden = !v
368
372
  // 清除列目时,清除固定属性
369
373
  v ? '' : item.attr.fixed = false
@@ -371,12 +375,12 @@ const handleCheckAllChange = (v) => {
371
375
  })
372
376
  } else {
373
377
  currentTable.value.map(item => {
374
- if (v) { // 追加
375
- insertColumn(item, true)
376
- } else {
377
- pullAwayColumn(item)
378
- }
379
378
  if (!unChangedColumn.value.includes(item.prop)) {
379
+ if (v) { // 追加
380
+ insertColumn(item, true)
381
+ } else {
382
+ pullAwayColumn(item)
383
+ }
380
384
  item.initHidden = !v
381
385
  // 清除列目时,清除固定属性
382
386
  v ? '' : item.attr.fixed = false
@@ -2,36 +2,36 @@
2
2
  <div class="nf-search-form" ref="topDom">
3
3
  <!-- 空行以下保留原有,未重新梳理 -->
4
4
  <nf-form ref="nfSearchFormRef"
5
- :model="nfSearchFormModel"
6
- :inline="inline"
7
- :label-position="labelPosition"
8
- :label-width="useLabelWidth"
9
- :size="size"
10
- :disabled="disabled"
11
-
12
- :rules="rules"
13
- :label-suffix="labelSuffix"
14
- :hide-required-asterisk="hideRequiredAsterisk"
15
- :show-message="showMessage"
16
- :inline-message="inlineMessage"
17
- :status-icon="statusIcon"
18
- :validate-on-rule-change="validateOnRuleChange"
19
- :expand-btn-type="expandBtnType"
20
- :expand-btn-icon="expandBtnIcon"
21
- :expand-btn-plain="expandBtnPlain"
22
- :expand-btn-size="expandBtnSize"
23
- :expand-btn-round="expandBtnRound"
24
- :expand-btn-circle="expandBtnCircle"
25
- :expand-btn-loading="expandBtnLoading"
26
- :expand-btn-disabled="expandBtnDisabled"
27
- :columns="inline ? newColumns : columns"
28
- :up-icon="upIcon"
29
- :down-icon="downIcon"
30
- :show-btn="showBtn"
31
- :is-collapse="isCollapse"
32
- :expand-btn-tooltip-desc="expandBtnTooltipDesc"
33
- :shrink-btn-tooltip-desc="shrinkBtnTooltipDesc"
34
- @isCollapseChange="isCollapseChange"
5
+ :model="nfSearchFormModel"
6
+ :inline="inline"
7
+ :label-position="labelPosition"
8
+ :label-width="useLabelWidth"
9
+ :size="size"
10
+ :disabled="disabled"
11
+ :rules="rules"
12
+ :requiredValidate="requiredValidate"
13
+ :label-suffix="labelSuffix"
14
+ :hide-required-asterisk="hideRequiredAsterisk"
15
+ :show-message="showMessage"
16
+ :inline-message="inlineMessage"
17
+ :status-icon="statusIcon"
18
+ :validate-on-rule-change="validateOnRuleChange"
19
+ :expand-btn-type="expandBtnType"
20
+ :expand-btn-icon="expandBtnIcon"
21
+ :expand-btn-plain="expandBtnPlain"
22
+ :expand-btn-size="expandBtnSize"
23
+ :expand-btn-round="expandBtnRound"
24
+ :expand-btn-circle="expandBtnCircle"
25
+ :expand-btn-loading="expandBtnLoading"
26
+ :expand-btn-disabled="expandBtnDisabled"
27
+ :columns="inline ? newColumns : columns"
28
+ :up-icon="upIcon"
29
+ :down-icon="downIcon"
30
+ :show-btn="showBtn"
31
+ :is-collapse="isCollapse"
32
+ :expand-btn-tooltip-desc="expandBtnTooltipDesc"
33
+ :shrink-btn-tooltip-desc="shrinkBtnTooltipDesc"
34
+ @isCollapseChange="isCollapseChange"
35
35
  >
36
36
  <template
37
37
  v-for="item in renderSearchFormItemOptions"
@@ -50,7 +50,7 @@
50
50
  :label-width="item.labelWidth"
51
51
  >
52
52
  <slot :name="item.labelSlot" slot="label">
53
- {{ item.label ? (item.isShowColon?item.label + ':':item.label) : '' }}
53
+ {{ resolveValue(item.label, nfSearchFormModel) ? (item.isShowColon?resolveValue(item.label, nfSearchFormModel) + ':':resolveValue(item.label, nfSearchFormModel)) : '' }}
54
54
  </slot>
55
55
  <search-form-item
56
56
  :key="item.key"
@@ -363,7 +363,8 @@ import {
363
363
  deepClone,
364
364
  createUniqueString,
365
365
  validate as useValidate,
366
- mapDispose
366
+ mapDispose,
367
+ resolveValue
367
368
  } from '@94ai/common-utils'
368
369
  import {
369
370
  throttle
@@ -386,7 +387,7 @@ interface IBtnItems {
386
387
  class?: string,
387
388
  validate?: boolean,
388
389
  onClick?: (formData: Record<string, any>) => void,
389
- show?: (formData: Record<string, any>) => boolean,
390
+ show?: boolean | ((formData: Record<string, any>) => boolean),
390
391
  [key: string]: any,
391
392
  }
392
393
 
@@ -418,6 +419,7 @@ const props = withDefaults(defineProps<{
418
419
  /**
419
420
  * 以下同el-form配置项
420
421
  */
422
+ requiredValidate?: boolean
421
423
  rules?: Record<string, any>
422
424
  labelSuffix?: string
423
425
  hideRequiredAsterisk?: boolean
@@ -576,6 +578,7 @@ const props = withDefaults(defineProps<{
576
578
  columns: undefined,
577
579
  labelPosition: 'top',
578
580
  inline: true,
581
+ requiredValidate: false, // 当前表单搜索时是否需要校验必填项
579
582
  rules: undefined,
580
583
  labelSuffix: undefined,
581
584
  hideRequiredAsterisk: false,
@@ -1012,7 +1015,7 @@ const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
1012
1015
  item._index = index // 混合缓存后的数据
1013
1016
  item.__index = index // 原始顺序
1014
1017
  set(item, 'initHidden', !!item.initHidden)
1015
- set(item, 'destory', !!item.destory)
1018
+ set(item, 'destory', item.destory)
1016
1019
  if (!item.options) set(item, 'options', [])
1017
1020
  return item
1018
1021
  })
@@ -1038,9 +1041,7 @@ syncCookiesToSearchFormItemOptions()
1038
1041
  * @param prop
1039
1042
  */
1040
1043
  const itemIsShow = (item: NfSearchFormItemOption) => {
1041
- return !item.initHidden && !item.destory && (
1042
- useValidate.isFunction(item.show) ? item?.show?.(nfSearchFormModel.value) : true
1043
- )
1044
+ return !item.initHidden && !resolveValue(item.destory, nfSearchFormModel.value) && resolveValue((item?.show === undefined ? true : item?.show), nfSearchFormModel.value)
1044
1045
  }
1045
1046
 
1046
1047
  /**
@@ -1048,7 +1049,7 @@ const itemIsShow = (item: NfSearchFormItemOption) => {
1048
1049
  * @param prop
1049
1050
  */
1050
1051
  const btnIsShow = (item: IBtnItems) => {
1051
- return item.show ? item.show(nfSearchFormModel.value) : true
1052
+ return resolveValue((item?.show === undefined ? true : item?.show), nfSearchFormModel.value)
1052
1053
  }
1053
1054
 
1054
1055
  /**
@@ -1105,7 +1106,7 @@ onBeforeMount(() => {
1105
1106
  * @description 未勾选的筛选项,给予undefined;已勾选的若初次展示,设置默认值
1106
1107
  */
1107
1108
  const refreshNfSearchFormModel = () => {
1108
- props.formOptions.filter(item => !item.destory).forEach(v => {
1109
+ props.formOptions.filter(item => !resolveValue(item.destory, nfSearchFormModel.value)).forEach(v => {
1109
1110
  if (!localShowItems.value.includes(v.prop)) {
1110
1111
  mapDispose.setValue(nfSearchFormModel.value, v.key, undefined)
1111
1112
  } else if (nfSearchFormModel.value[v.prop] === undefined) {
@@ -1119,7 +1120,7 @@ const formsInit = () => {
1119
1120
  // refreshNfSearchFormModel()
1120
1121
  getChangePropKeys()
1121
1122
  props.formOptions.forEach(item => {
1122
- if (item.destory || !localShowItems.value.includes(item.prop)) return
1123
+ if (resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop)) return
1123
1124
  // 设置默认值
1124
1125
  setDefaultVal(item, true)
1125
1126
  // // 处理动态表单列表
@@ -1210,6 +1211,7 @@ const resetNfSearchFormModel = () => {
1210
1211
  */
1211
1212
  const onNfSearchFormValidate = (callback) => {
1212
1213
  nfSearchFormRef.value.validate(valid => {
1214
+ if (props.requiredValidate && !valid) { return } // 校验不通过
1213
1215
  callback?.(valid)
1214
1216
  })
1215
1217
  }
package/package/types.ts CHANGED
@@ -11,11 +11,11 @@ export type NfSearchFormItemOption = {
11
11
  _index?: number
12
12
  __index?: number
13
13
  initHidden?: boolean
14
- destory?: boolean
14
+ destory?: boolean | ((any: any) => boolean)
15
15
  /**
16
16
  * nf-form-item配置
17
17
  */
18
- label?: string,
18
+ label?: string | ((any: any) => string),
19
19
  addLabel?: string,
20
20
  prop?: string,
21
21
  width?: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-search-form",
3
- "version": "8.0.5",
3
+ "version": "8.0.12",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,23 +14,23 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-constants": "^8.0.5",
18
- "@94ai/common-utils": "^8.0.5",
19
- "@94ai/nf-button": "^8.0.5",
20
- "@94ai/nf-double-half-year": "^8.0.5",
21
- "@94ai/nf-double-quarter": "^8.0.5",
22
- "@94ai/nf-double-week": "^8.0.5",
23
- "@94ai/nf-double-year": "^8.0.5",
24
- "@94ai/nf-drawer": "^8.0.5",
25
- "@94ai/nf-form": "^8.0.5",
26
- "@94ai/nf-form-item": "^8.0.5",
27
- "@94ai/nf-half-year-picker": "^8.0.5",
28
- "@94ai/nf-lazy-select": "^8.0.5",
29
- "@94ai/nf-message": "^8.0.5",
30
- "@94ai/nf-quarter-picker": "^8.0.5",
31
- "@94ai/nf-theme-chalk": "^8.0.5",
32
- "@94ai/nf-transfer-select": "^8.0.5",
33
- "@94ai/nf-virtual-select": "^8.0.5",
17
+ "@94ai/common-constants": "^8.0.12",
18
+ "@94ai/common-utils": "^8.0.12",
19
+ "@94ai/nf-button": "^8.0.12",
20
+ "@94ai/nf-double-half-year": "^8.0.12",
21
+ "@94ai/nf-double-quarter": "^8.0.12",
22
+ "@94ai/nf-double-week": "^8.0.12",
23
+ "@94ai/nf-double-year": "^8.0.12",
24
+ "@94ai/nf-drawer": "^8.0.12",
25
+ "@94ai/nf-form": "^8.0.12",
26
+ "@94ai/nf-form-item": "^8.0.12",
27
+ "@94ai/nf-half-year-picker": "^8.0.12",
28
+ "@94ai/nf-lazy-select": "^8.0.12",
29
+ "@94ai/nf-message": "^8.0.12",
30
+ "@94ai/nf-quarter-picker": "^8.0.12",
31
+ "@94ai/nf-theme-chalk": "^8.0.12",
32
+ "@94ai/nf-transfer-select": "^8.0.12",
33
+ "@94ai/nf-virtual-select": "^8.0.12",
34
34
  "idb-keyval": "^6.2.1",
35
35
  "resize-observer-polyfill": "^1.5.1",
36
36
  "vue-demi": "^0.14.5",
@@ -50,5 +50,5 @@
50
50
  "types": "lib/index.d.ts",
51
51
  "main": "lib/nf-search-form.cjs.js",
52
52
  "module": "lib/nf-search-form.esm-bundler.js",
53
- "gitHead": "fab708c9a9c54ca34e3fea3c92a4a378184da4b3"
53
+ "gitHead": "dd2adc2b66c074a49c7a33477c806464d85ee254"
54
54
  }