lw-cdp-ui 1.2.28 → 1.2.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.
@@ -2,25 +2,24 @@
2
2
  <draggable :list="formItems"
3
3
  item-key="name"
4
4
  group="people"
5
- :disabled="!hideBorder"
5
+ :disabled="hideBorder"
6
6
  class="draggable-item"
7
7
  ghost-class="draggable-ghost"
8
- :class="{ showBorder: hideBorder, cur: curIndex == (formItems.name || formItems?.options?.items[0]?.name) }">
8
+ :class="{ showBorder: !hideBorder, cur: curIndex == (`${this.uuid}${formItems.name || formItems?.options?.items[0]?.name}`) }">
9
9
  <template #item="{element: item, index}">
10
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) }"
11
+ :class="{ borderItem: !hideBorder, cur: !hideBorder && curIndex == (`${this.uuid}${item.name || item?.options?.items[0]?.name}`) }"
12
12
  v-if="!hideHandle(item)"
13
- @click.capture="changeClick(item)">
13
+ @click.stop="changeClick(item)">
14
14
  <!-- 组合 -->
15
15
  <template v-if="['object'].includes(item.component)">
16
- <el-form-item :label="item.label"
17
- @click.capture="changeClick(item)">
16
+ <el-form-item :label="item.label">
18
17
  <JsonItem :formItems="item.value"
19
18
  :form="form[item.name]"
20
19
  class="object-item"
21
20
  :custom="custom"
22
21
  :hideBorder="hideBorder"
23
- @curClick="changeClick">
22
+ @curClick="emitClick">
24
23
  <template v-for="c in custom"
25
24
  v-slot:[c.component]="{ itemCur, formCur }">
26
25
  <slot :name="c.component"
@@ -33,10 +32,10 @@
33
32
  </template>
34
33
  <!-- 列表 显示时 -->
35
34
  <template v-else-if="['list'].includes(item.component)">
36
- <el-form-item @click.capture="changeClick(item)">
35
+ <el-form-item>
37
36
  <template #label>
38
37
  {{ item.label }}
39
- <el-button v-if="!hideBorder"
38
+ <el-button v-if="hideBorder"
40
39
  type="primary"
41
40
  class="add-btn"
42
41
  plain
@@ -47,13 +46,13 @@
47
46
  <el-col :span="item.span || 24"
48
47
  v-for="(x, xIndex) in item.value">
49
48
  <div class="list-item"
50
- :class="{borderItem: hideBorder}">
49
+ :class="{borderItem: !hideBorder}">
51
50
  <JsonItem v-if="form[item.name]"
52
51
  :formItems="x"
53
52
  :custom="custom"
54
53
  :form="form[item.name][xIndex]"
55
54
  :hideBorder="hideBorder"
56
- @curClick="changeClick">
55
+ @curClick="emitClick">
57
56
  <template v-for="c in custom"
58
57
  v-slot:[c.component]="{ itemCur, formCur }">
59
58
  <slot :name="c.component"
@@ -63,7 +62,7 @@
63
62
  </JsonItem>
64
63
  <el-icon class="remove-btn"
65
64
  size="14"
66
- v-if="!hideBorder && item.value.length > 1"
65
+ v-if="hideBorder && item.value.length > 1"
67
66
  @click="deleteListItem(item.value, xIndex)"><el-icon-delete /></el-icon>
68
67
  </div>
69
68
 
@@ -83,9 +82,8 @@
83
82
  :formCur="form"></slot>
84
83
  </template>
85
84
  </FormItem>
86
-
87
85
  <!-- 工具 -->
88
- <div v-if="hideBorder && curIndex == (item.name || item?.options?.items[0]?.name)"
86
+ <div v-if="!hideBorder && curIndex == (`${this.uuid}${item.name || item?.options?.items[0]?.name}`)"
89
87
  class="tool-list">
90
88
  <el-icon class="btn"
91
89
  size="14"
@@ -107,6 +105,11 @@ import FormItem from '../lwFormMini/FormItem'
107
105
  import draggable from 'vuedraggable'
