@cloudbase/weda-ui-mp 3.7.9 → 3.7.11
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/formdetail/index.js +18 -20
- package/components/lottery/index.js +6 -4
- package/components/modal/index.js +5 -4
- package/components/wd-cascader/index.js +6 -3
- package/components/wd-cascader/utils.js +17 -14
- package/components/wd-form-arr/index.js +21 -3
- package/components/wd-form-arr/wd-form-obj.wxss +15 -5
- package/components/wd-form-obj/wd-form-obj.wxss +15 -5
- package/package.json +1 -1
|
@@ -229,11 +229,12 @@ Component({
|
|
|
229
229
|
);
|
|
230
230
|
return parent;
|
|
231
231
|
},
|
|
232
|
-
updateWidgetAPI() {
|
|
232
|
+
updateWidgetAPI(apis = {}) {
|
|
233
233
|
const { name, preValue, label, visible, readOnly, disabled } = this.data;
|
|
234
234
|
const that = this;
|
|
235
235
|
this.setReadonlyAttributes &&
|
|
236
236
|
this.setReadonlyAttributes({
|
|
237
|
+
...apis,
|
|
237
238
|
name,
|
|
238
239
|
value: preValue,
|
|
239
240
|
label,
|
|
@@ -287,7 +288,22 @@ Component({
|
|
|
287
288
|
},
|
|
288
289
|
lifetimes: {
|
|
289
290
|
attached: function () {
|
|
290
|
-
this.updateWidgetAPI(
|
|
291
|
+
this.updateWidgetAPI({
|
|
292
|
+
getConfig: () => {
|
|
293
|
+
return {
|
|
294
|
+
componentType: 'formdetail',
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
addition: () => {
|
|
298
|
+
this.onChange('add', null);
|
|
299
|
+
},
|
|
300
|
+
remove: (params) => {
|
|
301
|
+
this.onChange('remove', params);
|
|
302
|
+
},
|
|
303
|
+
change: (params) => {
|
|
304
|
+
this.onChange('change', params);
|
|
305
|
+
},
|
|
306
|
+
});
|
|
291
307
|
this.setData({ id: this.id });
|
|
292
308
|
const { value } = this.data;
|
|
293
309
|
const childFormItem = this.getChildFormItem(value);
|
|
@@ -302,24 +318,6 @@ Component({
|
|
|
302
318
|
data: [],
|
|
303
319
|
});
|
|
304
320
|
}
|
|
305
|
-
this.triggerEvent('attached', {
|
|
306
|
-
methods: {
|
|
307
|
-
getConfig: () => {
|
|
308
|
-
return {
|
|
309
|
-
componentType: 'formdetail',
|
|
310
|
-
};
|
|
311
|
-
},
|
|
312
|
-
addition: () => {
|
|
313
|
-
this.onChange('add', null);
|
|
314
|
-
},
|
|
315
|
-
remove: (params) => {
|
|
316
|
-
this.onChange('remove', params);
|
|
317
|
-
},
|
|
318
|
-
change: (params) => {
|
|
319
|
-
this.onChange('change', params);
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
});
|
|
323
321
|
},
|
|
324
322
|
detached: function () {
|
|
325
323
|
this.triggerEvent('onDataChange', {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { getTempFileURL } from '../../utils/tcb';
|
|
2
|
+
import { commonCompBehavior } from '../../utils/common-behavior';
|
|
2
3
|
|
|
3
4
|
Component({
|
|
5
|
+
behaviors: [commonCompBehavior],
|
|
6
|
+
|
|
4
7
|
/** 页面的初始数据 */
|
|
5
8
|
data: {
|
|
6
9
|
lotteryList: [
|
|
@@ -138,11 +141,10 @@ Component({
|
|
|
138
141
|
},
|
|
139
142
|
lifetimes: {
|
|
140
143
|
attached() {
|
|
141
|
-
this.
|
|
142
|
-
|
|
144
|
+
this.setReadonlyAttributes &&
|
|
145
|
+
this.setReadonlyAttributes({
|
|
143
146
|
start: this.start.bind(this),
|
|
144
|
-
}
|
|
145
|
-
});
|
|
147
|
+
});
|
|
146
148
|
},
|
|
147
149
|
},
|
|
148
150
|
methods: {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import handleEvents from '../../utils/handleEvents';
|
|
2
|
+
import { commonCompBehavior } from '../../utils/common-behavior';
|
|
2
3
|
|
|
3
4
|
Component({
|
|
5
|
+
behaviors: [commonCompBehavior],
|
|
4
6
|
options: {
|
|
5
7
|
virtualHost: true,
|
|
6
8
|
multipleSlots: true,
|
|
@@ -46,13 +48,12 @@ Component({
|
|
|
46
48
|
},
|
|
47
49
|
lifetimes: {
|
|
48
50
|
attached() {
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
+
this.setReadonlyAttributes &&
|
|
52
|
+
this.setReadonlyAttributes({
|
|
51
53
|
toggle: this.toggle.bind(this),
|
|
52
54
|
open: this.toggle.bind(this, true),
|
|
53
55
|
close: this.toggle.bind(this, false),
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
+
});
|
|
56
57
|
},
|
|
57
58
|
},
|
|
58
59
|
observers: {
|
|
@@ -128,9 +128,12 @@ Component({
|
|
|
128
128
|
const initData = transformTabData(data);
|
|
129
129
|
const tabData = initTabData(initData, _value || [], placeholderItem);
|
|
130
130
|
const listOptions = initListOptions(initData, _value || []);
|
|
131
|
-
const selectedOptions = _value?.map(
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
const selectedOptions = _value?.map(
|
|
132
|
+
(i) => getSelectedOptions(data, i) || { label: i, value: i }
|
|
133
|
+
);
|
|
134
|
+
const displayValue = selectedOptions
|
|
135
|
+
?.map((i) => i?.label || i?.value)
|
|
136
|
+
?.join(' / ');
|
|
134
137
|
this.setData({
|
|
135
138
|
tabData,
|
|
136
139
|
listOptions,
|
|
@@ -28,21 +28,24 @@ export const transformTabData = (data, pid = 'root', level = 0) => {
|
|
|
28
28
|
export const setSelectedValue = (data, value) => {
|
|
29
29
|
if (!Array.isArray(data)) return [];
|
|
30
30
|
const _value = [].concat(value);
|
|
31
|
-
return data
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
item.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
return data
|
|
32
|
+
.map((item) => {
|
|
33
|
+
if (!item) return null;
|
|
34
|
+
item.selected = !!_value.find((i) => i === item?.value);
|
|
35
|
+
if (item.children) {
|
|
36
|
+
item.children = setSelectedValue(item.children, value);
|
|
37
|
+
}
|
|
38
|
+
return { ...item };
|
|
39
|
+
})
|
|
40
|
+
.filter((i) => i);
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
export const initTabData = (data, value, placeholderItem) => {
|
|
41
44
|
if (!Array.isArray(data)) return [];
|
|
42
45
|
let tabDataRes = [placeholderItem];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
const selectedOptions =
|
|
47
|
+
value?.map((i) => getSelectedOptions(data, i)).filter((i) => i) || [];
|
|
48
|
+
if (value.length && selectedOptions.length) {
|
|
46
49
|
const selectedItem = selectedOptions[selectedOptions.length - 1];
|
|
47
50
|
|
|
48
51
|
tabDataRes = setSelectedValue(selectedOptions, selectedItem?.value);
|
|
@@ -53,12 +56,12 @@ export const initTabData = (data, value, placeholderItem) => {
|
|
|
53
56
|
export const initListOptions = (data, value) => {
|
|
54
57
|
if (!Array.isArray(data)) return [];
|
|
55
58
|
let listOptionsRes = deepClone(data);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
const selectedOptions =
|
|
60
|
+
value?.map((i) => getSelectedOptions(data, i)).filter((i) => i) || [];
|
|
61
|
+
if (value.length && selectedOptions.length) {
|
|
59
62
|
const selectedItem = selectedOptions[selectedOptions.length - 1];
|
|
60
63
|
listOptionsRes =
|
|
61
|
-
getSelectedOptions(data, selectedItem
|
|
64
|
+
getSelectedOptions(data, selectedItem?.pid)?.children || data;
|
|
62
65
|
}
|
|
63
66
|
return listOptionsRes;
|
|
64
67
|
};
|
|
@@ -27,6 +27,10 @@ Component({
|
|
|
27
27
|
type: String,
|
|
28
28
|
value: 'form-obj',
|
|
29
29
|
},
|
|
30
|
+
addDefaultValue: {
|
|
31
|
+
type: null,
|
|
32
|
+
value: {},
|
|
33
|
+
},
|
|
30
34
|
},
|
|
31
35
|
data: {
|
|
32
36
|
status: 'edit',
|
|
@@ -126,6 +130,15 @@ Component({
|
|
|
126
130
|
},
|
|
127
131
|
},
|
|
128
132
|
methods: {
|
|
133
|
+
sleep(cb, time = 100) {
|
|
134
|
+
return new Promise((resolve) => {
|
|
135
|
+
// eslint-disable-next-line rulesdir/no-timer
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
cb?.();
|
|
138
|
+
resolve(true);
|
|
139
|
+
}, time);
|
|
140
|
+
});
|
|
141
|
+
},
|
|
129
142
|
updateWidgetAPI(apis = {}) {
|
|
130
143
|
const { name, objValue, label, visible, readOnly, disabled, status } =
|
|
131
144
|
this.data;
|
|
@@ -199,7 +212,7 @@ Component({
|
|
|
199
212
|
params,
|
|
200
213
|
{ isUpdateParentForm = false, isUpdateChildValue = true } = {}
|
|
201
214
|
) {
|
|
202
|
-
const { objValue, name } = this.data;
|
|
215
|
+
const { objValue, name, addDefaultValue } = this.data;
|
|
203
216
|
let value = deepClone(params.value);
|
|
204
217
|
|
|
205
218
|
// 顶层为数组类型
|
|
@@ -207,7 +220,7 @@ Component({
|
|
|
207
220
|
// 触发添加操作,则增加一个undefined值
|
|
208
221
|
if (params.type === 'add') {
|
|
209
222
|
value = deepClone(objValue);
|
|
210
|
-
value.push(
|
|
223
|
+
value.push(addDefaultValue);
|
|
211
224
|
}
|
|
212
225
|
|
|
213
226
|
// 触发删除操作,则删除对应索引的值
|
|
@@ -234,7 +247,8 @@ Component({
|
|
|
234
247
|
|
|
235
248
|
if (isUpdateChildValue) {
|
|
236
249
|
// 外部设置数据,同时去更新子组件的值
|
|
237
|
-
|
|
250
|
+
// 延迟更新,避免子组件默认值覆盖当前值
|
|
251
|
+
this.sleep(() => this.updateChildValue(value));
|
|
238
252
|
}
|
|
239
253
|
|
|
240
254
|
const parentForm = this.getParentForm();
|
|
@@ -317,6 +331,10 @@ Component({
|
|
|
317
331
|
value: function (value) {
|
|
318
332
|
this.setData({ objValue: value });
|
|
319
333
|
this.updateWidgetAPI();
|
|
334
|
+
// 避免初始化的时候,整个数组值被子组件初始值覆盖
|
|
335
|
+
this.sleep(() => {
|
|
336
|
+
this.change({ value }, { isUpdateParentForm: true });
|
|
337
|
+
});
|
|
320
338
|
},
|
|
321
339
|
objValue: function (objValue) {
|
|
322
340
|
this.updateWidgetAPI();
|
|
@@ -49,20 +49,30 @@
|
|
|
49
49
|
padding: 0;
|
|
50
50
|
margin: 0;
|
|
51
51
|
}
|
|
52
|
-
.wd-form-obj-root.wd-h5-form-obj-root .wd-
|
|
52
|
+
.wd-form-obj-root.wd-h5-form-obj-root .wd-h5-card-root {
|
|
53
53
|
margin-bottom: var(--wd-form-item-pd);
|
|
54
54
|
}
|
|
55
|
-
.wd-form-obj-root.wd-h5-form-obj-root .wd-h5-form-obj > div > .wd-form-item > .wd-form-item-wrap {
|
|
55
|
+
.wd-form-obj-root.wd-h5-form-obj-root .wd-h5-form-obj > div > .wd-form-obj-item > .wd-form-item-wrap {
|
|
56
56
|
border: none;
|
|
57
57
|
}
|
|
58
|
+
.wd-form-obj-root .wd-card__header .wd-icon {
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
.wd-form-obj-root .wd-card__header .wd-icon:hover {
|
|
62
|
+
box-shadow: inset 0 -100vh var(--wd-color-bg-active);
|
|
63
|
+
}
|
|
64
|
+
.wd-form-obj-root .wd-card__header .wd-form-item-wrap__label.wd-form-obj__label {
|
|
65
|
+
padding: 0;
|
|
66
|
+
}
|
|
58
67
|
|
|
59
68
|
.wd-form.wd-form--weui .wd-h5-form-obj-root > .wd-form-item-wrap {
|
|
60
69
|
border: none;
|
|
61
70
|
}
|
|
62
71
|
|
|
63
|
-
.wd-form
|
|
64
|
-
|
|
72
|
+
.wd-form-item--weui.wd-form-obj-root > .wd-form-item-wrap {
|
|
73
|
+
border: none;
|
|
65
74
|
}
|
|
75
|
+
|
|
66
76
|
.wd-form.wd-pc-form .wd-form-obj-root .wd-form-obj > div > .wd-form-item {
|
|
67
77
|
padding-top: 0;
|
|
68
78
|
margin-top: calc(var(--wd-space-base) * 2.5);
|
|
@@ -88,6 +98,6 @@
|
|
|
88
98
|
.wd-mp-form-obj-root .wd-mp-card-root {
|
|
89
99
|
margin-bottom: var(--wd-form-item-pd);
|
|
90
100
|
}
|
|
91
|
-
.wd-mp-form-obj-root .wd-mp-form-obj >
|
|
101
|
+
.wd-mp-form-obj-root .wd-mp-form-item-obj > .wd-form-item-wrap {
|
|
92
102
|
border: none;
|
|
93
103
|
}
|
|
@@ -49,20 +49,30 @@
|
|
|
49
49
|
padding: 0;
|
|
50
50
|
margin: 0;
|
|
51
51
|
}
|
|
52
|
-
.wd-form-obj-root.wd-h5-form-obj-root .wd-
|
|
52
|
+
.wd-form-obj-root.wd-h5-form-obj-root .wd-h5-card-root {
|
|
53
53
|
margin-bottom: var(--wd-form-item-pd);
|
|
54
54
|
}
|
|
55
|
-
.wd-form-obj-root.wd-h5-form-obj-root .wd-h5-form-obj > div > .wd-form-item > .wd-form-item-wrap {
|
|
55
|
+
.wd-form-obj-root.wd-h5-form-obj-root .wd-h5-form-obj > div > .wd-form-obj-item > .wd-form-item-wrap {
|
|
56
56
|
border: none;
|
|
57
57
|
}
|
|
58
|
+
.wd-form-obj-root .wd-card__header .wd-icon {
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
.wd-form-obj-root .wd-card__header .wd-icon:hover {
|
|
62
|
+
box-shadow: inset 0 -100vh var(--wd-color-bg-active);
|
|
63
|
+
}
|
|
64
|
+
.wd-form-obj-root .wd-card__header .wd-form-item-wrap__label.wd-form-obj__label {
|
|
65
|
+
padding: 0;
|
|
66
|
+
}
|
|
58
67
|
|
|
59
68
|
.wd-form.wd-form--weui .wd-h5-form-obj-root > .wd-form-item-wrap {
|
|
60
69
|
border: none;
|
|
61
70
|
}
|
|
62
71
|
|
|
63
|
-
.wd-form
|
|
64
|
-
|
|
72
|
+
.wd-form-item--weui.wd-form-obj-root > .wd-form-item-wrap {
|
|
73
|
+
border: none;
|
|
65
74
|
}
|
|
75
|
+
|
|
66
76
|
.wd-form.wd-pc-form .wd-form-obj-root .wd-form-obj > div > .wd-form-item {
|
|
67
77
|
padding-top: 0;
|
|
68
78
|
margin-top: calc(var(--wd-space-base) * 2.5);
|
|
@@ -88,6 +98,6 @@
|
|
|
88
98
|
.wd-mp-form-obj-root .wd-mp-card-root {
|
|
89
99
|
margin-bottom: var(--wd-form-item-pd);
|
|
90
100
|
}
|
|
91
|
-
.wd-mp-form-obj-root .wd-mp-form-obj >
|
|
101
|
+
.wd-mp-form-obj-root .wd-mp-form-item-obj > .wd-form-item-wrap {
|
|
92
102
|
border: none;
|
|
93
103
|
}
|