leisure-core 0.5.35 → 0.5.37
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.
- package/le-list-form/src/main.vue +63 -11
- package/package.json +1 -1
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
v-bind="mergeProps(getComponentProps(item), item.attr || {})"
|
|
22
22
|
v-on="item.event"
|
|
23
23
|
class="compontClass"
|
|
24
|
+
:key="`component-${index}-${item.prop}-${item.type}`"
|
|
24
25
|
>
|
|
25
26
|
<template v-if="item.type === 'radio'">
|
|
26
27
|
<el-radio
|
|
@@ -102,6 +103,10 @@ export default {
|
|
|
102
103
|
type: String,
|
|
103
104
|
default: "16px",
|
|
104
105
|
},
|
|
106
|
+
externalComponentMap: {
|
|
107
|
+
type: Object,
|
|
108
|
+
default: () => ({}),
|
|
109
|
+
},
|
|
105
110
|
},
|
|
106
111
|
watch: {
|
|
107
112
|
formData: {
|
|
@@ -124,7 +129,43 @@ export default {
|
|
|
124
129
|
},
|
|
125
130
|
data() {
|
|
126
131
|
return {
|
|
127
|
-
componentMap: {
|
|
132
|
+
// componentMap: {
|
|
133
|
+
// input: {
|
|
134
|
+
// component: "le-input",
|
|
135
|
+
// props: { placeholder: "请输入" },
|
|
136
|
+
// },
|
|
137
|
+
// number: {
|
|
138
|
+
// component: "le-input-number",
|
|
139
|
+
// props: {},
|
|
140
|
+
// },
|
|
141
|
+
// radio: { component: "el-radio-group", props: {} },
|
|
142
|
+
// money: {
|
|
143
|
+
// component: "le-input-advanced",
|
|
144
|
+
// props: {},
|
|
145
|
+
// },
|
|
146
|
+
// date: {
|
|
147
|
+
// component: "le-date-picker",
|
|
148
|
+
// props: {
|
|
149
|
+
// format: "yyyy-MM-dd",
|
|
150
|
+
// "value-format": "timestamp",
|
|
151
|
+
// translateDate: true,
|
|
152
|
+
// },
|
|
153
|
+
// },
|
|
154
|
+
// select: { component: "le-select", props: {} },
|
|
155
|
+
// smulti: { component: "le-select-multi", props: {} },
|
|
156
|
+
// image: { component: "le-image-container", props: {} },
|
|
157
|
+
// area: {
|
|
158
|
+
// component: "le-area",
|
|
159
|
+
// props: {},
|
|
160
|
+
// },
|
|
161
|
+
// },
|
|
162
|
+
formPop: {},
|
|
163
|
+
options: {}, //{field1:[{value:1,label:'选项1'},{value:2,label:'选项2'}]}
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
computed: {
|
|
167
|
+
dynamicComponentMap() {
|
|
168
|
+
const baseMap = {
|
|
128
169
|
input: {
|
|
129
170
|
component: "le-input",
|
|
130
171
|
props: { placeholder: "请输入" },
|
|
@@ -153,12 +194,9 @@ export default {
|
|
|
153
194
|
component: "le-area",
|
|
154
195
|
props: {},
|
|
155
196
|
},
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
computed: {
|
|
197
|
+
};
|
|
198
|
+
return { ...baseMap, ...this.externalComponentMap };
|
|
199
|
+
},
|
|
162
200
|
gridStyle() {
|
|
163
201
|
return {
|
|
164
202
|
"grid-template-columns": `repeat(${this.columnsPerRow}, 1fr)`,
|
|
@@ -170,19 +208,33 @@ export default {
|
|
|
170
208
|
mounted() {},
|
|
171
209
|
methods: {
|
|
172
210
|
componentType(type) {
|
|
173
|
-
let result = this.componentMap[type]?.component || "le-input";
|
|
174
|
-
return result;
|
|
211
|
+
// let result = this.componentMap[type]?.component || "le-input";
|
|
212
|
+
// return result;
|
|
213
|
+
|
|
214
|
+
if (!this.dynamicComponentMap[type]) {
|
|
215
|
+
console.warn(
|
|
216
|
+
`组件类型 "${type}" 未在 componentMap 中定义,将使用默认输入框`
|
|
217
|
+
);
|
|
218
|
+
return "le-input";
|
|
219
|
+
}
|
|
220
|
+
return this.dynamicComponentMap[type]?.component || "le-input";
|
|
175
221
|
},
|
|
176
222
|
getComponentProps(item) {
|
|
177
223
|
let type = item.type;
|
|
178
|
-
|
|
224
|
+
|
|
225
|
+
// 如果组件类型未定义,返回空对象
|
|
226
|
+
if (!this.dynamicComponentMap[type]) {
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let props = this.dynamicComponentMap[type]?.props || {};
|
|
179
231
|
if (type === "image") {
|
|
180
232
|
let images = [];
|
|
181
233
|
images.push(this.formPop[item.prop]);
|
|
182
234
|
props = { ...props, images: images };
|
|
183
235
|
return props;
|
|
184
236
|
}
|
|
185
|
-
return this.
|
|
237
|
+
return this.dynamicComponentMap[item.type]?.props || {};
|
|
186
238
|
},
|
|
187
239
|
mergeProps(defaultProps, customProps) {
|
|
188
240
|
return { ...defaultProps, ...customProps };
|