@cloudbase/weda-ui-mp 3.11.8 → 3.11.10

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.
@@ -208,6 +208,20 @@ Component({
208
208
  * @param param1.isUpdateChildValue 是否更新子组件值, 因子组件值变化调用change时不去触发updateChildValueWithoutForm;因为外部设置了值,则触发updateChildValueWithoutForm去更新子组件值
209
209
  * @returns
210
210
  */
211
+ getTempValue(value) {
212
+ if (Array.isArray(value)) {
213
+ return value.map((i = {}) => {
214
+ const item = {};
215
+ Object.keys(i).forEach((j) => {
216
+ if (j) {
217
+ item[j] = i[j] || null;
218
+ }
219
+ });
220
+ return item;
221
+ });
222
+ }
223
+ return value;
224
+ },
211
225
  change(
212
226
  params,
213
227
  { isUpdateParentForm = false, isUpdateChildValue = true } = {}
@@ -239,7 +253,10 @@ Component({
239
253
  lodashSet(value, getValueName(params.name, name), params.value);
240
254
  }
241
255
 
242
- if (equal(value, objValue)) {
256
+ const tempValue = this.getTempValue(value);
257
+
258
+ const tempObjValue = this.getTempValue(objValue);
259
+ if (equal(tempValue, tempObjValue)) {
243
260
  return;
244
261
  }
245
262
 
@@ -257,7 +274,8 @@ Component({
257
274
  // 不存在父级嵌套表单时,去更新父级普通表单,避免重复更新
258
275
  if (!parentFormObj && isUpdateParentForm) {
259
276
  // 触发父级普通表单值更新
260
- parentForm?.setValue?.({ [name]: value }, false, true);
277
+ // 子组件向上同步值,不调用setValue
278
+ // parentForm?.setValue?.({ [name]: value }, false, true);
261
279
  // 刷新父级普通表单的formData
262
280
  parentForm?.updateFormContext();
263
281
  }
@@ -285,9 +303,13 @@ Component({
285
303
  const value = deepClone(objValue);
286
304
  lodashSet(value, getValueName(params.name, name), params.value);
287
305
 
288
- if (equal(value, objValue)) {
306
+ const tempValue = this.getTempValue(value);
307
+
308
+ const tempObjValue = this.getTempValue(objValue);
309
+ if (equal(tempValue, tempObjValue)) {
289
310
  return;
290
311
  }
312
+ this.setData({ objValue: value || [] });
291
313
 
292
314
  const parentFormObj = this.getParentFormObj();
293
315
  const parentForm = this.getParentForm();
@@ -309,12 +331,11 @@ Component({
309
331
 
310
332
  if (!parentFormObj && parentForm) {
311
333
  // 触发父级普通表单值更新
312
- parentForm?.setValue?.({ [name]: value }, false, true);
334
+ // 子组件向上同步值,不调用setValue
335
+ // parentForm?.setValue?.({ [name]: value }, false, true);
313
336
  // 刷新父级普通表单的formData
314
337
  parentForm?.updateFormContext();
315
338
  }
316
-
317
- this.setData({ objValue: value || [] });
318
339
  },
319
340
  },
320
341
  observers: {
@@ -336,13 +357,14 @@ Component({
336
357
  this.change({ value }, { isUpdateParentForm: true });
337
358
  });
338
359
  },
339
- objValue: function (objValue) {
360
+ objValue: function () {
340
361
  this.updateWidgetAPI();
362
+ // 更新子组件的值需要主动去调用,不被动执行
341
363
  // 如果是最顶层的嵌套表单,则去更新子组件的值,否则自己的值更新不去触发子组件值更新,因为父级普通表单会去更新
342
- const parentFormObj = this.getParentFormObj();
343
- if (!parentFormObj) {
344
- this.updateChildValue(objValue);
345
- }
364
+ // const parentFormObj = this.getParentFormObj();
365
+ // if (!parentFormObj) {
366
+ // // this.updateChildValue(objValue);
367
+ // }
346
368
  },
347
369
  },
348
370
  });
@@ -218,7 +218,8 @@ Component({
218
218
  // 不存在父级嵌套表单时,去更新父级普通表单,避免重复更新
219
219
  if (!parentFormObj && isUpdateParentForm) {
220
220
  // 触发父级普通表单值更新
221
- parentForm?.setValue?.({ [name]: value }, false, true);
221
+ // 子组件向上同步值,不调用setValue
222
+ // parentForm?.setValue?.({ [name]: value }, false, true);
222
223
  // 刷新父级普通表单的formData
223
224
  parentForm?.updateFormContext();
224
225
  }
@@ -270,7 +271,8 @@ Component({
270
271
 
271
272
  if (!parentFormObj && parentForm) {
272
273
  // 触发父级普通表单值更新
273
- parentForm?.setValue?.({ [name]: value }, false, true);
274
+ // 子组件向上同步值,不调用setValue
275
+ // parentForm?.setValue?.({ [name]: value }, false, true);
274
276
  // 刷新父级普通表单的formData
275
277
  parentForm?.updateFormContext();
276
278
  }
@@ -294,12 +296,13 @@ Component({
294
296
  this.setData({ objValue: value });
295
297
  this.updateWidgetAPI();
296
298
  },
297
- objValue: function (objValue) {
299
+ objValue: function () {
298
300
  // 如果是最顶层的嵌套表单,则去更新子组件的值,否则自己的值更新不去触发子组件值更新,因为父级普通表单会去更新
299
- const parentFormObj = this.getParentFormObj();
300
- if (!parentFormObj) {
301
- this.updateChildValue(objValue);
302
- }
301
+ // 更新子组件的值需要主动去调用,不被动执行
302
+ // const parentFormObj = this.getParentFormObj();
303
+ // if (!parentFormObj) {
304
+ // this.updateChildValue(objValue);
305
+ // }
303
306
  },
304
307
  },
305
308
  });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.11.8",
6
+ "version": "3.11.10",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"