108
106
  export default {
109
107
  name: 'JsonItem',
108
+ data() {
109
+ return {
110
+ uuid: this.$tool.getUUID('', 12)
111
+ }
112
+ },
110
113
  components: {
111
114
  FormItem,
112
115
  draggable
@@ -121,7 +124,7 @@ export default {
121
124
  default: () => { }
122
125
  },
123
126
  // 是否是显示边界
124
- hideBorder: { type: Boolean, default: true },
127
+ hideBorder: { type: Boolean, default: false },
125
128
  // 自定义组件
126
129
  custom: { type: Array, default: () => [] },
127
130
  },
@@ -143,7 +146,10 @@ export default {
143
146
  return false
144
147
  },
145
148
  changeClick(item) {
146
- this.$store.state.curIndex = item.name || item?.options.items[0]?.name
149
+ this.$store.state.curIndex = `${this.uuid}${item.name || item?.options.items[0]?.name}`
150
+ this.emitClick(item)
151
+ },
152
+ emitClick(item) {
147
153
  this.$emit('curClick', item)
148
154
  },
149
155
  // 列表删除
@@ -538,6 +538,7 @@ export default {
538
538
  .input-body {
539
539
  display: flex;
540
540
  align-items: center;
541
+ gap: 5px;
541
542
  }
542
543
  }
543
544
  </style>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <el-container :style="{ maxHeight }">
3
- <el-aside v-if="hideTool"
3
+ <el-aside v-if="!hideModule"
4
4
  width="200px"
5
5
  class="form-json-body">
6
6
  <div class="menu-list">
@@ -15,7 +15,7 @@
15
15
  :clone="cloneItem"
16
16
  item-key="name">
17
17
  <template #item="{ element }">
18
- <div class="list-group-item">
18
+ <div v-if="!element?.hide" class="list-group-item">
19
19
  {{ element.label }}
20
20
  </div>
21
21
  </template>
@@ -56,7 +56,7 @@
56
56
  </el-main>
57
57
  </el-container>
58
58
 
59
- <el-aside v-if="hideTool"
59
+ <el-aside v-if="!hideConfig"
60
60
  width="300px"
61
61
  class="aside-right">
62
62
  <StatsConfig :item="curItem"
@@ -115,14 +115,19 @@ export default {
115
115
  maxHeight: { type: String, default: 'calc(100vh - 137px)' },
116
116
  // 自定义组件
117
117
  custom: { type: Array, default: () => [] },
118
+ customTitle: { type: String, default: '自定义组件' },
118
119
  // 是否显示加载中
119
120
  loading: { type: Boolean, default: false },
120
- // 是否显示工具
121
+ // 隐藏工具、组件、属性
121
122
  hideTool: { type: Boolean, default: true },
123
+ hideModule: { type: Boolean, default: false },
124
+ hideConfig: { type: Boolean, default: false },
122
125
  // 是否是查看模式
123
126
  isView: { type: Boolean, default: false },
124
- // 是否是显示边界
125
- hideBorder: { type: Boolean, default: true }
127
+ // 隐藏边界
128
+ hideBorder: { type: Boolean, default: false },
129
+ // 隐藏默认组件
130
+ hideDefault: { type: Boolean, default: false }
126
131
  },
127
132
  data() {
128
133
  return {
@@ -154,23 +159,29 @@ export default {
154
159
  },
155
160
  custom: {
156
161
  handler(val) {
157
- this.menuList = []
158
- if (val && val.length > 0) {
159
- let menuIndex = MenuList.findIndex((item) => {
160
- return item.title == '自定义组件'
161
- })
162
+ // 初始化菜单列表
163
+ this.menuList = this.hideDefault ? [] : [...MenuList];
162
164
 
163
- if (menuIndex > -1) {
164
- MenuList[menuIndex].list = val
165
+ // 如果有自定义组件
166
+ if (val.length) {
167
+
168
+ // 查找现有的自定义组件菜单
169
+ const existingCustomMenu = this.menuList.find(item => item.title === this.customTitle);
170
+
171
+ if (existingCustomMenu) {
172
+ // 更新现有的自定义组件列表
173
+ existingCustomMenu.list = val;
165
174
  } else {
166
- let custom = {
167
- title: '自定义组件',
175
+ // 添加新的自定义组件菜单
176
+ this.menuList.push({
177
+ title: this.customTitle,
168
178
  list: val
169
- }
170
- MenuList.push(custom)
179
+ });
171
180
  }
172
181
  }
173
- this.menuList = MenuList
182
+
183
+ // 设置默认激活的菜单
184
+ this.activeNames = this.menuList[0]?.title ?? '';
174
185
  },
175
186
  immediate: true,
176
187
  deep: true