lw-cdp-ui 1.1.38 → 1.1.40

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.
@@ -439,8 +439,8 @@ export default {
439
439
  },
440
440
  watch: {
441
441
  modelValue(val, old) {
442
- if (this.hasConfig) {
443
- this.deepMerge(this.form, JSON.parse(JSON.stringify(this.modelValue)))
442
+ if (this.hasConfig && this.hasValue) {
443
+ this.deepMerge(this.form, JSON.parse(JSON.stringify(val)))
444
444
  }
445
445
  },
446
446
  config() {
@@ -458,7 +458,7 @@ export default {
458
458
  return Object.keys(this.config).length > 0
459
459
  },
460
460
  hasValue() {
461
- return Object.keys(this.modelValue).length > 0
461
+ return this?.modelValue ? Object.keys(this.modelValue).length > 0 : false
462
462
  },
463
463
 
464
464
  },
@@ -234,6 +234,15 @@
234
234
  color="var(--el-color-primary)" />
235
235
  </span>
236
236
 
237
+ <!-- 自定义插槽 -->
238
+ <template v-else-if="t.slot">
239
+ <slot :name="t.component"
240
+ :row="scope.row">
241
+ <el-tag type="danger">[{{t.component}}]
242
+ 没有这个默认组件也未自定义插槽内容</el-tag>
243
+ </slot>
244
+ </template>
245
+
237
246
  <!-- 常规渲染 -->
238
247
  <template v-else>
239
248
  {{ scope.row[t.dataIndex] ? scope.row[t.dataIndex] :scope.row[t.dataIndex] === 0?'0':'' }}
@@ -11,7 +11,7 @@
11
11
  :min-width="item.minWidth"
12
12
  :key="index"
13
13
  :label="item.label"
14
- :prop="item?.options?.name ? `${item.name}.${item.options.name}` : item.name"
14
+ :prop="getPropName(item)"
15
15
  :align="item.align ?? 'left'"
16
16
  :fixed="item.fixed"
17
17
  :sortable="item.sortable"
@@ -39,7 +39,17 @@
39
39
  <template v-else-if="item.component=='upload'">
40
40
  <el-col v-for="(_item, _index) in item.options.items"
41
41
  :key="_index">
42
- <lw-upload v-model="row[_item.name]"></lw-upload>
42
+ <lw-upload v-model="row[_item.name]"
43
+ :maxSize="_item.maxSize"
44
+ :accept="_item.accept"
45
+ :title="_item.label"
46
+ :parseData="item.parseData"
47
+ :disabled="_item?.disabled"
48
+ :multiple="_item?.multiple"
49
+ :limit="_item?.limit"
50
+ :returnFile="_item?.returnFile"
51
+ :tip="_item?.tip"
52
+ :apiObj="item.apiObj"></lw-upload>
43
53
  <div class="error-tips">
44
54
  {{ row['errorMsg'][_item.name] }}
45
55
  </div>
@@ -267,16 +277,7 @@
267
277
  <!-- 错误提示 -->
268
278
  <div v-if="row.errorMsg"
269
279
  class="error-tips">
270
- <template
271
- v-if="item.component != 'checkbox' && item.component != 'upload'">
272
- <template v-if="item?.options?.name && row['errorMsg'][item.name]">
273
- {{ row['errorMsg'][item.name][item.options.name] }}
274
- </template>
275
- <template v-else>
276
- {{ row['errorMsg'][item?.name] }}
277
- </template>
278
-
279
- </template>
280
+ {{ row['errorMsg'][item?.name] }}
280
281
  </div>
281
282
  </template>
282
283
  </el-table-column>
@@ -312,27 +313,26 @@ export default {
312
313
  tableData: [],
313
314
  tagValue: '',
314
315
  ids: [],
315
- isChange: true,
316
+ internalUpdate: true,
316
317
  tagVisible: false,
317
318
  }
318
319
  },
319
320
  watch: {
320
321
  tableData: {
321
- async handler(val) {
322
- this.isChange = false;
323
- setTimeout(() => {
324
- this.isChange = true
325
- }, 1000)
326
- this.$emit("update:modelValue", await this.unflattenObject(val))
322
+ handler(val) {
323
+ if (!this.internalUpdate) {
324
+ this.$emit("update:modelValue", this.unflattenObject(val));
325
+ }
326
+ this.internalUpdate = false;
327
327
  },
328
328
  deep: true
329
329
  },
330
330
  modelValue: {
331
- async handler(val) {
332
- if (this.isChange) {
333
- this.tableData = await this.flattenObject(val)
331
+ handler(val) {
332
+ if (!this.internalUpdate) {
333
+ this.internalUpdate = true; // 设置标志位,避免递归
334
+ this.tableData = this.flattenObject(val);
334
335
  }
335
- this.isChange = true;
336
336
  },
337
337
  deep: true
338
338
  }
@@ -417,26 +417,14 @@ export default {
417
417
  item.rules.forEach((rule) => {
418
418
  let isVal = false;
419
419
  if (item.component == 'checkbox' || item.component == 'upload') {
420
- if (item.name) {
421
- const value = {};
422
- item.options.items.forEach((option) => {
423
- if (this.isEmpty(data[item.name][option.name])) {
424
- if (!data?.errorMsg) {
425
- data.errorMsg = {}
426
- }
427
- data['errorMsg'][item.name][option.name] = rule.message
428
- }
429
- })
430
- } else if (item?.options?.items) {
431
- item.options.items.forEach((option) => {
432
- if (this.isEmpty(data[item.name])) {
433
- if (!data?.errorMsg) {
434
- data.errorMsg = {}
435
- }
436
- data['errorMsg'][item.name] = rule.message
420
+ item.options.items.forEach((option) => {
421
+ if (this.isEmpty(data[option.name])) {
422
+ if (!data?.errorMsg) {
423
+ data.errorMsg = {}
437
424
  }
438
- });
439
- }
425
+ data['errorMsg'][option.name] = rule.message
426
+ }
427
+ })
440
428
  } else {
441
429
  if (rule.required && this.isEmpty(data[item.name])) {
442
430
  if (!data?.errorMsg) {
@@ -589,17 +577,20 @@ export default {
589
577
  // 增加tag
590
578
  tagInputConfirm(item, row) {
591
579
  if (this.tagValue) {
592
- if (item?.options?.name) {
593
- row[item.name] = row[item.name] || {};
594
- row[item.name][item.options.name] = row[item.name][item.options.name] || [];
595
- row[item.name][item.options.name].push(this.tagValue)
596
- } else {
597
- row[item.name] = row[item.name] || []
598
- row[item.name].push(this.tagValue)
599
- }
580
+ row[item.name] = row[item.name] || []
581
+ row[item.name].push(this.tagValue)
600
582
  }
601
583
  row.tagVisible = false
602
584
  this.tagValue = ''
585
+ },
586
+ // prop NAME
587
+ getPropName(item) {
588
+ if (item.component == 'checkbox' || item.component == 'upload') {
589
+ return item.options.items[0].name
590
+
591
+ } else {
592
+ return item.name
593
+ }
603
594
  }
604
595
  }
605
596
  }