lw-cdp-ui 1.2.2 → 1.2.4

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.
@@ -146,12 +146,12 @@ export default {
146
146
  },
147
147
  deep: true
148
148
  },
149
- form: {
150
- handler(val) {
151
- this.$emit("update:modelValue", val)
152
- },
153
- deep: true
154
- },
149
+ // form: {
150
+ // handler(val) {
151
+ // this.$emit("update:modelValue", val)
152
+ // },
153
+ // deep: true
154
+ // },
155
155
  localConfig: {
156
156
  handler(val) {
157
157
  this.render(val)
@@ -239,10 +239,32 @@ export default {
239
239
  return result;
240
240
  }
241
241
 
242
- this.form = parse(config.formItems, this.modelValue);
243
- this.$emit("update:modelValue", this.form);
242
+ let form = parse(config.formItems, this.modelValue);
243
+ this.form = {
244
+ ...this.modelValue,
245
+ ...form
246
+ }
247
+
248
+ this.$emit("update:modelValue", this.parseNestedObject(this.form));
244
249
  this.localConfig = this.config;
245
250
  },
251
+ parseNestedObject(obj) {
252
+ const result = {};
253
+ for (const [key, value] of Object.entries(obj)) {
254
+ const keys = key.split('.');
255
+ let current = result;
256
+
257
+ keys.forEach((k, index) => {
258
+ if (!current[k]) {
259
+ current[k] = index === keys.length - 1 ? value : {};
260
+ }
261
+ current = current[k];
262
+ });
263
+
264
+ delete obj[key]
265
+ }
266
+ return result;
267
+ },
246
268
 
247
269
  //数据验证
248
270
  validate(valid, obj) {
@@ -268,10 +268,10 @@ export default {
268
268
  handler(val) {
269
269
  if (val.component === 'checkbox' || val.component === 'upload') {
270
270
  val.options?.items?.forEach((option) => {
271
- this.unflattenObject(this.form, option.name, option[option.name])
271
+ this.unflattenObject(this.form, option.name, option.value)
272
272
  });
273
273
  } else {
274
- this.unflattenObject(this.form, this.item.name, val[this.item.name])
274
+ this.unflattenObject(this.form, this.item.name, val.value)
275
275
  }
276
276
  },
277
277
  deep: true
@@ -281,6 +281,7 @@ export default {
281
281
  flattenObject(obj, key, defaultValue = '') {
282
282
  if (!key || !obj) { return false }
283
283
  const keys = key.split('.'); // 将路径拆分成数组
284
+
284
285
  let current = obj;
285
286
  // 遍历路径并逐层查找
286
287
  for (let i = 0; i < keys.length; i++) {
@@ -291,7 +292,7 @@ export default {
291
292
  // 否则,继续向下查找
292
293
  current = current[keys[i]];
293
294
  }
294
-
295
+
295
296
  return current;
296
297
  },
297
298
  unflattenObject(obj, path, value) {
@@ -310,6 +311,8 @@ export default {
310
311
  current = current[key]; // 进入下一层
311
312
  }
312
313
  });
314
+
315
+
313
316
  },
314
317
  // 删除tag
315
318
  tagClose(tag, item) {
@@ -437,11 +440,11 @@ export default {
437
440
  }
438
441
  }
439
442
 
440
- :deep(.el-tag){
441
- &+.button-new-tag{
443
+ :deep(.el-tag) {
444
+ & + .button-new-tag {
442
445
  margin-left: 10px;
443
446
  }
444
- &+.w-20{
447
+ & + .w-20 {
445
448
  margin-left: 10px;
446
449
  }
447
450
  }
@@ -135,20 +135,12 @@ export default {
135
135
  })
136
136
  }
137
137
  },
138
- immediate: true,
139
- deep: true
140
- },
141
- form: {
142
- handler(val) {
143
- this.$emit("update:modelValue", val)
144
- },
145
138
  deep: true
146
139
  },
147
140
  localConfig: {
148
141
  handler(val) {
149
142
  this.render(val)
150
143
  this.$emit("update:config", val)
151
-
152
144
  },
153
145
  deep: true
154
146
  },
@@ -206,6 +198,7 @@ export default {
206
198
  result[item.name] = existingValue ?? (item.value !== undefined ? Number(item.value) : item.options?.min || 0);
207
199
  } else {
208
200
  result[item.name] = existingValue ?? item.value;
201
+
209
202
  }
210
203
  }
211
204
  });
@@ -213,10 +206,35 @@ export default {
213
206
  return result;
214
207
  }
215
208
 
216
- this.form = parse(config.formItems, this.modelValue);
217
- this.$emit("update:modelValue", this.form);
209
+ let form = parse(config.formItems, this.modelValue);
210
+
211
+ this.form = {
212
+ ...this.modelValue,
213
+ ...form
214
+ }
215
+
216
+ this.$emit("update:modelValue", this.parseNestedObject(this.form));
218
217
  this.localConfig = this.config;
219
218
  },
