lw-cdp-ui 1.1.71 → 1.2.2

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.
@@ -1,25 +1,59 @@
1
1
  <template>
2
-
3
2
  <draggable :list="formItems"
4
3
  item-key="name"
5
4
  group="people"
6
- ghost-class="draggable-ghost"
5
+ :disabled="!hideBorder"
7
6
  class="draggable-item"
8
- :class="{ cur: formItems.name == curIndex }">
7
+ ghost-class="draggable-ghost"
8
+ :class="{ showBorder: hideBorder, cur: curIndex == (formItems.name || formItems?.options?.items[0]?.name) }">
9
9
  <template #item="{element: item, index}">
10
- <el-col :span="item.span || 24"
11
- :class="{ borderItem: !isBorder, cur: item.name == curIndex }"
10
+ <el-col :span="['list'].includes(item.component) ? 24 : item.span || 24"
11
+ :class="{ borderItem: hideBorder, cur: hideBorder && curIndex == (item.name || item?.options?.items[0]?.name) }"
12
12
  v-if="!hideHandle(item)">
13
13
  <!-- 组合/列表 -->
14
- <template v-if="['object', 'list'].includes(item.component)">
14
+ <template v-if="['object'].includes(item.component)">
15
15
  <el-form-item :label="item.label"
16
- class="padding-item"
17
- @click.capture="changeClick(item)"
18
- :class="{ borderItem: !isBorder }">
16
+ @click.capture="changeClick(item)">
19
17
  <JsonItem :formItems="item.value"
20
- :form="form"
18
+ :form="form[item.name]"
19
+ class="object-item"
20
+ :hideBorder="hideBorder"
21
21
  @curClick="changeClick"></JsonItem>
22
22
  </el-form-item>
23
+
24
+ </template>
25
+ <!-- 列表 显示时 -->
26
+ <template v-else-if="['list'].includes(item.component)">
27
+ <el-form-item @click.capture="changeClick(item)">
28
+ <template #label>
29
+ {{ item.label }}
30
+ <el-button v-if="!hideBorder"
31
+ type="primary"
32
+ class="add-btn"
33
+ plain
34
+ size="small"
35
+ icon="el-icon-plus"
36
+ @click="addListItem(item.value)">{{ $t('btn.add') }}</el-button>
37
+ </template>
38
+ <el-col :span="item.span || 24"
39
+ v-for="(x, xIndex) in item.value">
40
+ <div class="list-item"
41
+ :class="{borderItem: hideBorder}">
42
+ <JsonItem v-if="form[item.name]"
43
+ :formItems="x"
44
+ :form="form[item.name][xIndex]"
45
+ :hideBorder="hideBorder"
46
+ @curClick="changeClick"></JsonItem>
47
+ <el-icon class="remove-btn"
48
+ size="14"
49
+ v-if="!hideBorder && item.value.length > 1"
50
+ @click="deleteListItem(item.value, xIndex)"><el-icon-delete /></el-icon>
51
+ </div>
52
+
53
+ </el-col>
54
+
55
+ </el-form-item>
56
+
23
57
  </template>
24
58
  <FormItem v-else
25
59
  :item="item"
@@ -30,14 +64,21 @@
30
64
  v-slot:[item.component]>
31
65
  <slot :name="item.component"
32
66
  :itemCur="item"
33
- :formCur="form">
34
- <el-tag type="danger">
35
- [{{ item.component }}]
36
- 没有这个默认组件也未自定义插槽内容
37
- </el-tag>
38
- </slot>
67
+ :formCur="form"></slot>
39
68
  </template>
40
69
  </FormItem>
70
+
71
+ <!-- 工具 -->
72
+ <div v-if="hideBorder && curIndex == (item.name || item?.options?.items[0]?.name)"
73
+ class="tool-list">
74
+ <el-icon class="btn"
75
+ size="14"
76
+ @click="copyItem(item, index)"><el-icon-copy-document /></el-icon>
77
+ <el-icon class="btn"
78
+ size="14"
79
+ @click="deleteItem(index)"><el-icon-delete /></el-icon>
80
+ </div>
81
+
41
82
  </el-col>
42
83
  </template>
43
84
  </draggable>
@@ -62,7 +103,7 @@ export default {
62
103
  default: () => { }
63
104
  },
64
105
  // 是否是显示边界
65
- isBorder: { type: Boolean, default: false }
106
+ hideBorder: { type: Boolean, default: true }
66
107
  },
