@cloudbase/weda-ui-mp 3.14.4 → 3.15.1
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.
- package/components/chart/common/data-transform.js +6 -16
- package/components/form/form/wd-form.wxss +15 -0
- package/components/form/select/dropdown-select/index.js +41 -58
- package/components/form/select/dropdown-select/index.wxml +1 -1
- package/components/form/select/dropdown-select/index.wxss +1 -2
- package/components/form/select/index.js +1 -1
- package/components/form/selectMultiple/dropdown-select/index.js +10 -20
- package/components/form/selectMultiple/dropdown-select/index.wxss +2 -6
- package/components/form/selectMultiple/index.js +94 -45
- package/components/form/uploader/index.js +7 -15
- package/components/form/uploaderFile/index.js +3 -2
- package/components/formdetail/index.js +9 -28
- package/components/listView/index.js +1 -1
- package/components/listView/index.wxml +5 -5
- package/components/listView/index.wxss +20 -67
- package/components/qrcode/index.js +3 -4
- package/components/wd-form/index.js +72 -163
- package/components/wd-form/wd-form.wxss +15 -0
- package/components/wd-form-item/wd-form-item.wxss +15 -0
- package/components/wd-form-item-obj/wd-form-item.wxss +15 -0
- package/components/wd-input/inner-input/index.js +22 -56
- package/components/wd-input/inner-input/index.wxml +6 -2
- package/components/wd-input/inner-input/wd-input.wxss +15 -0
- package/components/wd-progress/wd-progress.wxss +15 -0
- package/components/wd-rating/wd-rating.wxss +15 -0
- package/components/wd-select/index.js +14 -10
- package/components/wd-select/index.json +1 -1
- package/components/wd-select/index.wxml +3 -0
- package/components/wd-select/select/formats-util.js +9 -0
- package/components/wd-select/select/index.js +545 -0
- package/components/wd-select/select/index.json +8 -0
- package/components/wd-select/select/index.wxml +26 -0
- package/components/wd-select/select/index.wxss +5 -0
- package/components/wd-select-multiple/index.js +13 -5
- package/components/wd-select-multiple/index.wxml +3 -0
- package/components/wd-switch/wd-switch.wxss +15 -0
- package/components/wd-tag-select/wd-tag-select.wxss +15 -0
- package/components/wd-textarea/wd-textarea.wxss +41 -0
- package/package.json +1 -1
- package/utils/getModelParams.js +27 -1
- package/utils/tcb.js +11 -2
|
@@ -13,6 +13,18 @@ Component({
|
|
|
13
13
|
type: String,
|
|
14
14
|
value: 'select',
|
|
15
15
|
},
|
|
16
|
+
supportManyRelated: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
value: false,
|
|
19
|
+
},
|
|
20
|
+
queryCondition: {
|
|
21
|
+
type: null,
|
|
22
|
+
value: [],
|
|
23
|
+
},
|
|
24
|
+
sorter: {
|
|
25
|
+
type: Array,
|
|
26
|
+
value: [],
|
|
27
|
+
},
|
|
16
28
|
},
|
|
17
29
|
data: {
|
|
18
30
|
options: [],
|
|
@@ -50,11 +62,7 @@ Component({
|
|
|
50
62
|
this.finalUpdateWidgetAPI();
|
|
51
63
|
},
|
|
52
64
|
'suffixType,suffixIcon': function (suffixType, suffixIcon) {
|
|
53
|
-
const [_suffixType, _suffixIcon] = convertFixedIcon(
|
|
54
|
-
suffixType,
|
|
55
|
-
suffixIcon,
|
|
56
|
-
SELECT_ICON_H5
|
|
57
|
-
);
|
|
65
|
+
const [_suffixType, _suffixIcon] = convertFixedIcon(suffixType, suffixIcon, SELECT_ICON_H5);
|
|
58
66
|
this.setData({ _suffixType, _suffixIcon });
|
|
59
67
|
},
|
|
60
68
|
options: function (options) {
|
|
@@ -62,11 +70,7 @@ Component({
|
|
|
62
70
|
this.setData({ itemMap });
|
|
63
71
|
},
|
|
64
72
|
'itemMap, value': function (itemMap, value) {
|
|
65
|
-
const { selectedLabel, selectedItem } = getSelected(
|
|
66
|
-
itemMap,
|
|
67
|
-
value,
|
|
68
|
-
false
|
|
69
|
-
);
|
|
73
|
+
const { selectedLabel, selectedItem } = getSelected(itemMap, value, false);
|
|
70
74
|
this.setData({ selectedLabel, selectedItem });
|
|
71
75
|
},
|
|
72
76
|
},
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
<wd-input-group before="{{before}}" after="{{after}}" block="{{true}}" size="{{_size}}" classRoot="{{classRoot}}" readOnly="{{readOnly}}">
|
|
23
23
|
<wd-input-wrap block="{{block}}" classRoot="{{classRoot}}" before="{{before}}" after="{{after}}" disabled="{{disabled}}" prefixType="{{prefixType}}" prefixIcon="{{prefixIcon}}" prefixSrc="{{prefixSrc}}" suffixType="{{_suffixType}}" suffixIcon="{{_suffixIcon}}" suffixSrc="{{suffixSrc}}" hasClearIcon="{{hasClearIcon}}" bind:onClear="handleClear" readOnly="{{readOnly}}">
|
|
24
24
|
<old-select
|
|
25
|
+
supportManyRelated="{{supportManyRelated}}"
|
|
26
|
+
queryCondition="{{queryCondition}}"
|
|
27
|
+
sorter="{{sorter}}"
|
|
25
28
|
name="{{name}}"
|
|
26
29
|
labelVisible="{{false}}"
|
|
27
30
|
label=""
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const SINGLE_FOREIGN_FORMATS = ['father-son', 'related', 'many-one', 'one-one', 'one-one-r'];
|
|
2
|
+
/** do NOT export this array */
|
|
3
|
+
const formatNeedDataFetch = [...SINGLE_FOREIGN_FORMATS, 'x-enum'];
|
|
4
|
+
export function isSingleForeignFormat(format) {
|
|
5
|
+
return SINGLE_FOREIGN_FORMATS.includes(format);
|
|
6
|
+
}
|
|
7
|
+
export function isFormatNeedFetch(format) {
|
|
8
|
+
return formatNeedDataFetch.includes(format);
|
|
9
|
+
}
|
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import destr from '../../../utils/destr';
|
|
2
|
+
import deepEqual from '../../../utils/deepEqual';
|
|
3
|
+
import { callDataSourceApi, callWedaApi } from '../../../utils/tcb';
|
|
4
|
+
import { getDefaultQuery } from '../../../utils/getModelParams';
|
|
5
|
+
import { isFormatNeedFetch, isSingleForeignFormat } from './formats-util';
|
|
6
|
+
|
|
7
|
+
const STATUS_CLOSED = -1;
|
|
8
|
+
const STATUS_LOADING = 1;
|
|
9
|
+
const STATUS_FAILED = 2;
|
|
10
|
+
const STATUS_EMPTY = 3;
|
|
11
|
+
|
|
12
|
+
Component({
|
|
13
|
+
options: {
|
|
14
|
+
virtualHost: true,
|
|
15
|
+
pureDataPattern: /^__/,
|
|
16
|
+
},
|
|
17
|
+
properties: {
|
|
18
|
+
placeholder: {
|
|
19
|
+
type: String,
|
|
20
|
+
value: '请选择',
|
|
21
|
+
},
|
|
22
|
+
mode: {
|
|
23
|
+
type: String,
|
|
24
|
+
value: 'selector',
|
|
25
|
+
},
|
|
26
|
+
disabled: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
value: false,
|
|
29
|
+
},
|
|
30
|
+
range: {
|
|
31
|
+
type: Array,
|
|
32
|
+
value: [],
|
|
33
|
+
},
|
|
34
|
+
defaultValue: {
|
|
35
|
+
type: null,
|
|
36
|
+
},
|
|
37
|
+
format: {
|
|
38
|
+
type: String,
|
|
39
|
+
value: '',
|
|
40
|
+
},
|
|
41
|
+
dataSourceName: {
|
|
42
|
+
type: String,
|
|
43
|
+
value: '',
|
|
44
|
+
},
|
|
45
|
+
viewId: {
|
|
46
|
+
type: String,
|
|
47
|
+
value: '',
|
|
48
|
+
},
|
|
49
|
+
primaryField: {
|
|
50
|
+
type: String,
|
|
51
|
+
value: '',
|
|
52
|
+
},
|
|
53
|
+
enumName: {
|
|
54
|
+
type: String,
|
|
55
|
+
value: '',
|
|
56
|
+
},
|
|
57
|
+
where: {
|
|
58
|
+
type: Array,
|
|
59
|
+
value: [],
|
|
60
|
+
},
|
|
61
|
+
allPickerShow: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
value: false,
|
|
64
|
+
},
|
|
65
|
+
version: {
|
|
66
|
+
type: String,
|
|
67
|
+
value: '',
|
|
68
|
+
},
|
|
69
|
+
readOnly: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
value: false,
|
|
72
|
+
},
|
|
73
|
+
ignoreCase: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
value: true,
|
|
76
|
+
},
|
|
77
|
+
staticSearchable: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
value: true,
|
|
80
|
+
},
|
|
81
|
+
supportManyRelated: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
value: false,
|
|
84
|
+
},
|
|
85
|
+
queryCondition: {
|
|
86
|
+
type: null,
|
|
87
|
+
value: [],
|
|
88
|
+
},
|
|
89
|
+
sorter: {
|
|
90
|
+
type: Array,
|
|
91
|
+
value: [],
|
|
92
|
+
},
|
|
93
|
+
multiple: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
value: false,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
data: {
|
|
99
|
+
selectRange: [],
|
|
100
|
+
start: '',
|
|
101
|
+
end: '',
|
|
102
|
+
value: '',
|
|
103
|
+
displayValue: '',
|
|
104
|
+
isSearch: false,
|
|
105
|
+
records: [],
|
|
106
|
+
searchRecords: [],
|
|
107
|
+
loadStatus: 0,
|
|
108
|
+
searchStatus: 0,
|
|
109
|
+
option: [],
|
|
110
|
+
searchOption: [],
|
|
111
|
+
_queryCondition: {},
|
|
112
|
+
queryParam: { select: { $master: true } },
|
|
113
|
+
chooseIndexValue: '',
|
|
114
|
+
chooseIndexLable: '',
|
|
115
|
+
isTurnPages: false,
|
|
116
|
+
pageNo: 1,
|
|
117
|
+
prevWhere: null,
|
|
118
|
+
},
|
|
119
|
+
lifetimes: {
|
|
120
|
+
attached() {
|
|
121
|
+
const { range, format } = this.properties;
|
|
122
|
+
let selectRange, start, end, displayValue;
|
|
123
|
+
|
|
124
|
+
if (isFormatNeedFetch(format)) {
|
|
125
|
+
selectRange = this.data.option.map((item) => item.label);
|
|
126
|
+
} else {
|
|
127
|
+
selectRange = range.map((item) => item.label);
|
|
128
|
+
}
|
|
129
|
+
if (isSingleForeignFormat(format)) {
|
|
130
|
+
this.setData({
|
|
131
|
+
isTurnPages: true,
|
|
132
|
+
});
|
|
133
|
+
} else if (format === 'x-enum') {
|
|
134
|
+
this.setData({
|
|
135
|
+
isTurnPages: false,
|
|
136
|
+
});
|
|
137
|
+
} else {
|
|
138
|
+
// 默认
|
|
139
|
+
this.setData({
|
|
140
|
+
option: range,
|
|
141
|
+
loadStatus: range.length > 0 ? 0 : STATUS_CLOSED,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this.setData({
|
|
146
|
+
selectRange,
|
|
147
|
+
start,
|
|
148
|
+
end,
|
|
149
|
+
displayValue,
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
observers: {
|
|
154
|
+
'defaultValue, option': function (defaultValue, option) {
|
|
155
|
+
const { range, mode, placeholder, format } = this.properties;
|
|
156
|
+
|
|
157
|
+
if (
|
|
158
|
+
deepEqual(
|
|
159
|
+
{
|
|
160
|
+
defaultValue,
|
|
161
|
+
option,
|
|
162
|
+
range,
|
|
163
|
+
mode,
|
|
164
|
+
placeholder,
|
|
165
|
+
format,
|
|
166
|
+
},
|
|
167
|
+
this.data.__prev,
|
|
168
|
+
)
|
|
169
|
+
) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let value, displayValue;
|
|
174
|
+
switch (mode) {
|
|
175
|
+
case 'selector': {
|
|
176
|
+
// TODO: == 故意的
|
|
177
|
+
if (!isFormatNeedFetch(format)) {
|
|
178
|
+
const index = range.findIndex((item) => item.value == defaultValue);
|
|
179
|
+
// 小程序picker组件,value值表示选择了 range 中的第几个(下标从 0 开始),类型为number
|
|
180
|
+
value = index < 0 ? 0 : index;
|
|
181
|
+
displayValue = index < 0 ? defaultValue : range[index].label;
|
|
182
|
+
// 更新选中值
|
|
183
|
+
this.setData({
|
|
184
|
+
chooseIndexValue: index < 0 ? defaultValue : range[index].value,
|
|
185
|
+
chooseIndexLable: displayValue,
|
|
186
|
+
});
|
|
187
|
+
} else {
|
|
188
|
+
const { chooseIndexValue } = this.data;
|
|
189
|
+
const currentValue = defaultValue;
|
|
190
|
+
const index = option.findIndex((item) => item.value == currentValue);
|
|
191
|
+
if (
|
|
192
|
+
!chooseIndexValue &&
|
|
193
|
+
this.data.option.length > 0 &&
|
|
194
|
+
index === -1 &&
|
|
195
|
+
defaultValue &&
|
|
196
|
+
defaultValue.length > 0
|
|
197
|
+
) {
|
|
198
|
+
// 没查找到,接口查找
|
|
199
|
+
this._fetchData({ defaultValue, isUpdate: true });
|
|
200
|
+
// 再次判断
|
|
201
|
+
if (this.data.chooseIndexValue && this.data.chooseIndexValue.length > 0) {
|
|
202
|
+
// 找到了
|
|
203
|
+
displayValue = this.data.chooseIndexLable;
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
value = index < 0 ? 0 : index;
|
|
207
|
+
displayValue = index < 0 ? currentValue : option[index].label;
|
|
208
|
+
}
|
|
209
|
+
// 更新value
|
|
210
|
+
this.setData({
|
|
211
|
+
chooseIndexValue: currentValue,
|
|
212
|
+
chooseIndexLable: displayValue,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
default: {
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
this.setData({
|
|
222
|
+
displayValue,
|
|
223
|
+
value,
|
|
224
|
+
__prev: {
|
|
225
|
+
defaultValue,
|
|
226
|
+
option,
|
|
227
|
+
range,
|
|
228
|
+
mode,
|
|
229
|
+
placeholder,
|
|
230
|
+
format,
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
range: function (range) {
|
|
235
|
+
// 防止range在不改变的情况下重新对option赋值,导致触发option的observer改变选中值
|
|
236
|
+
if (JSON.stringify(this.data.oldRange) === JSON.stringify(range)) return;
|
|
237
|
+
this.data.oldRange = range;
|
|
238
|
+
const { mode, format } = this.properties;
|
|
239
|
+
let selectRange = '';
|
|
240
|
+
switch (mode) {
|
|
241
|
+
case 'selector': {
|
|
242
|
+
if (!isFormatNeedFetch(format)) {
|
|
243
|
+
selectRange = range.map((item) => item.label);
|
|
244
|
+
const stringRange = range.map((item) => ({
|
|
245
|
+
...item,
|
|
246
|
+
value: String(item.value),
|
|
247
|
+
}));
|
|
248
|
+
// 默认
|
|
249
|
+
this.setData({
|
|
250
|
+
option: stringRange,
|
|
251
|
+
loadStatus: range.length > 0 ? 0 : STATUS_CLOSED,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
default: {
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (selectRange != '') {
|
|
261
|
+
this.setData({
|
|
262
|
+
selectRange,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
enumName: function (enumName) {
|
|
267
|
+
if (this.properties.format === 'x-enum' && enumName) {
|
|
268
|
+
this._fetchEnumData();
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
'where,queryCondition,sorter': function (where, queryCondition, sorter) {
|
|
272
|
+
const _queryParam = getDefaultQuery({
|
|
273
|
+
supportManyRelated: this.data.supportManyRelated,
|
|
274
|
+
queryCondition,
|
|
275
|
+
where,
|
|
276
|
+
sorter,
|
|
277
|
+
});
|
|
278
|
+
if (deepEqual(_queryParam, this.data.queryParam)) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const { format, dataSourceName } = this.properties;
|
|
283
|
+
this.setData({ queryParam: _queryParam });
|
|
284
|
+
if (
|
|
285
|
+
isSingleForeignFormat(format) &&
|
|
286
|
+
dataSourceName &&
|
|
287
|
+
!this.data.isSearch // 防止多次执行对搜索影响
|
|
288
|
+
) {
|
|
289
|
+
this.setData({
|
|
290
|
+
records: [],
|
|
291
|
+
option: [],
|
|
292
|
+
pageNo: 1,
|
|
293
|
+
});
|
|
294
|
+
this._fetchData({ queryParam: _queryParam });
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
records: function (records) {
|
|
298
|
+
const { primaryField } = this.properties;
|
|
299
|
+
if (records && records.length !== 0 && primaryField) {
|
|
300
|
+
const option = records.map((item) => {
|
|
301
|
+
return {
|
|
302
|
+
label: item[primaryField] || item._id,
|
|
303
|
+
value: item._id,
|
|
304
|
+
name: item[primaryField] || item._id,
|
|
305
|
+
};
|
|
306
|
+
});
|
|
307
|
+
this.setData({ selectRange: option.map((item) => item.label), option });
|
|
308
|
+
} else {
|
|
309
|
+
this.setData({
|
|
310
|
+
selectRange: [].map((item) => item.label),
|
|
311
|
+
option: [],
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
searchRecords: function (searchRecords) {
|
|
316
|
+
const { primaryField } = this.properties;
|
|
317
|
+
if (searchRecords && searchRecords.length !== 0 && primaryField) {
|
|
318
|
+
const option = searchRecords.map((item) => {
|
|
319
|
+
return {
|
|
320
|
+
label: item[primaryField] || item._id,
|
|
321
|
+
value: item._id,
|
|
322
|
+
name: item[primaryField] || item._id,
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
this.setData({ searchOption: option });
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
option: function (options) {
|
|
329
|
+
this.triggerEvent('changeOptions', { value: { options } });
|
|
330
|
+
},
|
|
331
|
+
'format,defaultValue': function (format, defaultValue) {
|
|
332
|
+
this.setData({
|
|
333
|
+
formatNeedFetch: isFormatNeedFetch(format),
|
|
334
|
+
});
|
|
335
|
+
if (isFormatNeedFetch(format)) {
|
|
336
|
+
this._fetchData({ defaultValue });
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
methods: {
|
|
341
|
+
// 最终选择的选项
|
|
342
|
+
onSelectPicker: function (e) {
|
|
343
|
+
if (this.data.disabled === true) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
if (e.detail?.label) {
|
|
347
|
+
this.setData({
|
|
348
|
+
chooseIndexLable: e.detail.label,
|
|
349
|
+
value: e.detail.label,
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
if (e.detail?.value) {
|
|
353
|
+
this.setData({
|
|
354
|
+
chooseIndexValue: e.detail.value,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
if (e.detail?.clear === 'true') {
|
|
358
|
+
this.setData({
|
|
359
|
+
chooseIndexValue: null,
|
|
360
|
+
chooseIndexLable: null,
|
|
361
|
+
value: null,
|
|
362
|
+
displayValue: '',
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
const { displayValue, chooseIndexLable, allPickerShow } = this.data;
|
|
366
|
+
this.setData({
|
|
367
|
+
allPickerShow: !allPickerShow,
|
|
368
|
+
displayValue: chooseIndexLable === '' ? displayValue : chooseIndexLable,
|
|
369
|
+
});
|
|
370
|
+
const { isSearch, option, searchOption, chooseIndexValue } = this.data;
|
|
371
|
+
if (chooseIndexValue && chooseIndexLable !== displayValue) {
|
|
372
|
+
const index = (isSearch ? searchOption : option)?.findIndex((item) => item.value === chooseIndexValue);
|
|
373
|
+
this.onChange({ detail: { value: index < 0 ? 0 : index } });
|
|
374
|
+
} else if (e.detail?.clear === 'true') {
|
|
375
|
+
this.onChange({ detail: { value: null } });
|
|
376
|
+
}
|
|
377
|
+
if (searchOption.length <= 0 && (this.data.dataSourceName?.length > 0 || isFormatNeedFetch(this.data.format))) {
|
|
378
|
+
this._fetchData({});
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
// 获取数据列表:关联关系和主子明细
|
|
382
|
+
_fetchData: async function ({
|
|
383
|
+
queryParam = this.data.queryParam,
|
|
384
|
+
searchValue = '',
|
|
385
|
+
defaultValue = '',
|
|
386
|
+
pageNo = 1,
|
|
387
|
+
isUpdate = false,
|
|
388
|
+
}) {
|
|
389
|
+
const { dataSourceName, viewId, records, searchRecords } = this.data;
|
|
390
|
+
if (!dataSourceName) return;
|
|
391
|
+
// 默认筛选条件
|
|
392
|
+
let _filter = destr(this.data.queryParam.filter) ?? {};
|
|
393
|
+
// 根据搜索值查询
|
|
394
|
+
if (searchValue) {
|
|
395
|
+
const search = this.data.ignoreCase ? '$search_ci' : '$search';
|
|
396
|
+
_filter = {
|
|
397
|
+
where: {
|
|
398
|
+
$and: [_filter.where, { $and: [{ [this.data.primaryField]: { [`${search}`]: searchValue } }] }],
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
// 查找默认值选项,用于回显
|
|
403
|
+
if (defaultValue) {
|
|
404
|
+
_filter = {
|
|
405
|
+
where: {
|
|
406
|
+
$and: [{ $and: [{ _id: { $search: defaultValue } }] }],
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
let pageSize = 50;
|
|
412
|
+
let data = await callDataSourceApi({
|
|
413
|
+
dataSourceName: dataSourceName,
|
|
414
|
+
viewId: viewId,
|
|
415
|
+
methodName: 'wedaGetRecordsV2',
|
|
416
|
+
params: {
|
|
417
|
+
...queryParam,
|
|
418
|
+
filter: _filter,
|
|
419
|
+
pageNumber: pageNo,
|
|
420
|
+
pageSize: pageSize,
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
const results = data?.records;
|
|
424
|
+
if (isUpdate && results && results.length > 0) {
|
|
425
|
+
this.setData({
|
|
426
|
+
chooseIndexLable: results[0][this.properties.primaryField] || results[0]._id,
|
|
427
|
+
chooseIndexValue: results[0]._id,
|
|
428
|
+
displayValue: results[0][this.properties.primaryField] || results[0]._id,
|
|
429
|
+
});
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
let status = 0;
|
|
433
|
+
if (!results) {
|
|
434
|
+
status = STATUS_FAILED;
|
|
435
|
+
} else if (results.length === 0) {
|
|
436
|
+
status = STATUS_EMPTY;
|
|
437
|
+
}
|
|
438
|
+
const isSearch = this.data.isSearch;
|
|
439
|
+
if (this.data.records.length === 0 && results?.length === 0) {
|
|
440
|
+
// 当异常的时候,主要为了不引起records的observer变化变化设置默认值
|
|
441
|
+
this.setData(isSearch ? { searchStatus: status } : { loadStatus: STATUS_CLOSED });
|
|
442
|
+
} else {
|
|
443
|
+
this.setData(
|
|
444
|
+
isSearch
|
|
445
|
+
? {
|
|
446
|
+
searchRecords: searchRecords.concat(
|
|
447
|
+
(results ?? []).filter((item) => searchRecords.findIndex((r) => r._id === item._id) < 0) || [],
|
|
448
|
+
),
|
|
449
|
+
records: records.concat(
|
|
450
|
+
(results ?? []).filter((item) => records.findIndex((r) => r._id === item._id) < 0) || [],
|
|
451
|
+
),
|
|
452
|
+
searchStatus: status,
|
|
453
|
+
}
|
|
454
|
+
: {
|
|
455
|
+
searchRecords: searchRecords.concat(
|
|
456
|
+
(results ?? []).filter((item) => searchRecords.findIndex((r) => r._id === item._id) < 0) || [],
|
|
457
|
+
),
|
|
458
|
+
records: records.concat(
|
|
459
|
+
(results ?? []).filter((item) => records.findIndex((r) => r._id === item._id) < 0) || [],
|
|
460
|
+
),
|
|
461
|
+
loadStatus: status,
|
|
462
|
+
},
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
_childFetchData: function (data) {
|
|
467
|
+
const { isSearch, pageNo, searchValue } = data.detail;
|
|
468
|
+
this.setData({
|
|
469
|
+
isSearch,
|
|
470
|
+
});
|
|
471
|
+
if (isSearch) {
|
|
472
|
+
if (pageNo === 1) {
|
|
473
|
+
this.setData({
|
|
474
|
+
searchRecords: [],
|
|
475
|
+
searchOption: [],
|
|
476
|
+
searchStatus: STATUS_LOADING,
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
this._fetchData({ searchValue, pageNo });
|
|
480
|
+
} else {
|
|
481
|
+
if (pageNo === 1) {
|
|
482
|
+
this.setData({
|
|
483
|
+
records: [],
|
|
484
|
+
option: [],
|
|
485
|
+
loadStatus: STATUS_LOADING,
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
this.setData({
|
|
489
|
+
pageNo,
|
|
490
|
+
});
|
|
491
|
+
this._fetchData({ pageNo });
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
// 获取通用选项集列表
|
|
495
|
+
_fetchEnumData: async function () {
|
|
496
|
+
let data = await callWedaApi({
|
|
497
|
+
action: 'DescribeGeneralOptionsDetailList',
|
|
498
|
+
data: {
|
|
499
|
+
OptNameList: [this.properties.enumName],
|
|
500
|
+
PageIndex: 1,
|
|
501
|
+
PageSize: 10,
|
|
502
|
+
},
|
|
503
|
+
});
|
|
504
|
+
const config = destr(data?.Items?.[0]?.Config) ?? [];
|
|
505
|
+
const option = config.map((item) => {
|
|
506
|
+
return {
|
|
507
|
+
label: item.value,
|
|
508
|
+
value: item.key,
|
|
509
|
+
name: item.value,
|
|
510
|
+
};
|
|
511
|
+
});
|
|
512
|
+
this.setData({
|
|
513
|
+
selectRange: option.map((item) => item.label),
|
|
514
|
+
option,
|
|
515
|
+
searchOption: option,
|
|
516
|
+
loadStatus: option.length > 0 ? 0 : STATUS_CLOSED,
|
|
517
|
+
});
|
|
518
|
+
},
|
|
519
|
+
onChange(e) {
|
|
520
|
+
const { range, mode, format } = this.properties;
|
|
521
|
+
let displayValue;
|
|
522
|
+
|
|
523
|
+
if (!isFormatNeedFetch(format)) {
|
|
524
|
+
const data = e.detail?.value != null ? range[e.detail.value] : { label: null, value: null };
|
|
525
|
+
this.triggerEvent('change', { ...data, value: data.value, context: { option: data } });
|
|
526
|
+
displayValue = data.label;
|
|
527
|
+
} else {
|
|
528
|
+
const { isSearch, searchOption, option } = this.data;
|
|
529
|
+
const opt = isSearch ? searchOption : option;
|
|
530
|
+
const data = e.detail?.value != null ? opt[e.detail.value] : { label: null, value: null };
|
|
531
|
+
this.triggerEvent('change', { ...data, value: data.value, context: { option: data } });
|
|
532
|
+
|
|
533
|
+
displayValue = this.properties.displayValue;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
this.setData({ displayValue });
|
|
537
|
+
},
|
|
538
|
+
onCancel(e) {
|
|
539
|
+
this.triggerEvent('cancel', e.detail);
|
|
540
|
+
},
|
|
541
|
+
onSearch(event) {
|
|
542
|
+
this.triggerEvent('search', { value: event.detail.value });
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<wd-form-item-read-only version="{{version}}" readOnly="{{readOnly}}" readValue="{{displayValue}}">
|
|
2
|
+
<view class="wd-select">
|
|
3
|
+
<view class="wd-select-input-group" bindchange="onChange" bindtap="onSelectPicker" data-show="true">
|
|
4
|
+
<label class="wd-select-input {{displayValue ? '' : 'weui-input__placeholder'}}">{{displayValue || placeholder}}</label>
|
|
5
|
+
</view>
|
|
6
|
+
<block wx:if="{{allPickerShow}}">
|
|
7
|
+
<dropdownSelect
|
|
8
|
+
ignoreCase="{{ignoreCase}}"
|
|
9
|
+
staticSearchable="{{staticSearchable}}"
|
|
10
|
+
class="weui-picker__group weui-input"
|
|
11
|
+
bindchange="onChange"
|
|
12
|
+
bind:_childFetchData="_childFetchData"
|
|
13
|
+
bind:onSelectPicker="onSelectPicker"
|
|
14
|
+
option="{{option}}"
|
|
15
|
+
loadStatus="{{loadStatus}}"
|
|
16
|
+
searchOption="{{searchOption}}"
|
|
17
|
+
searchStatus="{{searchStatus}}"
|
|
18
|
+
chooseIndexValue="{{chooseIndexValue}}"
|
|
19
|
+
isTurnPages="{{isTurnPages}}"
|
|
20
|
+
pageNo="{{pageNo}}"
|
|
21
|
+
_needFetch="{{formatNeedFetch}}"
|
|
22
|
+
bind:search="onSearch"
|
|
23
|
+
/>
|
|
24
|
+
</block>
|
|
25
|
+
</view>
|
|
26
|
+
</wd-form-item-read-only>
|
|
@@ -13,6 +13,18 @@ Component({
|
|
|
13
13
|
type: String,
|
|
14
14
|
value: 'select-multiple',
|
|
15
15
|
},
|
|
16
|
+
supportManyRelated: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
value: false,
|
|
19
|
+
},
|
|
20
|
+
queryCondition: {
|
|
21
|
+
type: null,
|
|
22
|
+
value: [],
|
|
23
|
+
},
|
|
24
|
+
sorter: {
|
|
25
|
+
type: Array,
|
|
26
|
+
value: [],
|
|
27
|
+
},
|
|
16
28
|
},
|
|
17
29
|
data: {
|
|
18
30
|
options: [],
|
|
@@ -50,11 +62,7 @@ Component({
|
|
|
50
62
|
this.finalUpdateWidgetAPI();
|
|
51
63
|
},
|
|
52
64
|
'suffixType,suffixIcon': function (suffixType, suffixIcon) {
|
|
53
|
-
const [_suffixType, _suffixIcon] = convertFixedIcon(
|
|
54
|
-
suffixType,
|
|
55
|
-
suffixIcon,
|
|
56
|
-
SELECT_ICON_H5
|
|
57
|
-
);
|
|
65
|
+
const [_suffixType, _suffixIcon] = convertFixedIcon(suffixType, suffixIcon, SELECT_ICON_H5);
|
|
58
66
|
this.setData({ _suffixType, _suffixIcon });
|
|
59
67
|
},
|
|
60
68
|
options: function (options) {
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
<wd-input-group before="{{before}}" after="{{after}}" block="{{true}}" size="{{_size}}" classRoot="{{classRoot}}" readOnly="{{readOnly}}">
|
|
23
23
|
<wd-input-wrap block="{{block}}" classRoot="{{classRoot}}" before="{{before}}" after="{{after}}" disabled="{{disabled}}" prefixType="{{prefixType}}" prefixIcon="{{prefixIcon}}" prefixSrc="{{prefixSrc}}" suffixType="{{_suffixType}}" suffixIcon="{{_suffixIcon}}" suffixSrc="{{suffixSrc}}" hasClearIcon="{{hasClearIcon}}" bind:onClear="handleClear" readOnly="{{readOnly}}">
|
|
24
24
|
<old-select
|
|
25
|
+
supportManyRelated="{{supportManyRelated}}"
|
|
26
|
+
queryCondition="{{queryCondition}}"
|
|
27
|
+
sorter="{{sorter}}"
|
|
25
28
|
labelVisible="{{false}}"
|
|
26
29
|
label=""
|
|
27
30
|
readOnly="{{readOnly}}"
|