@jetlinks-web/components 3.1.5 → 3.1.7

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,3 +1,9 @@
1
+ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) {
2
+ return lhs;
3
+ }
4
+ else {
5
+ return rhsFn();
6
+ } }
1
7
  function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
2
8
  const op = ops[i];
3
9
  const fn = ops[i + 1];
@@ -20,17 +26,24 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
20
26
  "autoCompleteProps": "setup-maybe-ref",
21
27
  "ref": "setup-const",
22
28
  "watch": "setup-const",
29
+ "computed": "setup-const",
30
+ "omit": "setup-maybe-ref",
23
31
  "props": "setup-reactive-const",
24
32
  "emit": "setup-const",
25
- "_options": "setup-ref",
33
+ "displayText": "setup-ref",
34
+ "selectedValue": "setup-ref",
35
+ "keyword": "setup-ref",
36
+ "filteredOptions": "setup-ref",
26
37
  "onSearch": "setup-const",
27
- "dropdownVisibleChange": "setup-const"
38
+ "onSelect": "setup-const",
39
+ "onChange": "setup-const"
28
40
  } */
29
41
  import { defineComponent as _defineComponent } from 'vue';
30
- import { renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, unref as _unref, mergeProps as _mergeProps, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock } from "vue";
42
+ import { unref as _unref, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, mergeProps as _mergeProps, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock } from "vue";
31
43
  import { AutoComplete } from 'ant-design-vue';
32
44
  import { autoCompleteProps } from 'ant-design-vue/lib/auto-complete';
