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

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
+ };
@@ -6897,6 +6897,12 @@ __sfc_main.props = {
6897
6897
  type: String,
6898
6898
  default: "收起"
6899
6899
  },
6900
+ requiredValidate: {
6901
+ key: "requiredValidate",
6902
+ required: false,
6903
+ type: Boolean,
6904
+ default: false
6905
+ },
6900
6906
  rules: {
6901
6907
  key: "rules",
6902
6908
  required: false,
@@ -7691,7 +7697,7 @@ __sfc_main.setup = (__props, __ctx) => {
7691
7697
  item._index = index2;
7692
7698
  item.__index = index2;
7693
7699
  vue.set(item, "initHidden", !!item.initHidden);
7694
- vue.set(item, "destory", !!item.destory);
7700
+ vue.set(item, "destory", item.destory);
7695
7701
  if (!item.options)
7696
7702
  vue.set(item, "options", []);
7697
7703
  return item;
@@ -7710,11 +7716,10 @@ __sfc_main.setup = (__props, __ctx) => {
7710
7716
  };
7711
7717
  syncCookiesToSearchFormItemOptions();
7712
7718
  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);
7719
+ 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
7720
  };
7716
7721
  const btnIsShow = (item) => {
7717
- return item.show ? item.show(nfSearchFormModel.value) : true;
7722
+ return commonUtils.resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7718
7723
  };