67
108
  computed: {
68
109
  curIndex() {
@@ -82,8 +123,28 @@ export default {
82
123
  return false
83
124
  },
84
125
  changeClick(item) {
85
- this.$store.state.curIndex = item.name
126
+ this.$store.state.curIndex = item.name || item?.options.items[0]?.name
86
127
  this.$emit('curClick', item)
128
+ },
129
+ // 列表删除
130
+ deleteListItem(list, index) {
131
+ list.splice(index, 1)
132
+ },
133
+ // 列表新增
134
+ addListItem(list) {
135
+ let item = list[0]
136
+ let x = JSON.parse(JSON.stringify(item))
137
+ list.push(x)
138
+ },
139
+ // 删除
140
+ deleteItem(index) {
141
+ this.formItems.splice(index, 1)
142
+ },
143
+ // 复制
144
+ copyItem(item, index) {
145
+ let x = JSON.parse(JSON.stringify(item))
146
+ x.name = `${item.component}-${this.$tool.getUUID('', 2)}`
147
+ this.formItems.splice(index + 1, 0, x)
87
148
  }
88
149
  }
89
150
  }
@@ -95,8 +156,7 @@ export default {
95
156
  min-height: 40px;
96
157
  display: flex;
97
158
  flex-wrap: wrap;
98
- border: 1px dashed var(--el-border-color-light);
99
- background-color: rgba($color: #000000, $alpha: 0.01);
159
+
100
160
  > div {
101
161
  .title-name {
102
162
  margin-top: 0;
@@ -107,17 +167,33 @@ export default {
107
167
  }
108
168
  }
109
169
  }
170
+ &.showBorder {
171
+ border: 1px dashed var(--el-border-color-light);
172
+ background-color: rgba($color: #000000, $alpha: 0.01);
173
+ }
110
174
  }
111
- .padding-item {
175
+ .object-item {
112
176
  padding: 10px;
113
- background-color: rgba($color: #000000, $alpha: 0.01);
177
+ background-color: rgba($color: #000000, $alpha: 0.03);
114
178
  }
115
179
 
116
180
  :deep(.el-col) {
117
181
  border: 1px dashed transparent;
118
182
  }
119
- :deep(.cur) {
120
- border: 1px dashed var(--el-color-primary) !important;
183
+
184
+ .list-item {
185
+ width: 100%;
186
+ padding: 10px;
187
+ background-color: rgba($color: #000000, $alpha: 0.03);
188
+ margin-bottom: 10px;
189
+ position: relative;
190
+ .remove-btn {
191
+ position: absolute;
192
+ top: 10px;
193
+ right: 10px;
194
+ color: var(--el-color-primary);
195
+ cursor: pointer;
196
+ }
121
197
  }
122
198
 
123
199
  .borderItem {
@@ -125,10 +201,36 @@ export default {
125
201
  box-sizing: border-box;
126
202
  padding: 10px;
127
203
  cursor: move;
204
+ position: relative;
128
205
  &:hover {
129
206
  border: 1px dashed var(--el-border-color);
130
207
  background-color: rgba($color: #000000, $alpha: 0.01);
131
208
  }
209
+
210
+ .tool-list {
211
+ display: none;
212
+ }
213
+ }
214
+ :deep(.cur) {
215
+ border: 1px dashed var(--el-color-primary) !important;
216
+ .tool-list {
217
+ position: absolute;
218
+ bottom: 0;
219
+ right: 0;
220
+ display: block;
221
+ border-top-left-radius: 10px;
222
+ z-index: 8;
223
+ background-color: var(--el-color-primary);
224
+ color: #fff;
225
+ display: flex;
226
+ gap: 10px;
227
+ padding: 2px 10px;
228
+ .btn {
229
+ cursor: pointer;
230
+ width: 20px;
231
+ height: 20px;
232
+ }
233
+ }
132
234
  }
133
235
 
134
236
  :deep(.draggable-ghost) {
@@ -137,4 +239,25 @@ export default {
137
239
  padding: 10px;
138
240
  width: 100%;
139
241
  }
242
+ :deep(.el-form-item) {
243
+ position: relative;
244
+ }
245
+ .add-btn {
246
+ top: 0px;
247
+ right: 0;
248
+ z-index: 9;
249
+ position: absolute;
250
+ }
251
+ :deep(.el-form-item--label-right),:deep(.el-form-item--label-left) {
252
+ .el-form-item__label {
253
+ position: relative;
254
+ .add-btn {
255
+ top: 30px;
256
+ right: 10px;
257
+ // left: 0;
258
+ // z-index: 9;
259
+ // position: absolute;
260
+ }
261
+ }
262
+ }
140
263
  </style>