219
+
220
+ parseNestedObject(obj) {
221
+ const result = {};
222
+ for (const [key, value] of Object.entries(obj)) {
223
+ const keys = key.split('.');
224
+ let current = result;
225
+
226
+ keys.forEach((k, index) => {
227
+ if (!current[k]) {
228
+ current[k] = index === keys.length - 1 ? value : {};
229
+ }
230
+ current = current[k];
231
+ });
232
+
233
+ delete obj[key]
234
+ }
235
+ return result;
236
+ },
237
+
220
238
  //处理动态隐藏
221
239
  hideHandle(item) {
222
240
  if (typeof item?.hideHandle === 'string') {
@@ -1,23 +1,23 @@
1
1
  <template>
2
2
  <div class="adminui-tags">
3
- <ul ref="tags">
4
- <draggable v-model="$store.state.viewTags.viewTags"
5
- @change="changeTages"
6
- itemKey="name">
7
- <template #item="{element: tag, index}" keyName="tag">
8
- <li v-bind:key="tag"
9
- :class="[isActive(tag)?'active':'',tag.meta.affix?'affix':'' ]"
10
- @contextmenu.prevent="openContextMenu($event, tag)">
11
- <router-link :to="tag">
12
- <span>{{ getIdName(tag) }}</span>
13
- <el-icon v-if="!tag.meta.affix"
14
- @click.prevent.stop='closeSelectedTag(tag)'><el-icon-close /></el-icon>
15
- </router-link>
16
- </li>
17
- </template>
18
- </draggable>
19
-
20
- </ul>
3
+ <draggable v-model="$store.state.viewTags.viewTags"
4
+ @change="changeTages"
5
+ class="context-menu-list"
6
+ ref="tags"
7
+ itemKey="name">
8
+ <template #item="{element: tag, index}"
9
+ keyName="tag">
10
+ <li v-bind:key="tag"
11
+ :class="[isActive(tag)?'active':'',tag.meta.affix?'affix':'' ]"
12
+ @contextmenu.prevent="openContextMenu($event, tag)">
13
+ <router-link :to="tag">
14
+ <span>{{ getIdName(tag) }}</span>
15
+ <el-icon v-if="!tag.meta.affix"
16
+ @click.prevent.stop='closeSelectedTag(tag)'><el-icon-close /></el-icon>
17
+ </router-link>
18
+ </li>
19
+ </template>
20
+ </draggable>
21
21
  </div>
22
22
 
23
23
  <transition name="el-zoom-in-top">
@@ -90,19 +90,6 @@ export default {
90
90
  },
91
91
  $route(e) {
92
92
  this.addViewTags(e);
93
- //判断标签容器是否出现滚动条
94
- this.$nextTick(() => {
95
- const tags = this.$refs.tags
96
- if (tags && tags.scrollWidth > tags.clientWidth) {
97
- //确保当前标签在可视范围内
98
- let targetTag = tags.querySelector(".active")
99
- targetTag.scrollIntoView()
100
- //显示提示
101
- if (!this.tipDisplayed) {
102
- this.tipVisible = true
103
- }
104
- }
105
- })
106
93
  },
107
94
  contextMenuVisible(value) {
108
95
  var _this = this;
@@ -157,7 +144,7 @@ export default {
157
144
  return null
158
145
  },
159
146
  // 拖动排序
160
- changeTages (val) {
147
+ changeTages(val) {
161
148
  this.$tool.data.set('RouteTags', this.$store.state.viewTags.viewTags)
162
149
  },
163
150
  //增加tag
@@ -169,6 +156,20 @@ export default {
169
156
  this.$store.commit("pushKeepLive", route.name)
170
157
  this.$tool.data.set('RouteTags', this.$store.state.viewTags.viewTags)
171
158
  }
159
+
160
+ //判断标签容器是否出现滚动条
161
+ this.$nextTick(() => {
162
+ const tags = document.querySelector(".context-menu-list")
163
+ if (tags && tags.scrollWidth > tags.clientWidth) {
164
+ //确保当前标签在可视范围内
165
+ let targetTag = tags.querySelector(".active")
166
+ targetTag.scrollIntoView()
167
+ //显示提示
168
+ if (!this.tipDisplayed) {
169
+ this.tipVisible = true
170
+ }
171
+ }
172
+ })
172
173
  },
173
174
  //高亮tag
174
175
  isActive(route) {
@@ -289,7 +290,7 @@ export default {
289
290
  },
290
291
  //横向滚动
291
292
  scrollInit() {
292
- const scrollDiv = this.$refs.tags;
293
+ const scrollDiv = document.querySelector('.context-menu-list')
293
294
  scrollDiv.addEventListener('mousewheel', handler, false) || scrollDiv.addEventListener("DOMMouseScroll", handler, false)
294
295
  function handler(event) {
295
296
  const detail = event.wheelDelta || event.detail;
@@ -383,8 +384,4 @@ export default {
383
384
  .tags-tip p {
384
385
  margin-bottom: 10px;
385
386
  }
386
-
387
- .dark .contextmenu li {
388
- color: var(--el-text-color-primary);
389
- }
390
387
  </style>