lw-cdp-ui 1.1.29 → 1.1.30

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.
@@ -26,7 +26,7 @@
26
26
  </div>
27
27
  <!-- 表单内容 -->
28
28
  <el-form-item v-else
29
- :prop="item?.options?.name ? `${item.name}.${item.options.name}` : item.name"
29
+ :prop="getPropName(item)"
30
30
  :rules="rulesHandle(item)">
31
31
  <template #label>
32
32
  {{ item.label }}
@@ -78,7 +78,10 @@
78
78
  :accept="_item.accept"
79
79
  :title="_item.label"
80
80
  :parseData="item.parseData"
81
- :disabled="item.options.disabled"
81
+ :disabled="item.options?.disabled"
82
+ :multiple="_item?.multiple"
83
+ :limit="_item?.limit"
84
+ :tip="_item?.tip"
82
85
  :apiObj="item.apiObj"></lw-upload>
83
86
  </div>
84
87
  </template>
@@ -89,7 +92,10 @@
89
92
  :accept="_item.accept"
90
93
  :title="_item.label"
91
94
  :parseData="item.parseData"
92
- :disabled="item.options.disabled"
95
+ :disabled="item.options?.disabled"
96
+ :multiple="_item?.multiple"
97
+ :limit="_item?.limit"
98
+ :tip="_item?.tip"
93
99
  :apiObj="item.apiObj"></lw-upload>
94
100
  </div>
95
101
  </template>
@@ -580,6 +586,19 @@ export default {
580
586
  }
581
587
  this.tagVisible = false
582
588
  this.tagValue = ''
589
+ },
590
+ // prop NAME
591
+ getPropName(item) {
592
+ if (item.component == 'checkbox' || item.component == 'upload') {
593
+ if (item.name) {
594
+ return `${item.name}.${item.options.items[0].name}`
595
+ } else {
596
+ return item.options.items[0].name
597
+ }
598
+
599
+ } else {
600
+ return item?.options?.name ? `${item.name}.${item.options.name}` : item.name
601
+ }
583
602
  }
584
603
  }
585
604
  }
@@ -41,13 +41,13 @@
41
41
  <el-input v-model="form[item.name]"
42
42
  :placeholder="item.options?.placeholder"
43
43
  clearable
44
- :type="item.options.type"
45
- :disabled="item.options.disabled"
46
- :maxlength="item.options.maxlength"
44
+ :type="item.options?.type"
45
+ :disabled="item.options?.disabled"
46
+ :maxlength="item.options?.maxlength"
47
47
  show-word-limit>
48
- <template v-if="item.options.prepend"
48
+ <template v-if="item.options?.prepend"
49
49
  #prepend>{{ item.options.prepend }}</template>
50
- <template v-if="item.options.append"
50
+ <template v-if="item.options?.append"
51
51
  #append>{{ item.options.append }}</template>
52
52
  </el-input>
53
53
  </template>
@@ -60,7 +60,10 @@
60
60
  :accept="_item.accept"
61
61
  :title="_item.label"
62
62
  :parseData="item.parseData"
63
- :disabled="item.options.disabled"
63
+ :disabled="item.options?.disabled"
64
+ :multiple="_item?.multiple"
65
+ :limit="_item?.limit"
66
+ :tip="_item?.tip"
64
67
  :apiObj="item.apiObj"></lw-upload>
65
68
 
66
69
  </template>
@@ -105,6 +108,16 @@
105
108
  :value="option.value"></el-option>
106
109
  </el-select>
107
110
 
111
+ </template>
112
+ <!-- treeSelect -->
113
+ <template v-else-if="item.component == 'treeSelect'">
114
+ <el-tree-select v-model="form[item.name]"
115
+ :props="item.options?.props"
116
+ :node-Key="item.options?.nodeKey"
117
+ :multiple="item.options?.multiple"
118
+ :check-Strictly="item.options?.checkStrictly"
119
+ :data="item.options?.items"></el-tree-select>
120
+
108
121
  </template>
109
122
  <!-- cascader -->
110
123
  <template v-else-if="item.component == 'cascader'">
@@ -178,7 +191,7 @@
178
191
  @close="tagClose(tag, form[item.name])">
179
192
  {{ tag }}
180
193
  </el-tag>
181
- <el-input v-if="tagVisible"
194
+ <el-input v-if="tagVisible[item.name]"
182
195
  v-model="tagValue"
183
196
  class="w-20"
184
197
  size="small"
@@ -187,7 +200,7 @@
187
200
  <el-button v-else
188
201
  class="button-new-tag"
189
202
  size="small"
190
- @click="tagVisible = true">
203
+ @click="tagVisible[item.name] = true">
191
204
  + 添加
