cnhis-design-vue 3.1.23-beta.14 → 3.1.23-beta.15

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.
@@ -71,11 +71,18 @@ const script = defineComponent({
71
71
  async function fetchData(node, keyword) {
72
72
  try {
73
73
  if (node && !node.__keyword && node.isLeaf) {
74
- valueRef.value = createOptionValue(node);
75
- showRef.value = false;
76
- return Promise.reject();
74
+ return updateValue(node);
77
75
  }
78
- if (node == null ? void 0 : node.__keyword) {
76
+ if (!(node == null ? void 0 : node.__keyword)) {
77
+ const result = await asyncQueue.addAsync(createParams(props.wordbook, props.autograph, field.value, node, fieldKey.value));
78
+ if (!node) {
79
+ optionsRef.value = result.map((option) => enrichKeywordOption(option, keyword));
80
+ } else {
81
+ if (!result.length)
82
+ return updateValue(node);
83
+ node.children = result.map((option) => enrichChildOption(option, node, depth.value));
84
+ }
85
+ } else {
79
86
  if (!isString(node.id_link))
80
87
  return Promise.reject();
81
88
  const linkList = parseLinkFromString2List(node.id_link);
@@ -89,31 +96,33 @@ const script = defineComponent({
89
96
  await fetchData(lastOption);
90
97
  if (isEmpty(lastOption.children)) {
91
98
  valueRef.value = sortOptionWithIdList(primaryKeyOptions, linkList);
99
+ showRef.value = false;
100
+ return Promise.reject();
92
101
  } else {
93
102
  optionsRef.value = options;
94
103
  return lastOption;
95
104
  }
96
- } else {
97
- const result = await asyncQueue.addAsync(createParams(props.wordbook, props.autograph, field.value, node, fieldKey.value));
98
- if (!node) {
99
- optionsRef.value = result.map((option) => {
100
- option.__keyword = !!keyword;
101
- option.isLeaf = !!keyword;
102
- return option;
103
- });
104
- } else {
105
- node.children = result.map((option) => {
106
- return {
107
- ...option,
108
- parent: node,
109
- isLeaf: getNodeDepth(node) + 1 >= depth.value
110
- };
111
- });
112
- }
113
105
  }
114
106
  } catch (e) {
115
107
  isString(e) && formRenderLog(e);
116
108
  }
109
+ function enrichChildOption(option, parent, depth2) {
110
+ return {
111
+ ...option,
112
+ parent,
113
+ isLeaf: getNodeDepth(parent) + 1 >= depth2
114
+ };
115
+ }
116
+ function enrichKeywordOption(option, keyword2) {
117
+ option.__keyword = !!keyword2;
118
+ option.isLeaf = !!keyword2;
119
+ return option;
120
+ }
121
+ function updateValue(node2) {
122
+ valueRef.value = createOptionValue(node2);
123
+ showRef.value = false;
124
+ return Promise.reject();
125
+ }
117
126
  function sortOptionWithIdList(options, idList) {
118
127
  return idList.map((id) => {
119
128
  return options.find((option) => option[valueKey.value] === id);
@@ -127,12 +136,12 @@ const script = defineComponent({
127
136
  lastOption = option;
128
137
  return [option];
129
138
  }
130
- lastOption = option;
131
139
  Object.assign(option, {
132
- parent: res[0],
140
+ parent: lastOption,
133
141
  isLeaf: index + 1 >= depth.value
134
142
  });
135
- res[0].children = [option];
143
+ lastOption.children = [option];
144
+ lastOption = option;
136
145
  return res;
137
146
  }, []);
138
147
  return {
@@ -161,7 +170,7 @@ const script = defineComponent({
161
170
  wordbookId: "id",
162
171
  wordbookType: "type",
163
172
  fieldKeys: () => wordbook.search_key ? JSON.stringify(wordbook.search_key) : void 0,
164
- conObj: () => JSON.stringify(createConfigObject(wordbook, node2)),
173
+ conObj: () => JSON.stringify(createConfigObject(wordbook, keyword, node2)),
165
174
  primaryKey: "primary_key",
166
175
  levelKey: "level_key",
167
176
  keyword: () => keyword,
@@ -177,7 +186,9 @@ const script = defineComponent({
177
186
  key: key2
178
187
  };
179
188
  }
180
- function createConfigObject(wordbook, node2) {
189
+ function createConfigObject(wordbook, keyword2, node2) {
190
+ if (keyword2)
191
+ return wordbook.conObj || [];
181
192
  if (!node2)
182
193
  return wordbook.conObjFirstLevel || [];
183
194
  return [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
- "version": "3.1.23-beta.14",
3
+ "version": "3.1.23-beta.15",
4
4
  "license": "ISC",
5
5
  "module": "./es/components/index.js",
6
6
  "main": "./es/components/index.js",
@@ -66,5 +66,5 @@
66
66
  "iOS 7",
67
67
  "last 3 iOS versions"
68
68
  ],
69
- "gitHead": "112bf14c5aaabbb89b6c5d96e1d89bbbd4158e19"
69
+ "gitHead": "db833e188fcf7242cf2b7cc7816e113a66fee0f7"
70
70
  }