lw-cdp-ui 1.3.3 → 1.3.5

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.
@@ -2,8 +2,8 @@
2
2
  <!-- 间隔标题 -->
3
3
  <div v-if="item.component == 'divider'"
4
4
  class="title-name title-name-divider"
5
- :id="'divider-' + index"
6
- :data-index="index">
5
+ :id="'divider-' + item.label"
6
+ :data-index="item.label">
7
7
  <span>
8
8
  {{ item.label }}
9
9
  <el-tooltip v-if="item.tips"
@@ -384,35 +384,6 @@ export default {
384
384
 
385
385
 
386
386
  <style lang="scss" scoped>
387
- :deep(.el-col) {
388
- &:first-child {
389
- .title-name {
390
- border: 0;
391
- padding-top: 25px;
392
- margin-top: 0;
393
- }
394
- }
395
- }
396
-
397
- .title-name {
398
- font-size: 18px;
399
- font-weight: bold;
400
- margin-bottom: 10px;
401
- margin-top: 25px;
402
- border-top: 10px solid #f5f7fa;
403
- padding-top: 20px;
404
- }
405
-
406
- .form-mini {
407
- display: flex;
408
- width: 100%;
409
- box-sizing: border-box;
410
- }
411
- .form-affix {
412
- min-width: 130px;
413
- padding-left: 20px;
414
- }
415
-
416
387
  .w-20 {
417
388
  width: 100px;
418
389
  }
@@ -422,48 +393,7 @@ export default {
422
393
  display: none !important;
423
394
  }
424
395
  }
425
- .affix-body {
426
- background-color: var(--el-fill-color-light);
427
- border: 1px solid var(--el-border-color-light);
428
- margin: 0;
429
- position: relative;
430
- &::after {
431
- content: "";
432
- position: absolute;
433
- left: -2px;
434
- right: 0;
435
- height: 16px;
436
- background-color: #ffffff;
437
- top: -17px;
438
- }
439
- .anchor-link {
440
- padding: 0 20px;
441
- height: var(--el-tabs-header-height);
442
- box-sizing: border-box;
443
- list-style: none;
444
- font-size: var(--el-font-size-base);
445
- font-weight: bold;
446
- color: var(--el-text-color-secondary);
447
- position: relative;
448
- height: 40px;
449
- display: inline-block;
450
- line-height: 40px;
451
- cursor: pointer;
452
- border-left: 1px solid transparent;
453
- border-right: 1px solid transparent;
454
- }
455
- .active {
456
- color: var(--el-color-primary);
457
- background-color: var(--el-bg-color-overlay);
458
- border-bottom: 1px solid var(--el-bg-color-overlay);
459
- border-right-color: var(--el-border-color);
460
- border-left: 1px solid var(--el-border-color-light);
461
- border-right: 1px solid var(--el-border-color-light);
462
- &:first-child {
463
- border-left: 1px solid var(--el-fill-color-light);
464
- }
465
- }
466
- }
396
+
467
397
 