192
205
  </el-button>
193
206
  </div>
@@ -273,7 +286,7 @@ export default {
273
286
  return {
274
287
  form: {},
275
288
  tagValue: '',
276
- tagVisible: false,
289
+ tagVisible: {},
277
290
  isChange: true,
278
291
  renderLoading: false
279
292
  }
@@ -282,7 +295,8 @@ export default {
282
295
  modelValue: {
283
296
  handler(val, old) {
284
297
  if (this.hasConfig && this.isChange) {
285
- this.form = this.flattenObject(val)
298
+ let form = this.flattenObject(val)
299
+ this.form = Object.assign(this.form, form)
286
300
  }
287
301
  },
288
302
  deep: true
@@ -344,7 +358,8 @@ export default {
344
358
  })
345
359
 
346
360
  if (this.hasValue) {
347
- this.form = this.flattenObject(this.modelValue)
361
+ let form = this.flattenObject(this.modelValue)
362
+ this.form = Object.assign(this.form, form)
348
363
  }
349
364
  },
350
365
  flattenObject(obj, prefix = '') {
@@ -428,7 +443,7 @@ export default {
428
443
  row[item.name] = row[item.name] || []
429
444
  row[item.name].push(this.tagValue)
430
445
  }
431
- this.tagVisible = false
446
+ this.tagVisible[item.name] = false
432
447
  this.tagValue = ''
433
448
  }
434
449
  }
@@ -1,7 +1,31 @@
1
1
  <template>
2
2
  <div class="lw-upload"
3
- :class="{ 'lw-upload-round': round }"
4
- :style="style">
3
+ :class="{ 'lw-upload-round': round }">
4
+
5
+ <template v-for="(f, index) in fileList">
6
+ <div class="lw-upload__img"
7
+ :style="style">
8
+ <el-image class="image"
9
+ :src="f"
10
+ :preview-src-list="fileList"
11
+ fit="cover"
12
+ hide-on-click-modal
13
+ append-to-body
14
+ :z-index="9999">
15
+ <template #placeholder>
16
+ <div class="lw-upload__img-slot">
17
+ Loading...
18
+ </div>
19
+ </template>
20
+ </el-image>
21
+ <div class="lw-upload__img-actions"
22
+ v-if="!disabled">
23
+ <span class="del"
24
+ @click="handleRemove(index)"><el-icon><el-icon-delete /></el-icon></span>
25
+ </div>
26
+ </div>
27
+ </template>
28
+
5
29
  <div v-if="file && file.status != 'success'"
6
30
  class="lw-upload__uploading">
7
31
  <div class="lw-upload__progress">
@@ -13,29 +37,10 @@
13
37
  :src="file.tempFile"
14
38
  fit="cover"></el-image>
15
39
  </div>
16
- <div v-if="file && file.status == 'success'"
17
- class="lw-upload__img">
18
- <el-image class="image"
19
- :src="file.url"
20
- :preview-src-list="[file.url]"
21
- fit="cover"
22
- hide-on-click-modal
23
- append-to-body
24
- :z-index="9999">
25
- <template #placeholder>
26
- <div class="lw-upload__img-slot">
27
- Loading...
28
- </div>
29
- </template>
30
- </el-image>
31
- <div class="lw-upload__img-actions"
32
- v-if="!disabled">
33
- <span class="del"
34
- @click="handleRemove()"><el-icon><el-icon-delete /></el-icon></span>
35
- </div>
36
- </div>
37
- <el-upload v-if="!file"
40
+
41
+ <el-upload v-if="fileList.length < limit"
38
42
  class="uploader"
43
+ :style="style"
39
44
  ref="uploader"
40
45
  :auto-upload="autoUpload"
41
46
  :disabled="disabled"
@@ -44,7 +49,7 @@
44
49
  :name="name"
45
50
  :data="data"
46
51
  :accept="accept"
47
- :limit="1"
52
+ :limit="limit"
48
53
  :http-request="request"
49
54
  :on-change="change"
50
55
  :before-upload="before"
@@ -61,9 +66,8 @@
61
66
  </div>
62
67
  </div>
63
68
  </slot>
69
+ <template #tip>{{ tip }}</template>
64
70
  </el-upload>
65
- <span style="display:none!important"><el-input v-model="value"></el-input></span>
66
-
67
71
  </div>
68
72
  </template>
69
73
 
