leisure-core 0.5.36 → 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 +62 -11
- package/package.json +1 -1
|
@@ -103,6 +103,10 @@ export default {
|
|
|
103
103
|
type: String,
|
|
104
104
|
default: "16px",
|
|
105
105
|
},
|
|
106
|
+
externalComponentMap: {
|
|
107
|
+
type: Object,
|
|
108
|
+
default: () => ({}),
|
|
109
|
+
},
|
|
106
110
|
},
|
|
107
111
|
watch: {
|
|
108
112
|
formData: {
|
|
@@ -125,7 +129,43 @@ export default {
|
|
|
125
129
|
},
|
|
126
130
|
data() {
|
|
127
131
|
return {
|
|
128
|
-
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 = {
|
|
129
169
|
input: {
|
|
130
170
|
component: "le-input",
|
|
131
171
|
props: { placeholder: "请输入" },
|
|
@@ -154,12 +194,9 @@ export default {
|
|
|
154
194
|
component: "le-area",
|
|
155
195
|
props: {},
|
|
156
196
|
},
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
};
|
|
161
|
-
},
|
|
162
|
-
computed: {
|
|
197
|
+
};
|
|
198
|
+
return { ...baseMap, ...this.externalComponentMap };
|
|
199
|
+
},
|
|
163
200
|
gridStyle() {
|
|
164
201
|
return {
|
|
165
202
|
"grid-template-columns": `repeat(${this.columnsPerRow}, 1fr)`,
|
|
@@ -171,19 +208,33 @@ export default {
|
|
|
171
208
|
mounted() {},
|
|
172
209
|
methods: {
|
|
173
210
|
componentType(type) {
|
|
174
|
-
let result = this.componentMap[type]?.component || "le-input";
|
|
175
|
-
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";
|
|
176
221
|
},
|
|
177
222
|
getComponentProps(item) {
|
|
178
223
|
let type = item.type;
|
|
179
|
-
|
|
224
|
+
|
|
225
|
+
// 如果组件类型未定义,返回空对象
|
|
226
|
+
if (!this.dynamicComponentMap[type]) {
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let props = this.dynamicComponentMap[type]?.props || {};
|
|
180
231
|
if (type === "image") {
|
|
181
232
|
let images = [];
|
|
182
233
|
images.push(this.formPop[item.prop]);
|
|
183
234
|
props = { ...props, images: images };
|
|
184
235
|
return props;
|
|
185
236
|
}
|
|
186
|
-
return this.
|
|
237
|
+
return this.dynamicComponentMap[item.type]?.props || {};
|
|
187
238
|
},
|
|
188
239
|
mergeProps(defaultProps, customProps) {
|
|
189
240
|
return { ...defaultProps, ...customProps };
|