7719
7724
  vueDemi.watch(() => nfSearchFormModel.value, () => {
7720
7725
  emit("onChange", nfSearchFormModel.value);
@@ -7745,7 +7750,7 @@ __sfc_main.setup = (__props, __ctx) => {
7745
7750
  formsInit();
7746
7751
  });
7747
7752
  const refreshNfSearchFormModel = () => {
7748
- props.formOptions.filter((item) => !item.destory).forEach((v) => {
7753
+ props.formOptions.filter((item) => !commonUtils.resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7749
7754
  if (!localShowItems.value.includes(v.prop)) {
7750
7755
  commonUtils.mapDispose.setValue(nfSearchFormModel.value, v.key, void 0);
7751
7756
  } else if (nfSearchFormModel.value[v.prop] === void 0) {
@@ -7756,7 +7761,7 @@ __sfc_main.setup = (__props, __ctx) => {
7756
7761
  const formsInit = () => {
7757
7762
  getChangePropKeys();
7758
7763
  props.formOptions.forEach((item) => {
7759
- if (item.destory || !localShowItems.value.includes(item.prop))
7764
+ if (commonUtils.resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop))
7760
7765
  return;
7761
7766
  setDefaultVal(item, true);
7762
7767
  triggerGetOptions(item);
@@ -7833,6 +7838,9 @@ __sfc_main.setup = (__props, __ctx) => {
7833
7838
  };
7834
7839
  const onNfSearchFormValidate = (callback) => {
7835
7840
  nfSearchFormRef.value.validate((valid) => {
7841
+ if (props.requiredValidate && !valid) {
7842
+ return;
7843
+ }
7836
7844
  callback == null ? void 0 : callback(valid);
7837
7845
  });
7838
7846
  };
@@ -7943,6 +7951,7 @@ __sfc_main.setup = (__props, __ctx) => {
7943
7951
  return data;
7944
7952
  };
7945
7953
  return Object.assign({
7954
+ resolveValue: commonUtils.resolveValue,
7946
7955
  defaultButtonSlot,
7947
7956
  nfSearchFormRef,
7948
7957
  columnCheckNfDrawer,
@@ -8073,6 +8082,7 @@ var _sfc_render = function render6() {
8073
8082
  "size": _vm.size,
8074
8083
  "disabled": _vm.disabled,
8075
8084
  "rules": _vm.rules,
8085
+ "requiredValidate": _vm.requiredValidate,
8076
8086
  "label-suffix": _vm.labelSuffix,
8077
8087
  "hide-required-asterisk": _vm.hideRequiredAsterisk,
8078
8088
  "show-message": _vm.showMessage,
@@ -8114,7 +8124,7 @@ var _sfc_render = function render6() {
8114
8124
  "label-width": item.labelWidth
8115
8125
  }
8116
8126
  }, [_vm._t(item.labelSlot, function() {
8117
- return [_vm._v(" " + _vm._s(item.label ? item.isShowColon ? item.label + ":" : item.label : "") + " ")];
8127
+ 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
8128
  }, {
8119
8129
  "slot": "label"
8120
8130
  }), _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";
@@ -6895,6 +6895,12 @@ __sfc_main.props = {
6895
6895
  type: String,
6896
6896
  default: "收起"
6897
6897
  },
6898
+ requiredValidate: {
6899
+ key: "requiredValidate",
6900
+ required: false,
6901
+ type: Boolean,
6902
+ default: false
6903
+ },
6898
6904
  rules: {
6899
6905
  key: "rules",
6900
6906
  required: false,
@@ -7689,7 +7695,7 @@ __sfc_main.setup = (__props, __ctx) => {
7689
7695
  item._index = index2;
7690
7696
  item.__index = index2;
7691
7697
  set(item, "initHidden", !!item.initHidden);
7692
- set(item, "destory", !!item.destory);
7698
+ set(item, "destory", item.destory);
7693
7699
  if (!item.options)
7694
7700
  set(item, "options", []);
7695
7701
  return item;
@@ -7708,11 +7714,10 @@ __sfc_main.setup = (__props, __ctx) => {
7708
7714
  };
7709
7715
  syncCookiesToSearchFormItemOptions();
7710
7716
  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);
7717
+ 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
7718
  };
7714
7719
  const btnIsShow = (item) => {
7715
- return item.show ? item.show(nfSearchFormModel.value) : true;
7720
+ return resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7716
7721
  };
7717
7722
  watch(() => nfSearchFormModel.value, () => {
7718
7723
  emit("onChange", nfSearchFormModel.value);
@@ -7743,7 +7748,7 @@ __sfc_main.setup = (__props, __ctx) => {
7743
7748
  formsInit();
7744
7749
  });
7745
7750
  const refreshNfSearchFormModel = () => {
7746
- props.formOptions.filter((item) => !item.destory).forEach((v) => {
7751
+ props.formOptions.filter((item) => !resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7747
7752
  if (!localShowItems.value.includes(v.prop)) {
7748
7753
  mapDispose.setValue(nfSearchFormModel.value, v.key, void 0);
7749
7754
  } else if (nfSearchFormModel.value[v.prop] === void 0) {
@@ -7754,7 +7759,7 @@ __sfc_main.setup = (__props, __ctx) => {
7754
7759
  const formsInit = () => {
7755
7760
  getChangePropKeys();
7756
7761
  props.formOptions.forEach((item) => {
7757
- if (item.destory || !localShowItems.value.includes(item.prop))
7762
+ if (resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop))
7758
7763
  return;
7759
7764
  setDefaultVal(item, true);
7760
7765
  triggerGetOptions(item);
@@ -7831,6 +7836,9 @@ __sfc_main.setup = (__props, __ctx) => {
7831
7836
  };
7832
7837
  const onNfSearchFormValidate = (callback) => {
7833
7838
  nfSearchFormRef.value.validate((valid) => {
7839
+ if (props.requiredValidate && !valid) {
7840
+ return;
7841
+ }
7834
7842
  callback == null ? void 0 : callback(valid);
7835
7843
  });
7836
7844
  };
@@ -7941,6 +7949,7 @@ __sfc_main.setup = (__props, __ctx) => {
7941
7949
  return data;
7942
7950
  };
7943
7951
  return Object.assign({
7952
+ resolveValue,
7944
7953
  defaultButtonSlot,
7945
7954
  nfSearchFormRef,
7946
7955
  columnCheckNfDrawer,
@@ -8071,6 +8080,7 @@ var _sfc_render = function render6() {
8071
8080
  "size": _vm.size,
8072
8081
  "disabled": _vm.disabled,
8073
8082
  "rules": _vm.rules,
8083
+ "requiredValidate": _vm.requiredValidate,
8074
8084
  "label-suffix": _vm.labelSuffix,
8075
8085
  "hide-required-asterisk": _vm.hideRequiredAsterisk,
8076
8086
  "show-message": _vm.showMessage,
@@ -8112,7 +8122,7 @@ var _sfc_render = function render6() {
8112
8122
  "label-width": item.labelWidth
8113
8123
  }
8114
8124
  }, [_vm._t(item.labelSlot, function() {
8115
- return [_vm._v(" " + _vm._s(item.label ? item.isShowColon ? item.label + ":" : item.label : "") + " ")];
8125
+ 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
8126
  }, {
8117
8127
  "slot": "label"
8118
8128
  }), _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 {};
@@ -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.8",
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.8",
18
+ "@94ai/common-utils": "^8.0.8",
19
+ "@94ai/nf-button": "^8.0.8",
20
+ "@94ai/nf-double-half-year": "^8.0.8",
21
+ "@94ai/nf-double-quarter": "^8.0.8",
22
+ "@94ai/nf-double-week": "^8.0.8",
23
+ "@94ai/nf-double-year": "^8.0.8",
24
+ "@94ai/nf-drawer": "^8.0.8",
25
+ "@94ai/nf-form": "^8.0.8",
26
+ "@94ai/nf-form-item": "^8.0.8",
27
+ "@94ai/nf-half-year-picker": "^8.0.8",
28
+ "@94ai/nf-lazy-select": "^8.0.8",
29
+ "@94ai/nf-message": "^8.0.8",
30
+ "@94ai/nf-quarter-picker": "^8.0.8",
31
+ "@94ai/nf-theme-chalk": "^8.0.8",
32
+ "@94ai/nf-transfer-select": "^8.0.8",
33
+ "@94ai/nf-virtual-select": "^8.0.8",
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": "348837ce37e1b93e62681cbd0021bc66cc94e660"
54
54
  }