33
- import { ref, watch } from 'vue';
45
+ import { ref, watch, computed } from 'vue';
46
+ import { omit } from "lodash-es";
34
47
  const __sfc_main__ = _defineComponent({
35
48
  ...{
36
49
  name: 'JAutoComplete'
@@ -42,38 +55,60 @@ const __sfc_main__ = _defineComponent({
42
55
  default: 'label',
43
56
  },
44
57
  },
45
- emits: ["select"],
58
+ emits: ["select", "change", "update:value"],
46
59
  setup(__props, { emit: __emit }) {
47
60
  const props = __props;
48
61
  const emit = __emit;
49
- const _options = ref([]);
62
+ const displayText = ref();
63
+ const selectedValue = ref();
64
+ const keyword = ref('');
65
+ const filteredOptions = computed(() => {
66
+ if (!keyword.value)
67
+ return props.options;
68
+ return props.options.filter(opt => String(_nullishCoalesce(opt[props.searchKey], () => ('')))
69
+ .includes(keyword.value));
70
+ });
50
71
  /**
51
72
  * 根据关键词提示
52
73
  * @param searchText 关键词
53
74
  */
54
75
  const onSearch = (searchText) => {
55
- _options.value = _optionalChain([props, 'access', _2 => _2.options, 'optionalAccess', _3 => _3.filter, 'call', _4 => _4((item) => !!_optionalChain([item, 'access', _5 => _5[props.searchKey], 'optionalAccess', _6 => _6.includes, 'call', _7 => _7(searchText)]))]) || [];
56
- if (!_options.value.length) {
57
- _options.value.unshift({ label: searchText, value: searchText });
58
- }
76
+ keyword.value = searchText;
77
+ // _options.value = props.options?.filter(
78
+ // (item) => !!item[props.searchKey]?.includes(searchText),
79
+ // ) || [];
80
+ // if (!_options.value.length) {
81
+ // _options.value.unshift({ label: searchText, value: searchText });
82
+ // }
59
83
  };
60
- const dropdownVisibleChange = (open) => {
61
- if (!open) {
62
- // 关闭还原下拉options
63
- setTimeout(() => {
64
- _options.value = props.options || [];
65
- });
66
- }
84
+ const onSelect = (val, option) => {
85
+ displayText.value = option.label;
86
+ emit('update:value', val);
87
+ emit('select', val, option);
88
+ };
89
+ const onChange = (val) => {
90
+ displayText.value = val;
91
+ keyword.value = val;
92
+ emit('update:value', '');
67
93
  };
68
- watch(() => JSON.stringify(props.options), // 处理options变化
69
- () => {
70
- _options.value = props.options || [];
94
+ watch(() => props.value, (val) => {
95
+ if (!val) {
96
+ displayText.value = '';
97
+ }
98
+ else {
99
+ const found = _optionalChain([props, 'access', _2 => _2.options, 'optionalAccess', _3 => _3.find, 'call', _4 => _4((opt) => opt.value === val)]);
100
+ displayText.value = _nullishCoalesce(_optionalChain([found, 'optionalAccess', _5 => _5.label]), () => (''));
101
+ }
71
102
  }, { immediate: true });
72
103
  return (_ctx, _cache) => {
73
- return (_openBlock(), _createBlock(_unref(AutoComplete), _mergeProps({ style: { "width": "100%" } }, props, {
74
- options: _options.value,
104
+ return (_openBlock(), _createBlock(_unref(AutoComplete), _mergeProps({ ..._unref(omit)(props, ['onSelect']) }, {
105
+ style: { "width": "100%" },
106
+ value: displayText.value,
107
+ "onUpdate:value": _cache[0] || (_cache[0] = ($event) => ((displayText).value = $event)),
108
+ options: filteredOptions.value,
75
109
  onSearch: onSearch,
76
- onDropdownVisibleChange: dropdownVisibleChange
110
+ onChange: onChange,
111
+ onSelect: onSelect
77
112
  }), {
78
113
  option: _withCtx(({ value, label }) => [
79
114
  _renderSlot(_ctx.$slots, "option", { value: value }, () => [
@@ -84,7 +119,7 @@ const __sfc_main__ = _defineComponent({
84
119
  _renderSlot(_ctx.$slots, "default")
85
120
  ]),
86
121
  _: 3 /* FORWARDED */
87
- }, 16 /* FULL_PROPS */, ["options"]));
122
+ }, 16 /* FULL_PROPS */, ["value", "options"]));
88
123
  };
89
124
  }
90
125
  });
@@ -11,12 +11,14 @@
11
11
  "ref": "setup-const",
12
12
  "watch": "setup-const",
13
13
  "genCompoentStyle": "setup-maybe-ref",
14
+ "Form": "setup-maybe-ref",
14
15
  "props": "setup-reactive-const",
15
16
  "emit": "setup-const",
16
17
  "selectKeys": "setup-ref",
17
18
  "prefixCls": "setup-ref",
18
19
  "wrapSSR": "setup-maybe-ref",
19
20
  "hashId": "setup-maybe-ref",
21
+ "formItemContext": "setup-maybe-ref",
20
22
  "CardSelectStyle": "setup-ref",
21
23
  "isMultiple": "setup-ref",
22
24
  "handleSelect": "setup-const"
@@ -26,6 +28,7 @@ const _hoisted_1 = ["onClick"];
26
28
  import { has } from 'lodash-es';
27
29
  import { computed, ref, watch } from 'vue';
28
30
  import genCompoentStyle from './style';
31
+ import { Form } from 'ant-design-vue';
29
32
  const __sfc_main__ = Object.assign({
30
33
  name: 'JCardSelect'
31
34
  }, {
@@ -66,6 +69,7 @@ const __sfc_main__ = Object.assign({
66
69
  const selectKeys = ref([]);
67
70
  const prefixCls = computed(() => 'j-card-select');
68
71
  const [wrapSSR, hashId] = genCompoentStyle(prefixCls);
72
+ const formItemContext = Form.useInjectFormItemContext();
69
73
  const CardSelectStyle = computed(() => {
70
74
  const _column = props.column > 0 && props.layout === 'horizontal' ? props.column : 1;
71
75
  return {
@@ -100,6 +104,7 @@ const __sfc_main__ = Object.assign({
100
104
  emit('change', key, node);
101
105
  emit('update:value', key);
102
106
  }
107
+ formItemContext.onFieldChange();
103
108
  };
104
109
  watch(() => props.value, () => {
105
110
  selectKeys.value = isMultiple.value ? (props.value || []) : [props.value];
@@ -10,11 +10,13 @@
10
10
  "watch": "setup-const",
11
11
  "isArray": "setup-maybe-ref",
12
12
  "useCheckButtonStyle": "setup-maybe-ref",
13
+ "Form": "setup-maybe-ref",
13
14
  "props": "setup-reactive-const",
14
15
  "emit": "setup-const",
15
16
  "prefixCls": "setup-ref",
16
17
  "wrapSSR": "setup-maybe-ref",
17
18
  "hashId": "setup-maybe-ref",
19
+ "formItemContext": "setup-maybe-ref",
18
20
  "myValue": "setup-ref",
19
21
  "optionsMap": "setup-ref",
20
22
  "_options": "setup-ref",
@@ -26,6 +28,7 @@ const _hoisted_1 = ["onClick"];
26
28
  import { computed, ref, watch } from 'vue';
27
29
  import { isArray } from '@jetlinks-web/utils';
28
30
  import useCheckButtonStyle from './style';
31
+ import { Form } from "ant-design-vue";
29
32
  const __sfc_main__ = _defineComponent({
30
33
  ...{
31
34
  name: 'JCheckButton'
@@ -63,6 +66,7 @@ const __sfc_main__ = _defineComponent({
63
66
  // 使用样式
64
67
  const prefixCls = computed(() => 'j-check-button');
65
68
  const [wrapSSR, hashId] = useCheckButtonStyle(prefixCls);
69
+ const formItemContext = Form.useInjectFormItemContext();
66
70
  const myValue = ref();
67
71
  const optionsMap = ref(new Map());
68
72
  const _options = computed(() => {
@@ -103,6 +107,7 @@ const __sfc_main__ = _defineComponent({
103
107
  emit('update:value', _value);
104
108
  emit('change', _value, props.multiple ? optionsItems : optionsItems[0]);
105
109
  emit('select', _value, props.multiple ? optionsItems : optionsItems[0]);
110
+ formItemContext.onFieldChange();
106
111
  };
107
112
  return (_ctx, _cache) => {
108
113
  return (_openBlock(), _createElementBlock("div", {
@@ -369,10 +369,7 @@ const __sfc_main__ = _defineComponent({
369
369
  expandChange: expandChange
370
370
  }, () => [
371
371
  _createElementVNode("div", _hoisted_6, [
372
- _createVNode(_unref(Button), {
373
- type: "stroke",
374
- onClick: reset
375
- }, {
372
+ _createVNode(_unref(Button), { onClick: reset }, {
376
373
  default: _withCtx(() => [
377
374
  _createTextVNode(_toDisplayString(_unref(contextLocale).advanced.reset), 1 /* TEXT */)
378
375
  ]),
package/es/Search/Item.js CHANGED
@@ -50,6 +50,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
50
50
  "columnsValues": "setup-maybe-ref",
51
51
  "targetComponents": "setup-ref",
52
52
  "valueOptions": "setup-ref",
53
+ "btwKeys": "setup-const",
53
54
  "prefixCls": "setup-ref",
54
55
  "wrapSSR": "setup-maybe-ref",
55
56
  "hashId": "setup-maybe-ref",
@@ -131,6 +132,7 @@ const __sfc_main__ = _defineComponent({
131
132
  const columnsValues = useDefaultValue();
132
133
  const targetComponents = ref({});
133
134
  const valueOptions = ref();
135
+ const btwKeys = ['in', 'nin'];
134
136
  const prefixCls = computed(() => 'JSearch');
135
137
  const [wrapSSR, hashId] = useSearchStyle(prefixCls);
136
138
  const termTypeOptions = computed(() => {
@@ -185,29 +187,40 @@ const __sfc_main__ = _defineComponent({
185
187
  onValueChange();
186
188
  };
187
189
  const onTermTypeChange = () => {
190
+ const isBtw = btwKeys.includes(termsModel.termType);
191
+ if (!isBtw && Array.isArray(termsModel.value)) {
192
+ termsModel.value = termsModel.value[0];
193
+ onValueChange();
194
+ }
195
+ else if (isBtw && !Array.isArray(termsModel.value)) {
196
+ termsModel.value = [termsModel.value];
197
+ onValueChange();
198
+ }
188
199
  emit('update:termType', termsModel.termType);
189
200
  };
190
201
  const onValueChange = () => {
191
202
  emit('update:value', termsModel.value);
192
203
  };
193
204
  watch(() => termsModel.termType, () => {
194
- const isBtw = ['in', 'nin'].includes(termsModel.termType);
205
+ const isBtw = btwKeys.includes(termsModel.termType);
195
206
  if (targetComponents.value.type === componentType.treeSelect) {
196
207
  targetComponents.value.props = {
197
- multiple: isBtw,
198
208
  ...targetComponents.value.props,
209
+ multiple: isBtw,
199
210
  };
200
211
  }
201
212
  else if (targetComponents.value.type === componentType.select) {
202
213
  targetComponents.value.props = {
203
- mode: isBtw ? 'multiple' : 'combobox',
204
214
  ...targetComponents.value.props,
215
+ mode: isBtw ? 'multiple' : 'combobox',
205
216
  };
206
217
  }
207
218
  }, { immediate: true });
208
- watch(() => termsModel.column, async () => {
219
+ watch(() => [termsModel.column, columnsMap.value], async () => {
209
220
  // 根据column从map中获取record,再解析search属性
210
221
  const record = findItemByColumn();
222
+ if (!record)
223
+ return;
211
224
  const options = findOptionsByColumn();
212
225
  targetComponents.value = componentProps(record.search);
213
226
  targetComponents.value.label = record.title;
@@ -218,7 +231,7 @@ const __sfc_main__ = _defineComponent({
218
231
  else {
219
232
  await handleColumnsOptions(record.search.options);
220
233
  }
221
- }, { immediate: true });
234
+ }, { immediate: true, deep: true });
222
235
  watch(() => [props.value, props.termType, props.column, props.type], () => {
223
236
  termsModel.value = props.value;
224
237
  termsModel.termType = props.termType;
@@ -73,7 +73,7 @@ export var useHandleColumns = function useHandleColumns(props, terms, options) {
73
73
  var initValues = function initValues() {
74
74
  var arr = Object.values(columnsMap.value);
75
75
  if (!arr.length) return;
76
- if (options.mode === 'advanced') {
76
+ if ((options === null || options === void 0 ? void 0 : options.mode) === 'advanced') {
77
77
  // 设置第一位
78
78
  terms.terms = [getItemDefaultValue(arr[0], defaultCacheValues.value)];
79
79
  } else {
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
2
  import { TreeSelect, Select, Input, InputNumber, DatePicker, TimePicker, InputPassword, RangePicker, TimeRangePicker } from 'ant-design-vue';
4
3
  import { filterSelectNode, filterTreeSelectNode } from "./util";
@@ -108,7 +107,7 @@ export var termType = function termType(locale) {
108
107
  };
109
108
  export var componentType = {
110
109
  input: 'input',
111
- inputNumber: 'inputNumber',
110
+ inputNumber: 'number',
112
111
  password: 'password',
113
112
  switch: 'switch',
114
113
  radio: 'radio',
@@ -183,7 +182,7 @@ export var componentProps = function componentProps(record) {
183
182
  return {
184
183
  type: type,
185
184
  name: TreeSelect,
186
- props: _objectSpread(_defineProperty({
185
+ props: _objectSpread({
187
186
  showSearch: true,
188
187
  height: 350,
189
188
  fieldNames: {
@@ -193,9 +192,7 @@ export var componentProps = function componentProps(record) {
193
192
  filterTreeNode: function filterTreeNode(v, option) {
194
193
  return filterTreeSelectNode(v, option);
195
194
  }
196
- }, "filterTreeNode", function filterTreeNode(v, option) {
197
- return filterTreeSelectNode(v, option);
198
- }), _props)
195
+ }, _props)
199
196
  };
200
197
  case componentType.select:
201
198
  return {
@@ -7,7 +7,11 @@ var _flattenTree = function flattenTree(tree) {
7
7
  var parentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
8
8
  return tree.flatMap(function (item) {
9
9
  var _item$children;
10
+ var _children = (item.children || []).map(function (i) {
11
+ return _objectSpread({}, omit(i, 'children'));
12
+ });
10
13
  var flatNode = _objectSpread(_objectSpread({}, omit(item, 'children')), {}, {
14
+ children: _children,
11
15
  level: level,
12
16
  parentId: parentId,
13
17
  expanded: false,
@@ -1,3 +1,9 @@
1
+ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) {
2
+ return lhs;
3
+ }
4
+ else {
5
+ return rhsFn();
6
+ } }
1
7
  function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
2
8
  const op = ops[i];
3
9
  const fn = ops[i + 1];
@@ -20,17 +26,24 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
20
26
  "autoCompleteProps": "setup-maybe-ref",
21
27
  "ref": "setup-const",
22
28
  "watch": "setup-const",
29
+ "computed": "setup-const",
30
+ "omit": "setup-maybe-ref",
23
31
  "props": "setup-reactive-const",
24
32
  "emit": "setup-const",
25
- "_options": "setup-ref",
33
+ "displayText": "setup-ref",
34
+ "selectedValue": "setup-ref",
35
+ "keyword": "setup-ref",
36
+ "filteredOptions": "setup-ref",
26
37
  "onSearch": "setup-const",
27
- "dropdownVisibleChange": "setup-const"
38
+ "onSelect": "setup-const",
39
+ "onChange": "setup-const"
28
40
  } */
29
41
  import { defineComponent as _defineComponent } from 'vue';
30
- import { renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, unref as _unref, mergeProps as _mergeProps, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock } from "vue";
42
+ import { unref as _unref, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, mergeProps as _mergeProps, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock } from "vue";
31
43
  import { AutoComplete } from 'ant-design-vue';
32
44
  import { autoCompleteProps } from 'ant-design-vue/lib/auto-complete';
33
- import { ref, watch } from 'vue';
45
+ import { ref, watch, computed } from 'vue';
46
+ import { omit } from "lodash-es";
34
47
  const __sfc_main__ = _defineComponent({
35
48
  ...{
36
49
  name: 'JAutoComplete'
@@ -42,38 +55,60 @@ const __sfc_main__ = _defineComponent({
42
55
  default: 'label',
43
56
  },
44
57
  },
45
- emits: ["select"],
58
+ emits: ["select", "change", "update:value"],
46
59
  setup(__props, { emit: __emit }) {
47
60
  const props = __props;
48
61
  const emit = __emit;
49
- const _options = ref([]);
62
+ const displayText = ref();
63
+ const selectedValue = ref();
64
+ const keyword = ref('');
65
+ const filteredOptions = computed(() => {
66
+ if (!keyword.value)
67
+ return props.options;
68
+ return props.options.filter(opt => String(_nullishCoalesce(opt[props.searchKey], () => ('')))
69
+ .includes(keyword.value));
70
+ });
50
71
  /**
51
72
  * 根据关键词提示
52
73
  * @param searchText 关键词
53
74
  */
54
75
  const onSearch = (searchText) => {
55
- _options.value = _optionalChain([props, 'access', _2 => _2.options, 'optionalAccess', _3 => _3.filter, 'call', _4 => _4((item) => !!_optionalChain([item, 'access', _5 => _5[props.searchKey], 'optionalAccess', _6 => _6.includes, 'call', _7 => _7(searchText)]))]) || [];
56
- if (!_options.value.length) {
57
- _options.value.unshift({ label: searchText, value: searchText });
58
- }
76
+ keyword.value = searchText;
77
+ // _options.value = props.options?.filter(
78
+ // (item) => !!item[props.searchKey]?.includes(searchText),
79
+ // ) || [];
80
+ // if (!_options.value.length) {
81
+ // _options.value.unshift({ label: searchText, value: searchText });
82
+ // }
59
83
  };
60
- const dropdownVisibleChange = (open) => {
61
- if (!open) {
62
- // 关闭还原下拉options
63
- setTimeout(() => {
64
- _options.value = props.options || [];
65
- });
66
- }
84
+ const onSelect = (val, option) => {
85
+ displayText.value = option.label;
86
+ emit('update:value', val);
87
+ emit('select', val, option);
88
+ };
89
+ const onChange = (val) => {
90
+ displayText.value = val;
91
+ keyword.value = val;
92
+ emit('update:value', '');
67
93
  };
68
- watch(() => JSON.stringify(props.options), // 处理options变化
69
- () => {
70
- _options.value = props.options || [];
94
+ watch(() => props.value, (val) => {
95
+ if (!val) {
96
+ displayText.value = '';
97
+ }
98
+ else {
99
+ const found = _optionalChain([props, 'access', _2 => _2.options, 'optionalAccess', _3 => _3.find, 'call', _4 => _4((opt) => opt.value === val)]);
100
+ displayText.value = _nullishCoalesce(_optionalChain([found, 'optionalAccess', _5 => _5.label]), () => (''));
101
+ }
71
102
  }, { immediate: true });
72
103
  return (_ctx, _cache) => {
73
- return (_openBlock(), _createBlock(_unref(AutoComplete), _mergeProps({ style: { "width": "100%" } }, props, {
74
- options: _options.value,
104
+ return (_openBlock(), _createBlock(_unref(AutoComplete), _mergeProps({ ..._unref(omit)(props, ['onSelect']) }, {
105
+ style: { "width": "100%" },
106
+ value: displayText.value,
107
+ "onUpdate:value": _cache[0] || (_cache[0] = ($event) => ((displayText).value = $event)),
108
+ options: filteredOptions.value,
75
109
  onSearch: onSearch,
76
- onDropdownVisibleChange: dropdownVisibleChange
110
+ onChange: onChange,
111
+ onSelect: onSelect
77
112
  }), {
78
113
  option: _withCtx(({ value, label }) => [
79
114
  _renderSlot(_ctx.$slots, "option", { value: value }, () => [
@@ -84,7 +119,7 @@ const __sfc_main__ = _defineComponent({
84
119
  _renderSlot(_ctx.$slots, "default")
85
120
  ]),
86
121
  _: 3 /* FORWARDED */
87
- }, 16 /* FULL_PROPS */, ["options"]));
122
+ }, 16 /* FULL_PROPS */, ["value", "options"]));
88
123
  };
89
124
  }
90
125
  });
@@ -11,12 +11,14 @@
11
11
  "ref": "setup-const",
12
12
  "watch": "setup-const",
13
13
  "genCompoentStyle": "setup-maybe-ref",
14
+ "Form": "setup-maybe-ref",
14
15
  "props": "setup-reactive-const",
15
16
  "emit": "setup-const",
16
17
  "selectKeys": "setup-ref",
17
18
  "prefixCls": "setup-ref",
18
19
  "wrapSSR": "setup-maybe-ref",
19
20
  "hashId": "setup-maybe-ref",
21
+ "formItemContext": "setup-maybe-ref",
20
22
  "CardSelectStyle": "setup-ref",
21
23
  "isMultiple": "setup-ref",
22
24
  "handleSelect": "setup-const"
@@ -26,6 +28,7 @@ const _hoisted_1 = ["onClick"];
26
28
  import { has } from 'lodash-es';
27
29
  import { computed, ref, watch } from 'vue';
28
30
  import genCompoentStyle from './style';
31
+ import { Form } from 'ant-design-vue';
29
32
  const __sfc_main__ = Object.assign({
30
33
  name: 'JCardSelect'
31
34
  }, {
@@ -66,6 +69,7 @@ const __sfc_main__ = Object.assign({
66
69
  const selectKeys = ref([]);
67
70
  const prefixCls = computed(() => 'j-card-select');
68
71
  const [wrapSSR, hashId] = genCompoentStyle(prefixCls);
72
+ const formItemContext = Form.useInjectFormItemContext();
69
73
  const CardSelectStyle = computed(() => {
70
74
  const _column = props.column > 0 && props.layout === 'horizontal' ? props.column : 1;
71
75
  return {
@@ -100,6 +104,7 @@ const __sfc_main__ = Object.assign({
100
104
  emit('change', key, node);
101
105
  emit('update:value', key);
102
106
  }
107
+ formItemContext.onFieldChange();
103
108
  };
104
109
  watch(() => props.value, () => {
105
110
  selectKeys.value = isMultiple.value ? (props.value || []) : [props.value];
@@ -10,11 +10,13 @@
10
10
  "watch": "setup-const",
11
11
  "isArray": "setup-maybe-ref",
12
12
  "useCheckButtonStyle": "setup-maybe-ref",
13
+ "Form": "setup-maybe-ref",
13
14
  "props": "setup-reactive-const",
14
15
  "emit": "setup-const",
15
16
  "prefixCls": "setup-ref",
16
17
  "wrapSSR": "setup-maybe-ref",
17
18
  "hashId": "setup-maybe-ref",
19
+ "formItemContext": "setup-maybe-ref",
18
20
  "myValue": "setup-ref",
19
21
  "optionsMap": "setup-ref",
20
22
  "_options": "setup-ref",
@@ -26,6 +28,7 @@ const _hoisted_1 = ["onClick"];
26
28
  import { computed, ref, watch } from 'vue';
27
29
  import { isArray } from '@jetlinks-web/utils';
28
30
  import useCheckButtonStyle from './style';
31
+ import { Form } from "ant-design-vue";
29
32
  const __sfc_main__ = _defineComponent({
30
33
  ...{
31
34
  name: 'JCheckButton'
@@ -63,6 +66,7 @@ const __sfc_main__ = _defineComponent({
63
66
  // 使用样式
64
67
  const prefixCls = computed(() => 'j-check-button');
65
68
  const [wrapSSR, hashId] = useCheckButtonStyle(prefixCls);
69
+ const formItemContext = Form.useInjectFormItemContext();
66
70
  const myValue = ref();
67
71
  const optionsMap = ref(new Map());
68
72
  const _options = computed(() => {
@@ -103,6 +107,7 @@ const __sfc_main__ = _defineComponent({
103
107
  emit('update:value', _value);
104
108
  emit('change', _value, props.multiple ? optionsItems : optionsItems[0]);
105
109
  emit('select', _value, props.multiple ? optionsItems : optionsItems[0]);
110
+ formItemContext.onFieldChange();
106
111
  };
107
112
  return (_ctx, _cache) => {
108
113
  return (_openBlock(), _createElementBlock("div", {
@@ -369,10 +369,7 @@ const __sfc_main__ = _defineComponent({
369
369
  expandChange: expandChange
370
370
  }, () => [
371
371
  _createElementVNode("div", _hoisted_6, [
372
- _createVNode(_unref(Button), {
373
- type: "stroke",
374
- onClick: reset
375
- }, {
372
+ _createVNode(_unref(Button), { onClick: reset }, {
376
373
  default: _withCtx(() => [
377
374
  _createTextVNode(_toDisplayString(_unref(contextLocale).advanced.reset), 1 /* TEXT */)
378
375
  ]),
@@ -50,6 +50,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
50
50
  "columnsValues": "setup-maybe-ref",
51
51
  "targetComponents": "setup-ref",
52
52
  "valueOptions": "setup-ref",
53
+ "btwKeys": "setup-const",
53
54
  "prefixCls": "setup-ref",
54
55
  "wrapSSR": "setup-maybe-ref",
55
56
  "hashId": "setup-maybe-ref",
@@ -131,6 +132,7 @@ const __sfc_main__ = _defineComponent({
131
132
  const columnsValues = useDefaultValue();
132
133
  const targetComponents = ref({});
133
134
  const valueOptions = ref();
135
+ const btwKeys = ['in', 'nin'];
134
136
  const prefixCls = computed(() => 'JSearch');
135
137
  const [wrapSSR, hashId] = useSearchStyle(prefixCls);
136
138
  const termTypeOptions = computed(() => {
@@ -185,29 +187,40 @@ const __sfc_main__ = _defineComponent({
185
187
  onValueChange();
186
188
  };
187
189
  const onTermTypeChange = () => {
190
+ const isBtw = btwKeys.includes(termsModel.termType);
191
+ if (!isBtw && Array.isArray(termsModel.value)) {
192
+ termsModel.value = termsModel.value[0];
193
+ onValueChange();
194
+ }
195
+ else if (isBtw && !Array.isArray(termsModel.value)) {
196
+ termsModel.value = [termsModel.value];
197
+ onValueChange();
198
+ }
188
199
  emit('update:termType', termsModel.termType);
189
200
  };
190
201
  const onValueChange = () => {
191
202
  emit('update:value', termsModel.value);
192
203
  };
193
204
  watch(() => termsModel.termType, () => {
194
- const isBtw = ['in', 'nin'].includes(termsModel.termType);
205
+ const isBtw = btwKeys.includes(termsModel.termType);
195
206
  if (targetComponents.value.type === componentType.treeSelect) {
196
207
  targetComponents.value.props = {
197
- multiple: isBtw,
198
208
  ...targetComponents.value.props,
209
+ multiple: isBtw,
199
210
  };
200
211
  }
201
212
  else if (targetComponents.value.type === componentType.select) {
202
213
  targetComponents.value.props = {
203
- mode: isBtw ? 'multiple' : 'combobox',
204
214
  ...targetComponents.value.props,
215
+ mode: isBtw ? 'multiple' : 'combobox',
205
216
  };
206
217
  }
207
218
  }, { immediate: true });
208
- watch(() => termsModel.column, async () => {
219
+ watch(() => [termsModel.column, columnsMap.value], async () => {
209
220
  // 根据column从map中获取record,再解析search属性
210
221
  const record = findItemByColumn();
222
+ if (!record)
223
+ return;
211
224
  const options = findOptionsByColumn();
212
225
  targetComponents.value = componentProps(record.search);
213
226
  targetComponents.value.label = record.title;
@@ -218,7 +231,7 @@ const __sfc_main__ = _defineComponent({
218
231
  else {
219
232
  await handleColumnsOptions(record.search.options);
220
233
  }
221
- }, { immediate: true });
234
+ }, { immediate: true, deep: true });
222
235
  watch(() => [props.value, props.termType, props.column, props.type], () => {
223
236
  termsModel.value = props.value;
224
237
  termsModel.termType = props.termType;
@@ -121,7 +121,7 @@ var useHandleColumns = exports.useHandleColumns = function useHandleColumns(prop
121
121
  var initValues = function initValues() {
122
122
  var arr = Object.values(columnsMap.value);
123
123
  if (!arr.length) return;
124
- if (options.mode === 'advanced') {
124
+ if ((options === null || options === void 0 ? void 0 : options.mode) === 'advanced') {
125
125
  // 设置第一位
126
126
  terms.terms = [(0, _util.getItemDefaultValue)(arr[0], defaultCacheValues.value)];
127
127
  } else {
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.typeOptions = exports.termType = exports.searchProps = exports.optionsMapKey = exports.componentType = exports.componentProps = exports.TermTypeMap = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
9
  var _antDesignVue = require("ant-design-vue");
11
10
  var _util = require("./util");
12
11
  var optionsMapKey = exports.optionsMapKey = Symbol('searchOptionsMap');
@@ -115,7 +114,7 @@ var termType = exports.termType = function termType(locale) {
115
114
  };
116
115
  var componentType = exports.componentType = {
117
116
  input: 'input',
118
- inputNumber: 'inputNumber',
117
+ inputNumber: 'number',
119
118
  password: 'password',
120
119
  switch: 'switch',
121
120
  radio: 'radio',
@@ -157,7 +156,7 @@ var componentProps = exports.componentProps = function componentProps(record) {
157
156
  return {
158
157
  type: type,
159
158
  name: _antDesignVue.TimePicker,
160
- props: (0, _objectSpread3.default)({
159
+ props: (0, _objectSpread2.default)({
161
160
  valueFormat: 'HH:mm:ss'
162
161
  }, _props)
163
162
  };
@@ -165,7 +164,7 @@ var componentProps = exports.componentProps = function componentProps(record) {
165
164
  return {
166
165
  type: type,
167
166
  name: _antDesignVue.DatePicker,
168
- props: (0, _objectSpread3.default)({
167
+ props: (0, _objectSpread2.default)({
169
168
  valueFormat: 'YYYY-MM-DD HH:mm:ss'
170
169
  }, _props)
171
170
  };
@@ -173,7 +172,7 @@ var componentProps = exports.componentProps = function componentProps(record) {
173
172
  return {
174
173
  type: type,
175
174
  name: _antDesignVue.TimeRangePicker,
176
- props: (0, _objectSpread3.default)({
175
+ props: (0, _objectSpread2.default)({
177
176
  valueFormat: 'HH:mm:ss'
178
177
  }, _props)
179
178
  };
@@ -181,7 +180,7 @@ var componentProps = exports.componentProps = function componentProps(record) {
181
180
  return {
182
181
  type: type,
183
182
  name: _antDesignVue.RangePicker,
184
- props: (0, _objectSpread3.default)({
183
+ props: (0, _objectSpread2.default)({
185
184
  valueFormat: 'YYYY-MM-DD HH:mm:ss',
186
185
  showTime: true
187
186
  }, _props)
@@ -190,7 +189,7 @@ var componentProps = exports.componentProps = function componentProps(record) {
190
189
  return {
191
190
  type: type,
192
191
  name: _antDesignVue.TreeSelect,
193
- props: (0, _objectSpread3.default)((0, _defineProperty2.default)({
192
+ props: (0, _objectSpread2.default)({
194
193
  showSearch: true,
195
194
  height: 350,
196
195
  fieldNames: {
@@ -200,15 +199,13 @@ var componentProps = exports.componentProps = function componentProps(record) {
200
199
  filterTreeNode: function filterTreeNode(v, option) {
201
200
  return (0, _util.filterTreeSelectNode)(v, option);
202
201
  }
203
- }, "filterTreeNode", function filterTreeNode(v, option) {
204
- return (0, _util.filterTreeSelectNode)(v, option);
205
- }), _props)
202
+ }, _props)
206
203
  };
207
204
  case componentType.select:
208
205
  return {
209
206
  type: type,
210
207
  name: _antDesignVue.Select,
211
- props: (0, _objectSpread3.default)({
208
+ props: (0, _objectSpread2.default)({
212
209
  showSearch: true,
213
210
  // mode: isBtw ? 'multiple' : 'combobox',
214
211
  filterOption: function filterOption(v, option) {
@@ -15,7 +15,11 @@ var _flattenTree = exports.flattenTree = function flattenTree(tree) {
15
15
  var parentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
16
16
  return tree.flatMap(function (item) {
17
17
  var _item$children;
18
+ var _children = (item.children || []).map(function (i) {
19
+ return (0, _objectSpread2.default)({}, (0, _lodashEs.omit)(i, 'children'));
20
+ });
18
21
  var flatNode = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodashEs.omit)(item, 'children')), {}, {
22
+ children: _children,
19
23
  level: level,
20
24
  parentId: parentId,
21
25
  expanded: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetlinks-web/components",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -154,9 +154,9 @@
154
154
  "webpack-dev-server": "^4.0.0",
155
155
  "webpack-merge": "^5.0.0",
156
156
  "webpackbar": "^5.0.2",
157
- "@jetlinks-web/hooks": "^1.1.1",
158
157
  "@jetlinks-web/constants": "^1.0.9",
159
- "@jetlinks-web/utils": "^1.2.12"
158
+ "@jetlinks-web/utils": "^1.2.12",
159
+ "@jetlinks-web/hooks": "^1.1.1"
160
160
  },
161
161
  "publishConfig": {
162
162
  "registry": "https://registry.npmjs.org/",