lw-cdp-ui 1.2.4 → 1.2.6

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.
@@ -73,10 +73,12 @@
73
73
  class="tool-list">
74
74
  <el-icon class="btn"
75
75
  size="14"
76
- @click="copyItem(item, index)"><el-icon-copy-document /></el-icon>
76
+ @click="copyItem(item, index)"
77
+ title="复制"><el-icon-copy-document /></el-icon>
77
78
  <el-icon class="btn"
78
79
  size="14"
79
- @click="deleteItem(index)"><el-icon-delete /></el-icon>
80
+ @click="deleteItem(index)"
81
+ title="删除"><el-icon-delete /></el-icon>
80
82
  </div>
81
83
 
82
84
  </el-col>
@@ -248,7 +250,8 @@ export default {
248
250
  z-index: 9;
249
251
  position: absolute;
250
252
  }
251
- :deep(.el-form-item--label-right),:deep(.el-form-item--label-left) {
253
+ :deep(.el-form-item--label-right),
254
+ :deep(.el-form-item--label-left) {
252
255
  .el-form-item__label {
253
256
  position: relative;
254
257
  .add-btn {
@@ -304,6 +304,26 @@
304
304
  </template>
305
305
 
306
306
  </div>
307
+
308
+ <div class="form-title">表单校验</div>
309
+ <div class="form-body">
310
+ <el-form-item label="提交校验">
311
+ <el-select v-model="item.rules"
312
+ multiple
313
+ clearable
314
+ placeholder="请选择">
315
+ <el-option v-for="item in rules"
316
+ :label="item.label"
317
+ :value="item.value" />
318
+ </el-select>
319
+ </el-form-item>
320
+ <el-form-item label="隐藏校验">
321
+ <el-input v-model="item.hideHandle"
322
+ placeholder="请输入"
323
+ clearable />
324
+ </el-form-item>
325
+
326
+ </div>
307
327
  </template>
308
328
  <template v-else>
309
329
  <div class="form-title">表单样式</div>
@@ -336,7 +356,17 @@ export default {
336
356
  data() {
337
357
  return {
338
358
  tagVisible: {},
339
- tagValue: ''
359
+ tagValue: '',
360
+ rules: [
361
+ {
362
+ label: '必填',
363
+ value: { required: true, message: '请输入', trigger: 'blur' }
364
+ },
365
+ {
366
+ label: '必选',
367
+ value: { required: true, message: '请选择', trigger: 'change' }
368
+ },
369
+ ]
340
370
  }
341
371
  },
342
372
  props: {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <el-container>
2
+ <el-container :style="{ maxHeight }">
3
3
  <el-aside v-if="hideTool"
4
4
  width="200px"
5
5
  class="form-json-body">
@@ -108,7 +108,9 @@ export default {
108
108
  * ...
109
109
  * }
110
110
  * **/
111
- config: { type: Object, default: () => { } },
111
+ config: { type: Object, default: () => { return {} } },
112
+ // 最大高度
113
+ maxHeight: { type: String, default: 'calc(100vh - 137px)' },
112
114
  // 自定义组件
113
115
  custom: { type: Array, default: () => [] },
114
116
  // 是否显示加载中
@@ -141,17 +143,13 @@ export default {
141
143
  deep: true
142
144
  },
143
145
  config: {
144
- handler() {
146
+ handler(val) {
145
147
  this.render()
148
+ this.localConfig = JSON.parse(JSON.stringify(val))
146
149
  },
150
+ immediate: true,
147
151
  deep: true
148
152
  },
149
- // form: {
150
- // handler(val) {
151
- // this.$emit("update:modelValue", val)
152
- // },
153
- // deep: true
154
- // },
155
153
  localConfig: {
156
154
  handler(val) {
157
155
  this.render(val)
@@ -240,13 +238,12 @@ export default {
240
238
  }
241
239
 
242
240
  let form = parse(config.formItems, this.modelValue);
243
- this.form = {
241
+ form = {
244
242
  ...this.modelValue,
245
243
  ...form
246
244
  }
247
-
248
- this.$emit("update:modelValue", this.parseNestedObject(this.form));
249
- this.localConfig = this.config;
245
+ this.form = this.parseNestedObject(form)
246
+ this.$emit("update:modelValue", this.form);
250
247
  },
251
248
  parseNestedObject(obj) {
252
249
  const result = {};
@@ -261,7 +258,10 @@ export default {
261
258
  current = current[k];
262
259
  });
263
260
 
264
- delete obj[key]
261
+ if (keys.length > 1) {
262
+ delete obj[key]
263
+ }
264
+
265
265
  }
266
266
  return result;
267
267
  },
@@ -306,6 +306,9 @@ export default {
306
306
 
307
307
  <style lang="scss" scoped>
308
308
  .menu-list {
309
+ :deep(.el-collapse) {
310
+ border-top: 0;
311
+ }
309
312
  .menu-list-title {
310
313
  :deep(.el-collapse-item__header) {
311
314
  font-weight: bold;
@@ -279,6 +279,7 @@ export default {
279
279
  },
280
280
  methods: {
281
281
  flattenObject(obj, key, defaultValue = '') {
282
+ console.log(obj, key)
282
283
  if (!key || !obj) { return false }
283
284
  const keys = key.split('.'); // 将路径拆分成数组
284
285
 
@@ -296,6 +297,7 @@ export default {
296
297
  return current;
297
298
  },
298
299
  unflattenObject(obj, path, value) {
300
+ if (!path || !obj) { return false }
299
301
  const keys = path.split('.'); // 按点分隔路径
300
302
  let current = obj; // 指向传入的对象(如 this.form)
301
303
 
@@ -127,14 +127,16 @@ export default {
127
127
  deep: true
128
128
  },
129
129
  config: {
130
- handler() {
130
+ handler(val) {
131
131
  this.render()
132
132
  if (this.showMenu) {
133
133
  this.$nextTick(() => {
134
134
  this.handleScroll()
135
135
  })
136
136
  }
137
+ this.localConfig = JSON.parse(JSON.stringify(val))
137
138
  },
139
+ immediate: true,
138
140
  deep: true
139
141
  },
140
142
  localConfig: {
@@ -207,14 +209,12 @@ export default {
207
209
  }
208
210
 
209
211
  let form = parse(config.formItems, this.modelValue);
210
-
211
- this.form = {
212
+ form = {
212
213
  ...this.modelValue,
213
214
  ...form
214
215
  }
215
-
216
- this.$emit("update:modelValue", this.parseNestedObject(this.form));
217
- this.localConfig = this.config;
216
+ this.form = this.parseNestedObject(form)
217
+ this.$emit("update:modelValue", this.form);
218
218
  },
219
219
 
220
220
  parseNestedObject(obj) {
@@ -31,6 +31,26 @@
31
31
  :sortable="t.sortable"
32
32
  :show-overflow-tooltip="t.tooltip"
33
33
  :key="t">
34
+ <template #header="{ column, $index }">
35
+ <template v-if="!t?.header">
36
+ {{ t.title }}
37
+ <el-tooltip v-if="t.tips">
38
+ <template #content>
39
+ <span style="max-width: 300px; display: inline-block;">
40
+ {{ t.tips }}
41
+ </span>
42
+ </template>
43
+ <el-icon><component :is="t.icon || 'el-icon-question-filled'" /></el-icon>
44
+ </el-tooltip>
45
+ </template>
46
+ <slot v-else
47
+ :name="t.header"
48
+ :scope="{column, $index, t}">
49
+ <el-tag type="danger">
50
+ [{{ item.header }}]没有这个自定义表头
51
+ </el-tag>
52
+ </slot>
53
+ </template>
34
54
  <template #default="scope">
35
55
  <!-- 操作 -->
36
56
  <template v-if="t?.operation">