@@ -87,14 +91,16 @@ export default {
87
91
  * @property {Boolean} showFileList - 是否显示已上传文件列表,默认为 false
88
92
  * @property {Boolean} disabled - 是否禁用上传功能,默认为 false
89
93
  * @property {Boolean} round - 是否显示圆角按钮,默认为 false
94
+ * @property {Boolean} multiple - 是否多个文件,默认为 false
90
95
  * @property {Function} onSuccess - 上传成功后的回调函数,默认为空函数
91
96
  * @property {Function} parseData - 解析上传响应数据的函数,默认为解析状态码、文件名、图片远程地址和描述字段
92
97
  */
93
98
  props: {
94
- modelValue: { type: String, default: "" },
99
+ modelValue: { type: [String, Array], default: "" },
95
100
  height: { type: Number, default: 148 },
96
101
  width: { type: Number, default: 148 },
97
102
  title: { type: String, default: "" },
103
+ tip: { type: String, default: "" },
98
104
  icon: { type: String, default: "el-icon-plus" },
99
105
  action: { type: String, default: () => { } },
100
106
  apiObj: { type: Object, default: () => { } },
@@ -105,6 +111,7 @@ export default {
105
111
  limit: { type: Number, default: 1 },
106
112
  autoUpload: { type: Boolean, default: true },
107
113
  showFileList: { type: Boolean, default: false },
114
+ multiple: { type: Boolean, default: false },
108
115
  disabled: { type: Boolean, default: false },
109
116
  round: { type: Boolean, default: false },
110
117
  onSuccess: { type: Function, default: () => { return true } },
@@ -124,6 +131,7 @@ export default {
124
131
  return {
125
132
  value: "",
126
133
  file: null,
134
+ fileList: [],
127
135
  style: {
128
136
  width: this.width + "px",
129
137
  height: this.height + "px"
@@ -156,7 +164,10 @@ export default {
156
164
  this.file = null
157
165
  }
158
166
  },
159
- handleRemove() {
167
+ handleRemove(index) {
168
+ if (this.multiple) {
169
+ this.fileList.splice(index, 1)
170
+ }
160
171
  this.clearFiles()
161
172
  },
162
173
  clearFiles() {
@@ -224,9 +235,16 @@ export default {
224
235
  })
225
236
  return false
226
237
  }
227
- var response = this.parseData(res,file)
238
+ var response = this.parseData(res, file)
228
239
  file.url = response.src
229
- this.value = file.url
240
+ console.log(this.fileList)
241
+ this.fileList.push(file.url)
242
+ if (this.multiple) {
243
+ this.value = this.fileList
244
+ } else {
245
+ this.value = file.url
246
+ }
247
+
230
248
  },
231
249
  error(err) {
232
250
  this.$nextTick(() => {
@@ -264,135 +282,150 @@ export default {
264
282
  }
265
283
  </script>
266
284
 
267
- <style lwoped>
268
- .el-form-item.is-error .lw-upload .el-upload--picture-card {
269
- border-color: var(--el-color-danger);
270
- }
271
-
272
- .lw-upload .el-upload--picture-card {
273
- border-radius: 0;
285
+ <style lang="scss" scoped>
286
+ // 表单错误状态样式
287
+ .el-form-item.is-error {
288
+ .lw-upload {
289
+ .el-upload--picture-card {
290
+ border-color: var(--el-color-danger);
291
+ }
292
+ }
274
293
  }
275
294
 
276
- .lw-upload .uploader,
277
- .lw-upload:deep(.el-upload) {
295
+ // 上传组件通用样式
296
+ .lw-upload {
297
+ display: flex;
298
+ gap: 10px;
278
299
  width: 100%;
279
- height: 100%;
280
- }
300
+ flex-wrap: wrap;
301
+ justify-content: left;
302
+ .el-upload--picture-card {
303
+ border-radius: 0;
304
+ }
281
305
 
282
- .lw-upload__img {
283
- width: 100%;
284
- height: 100%;
285
- position: relative;
286
- }
306
+ .uploader,
307
+ :deep(.el-upload) {
308
+ width: 100%;
309
+ height: 100%;
310
+ }
287
311
 
288
- .lw-upload__img .image {
289
- width: 100%;
290
- height: 100%;
291
- }
312
+ &__img {
313
+ width: 100%;
314
+ height: 100%;
315
+ position: relative;
292
316
 
293
- .lw-upload__img-actions {
294
- position: absolute;
295
- top: 0;
296
- right: 0;
297
- display: none;
298
- }
317
+ .image {
318
+ width: 100%;
319
+ height: 100%;
320
+ }
299
321
 
300
- .lw-upload__img-actions span {
301
- display: flex;
302
- justify-content: center;
303
- align-items: center;
304
- width: 25px;
305
- height: 25px;
306
- cursor: pointer;
307
- color: #fff;
308
- }
322
+ &-actions {
323
+ position: absolute;
324
+ top: 0;
325
+ right: 0;
326
+ display: none;
309
327
 
310
- .lw-upload__img-actions span i {
311
- font-size: 12px;
312
- }
328
+ span {
329
+ display: flex;
330
+ justify-content: center;
331
+ align-items: center;
332
+ width: 25px;
333
+ height: 25px;
334
+ cursor: pointer;
335
+ color: #fff;
313
336
 
314
- .lw-upload__img-actions .del {
315
- background: #f56c6c;
316
- }
337
+ i {
338
+ font-size: 12px;
339
+ }
317
340
 
318
- .lw-upload__img:hover .lw-upload__img-actions {
319
- display: block;
320
- }
341
+ &.del {
342
+ background: #f56c6c;
343
+ }
344
+ }
345
+ }
321
346
 
322
- .lw-upload__img-slot {
323
- display: flex;
324
- justify-content: center;
325
- align-items: center;
326
- width: 100%;
327
- height: 100%;
328
- font-size: 12px;
329
- background-color: var(--el-fill-color-lighter);
330
- }
347
+ &:hover {
348
+ &-actions {
349
+ display: block;
350
+ }
351
+ }
352
+ }
331
353
 
332
- .lw-upload__uploading {
333
- width: 100%;
334
- height: 100%;
335
- position: relative;
336
- }
354
+ &__img-slot {
355
+ display: flex;
356
+ justify-content: center;
357
+ align-items: center;
358
+ width: 100%;
359
+ height: 100%;
360
+ font-size: 12px;
361
+ background-color: var(--el-fill-color-lighter);
362
+ }
337
363
 
338
- .lw-upload__progress {
339
- position: absolute;
340
- width: 100%;
341
- height: 100%;
342
- display: flex;
343
- justify-content: center;
344
- align-items: center;
345
- background-color: var(--el-overlay-color-lighter);
346
- z-index: 1;
347
- padding: 10px;
348
- }
364
+ &__uploading {
365
+ width: 100%;
366
+ height: 100%;
367
+ position: relative;
349
368
 
350
- .lw-upload__progress .el-progress {
351
- width: 100%;
352
- }
369
+ .image {
370
+ width: 100%;
371
+ height: 100%;
372
+ }
353
373
 
354
- .lw-upload__uploading .image {
355
- width: 100%;
356
- height: 100%;
357
- }
374
+ &__progress {
375
+ position: absolute;
376
+ width: 100%;
377
+ height: 100%;
378
+ display: flex;
379
+ justify-content: center;
380
+ align-items: center;
381
+ background-color: var(--el-overlay-color-lighter);
382
+ z-index: 1;
383
+ padding: 10px;
358
384
 
359
- .lw-upload .file-empty {
360
- width: 100%;
361
- height: 100%;
362
- display: flex;
363
- justify-content: center;
364
- align-items: center;
365
- flex-direction: column;
366
- }
385
+ .el-progress {
386
+ width: 100%;
387
+ }
388
+ }
389
+ }
367
390
 
368
- .lw-upload .file-empty i {
369
- font-size: 28px;
370
- }
391
+ .file-empty {
392
+ width: 100%;
393
+ height: 100%;
394
+ display: flex;
395
+ justify-content: center;
396
+ align-items: center;
397
+ flex-direction: column;
371
398
 
372
- .lw-upload .file-empty h4 {
373
- font-size: 12px;
374
- font-weight: normal;
375
- color: #8c939d;
376
- margin-top: 8px;
377
- }
399
+ i {
400
+ font-size: 28px;
401
+ }
378
402
 
379
- .lw-upload.lw-upload-round {
380
- border-radius: 50%;
381
- overflow: hidden;
382
- }
403
+ h4 {
404
+ font-size: 12px;
405
+ font-weight: normal;
406
+ color: #8c939d;
407
+ margin-top: 8px;
408
+ }
409
+ }
383
410
 
384
- .lw-upload.lw-upload-round .el-upload--picture-card {
385
- border-radius: 50%;
386
- }
411
+ &.lw-upload-round {
412
+ border-radius: 50%;
413
+ overflow: hidden;
387
414
 
388
- .lw-upload.lw-upload-round .lw-upload__img-actions {
389
- top: auto;
390
- left: 0;
391
- right: 0;
392
- bottom: 0;
393
- }
415
+ .el-upload--picture-card {
416
+ border-radius: 50%;
417
+ }
394
418
 
395
- .lw-upload.lw-upload-round .lw-upload__img-actions span {
396
- width: 100%;
419
+ .lw-upload__img-actions {
420
+ top: auto;
421
+ left: 0;
422
+ right: 0;
423
+ bottom: 0;
424
+
425
+ span {
426
+ width: 100%;
427
+ }
428
+ }
429
+ }
397
430
  }
398
431
  </style>