468
398
  :deep(.el-tag) {
469
399
  & + .button-new-tag {
@@ -299,38 +299,6 @@ export default {
299
299
 
300
300
 
301
301
  <style lang="scss" scoped>
302
- :deep(.el-col) {
303
- &:first-child {
304
- .title-name {
305
- border: 0;
306
- padding-top: 25px;
307
- margin-top: 0;
308
- }
309
- }
310
- }
311
-
312
- .title-name {
313
- font-size: 18px;
314
- font-weight: bold;
315
- margin-bottom: 10px;
316
- margin-top: 25px;
317
- border-top: 10px solid #f5f7fa;
318
- padding-top: 20px;
319
- display: flex;
320
- align-items: center;
321
- justify-content: space-between;
322
- }
323
-
324
- .form-mini {
325
- display: flex;
326
- width: 100%;
327
- box-sizing: border-box;
328
- }
329
- .form-affix {
330
- min-width: 130px;
331
- padding-left: 20px;
332
- }
333
-
334
302
  .w-20 {
335
303
  width: 100px;
336
304
  }
@@ -340,48 +308,6 @@ export default {
340
308
  display: none !important;
341
309
  }
342
310
  }
343
- .affix-body {
344
- background-color: var(--el-fill-color-light);
345
- border: 1px solid var(--el-border-color-light);
346
- margin: 0;
347
- position: relative;
348
- &::after {
349
- content: "";
350
- position: absolute;
351
- left: -2px;
352
- right: 0;
353
- height: 16px;
354
- background-color: #ffffff;
355
- top: -17px;
356
- }
357
- .anchor-link {
358
- padding: 0 20px;
359
- height: var(--el-tabs-header-height);
360
- box-sizing: border-box;
361
- list-style: none;
362
- font-size: var(--el-font-size-base);
363
- font-weight: bold;
364
- color: var(--el-text-color-secondary);
365
- position: relative;
366
- height: 40px;
367
- display: inline-block;
368
- line-height: 40px;
369
- cursor: pointer;
370
- border-left: 1px solid transparent;
371
- border-right: 1px solid transparent;
372
- }
373
- .active {
374
- color: var(--el-color-primary);
375
- background-color: var(--el-bg-color-overlay);
376
- border-bottom: 1px solid var(--el-bg-color-overlay);
377
- border-right-color: var(--el-border-color);
378
- border-left: 1px solid var(--el-border-color-light);
379
- border-right: 1px solid var(--el-border-color-light);
380
- &:first-child {
381
- border-left: 1px solid var(--el-fill-color-light);
382
- }
383
- }
384
- }
385
311
 
386
312
  :deep(.el-tag) {
387
313
  & + .button-new-tag {
@@ -7,8 +7,8 @@
7
7
  :key="index">
8
8
  <a v-if="item.component === 'divider'"
9
9
  class="anchor-link"
10
- :class="{active: affixIndex == index}"
11
- @click="clickAffix(index)">
10
+ :class="{active: affixIndex == item.label}"
11
+ @click="clickAffix(item.label)">
12
12
  {{ item.label }}
13
13
  </a>
14
14
  </template>
@@ -20,68 +20,68 @@
20
20
 
21
21
  <el-form v-else
22
22
  ref="form"
23
+ class="lw-form-mini"
23
24
  :model="form"
24
25
  :label-width="config.labelWidth"
25
26
  :label-position="$i18n.locale == 'en-us' ? 'top' : config.labelPosition"
26
27
  v-loading="loading"
27
28
  :size="config?.size || 'default'"
28
29
  element-loading-text="Loading...">
29
- <el-row :gutter="15">
30
+ <div class="lw-form-mini-card"
31
+ v-for="card in formItems">
32
+ <el-row :gutter="15">
33
+ <template v-for="(item, index) in card">
34
+ <el-col :span="item.span || 24"
35
+ v-if="!hideHandle(item)">
36
+ <ViewItem v-if="isView && !item?.options?.isInput"
37
+ :item="item"
38
+ :form="form"
39
+ :index="index">
40
+ <!-- 没有组件是component值 就是插槽名称 -->
41
+ <template v-if="!['input', 'upload', 'checkbox', 'checkboxGroup', 'switch', 'select', 'treeSelect', 'cascader', 'date', 'number', 'radio', 'color', 'rate', 'slider','tags', 'divider'].includes(item.component)"
42
+ v-slot:[item.component]>
43
+ <slot :name="item.component"
44
+ :itemCur="item"
45
+ :formCur="form">
46
+ <el-tag type="danger">[{{ item.component }}]
47
+ 没有这个默认组件也未自定义插槽内容</el-tag>
48
+ </slot>
49
+ </template>
50
+ <template v-if="item?.options?.component"
51
+ v-slot:[item?.options?.component]>
52
+ <slot :name="item?.options?.component"></slot>
53
+ </template>
30
54
 
31
- <template v-for="(item, index) in config.formItems">
32
- <el-col :span="item.span || 24"
33
- v-if="!hideHandle(item)">
34
- <ViewItem v-if="isView && !item?.options?.isInput"
35
- :item="item"
36
- :form="form"
37
- :index="index">
38
- <!-- 没有组件是component值 就是插槽名称 -->
39
- <template v-if="!['input', 'upload', 'checkbox', 'checkboxGroup', 'switch', 'select', 'treeSelect', 'cascader', 'date', 'number', 'radio', 'color', 'rate', 'slider','tags', 'divider'].includes(item.component)"
40
- v-slot:[item.component]>
41
- <slot :name="item.component"
42
- :itemCur="item"
43
- :formCur="form">
44
- <el-tag type="danger">[{{ item.component }}]
45
- 没有这个默认组件也未自定义插槽内容</el-tag>
46
- </slot>
47
- </template>
48
- <template v-if="item?.options?.component"
49
- v-slot:[item?.options?.component]>
50
- <slot :name="item?.options?.component"></slot>
51
- </template>
52
-
53
- </ViewItem>
54
- <FormItem v-else
55
- :item="item"
56
- :form="form"
57
- :index="index">
58
- <!-- 没有组件是component值 就是插槽名称 -->
59
- <template v-if="!['input', 'upload', 'checkbox', 'checkboxGroup', 'switch', 'select', 'treeSelect', 'cascader', 'date', 'number', 'radio', 'color', 'rate', 'slider','tags', 'divider'].includes(item.component)"
60
- v-slot:[item.component]>
61
- <slot :name="item.component"
62
- :itemCur="item"
63
- :formCur="form">
64
- <el-tag type="danger">[{{ item.component }}]
65
- 没有这个默认组件也未自定义插槽内容</el-tag>
66
- </slot>
67
- </template>
68
- <template v-if="item?.options?.component"
69
- v-slot:[item?.options?.component]>
70
- <slot :name="item?.options?.component"></slot>
71
- </template>
72
- </FormItem>
73
- </el-col>
74
- </template>
75
- <el-col v-if="!isView"
76
- :span="24">
77
- <el-form-item>
78
- <slot>
79
- <el-button type="primary"
80
- @click="submit">提交</el-button>
81
- </slot>
82
- </el-form-item>
83
- </el-col>
84
- </el-row>
55
+ </ViewItem>
56
+ <FormItem v-else
57
+ :item="item"
58
+ :form="form"
59
+ :index="index">
60
+ <!-- 没有组件是component值 就是插槽名称 -->
61
+ <template v-if="!['input', 'upload', 'checkbox', 'checkboxGroup', 'switch', 'select', 'treeSelect', 'cascader', 'date', 'number', 'radio', 'color', 'rate', 'slider','tags', 'divider'].includes(item.component)"
62
+ v-slot:[item.component]>
63
+ <slot :name="item.component"
64
+ :itemCur="item"
65
+ :formCur="form">
66
+ <el-tag type="danger">[{{ item.component }}]
67
+ 没有这个默认组件也未自定义插槽内容</el-tag>
68
+ </slot>
69
+ </template>
70
+ <template v-if="item?.options?.component"
71
+ v-slot:[item?.options?.component]>
72
+ <slot :name="item?.options?.component"></slot>
73
+ </template>
74
+ </FormItem>
75
+ </el-col>
76
+ </template>
77
+ </el-row>
78
+ </div>
79
+ <el-form-item v-if="!isView">
80
+ <slot>
81
+ <el-button type="primary"
82
+ @click="submit">提交</el-button>
83
+ </slot>
84
+ </el-form-item>
85
85
  </el-form>
86
86
  </template>
87
87
 
@@ -138,7 +138,7 @@ export default {
138
138
  data() {
139
139
  return {
140
140
  form: {},
141
- affixIndex: 0,
141
+ affixIndex: '',
142
142
  isChange: true,
143
143
  scrollObserverEnabled: true,
144
144
  renderLoading: false
@@ -174,15 +174,38 @@ export default {
174
174
  hasValue() {
175
175
  return Object.keys(this.modelValue).length > 0
176
176
  },
177
+ formItems() {
178
+ const result = [];
179
+ let currentGroup = [];
180
+
181
+ this.config.formItems.forEach(item => {
182
+ if (item.component === "divider") {
183
+ if (!this.affixIndex) {
184
+ this.affixIndex = item.label
185
+ }
186
+
187
+ if (currentGroup.length) {
188
+ result.push(currentGroup);
189
+ currentGroup = [];
190
+ }
191
+ currentGroup.push(item);
192
+ } else {
193
+ currentGroup.push(item);
194
+ }
195
+ });
196
+
197
+ if (currentGroup.length) {
198
+ result.push(currentGroup);
199
+ }
177
200
 
201
+ return result;
202
+ }
178
203
  },
179
204
  mounted() {
180
205
  if (this.hasConfig) {
181
206
  this.render()
182
207
  }
183
208
  },
184
- beforeDestroy() {
185
- },
186
209
  methods: {
187
210
  /**
188
211
  * 渲染表单数据。
@@ -318,6 +341,7 @@ export default {
318
341
  if (distanceFromTop >= 0 && distanceFromTop <= 100 && _this.scrollObserverEnabled) {
319
342
  const dataIndex = entry.target.getAttribute('data-index');
320
343
  _this.affixIndex = dataIndex; // 更新 affixIndex
344
+ console.log(dataIndex)
321
345
  }
322
346
  }, {
323
347
  root: elMain, // 设置根元素为 el-main
@@ -333,16 +357,6 @@ export default {
333
357
  }
334
358
  </script>
335
359
  <style lang="scss" scoped>
336
- :deep(.el-col) {
337
- &:first-child {
338
- .title-name {
339
- border: 0;
340
- padding-top: 25px;
341
- margin-top: 0;
342
- }
343
- }
344
- }
345
-
346
360
  .form-mini {
347
361
  display: flex;
348
362
  width: 100%;
@@ -361,60 +375,9 @@ export default {
361
375
  margin-left: 10px;
362
376
  }
363
377
 
364
- .title-name {
365
- font-size: 18px;
366
- font-weight: bold;
367
- margin-bottom: 10px;
368
- margin-top: 25px;
369
- border-top: 10px solid #f5f7fa;
370
- padding-top: 20px;
371
- }
372
-
373
378
  :deep(.form-item-name-null) {
374
379
  > .el-form-item__label {
375
380
  display: none !important;
376
381
  }
377
382
  }
378
- .affix-body {
379
- background-color: var(--el-fill-color-light);
380
- border: 1px solid var(--el-border-color-light);
381
- margin: 0;
382
- position: relative;
383
- &::after {
384
- content: "";
385
- position: absolute;
386
- left: -2px;
387
- right: 0;
388
- height: 16px;
389
- background-color: #ffffff;
390
- top: -17px;
391
- }
392
- .anchor-link {
393
- padding: 0 20px;
394
- height: var(--el-tabs-header-height);
395
- box-sizing: border-box;
396
- list-style: none;
397
- font-size: var(--el-font-size-base);
398
- font-weight: bold;
399
- color: var(--el-text-color-secondary);
400
- position: relative;
401
- height: 40px;
402
- display: inline-block;
403
- line-height: 40px;
404
- cursor: pointer;
405
- border-left: 1px solid transparent;
406
- border-right: 1px solid transparent;
407
- }
408
- .active {
409
- color: var(--el-color-primary);
410
- background-color: var(--el-bg-color-overlay);
411
- border-bottom: 1px solid var(--el-bg-color-overlay);
412
- border-right-color: var(--el-border-color);
413
- border-left: 1px solid var(--el-border-color-light);
414
- border-right: 1px solid var(--el-border-color-light);
415
- &:first-child {
416
- border-left: 1px solid var(--el-fill-color-light);
417
- }
418
- }
419
- }
420
383
  </style>