@tmagic/form 1.2.0-beta.2 → 1.2.0-beta.21
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/dist/style.css +1 -1
- package/dist/tmagic-form.js +3673 -0
- package/dist/tmagic-form.js.map +1 -0
- package/dist/tmagic-form.umd.cjs +3713 -0
- package/dist/tmagic-form.umd.cjs.map +1 -0
- package/package.json +10 -9
- package/src/Form.vue +124 -159
- package/src/FormDialog.vue +108 -126
- package/src/containers/Col.vue +24 -38
- package/src/containers/Container.vue +143 -171
- package/src/containers/Fieldset.vue +15 -8
- package/src/containers/GroupList.vue +86 -116
- package/src/containers/GroupListItem.vue +91 -125
- package/src/containers/Panel.vue +29 -49
- package/src/containers/Row.vue +20 -40
- package/src/containers/Step.vue +38 -48
- package/src/containers/Table.vue +466 -481
- package/src/containers/Tabs.vue +94 -118
- package/src/fields/Cascader.vue +88 -136
- package/src/fields/Checkbox.vue +46 -50
- package/src/fields/CheckboxGroup.vue +39 -35
- package/src/fields/ColorPicker.vue +5 -3
- package/src/fields/Date.vue +21 -27
- package/src/fields/DateTime.vue +31 -39
- package/src/fields/Daterange.vue +4 -3
- package/src/fields/Display.vue +1 -1
- package/src/fields/DynamicField.vue +63 -77
- package/src/fields/Hidden.vue +1 -1
- package/src/fields/Link.vue +65 -86
- package/src/fields/Number.vue +32 -34
- package/src/fields/RadioGroup.vue +23 -23
- package/src/fields/Select.vue +294 -310
- package/src/fields/SelectOptionGroups.vue +11 -6
- package/src/fields/SelectOptions.vue +5 -3
- package/src/fields/Switch.vue +46 -49
- package/src/fields/Text.vue +99 -107
- package/src/fields/Textarea.vue +32 -44
- package/src/fields/Time.vue +21 -30
- package/src/index.ts +22 -23
- package/src/schema.ts +50 -12
- package/src/theme/form.scss +1 -1
- package/src/utils/form.ts +9 -5
- package/types/Form.vue.d.ts +211 -111
- package/types/FormDialog.vue.d.ts +813 -154
- package/types/containers/Col.vue.d.ts +96 -40
- package/types/containers/Container.vue.d.ts +126 -65
- package/types/containers/Fieldset.vue.d.ts +5 -3
- package/types/containers/GroupList.vue.d.ts +90 -53
- package/types/containers/GroupListItem.vue.d.ts +101 -67
- package/types/containers/Panel.vue.d.ts +96 -39
- package/types/containers/Row.vue.d.ts +96 -39
- package/types/containers/Step.vue.d.ts +106 -42
- package/types/containers/Table.vue.d.ts +161 -130
- package/types/containers/Tabs.vue.d.ts +97 -50
- package/types/fields/Cascader.vue.d.ts +95 -71
- package/types/fields/Checkbox.vue.d.ts +95 -56
- package/types/fields/CheckboxGroup.vue.d.ts +95 -53
- package/types/fields/ColorPicker.vue.d.ts +1 -3
- package/types/fields/Date.vue.d.ts +95 -54
- package/types/fields/DateTime.vue.d.ts +95 -54
- package/types/fields/Daterange.vue.d.ts +1 -3
- package/types/fields/Display.vue.d.ts +1 -3
- package/types/fields/DynamicField.vue.d.ts +95 -64
- package/types/fields/Hidden.vue.d.ts +1 -3
- package/types/fields/Link.vue.d.ts +60 -657
- package/types/fields/Number.vue.d.ts +99 -56
- package/types/fields/RadioGroup.vue.d.ts +96 -52
- package/types/fields/Select.vue.d.ts +97 -65
- package/types/fields/SelectOptionGroups.vue.d.ts +1 -3
- package/types/fields/SelectOptions.vue.d.ts +1 -3
- package/types/fields/Switch.vue.d.ts +95 -56
- package/types/fields/Text.vue.d.ts +98 -57
- package/types/fields/Textarea.vue.d.ts +100 -60
- package/types/fields/Time.vue.d.ts +95 -55
- package/types/index.d.ts +0 -1
- package/types/schema.d.ts +42 -9
- package/types/utils/form.d.ts +2 -1
- package/dist/tmagic-form.mjs +0 -3925
- package/dist/tmagic-form.mjs.map +0 -1
- package/dist/tmagic-form.umd.js +0 -3965
- package/dist/tmagic-form.umd.js.map +0 -1
- package/src/utils/fieldProps.ts +0 -39
- package/types/utils/fieldProps.d.ts +0 -21
|
@@ -0,0 +1,3713 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('@tmagic/design'), require('lodash-es'), require('sortablejs'), require('@tmagic/utils'), require('lodash-es/cloneDeep'), require('lodash-es/isEqual')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', '@tmagic/design', 'lodash-es', 'sortablejs', '@tmagic/utils', 'lodash-es/cloneDeep', 'lodash-es/isEqual'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicForm = {}, global.Vue, global.iconsVue, global.design, global.lodashEs, global.Sortable, global.utils, global.cloneDeep, global.isEqual));
|
|
5
|
+
})(this, (function (exports, vue, iconsVue, design, lodashEs, Sortable, utils, cloneDeep, isEqual) { 'use strict';
|
|
6
|
+
|
|
7
|
+
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
|
8
|
+
|
|
9
|
+
const Sortable__default = /*#__PURE__*/_interopDefaultLegacy(Sortable);
|
|
10
|
+
const cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
11
|
+
const isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
12
|
+
|
|
13
|
+
const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
|
|
14
|
+
const asyncLoadConfig = (value, initValue2, { asyncLoad, name, type }) => {
|
|
15
|
+
if (type === "html" && typeof asyncLoad === "object" && typeof name !== "undefined") {
|
|
16
|
+
asyncLoad.name = name;
|
|
17
|
+
value.asyncLoad = typeof initValue2.asyncLoad === "object" ? initValue2.asyncLoad : asyncLoad;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const isMultipleValue = (type) => typeof type === "string" && ["checkbox-group", "checkboxGroup", "table", "cascader", "group-list", "groupList"].includes(type);
|
|
21
|
+
const initItemsValue = (mForm, value, initValue2, { items, name, extensible }) => {
|
|
22
|
+
if (Array.isArray(initValue2[name])) {
|
|
23
|
+
value[name] = initValue2[name].map((v, index) => createValues(mForm, items, v, value[name]?.[index]));
|
|
24
|
+
} else {
|
|
25
|
+
value[name] = createValues(mForm, items, initValue2[name], value[name]);
|
|
26
|
+
if (extensible) {
|
|
27
|
+
value[name] = Object.assign({}, initValue2[name], value[name]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const setValue = (mForm, value, initValue2, item) => {
|
|
32
|
+
const { items, name, type, checkbox } = item;
|
|
33
|
+
if (isMultipleValue(type) || type === "tab" && item.dynamic) {
|
|
34
|
+
value[name] = initValue2[name] || [];
|
|
35
|
+
}
|
|
36
|
+
if (items) {
|
|
37
|
+
initItemsValue(mForm, value, initValue2, item);
|
|
38
|
+
} else {
|
|
39
|
+
value[name] = getDefaultValue(mForm, item);
|
|
40
|
+
}
|
|
41
|
+
if (type === "fieldset" && checkbox) {
|
|
42
|
+
if (typeof value[name] === "object") {
|
|
43
|
+
value[name].value = typeof initValue2[name] === "object" ? initValue2[name].value || 0 : 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const initValueItem = function(mForm, item, initValue2, value) {
|
|
48
|
+
const { items } = item;
|
|
49
|
+
const { names } = item;
|
|
50
|
+
const { type, name } = item;
|
|
51
|
+
if (isTableSelect(type) && name) {
|
|
52
|
+
value[name] = initValue2[name] || "";
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
asyncLoadConfig(value, initValue2, item);
|
|
56
|
+
if (name && !items && typeof initValue2[name] !== "undefined") {
|
|
57
|
+
if (typeof value[name] === "undefined") {
|
|
58
|
+
if (type === "number") {
|
|
59
|
+
value[name] = Number(initValue2[name]);
|
|
60
|
+
} else {
|
|
61
|
+
value[name] = typeof initValue2[name] === "object" ? lodashEs.cloneDeep(initValue2[name]) : initValue2[name];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
if (names) {
|
|
67
|
+
return names.forEach((n) => value[n] = initValue2[n] || "");
|
|
68
|
+
}
|
|
69
|
+
if (!name) {
|
|
70
|
+
return createValues(mForm, items, initValue2, value);
|
|
71
|
+
}
|
|
72
|
+
setValue(mForm, value, initValue2, item);
|
|
73
|
+
return value;
|
|
74
|
+
};
|
|
75
|
+
const createValues = function(mForm, config = [], initValue2 = {}, value = {}) {
|
|
76
|
+
if (Array.isArray(config)) {
|
|
77
|
+
config.forEach((item) => {
|
|
78
|
+
initValueItem(mForm, item, initValue2, value);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
82
|
+
};
|
|
83
|
+
const getDefaultValue = function(mForm, { defaultValue, type, filter, multiple }) {
|
|
84
|
+
if (typeof defaultValue === "function") {
|
|
85
|
+
return defaultValue(mForm);
|
|
86
|
+
}
|
|
87
|
+
if (defaultValue === "undefined") {
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
90
|
+
if (typeof defaultValue !== "undefined") {
|
|
91
|
+
return defaultValue;
|
|
92
|
+
}
|
|
93
|
+
if (type === "number" || filter === "number") {
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
if (["switch", "checkbox"].includes(type)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (multiple) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
return "";
|
|
103
|
+
};
|
|
104
|
+
const filterFunction = (mForm, config, props) => {
|
|
105
|
+
if (typeof config !== "function") {
|
|
106
|
+
return config;
|
|
107
|
+
}
|
|
108
|
+
return config(mForm, {
|
|
109
|
+
values: mForm?.initValues || {},
|
|
110
|
+
model: props.model,
|
|
111
|
+
parent: mForm?.parentValues || {},
|
|
112
|
+
formValue: mForm?.values || props.model,
|
|
113
|
+
prop: props.prop,
|
|
114
|
+
config: props.config
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
const display = function(mForm, config, props) {
|
|
118
|
+
if (config === "expand") {
|
|
119
|
+
return config;
|
|
120
|
+
}
|
|
121
|
+
if (typeof config === "function") {
|
|
122
|
+
return filterFunction(mForm, config, props);
|
|
123
|
+
}
|
|
124
|
+
if (config === false) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
};
|
|
129
|
+
const getRules = function(mForm, rules = [], props) {
|
|
130
|
+
rules = lodashEs.cloneDeep(rules);
|
|
131
|
+
if (typeof rules === "object" && !Array.isArray(rules)) {
|
|
132
|
+
rules = [rules];
|
|
133
|
+
}
|
|
134
|
+
return rules.map((item) => {
|
|
135
|
+
if (typeof item.validator === "function") {
|
|
136
|
+
const fnc = item.validator;
|
|
137
|
+
item.validator = (rule, value, callback, source, options) => fnc(
|
|
138
|
+
{
|
|
139
|
+
rule,
|
|
140
|
+
value: props.config.names ? props.model : value,
|
|
141
|
+
callback,
|
|
142
|
+
source,
|
|
143
|
+
options
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
values: mForm?.initValues || {},
|
|
147
|
+
model: props.model,
|
|
148
|
+
parent: mForm?.parentValues || {},
|
|
149
|
+
formValue: mForm?.values || props.model,
|
|
150
|
+
prop: props.prop,
|
|
151
|
+
config: props.config
|
|
152
|
+
},
|
|
153
|
+
mForm
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return item;
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
const initValue = async (mForm, { initValues, config }) => {
|
|
160
|
+
if (!Array.isArray(config))
|
|
161
|
+
throw new Error("config\u5E94\u8BE5\u4E3A\u6570\u7EC4");
|
|
162
|
+
let valuesTmp = createValues(mForm, config, vue.toRaw(initValues), {});
|
|
163
|
+
const [firstForm] = config;
|
|
164
|
+
if (firstForm && typeof firstForm.onInitValue === "function") {
|
|
165
|
+
valuesTmp = await firstForm.onInitValue(mForm, {
|
|
166
|
+
formValue: valuesTmp,
|
|
167
|
+
initValue: initValues
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return valuesTmp || {};
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const _hoisted_1$b = ["innerHTML"];
|
|
174
|
+
const _hoisted_2$7 = ["innerHTML"];
|
|
175
|
+
const _hoisted_3$7 = ["innerHTML"];
|
|
176
|
+
const _hoisted_4$6 = ["innerHTML"];
|
|
177
|
+
const _hoisted_5$4 = {
|
|
178
|
+
key: 4,
|
|
179
|
+
style: { "text-align": "center" }
|
|
180
|
+
};
|
|
181
|
+
const __default__$v = vue.defineComponent({
|
|
182
|
+
name: "MFormContainer"
|
|
183
|
+
});
|
|
184
|
+
const _sfc_main$v = /* @__PURE__ */ vue.defineComponent({
|
|
185
|
+
...__default__$v,
|
|
186
|
+
props: {
|
|
187
|
+
model: null,
|
|
188
|
+
config: null,
|
|
189
|
+
prop: { default: "" },
|
|
190
|
+
disabled: { type: Boolean },
|
|
191
|
+
labelWidth: null,
|
|
192
|
+
expandMore: { type: Boolean, default: false },
|
|
193
|
+
stepActive: null,
|
|
194
|
+
size: { default: "small" }
|
|
195
|
+
},
|
|
196
|
+
emits: ["change"],
|
|
197
|
+
setup(__props, { emit }) {
|
|
198
|
+
const props = __props;
|
|
199
|
+
const mForm = vue.inject("mForm");
|
|
200
|
+
const expand = vue.ref(false);
|
|
201
|
+
const name = vue.computed(() => props.config.name || "");
|
|
202
|
+
const items = vue.computed(() => props.config.items);
|
|
203
|
+
const itemProp = vue.computed(() => {
|
|
204
|
+
let n = "";
|
|
205
|
+
const { names } = props.config;
|
|
206
|
+
if (names?.[0]) {
|
|
207
|
+
[n] = names;
|
|
208
|
+
} else if (name.value) {
|
|
209
|
+
n = name.value;
|
|
210
|
+
} else {
|
|
211
|
+
return props.prop;
|
|
212
|
+
}
|
|
213
|
+
return `${props.prop}${props.prop ? "." : ""}${n}`;
|
|
214
|
+
});
|
|
215
|
+
const tagName = vue.computed(() => {
|
|
216
|
+
const component = vue.resolveComponent(`m-${items.value ? "form" : "fields"}-${type.value}`);
|
|
217
|
+
if (typeof component !== "string")
|
|
218
|
+
return component;
|
|
219
|
+
return "m-fields-text";
|
|
220
|
+
});
|
|
221
|
+
const disabled = vue.computed(
|
|
222
|
+
() => typeof props.disabled === "undefined" ? filterFunction(mForm, props.config.disabled, props) : props.disabled
|
|
223
|
+
);
|
|
224
|
+
const tooltip = vue.computed(() => filterFunction(mForm, props.config.tooltip, props));
|
|
225
|
+
const extra = vue.computed(() => filterFunction(mForm, props.config.extra, props));
|
|
226
|
+
const rule = vue.computed(() => getRules(mForm, props.config.rules, props));
|
|
227
|
+
const type = vue.computed(() => {
|
|
228
|
+
let { type: type2 } = props.config;
|
|
229
|
+
if (typeof type2 === "function") {
|
|
230
|
+
type2 = type2(mForm, {
|
|
231
|
+
model: props.model
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (type2 === "form")
|
|
235
|
+
return "";
|
|
236
|
+
return type2?.replace(/([A-Z])/g, "-$1").toLowerCase() || (items.value ? "" : "text");
|
|
237
|
+
});
|
|
238
|
+
const display$1 = vue.computed(() => {
|
|
239
|
+
const value = display(mForm, props.config.display, props);
|
|
240
|
+
if (value === "expand") {
|
|
241
|
+
return expand.value;
|
|
242
|
+
}
|
|
243
|
+
return value;
|
|
244
|
+
});
|
|
245
|
+
const itemLabelWidth = vue.computed(() => props.config.labelWidth || props.labelWidth);
|
|
246
|
+
vue.watchEffect(() => {
|
|
247
|
+
expand.value = props.expandMore;
|
|
248
|
+
});
|
|
249
|
+
const expandHandler = () => expand.value = !expand.value;
|
|
250
|
+
const key = (config) => config[mForm?.keyProps];
|
|
251
|
+
const filterHandler = (filter, value) => {
|
|
252
|
+
if (typeof filter === "function") {
|
|
253
|
+
return filter(mForm, value, {
|
|
254
|
+
model: props.model,
|
|
255
|
+
values: mForm?.initValues,
|
|
256
|
+
formValue: mForm?.values,
|
|
257
|
+
prop: itemProp.value,
|
|
258
|
+
config: props.config
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (filter === "number") {
|
|
262
|
+
return +value;
|
|
263
|
+
}
|
|
264
|
+
return value;
|
|
265
|
+
};
|
|
266
|
+
const changeHandler = (onChange, value) => {
|
|
267
|
+
if (typeof onChange === "function") {
|
|
268
|
+
return onChange(mForm, value, {
|
|
269
|
+
model: props.model,
|
|
270
|
+
values: mForm?.initValues,
|
|
271
|
+
formValue: mForm?.values,
|
|
272
|
+
prop: itemProp.value,
|
|
273
|
+
config: props.config
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
const trimHandler = (trim, value) => {
|
|
278
|
+
if (typeof value === "string" && trim) {
|
|
279
|
+
return value.replace(/^\s*/, "").replace(/\s*$/, "");
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
const onChangeHandler = async function(v, key2) {
|
|
283
|
+
const { filter, onChange, trim, name: name2, dynamicKey } = props.config;
|
|
284
|
+
let value = v;
|
|
285
|
+
try {
|
|
286
|
+
value = filterHandler(filter, v);
|
|
287
|
+
value = await changeHandler(onChange, value) ?? value;
|
|
288
|
+
value = trimHandler(trim, value) ?? value;
|
|
289
|
+
} catch (e) {
|
|
290
|
+
console.error(e);
|
|
291
|
+
}
|
|
292
|
+
if ((name2 || name2 === 0) && props.model !== value && (v !== value || props.model[name2] !== value)) {
|
|
293
|
+
props.model[name2] = value;
|
|
294
|
+
}
|
|
295
|
+
if (key2 !== void 0 && dynamicKey) {
|
|
296
|
+
props.model[key2] = value;
|
|
297
|
+
}
|
|
298
|
+
emit("change", props.model);
|
|
299
|
+
};
|
|
300
|
+
return (_ctx, _cache) => {
|
|
301
|
+
const _component_m_fields_hidden = vue.resolveComponent("m-fields-hidden");
|
|
302
|
+
const _component_Container = vue.resolveComponent("Container", true);
|
|
303
|
+
return __props.config ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
304
|
+
key: 0,
|
|
305
|
+
style: vue.normalizeStyle(__props.config.tip ? "display: flex;align-items: baseline;" : ""),
|
|
306
|
+
class: vue.normalizeClass([__props.config.className, "m-form-container"])
|
|
307
|
+
}, [
|
|
308
|
+
vue.unref(type) === "hidden" ? (vue.openBlock(), vue.createBlock(_component_m_fields_hidden, {
|
|
309
|
+
key: 0,
|
|
310
|
+
model: __props.model,
|
|
311
|
+
config: __props.config,
|
|
312
|
+
name: __props.config.name,
|
|
313
|
+
disabled: vue.unref(disabled),
|
|
314
|
+
prop: vue.unref(itemProp)
|
|
315
|
+
}, null, 8, ["model", "config", "name", "disabled", "prop"])) : vue.unref(items) && !__props.config.text && vue.unref(type) && vue.unref(display$1) ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(tagName)), {
|
|
316
|
+
key: key(__props.config),
|
|
317
|
+
size: __props.size,
|
|
318
|
+
model: __props.model,
|
|
319
|
+
config: __props.config,
|
|
320
|
+
disabled: vue.unref(disabled),
|
|
321
|
+
name: vue.unref(name),
|
|
322
|
+
prop: vue.unref(itemProp),
|
|
323
|
+
"step-active": __props.stepActive,
|
|
324
|
+
"expand-more": expand.value,
|
|
325
|
+
"label-width": vue.unref(itemLabelWidth),
|
|
326
|
+
onChange: onChangeHandler
|
|
327
|
+
}, null, 40, ["size", "model", "config", "disabled", "name", "prop", "step-active", "expand-more", "label-width"])) : vue.unref(type) && vue.unref(display$1) ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
328
|
+
vue.createVNode(vue.unref(design.TMagicFormItem), {
|
|
329
|
+
style: vue.normalizeStyle(__props.config.tip ? "flex: 1" : ""),
|
|
330
|
+
class: vue.normalizeClass({ hidden: `${vue.unref(itemLabelWidth)}` === "0" || !__props.config.text }),
|
|
331
|
+
prop: vue.unref(itemProp),
|
|
332
|
+
"label-width": vue.unref(itemLabelWidth),
|
|
333
|
+
rules: vue.unref(rule)
|
|
334
|
+
}, {
|
|
335
|
+
label: vue.withCtx(() => [
|
|
336
|
+
vue.createElementVNode("span", {
|
|
337
|
+
innerHTML: vue.unref(type) === "checkbox" ? "" : __props.config.text
|
|
338
|
+
}, null, 8, _hoisted_1$b)
|
|
339
|
+
]),
|
|
340
|
+
default: vue.withCtx(() => [
|
|
341
|
+
vue.unref(tooltip) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), { key: 0 }, {
|
|
342
|
+
content: vue.withCtx(() => [
|
|
343
|
+
vue.createElementVNode("div", { innerHTML: vue.unref(tooltip) }, null, 8, _hoisted_2$7)
|
|
344
|
+
]),
|
|
345
|
+
default: vue.withCtx(() => [
|
|
346
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(tagName)), {
|
|
347
|
+
key: key(__props.config),
|
|
348
|
+
size: __props.size,
|
|
349
|
+
model: __props.model,
|
|
350
|
+
config: __props.config,
|
|
351
|
+
name: vue.unref(name),
|
|
352
|
+
disabled: vue.unref(disabled),
|
|
353
|
+
prop: vue.unref(itemProp),
|
|
354
|
+
onChange: onChangeHandler
|
|
355
|
+
}, null, 40, ["size", "model", "config", "name", "disabled", "prop"]))
|
|
356
|
+
]),
|
|
357
|
+
_: 1
|
|
358
|
+
})) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(tagName)), {
|
|
359
|
+
key: key(__props.config),
|
|
360
|
+
size: __props.size,
|
|
361
|
+
model: __props.model,
|
|
362
|
+
config: __props.config,
|
|
363
|
+
name: vue.unref(name),
|
|
364
|
+
disabled: vue.unref(disabled),
|
|
365
|
+
prop: vue.unref(itemProp),
|
|
366
|
+
onChange: onChangeHandler
|
|
367
|
+
}, null, 40, ["size", "model", "config", "name", "disabled", "prop"])),
|
|
368
|
+
vue.unref(extra) ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
369
|
+
key: 2,
|
|
370
|
+
innerHTML: vue.unref(extra),
|
|
371
|
+
class: "m-form-tip"
|
|
372
|
+
}, null, 8, _hoisted_3$7)) : vue.createCommentVNode("", true)
|
|
373
|
+
]),
|
|
374
|
+
_: 1
|
|
375
|
+
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
376
|
+
__props.config.tip ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
377
|
+
key: 0,
|
|
378
|
+
placement: "left"
|
|
379
|
+
}, {
|
|
380
|
+
content: vue.withCtx(() => [
|
|
381
|
+
vue.createElementVNode("div", {
|
|
382
|
+
innerHTML: __props.config.tip
|
|
383
|
+
}, null, 8, _hoisted_4$6)
|
|
384
|
+
]),
|
|
385
|
+
default: vue.withCtx(() => [
|
|
386
|
+
vue.createVNode(vue.unref(design.TMagicIcon), { style: { "line-height": "40px", "margin-left": "5px" } }, {
|
|
387
|
+
default: vue.withCtx(() => [
|
|
388
|
+
vue.createVNode(vue.unref(iconsVue.WarningFilled))
|
|
389
|
+
]),
|
|
390
|
+
_: 1
|
|
391
|
+
})
|
|
392
|
+
]),
|
|
393
|
+
_: 1
|
|
394
|
+
})) : vue.createCommentVNode("", true)
|
|
395
|
+
], 64)) : vue.unref(items) && vue.unref(display$1) ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
396
|
+
(vue.unref(name) || vue.unref(name) === 0 ? __props.model[vue.unref(name)] : __props.model) ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(vue.unref(items), (item) => {
|
|
397
|
+
return vue.openBlock(), vue.createBlock(_component_Container, {
|
|
398
|
+
key: key(item),
|
|
399
|
+
model: vue.unref(name) || vue.unref(name) === 0 ? __props.model[vue.unref(name)] : __props.model,
|
|
400
|
+
config: item,
|
|
401
|
+
size: __props.size,
|
|
402
|
+
disabled: vue.unref(disabled),
|
|
403
|
+
"step-active": __props.stepActive,
|
|
404
|
+
"expand-more": expand.value,
|
|
405
|
+
"label-width": vue.unref(itemLabelWidth),
|
|
406
|
+
prop: vue.unref(itemProp),
|
|
407
|
+
onChange: onChangeHandler
|
|
408
|
+
}, null, 8, ["model", "config", "size", "disabled", "step-active", "expand-more", "label-width", "prop"]);
|
|
409
|
+
}), 128)) : vue.createCommentVNode("", true)
|
|
410
|
+
], 64)) : vue.createCommentVNode("", true),
|
|
411
|
+
__props.config.expand && vue.unref(type) !== "fieldset" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5$4, [
|
|
412
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
413
|
+
type: "primary",
|
|
414
|
+
size: "small",
|
|
415
|
+
disabled: false,
|
|
416
|
+
text: "",
|
|
417
|
+
onClick: expandHandler
|
|
418
|
+
}, {
|
|
419
|
+
default: vue.withCtx(() => [
|
|
420
|
+
vue.createTextVNode(vue.toDisplayString(expand.value ? "\u6536\u8D77\u914D\u7F6E" : "\u5C55\u5F00\u66F4\u591A\u914D\u7F6E"), 1)
|
|
421
|
+
]),
|
|
422
|
+
_: 1
|
|
423
|
+
})
|
|
424
|
+
])) : vue.createCommentVNode("", true)
|
|
425
|
+
], 6)) : vue.createCommentVNode("", true);
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
const _hoisted_1$a = ["innerHTML"];
|
|
431
|
+
const _hoisted_2$6 = ["innerHTML"];
|
|
432
|
+
const _hoisted_3$6 = { key: 1 };
|
|
433
|
+
const _hoisted_4$5 = ["innerHTML"];
|
|
434
|
+
const _hoisted_5$3 = ["innerHTML"];
|
|
435
|
+
const _hoisted_6$2 = {
|
|
436
|
+
key: 2,
|
|
437
|
+
style: { "display": "flex" }
|
|
438
|
+
};
|
|
439
|
+
const _hoisted_7$2 = { style: { "flex": "1" } };
|
|
440
|
+
const _hoisted_8$1 = ["src"];
|
|
441
|
+
const __default__$u = vue.defineComponent({
|
|
442
|
+
name: "MFormFieldset"
|
|
443
|
+
});
|
|
444
|
+
const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
|
|
445
|
+
...__default__$u,
|
|
446
|
+
props: {
|
|
447
|
+
labelWidth: null,
|
|
448
|
+
prop: { default: "" },
|
|
449
|
+
size: null,
|
|
450
|
+
model: null,
|
|
451
|
+
config: null,
|
|
452
|
+
rules: { default: {} },
|
|
453
|
+
disabled: { type: Boolean }
|
|
454
|
+
},
|
|
455
|
+
emits: ["change"],
|
|
456
|
+
setup(__props, { emit }) {
|
|
457
|
+
const props = __props;
|
|
458
|
+
const mForm = vue.inject("mForm");
|
|
459
|
+
const name = vue.computed(() => props.config.name || "");
|
|
460
|
+
const show = vue.computed(() => {
|
|
461
|
+
if (props.config.expand && name.value) {
|
|
462
|
+
return props.model[name.value]?.value;
|
|
463
|
+
}
|
|
464
|
+
return true;
|
|
465
|
+
});
|
|
466
|
+
const lWidth = vue.computed(() => {
|
|
467
|
+
if (props.config.items) {
|
|
468
|
+
return props.config.labelWidth || props.labelWidth;
|
|
469
|
+
}
|
|
470
|
+
return props.config.labelWidth || props.labelWidth || (props.config.text ? void 0 : "0");
|
|
471
|
+
});
|
|
472
|
+
const change = () => {
|
|
473
|
+
emit("change", props.model);
|
|
474
|
+
};
|
|
475
|
+
const key = (item, index) => item[mForm?.keyProp || "__key"] ?? index;
|
|
476
|
+
if (props.config.checkbox && name.value) {
|
|
477
|
+
vue.watch(
|
|
478
|
+
() => props.model[name.value]?.value,
|
|
479
|
+
() => {
|
|
480
|
+
emit("change", props.model);
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
return (_ctx, _cache) => {
|
|
485
|
+
return (vue.unref(name) ? __props.model[vue.unref(name)] : __props.model) ? (vue.openBlock(), vue.createElementBlock("fieldset", {
|
|
486
|
+
key: 0,
|
|
487
|
+
class: "m-fieldset",
|
|
488
|
+
style: vue.normalizeStyle(vue.unref(show) ? "padding: 15px 15px 0 5px;" : "border: 0")
|
|
489
|
+
}, [
|
|
490
|
+
vue.unref(name) && __props.config.checkbox ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(!vue.unref(show) ? "div" : "legend"), { key: 0 }, {
|
|
491
|
+
default: vue.withCtx(() => [
|
|
492
|
+
vue.createVNode(vue.unref(design.TMagicCheckbox), {
|
|
493
|
+
modelValue: __props.model[vue.unref(name)].value,
|
|
494
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[vue.unref(name)].value = $event),
|
|
495
|
+
prop: `${__props.prop}${__props.prop ? "." : ""}${__props.config.name}.value`,
|
|
496
|
+
"true-label": 1,
|
|
497
|
+
"false-label": 0
|
|
498
|
+
}, {
|
|
499
|
+
default: vue.withCtx(() => [
|
|
500
|
+
vue.createElementVNode("span", {
|
|
501
|
+
innerHTML: __props.config.legend
|
|
502
|
+
}, null, 8, _hoisted_1$a),
|
|
503
|
+
__props.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
504
|
+
key: 0,
|
|
505
|
+
innerHTML: __props.config.extra,
|
|
506
|
+
class: "m-form-tip"
|
|
507
|
+
}, null, 8, _hoisted_2$6)) : vue.createCommentVNode("", true)
|
|
508
|
+
]),
|
|
509
|
+
_: 1
|
|
510
|
+
}, 8, ["modelValue", "prop"])
|
|
511
|
+
]),
|
|
512
|
+
_: 1
|
|
513
|
+
})) : (vue.openBlock(), vue.createElementBlock("legend", _hoisted_3$6, [
|
|
514
|
+
vue.createElementVNode("span", {
|
|
515
|
+
innerHTML: __props.config.legend
|
|
516
|
+
}, null, 8, _hoisted_4$5),
|
|
517
|
+
__props.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
518
|
+
key: 0,
|
|
519
|
+
innerHTML: __props.config.extra,
|
|
520
|
+
class: "m-form-tip"
|
|
521
|
+
}, null, 8, _hoisted_5$3)) : vue.createCommentVNode("", true)
|
|
522
|
+
])),
|
|
523
|
+
__props.config.schematic && vue.unref(show) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6$2, [
|
|
524
|
+
vue.createElementVNode("div", _hoisted_7$2, [
|
|
525
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.config.items, (item, index) => {
|
|
526
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$v, {
|
|
527
|
+
key: key(item, index),
|
|
528
|
+
model: vue.unref(name) ? __props.model[vue.unref(name)] : __props.model,
|
|
529
|
+
rules: vue.unref(name) ? __props.rules[vue.unref(name)] : [],
|
|
530
|
+
config: item,
|
|
531
|
+
prop: __props.prop,
|
|
532
|
+
disabled: __props.disabled,
|
|
533
|
+
labelWidth: vue.unref(lWidth),
|
|
534
|
+
size: __props.size,
|
|
535
|
+
onChange: change
|
|
536
|
+
}, null, 8, ["model", "rules", "config", "prop", "disabled", "labelWidth", "size"]);
|
|
537
|
+
}), 128))
|
|
538
|
+
]),
|
|
539
|
+
vue.createElementVNode("img", {
|
|
540
|
+
class: "m-form-schematic",
|
|
541
|
+
src: __props.config.schematic
|
|
542
|
+
}, null, 8, _hoisted_8$1)
|
|
543
|
+
])) : vue.unref(show) ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 3 }, vue.renderList(__props.config.items, (item, index) => {
|
|
544
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$v, {
|
|
545
|
+
key: key(item, index),
|
|
546
|
+
model: vue.unref(name) ? __props.model[vue.unref(name)] : __props.model,
|
|
547
|
+
rules: vue.unref(name) ? __props.rules[vue.unref(name)] : [],
|
|
548
|
+
config: item,
|
|
549
|
+
prop: __props.prop,
|
|
550
|
+
labelWidth: vue.unref(lWidth),
|
|
551
|
+
size: __props.size,
|
|
552
|
+
disabled: __props.disabled,
|
|
553
|
+
onChange: change
|
|
554
|
+
}, null, 8, ["model", "rules", "config", "prop", "labelWidth", "size", "disabled"]);
|
|
555
|
+
}), 128)) : vue.createCommentVNode("", true)
|
|
556
|
+
], 4)) : vue.createCommentVNode("", true);
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
const _hoisted_1$9 = { class: "m-fields-group-list-item" };
|
|
562
|
+
const _hoisted_2$5 = /* @__PURE__ */ vue.createTextVNode("\u4E0A\u79FB");
|
|
563
|
+
const _hoisted_3$5 = /* @__PURE__ */ vue.createTextVNode("\u4E0B\u79FB");
|
|
564
|
+
const _hoisted_4$4 = ["innerHTML"];
|
|
565
|
+
const __default__$t = vue.defineComponent({
|
|
566
|
+
name: "MFormGroupListItem"
|
|
567
|
+
});
|
|
568
|
+
const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
|
|
569
|
+
...__default__$t,
|
|
570
|
+
props: {
|
|
571
|
+
model: null,
|
|
572
|
+
groupModel: null,
|
|
573
|
+
config: null,
|
|
574
|
+
labelWidth: null,
|
|
575
|
+
prop: null,
|
|
576
|
+
size: null,
|
|
577
|
+
index: null,
|
|
578
|
+
disabled: { type: Boolean }
|
|
579
|
+
},
|
|
580
|
+
emits: ["swap-item", "remove-item", "change"],
|
|
581
|
+
setup(__props, { emit }) {
|
|
582
|
+
const props = __props;
|
|
583
|
+
const mForm = vue.inject("mForm");
|
|
584
|
+
const expand = vue.ref(false);
|
|
585
|
+
vue.watchEffect(() => {
|
|
586
|
+
expand.value = !props.index;
|
|
587
|
+
});
|
|
588
|
+
const rowConfig = vue.computed(() => ({
|
|
589
|
+
type: "row",
|
|
590
|
+
span: props.config.span || 24,
|
|
591
|
+
items: props.config.items,
|
|
592
|
+
labelWidth: props.config.labelWidth,
|
|
593
|
+
[mForm?.keyProp || "__key"]: `${props.config[mForm?.keyProp || "__key"]}${String(props.index)}`
|
|
594
|
+
}));
|
|
595
|
+
const title = vue.computed(() => {
|
|
596
|
+
if (props.config.titleKey && props.model[props.config.titleKey]) {
|
|
597
|
+
return props.model[props.config.titleKey];
|
|
598
|
+
}
|
|
599
|
+
return `\u7EC4 ${String(props.index)}`;
|
|
600
|
+
});
|
|
601
|
+
const length = vue.computed(() => props.groupModel?.length || 0);
|
|
602
|
+
const itemExtra = vue.computed(() => filterFunction(mForm, props.config.itemExtra, props));
|
|
603
|
+
const removeHandler = () => emit("remove-item", props.index);
|
|
604
|
+
const changeHandler = () => emit("change");
|
|
605
|
+
const expandHandler = () => {
|
|
606
|
+
expand.value = !expand.value;
|
|
607
|
+
};
|
|
608
|
+
const showDelete = (index) => {
|
|
609
|
+
const deleteFunc = props.config.delete;
|
|
610
|
+
if (deleteFunc && typeof deleteFunc === "function") {
|
|
611
|
+
return deleteFunc(props.model, index, mForm?.values);
|
|
612
|
+
}
|
|
613
|
+
return true;
|
|
614
|
+
};
|
|
615
|
+
const changeOrder = (offset = 0) => emit("swap-item", props.index, `${String(props.index)}${offset}`);
|
|
616
|
+
const movable = () => {
|
|
617
|
+
const { movable: movable2 } = props.config;
|
|
618
|
+
if (movable2 === void 0)
|
|
619
|
+
return true;
|
|
620
|
+
if (typeof movable2 === "function") {
|
|
621
|
+
return movable2(mForm, props.index || 0, props.model, props.groupModel);
|
|
622
|
+
}
|
|
623
|
+
return movable2;
|
|
624
|
+
};
|
|
625
|
+
return (_ctx, _cache) => {
|
|
626
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$9, [
|
|
627
|
+
vue.createElementVNode("div", null, [
|
|
628
|
+
vue.createVNode(vue.unref(design.TMagicIcon), {
|
|
629
|
+
style: { "margin-right": "7px" },
|
|
630
|
+
onClick: expandHandler
|
|
631
|
+
}, {
|
|
632
|
+
default: vue.withCtx(() => [
|
|
633
|
+
expand.value ? (vue.openBlock(), vue.createBlock(vue.unref(iconsVue.CaretBottom), { key: 0 })) : (vue.openBlock(), vue.createBlock(vue.unref(iconsVue.CaretRight), { key: 1 }))
|
|
634
|
+
]),
|
|
635
|
+
_: 1
|
|
636
|
+
}),
|
|
637
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
638
|
+
text: "",
|
|
639
|
+
disabled: __props.disabled,
|
|
640
|
+
onClick: expandHandler
|
|
641
|
+
}, {
|
|
642
|
+
default: vue.withCtx(() => [
|
|
643
|
+
vue.createTextVNode(vue.toDisplayString(vue.unref(title)), 1)
|
|
644
|
+
]),
|
|
645
|
+
_: 1
|
|
646
|
+
}, 8, ["disabled"]),
|
|
647
|
+
vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
|
|
648
|
+
style: { "color": "#f56c6c" },
|
|
649
|
+
text: "",
|
|
650
|
+
icon: vue.unref(iconsVue.Delete),
|
|
651
|
+
disabled: __props.disabled,
|
|
652
|
+
onClick: removeHandler
|
|
653
|
+
}, null, 8, ["icon", "disabled"]), [
|
|
654
|
+
[vue.vShow, showDelete(parseInt(String(__props.index)))]
|
|
655
|
+
]),
|
|
656
|
+
movable() ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
657
|
+
vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
|
|
658
|
+
text: "",
|
|
659
|
+
disabled: __props.disabled,
|
|
660
|
+
size: "small",
|
|
661
|
+
onClick: _cache[0] || (_cache[0] = ($event) => changeOrder(-1))
|
|
662
|
+
}, {
|
|
663
|
+
default: vue.withCtx(() => [
|
|
664
|
+
_hoisted_2$5,
|
|
665
|
+
vue.createVNode(vue.unref(design.TMagicIcon), null, {
|
|
666
|
+
default: vue.withCtx(() => [
|
|
667
|
+
vue.createVNode(vue.unref(iconsVue.CaretTop))
|
|
668
|
+
]),
|
|
669
|
+
_: 1
|
|
670
|
+
})
|
|
671
|
+
]),
|
|
672
|
+
_: 1
|
|
673
|
+
}, 8, ["disabled"]), [
|
|
674
|
+
[vue.vShow, __props.index !== 0]
|
|
675
|
+
]),
|
|
676
|
+
vue.withDirectives(vue.createVNode(vue.unref(design.TMagicButton), {
|
|
677
|
+
disabled: __props.disabled,
|
|
678
|
+
text: "",
|
|
679
|
+
size: "small",
|
|
680
|
+
onClick: _cache[1] || (_cache[1] = ($event) => changeOrder(1))
|
|
681
|
+
}, {
|
|
682
|
+
default: vue.withCtx(() => [
|
|
683
|
+
_hoisted_3$5,
|
|
684
|
+
vue.createVNode(vue.unref(design.TMagicIcon), null, {
|
|
685
|
+
default: vue.withCtx(() => [
|
|
686
|
+
vue.createVNode(vue.unref(iconsVue.CaretBottom))
|
|
687
|
+
]),
|
|
688
|
+
_: 1
|
|
689
|
+
})
|
|
690
|
+
]),
|
|
691
|
+
_: 1
|
|
692
|
+
}, 8, ["disabled"]), [
|
|
693
|
+
[vue.vShow, __props.index !== vue.unref(length) - 1]
|
|
694
|
+
])
|
|
695
|
+
], 64)) : vue.createCommentVNode("", true),
|
|
696
|
+
vue.unref(itemExtra) ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
697
|
+
key: 1,
|
|
698
|
+
innerHTML: vue.unref(itemExtra),
|
|
699
|
+
class: "m-form-tip"
|
|
700
|
+
}, null, 8, _hoisted_4$4)) : vue.createCommentVNode("", true)
|
|
701
|
+
]),
|
|
702
|
+
expand.value ? (vue.openBlock(), vue.createBlock(_sfc_main$v, {
|
|
703
|
+
key: 0,
|
|
704
|
+
config: vue.unref(rowConfig),
|
|
705
|
+
model: __props.model,
|
|
706
|
+
labelWidth: __props.labelWidth,
|
|
707
|
+
prop: `${__props.prop}${__props.prop ? "." : ""}${String(__props.index)}`,
|
|
708
|
+
size: __props.size,
|
|
709
|
+
disabled: __props.disabled,
|
|
710
|
+
onChange: changeHandler
|
|
711
|
+
}, null, 8, ["config", "model", "labelWidth", "prop", "size", "disabled"])) : vue.createCommentVNode("", true)
|
|
712
|
+
]);
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
const _hoisted_1$8 = { class: "m-fields-group-list" };
|
|
718
|
+
const _hoisted_2$4 = ["innerHTML"];
|
|
719
|
+
const _hoisted_3$4 = {
|
|
720
|
+
key: 1,
|
|
721
|
+
class: "el-table__empty-block"
|
|
722
|
+
};
|
|
723
|
+
const _hoisted_4$3 = /* @__PURE__ */ vue.createElementVNode("span", { class: "el-table__empty-text" }, "\u6682\u65E0\u6570\u636E", -1);
|
|
724
|
+
const _hoisted_5$2 = [
|
|
725
|
+
_hoisted_4$3
|
|
726
|
+
];
|
|
727
|
+
const _hoisted_6$1 = /* @__PURE__ */ vue.createTextVNode("\u6DFB\u52A0\u7EC4");
|
|
728
|
+
const _hoisted_7$1 = /* @__PURE__ */ vue.createTextVNode("\u5207\u6362\u4E3A\u8868\u683C");
|
|
729
|
+
const __default__$s = vue.defineComponent({
|
|
730
|
+
name: "MFormGroupList"
|
|
731
|
+
});
|
|
732
|
+
const _sfc_main$s = /* @__PURE__ */ vue.defineComponent({
|
|
733
|
+
...__default__$s,
|
|
734
|
+
props: {
|
|
735
|
+
model: null,
|
|
736
|
+
config: null,
|
|
737
|
+
name: null,
|
|
738
|
+
labelWidth: null,
|
|
739
|
+
prop: null,
|
|
740
|
+
size: null,
|
|
741
|
+
disabled: { type: Boolean }
|
|
742
|
+
},
|
|
743
|
+
emits: ["change"],
|
|
744
|
+
setup(__props, { emit }) {
|
|
745
|
+
const props = __props;
|
|
746
|
+
const mForm = vue.inject("mForm");
|
|
747
|
+
const addable = vue.computed(() => {
|
|
748
|
+
if (!props.name)
|
|
749
|
+
return false;
|
|
750
|
+
if (typeof props.config.addable === "function") {
|
|
751
|
+
return props.config.addable(mForm, {
|
|
752
|
+
model: props.model[props.name],
|
|
753
|
+
formValue: mForm?.values,
|
|
754
|
+
prop: props.prop,
|
|
755
|
+
config: props.config
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
return typeof props.config.addable === "undefined" ? true : props.config.addable;
|
|
759
|
+
});
|
|
760
|
+
const changeHandler = () => {
|
|
761
|
+
if (!props.name)
|
|
762
|
+
return false;
|
|
763
|
+
emit("change", props.model[props.name]);
|
|
764
|
+
};
|
|
765
|
+
const addHandler = async () => {
|
|
766
|
+
if (!props.name)
|
|
767
|
+
return false;
|
|
768
|
+
let initValues = {};
|
|
769
|
+
if (typeof props.config.defaultAdd === "function") {
|
|
770
|
+
initValues = await props.config.defaultAdd(mForm, {
|
|
771
|
+
model: props.model[props.name],
|
|
772
|
+
formValue: mForm?.values,
|
|
773
|
+
prop: props.prop,
|
|
774
|
+
config: props.config
|
|
775
|
+
});
|
|
776
|
+
} else if (props.config.defaultAdd) {
|
|
777
|
+
initValues = props.config.defaultAdd;
|
|
778
|
+
}
|
|
779
|
+
const groupValue = await initValue(mForm, {
|
|
780
|
+
config: props.config.items,
|
|
781
|
+
initValues
|
|
782
|
+
});
|
|
783
|
+
props.model[props.name].push(groupValue);
|
|
784
|
+
};
|
|
785
|
+
const removeHandler = (index) => {
|
|
786
|
+
if (!props.name)
|
|
787
|
+
return false;
|
|
788
|
+
props.model[props.name].splice(index, 1);
|
|
789
|
+
changeHandler();
|
|
790
|
+
};
|
|
791
|
+
const swapHandler = (idx1, idx2) => {
|
|
792
|
+
if (!props.name)
|
|
793
|
+
return false;
|
|
794
|
+
const [currRow] = props.model[props.name].splice(idx1, 1);
|
|
795
|
+
props.model[props.name].splice(idx2, 0, currRow);
|
|
796
|
+
changeHandler();
|
|
797
|
+
};
|
|
798
|
+
const toggleMode = () => {
|
|
799
|
+
props.config.type = "table";
|
|
800
|
+
props.config.groupItems = props.config.items;
|
|
801
|
+
props.config.items = props.config.tableItems || props.config.items.map((item) => ({
|
|
802
|
+
...item,
|
|
803
|
+
label: item.label || item.text,
|
|
804
|
+
text: null
|
|
805
|
+
}));
|
|
806
|
+
};
|
|
807
|
+
return (_ctx, _cache) => {
|
|
808
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$8, [
|
|
809
|
+
__props.config.extra ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
810
|
+
key: 0,
|
|
811
|
+
innerHTML: __props.config.extra,
|
|
812
|
+
style: { "color": "rgba(0, 0, 0, 0.45)" }
|
|
813
|
+
}, null, 8, _hoisted_2$4)) : vue.createCommentVNode("", true),
|
|
814
|
+
!__props.model[__props.name] || !__props.model[__props.name].length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$4, _hoisted_5$2)) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 2 }, vue.renderList(__props.model[__props.name], (item, index) => {
|
|
815
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$t, {
|
|
816
|
+
key: index,
|
|
817
|
+
model: item,
|
|
818
|
+
config: __props.config,
|
|
819
|
+
prop: __props.prop,
|
|
820
|
+
index,
|
|
821
|
+
"label-width": __props.labelWidth,
|
|
822
|
+
size: __props.size,
|
|
823
|
+
disabled: __props.disabled,
|
|
824
|
+
"group-model": __props.model[__props.name],
|
|
825
|
+
onRemoveItem: removeHandler,
|
|
826
|
+
onSwapItem: swapHandler,
|
|
827
|
+
onChange: changeHandler
|
|
828
|
+
}, null, 8, ["model", "config", "prop", "index", "label-width", "size", "disabled", "group-model"]);
|
|
829
|
+
}), 128)),
|
|
830
|
+
vue.unref(addable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
831
|
+
key: 3,
|
|
832
|
+
onClick: addHandler,
|
|
833
|
+
size: "small",
|
|
834
|
+
disabled: __props.disabled
|
|
835
|
+
}, {
|
|
836
|
+
default: vue.withCtx(() => [
|
|
837
|
+
_hoisted_6$1
|
|
838
|
+
]),
|
|
839
|
+
_: 1
|
|
840
|
+
}, 8, ["disabled"])) : vue.createCommentVNode("", true),
|
|
841
|
+
__props.config.enableToggleMode ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
842
|
+
key: 4,
|
|
843
|
+
icon: vue.unref(iconsVue.Grid),
|
|
844
|
+
size: "small",
|
|
845
|
+
onClick: toggleMode
|
|
846
|
+
}, {
|
|
847
|
+
default: vue.withCtx(() => [
|
|
848
|
+
_hoisted_7$1
|
|
849
|
+
]),
|
|
850
|
+
_: 1
|
|
851
|
+
}, 8, ["icon"])) : vue.createCommentVNode("", true)
|
|
852
|
+
]);
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
const _hoisted_1$7 = { class: "clearfix" };
|
|
858
|
+
const _hoisted_2$3 = ["innerHTML"];
|
|
859
|
+
const _hoisted_3$3 = {
|
|
860
|
+
key: 0,
|
|
861
|
+
style: { "display": "flex" }
|
|
862
|
+
};
|
|
863
|
+
const _hoisted_4$2 = { style: { "flex": "1" } };
|
|
864
|
+
const _hoisted_5$1 = ["src"];
|
|
865
|
+
const __default__$r = vue.defineComponent({
|
|
866
|
+
name: "MFormPanel"
|
|
867
|
+
});
|
|
868
|
+
const _sfc_main$r = /* @__PURE__ */ vue.defineComponent({
|
|
869
|
+
...__default__$r,
|
|
870
|
+
props: {
|
|
871
|
+
model: null,
|
|
872
|
+
config: null,
|
|
873
|
+
name: null,
|
|
874
|
+
labelWidth: null,
|
|
875
|
+
prop: null,
|
|
876
|
+
size: null,
|
|
877
|
+
disabled: { type: Boolean }
|
|
878
|
+
},
|
|
879
|
+
emits: ["change"],
|
|
880
|
+
setup(__props, { emit }) {
|
|
881
|
+
const props = __props;
|
|
882
|
+
const mForm = vue.inject("mForm");
|
|
883
|
+
const expand = vue.ref(props.config.expand !== false);
|
|
884
|
+
const items = vue.computed(() => props.config.items);
|
|
885
|
+
const filter = (config) => filterFunction(mForm, config, props);
|
|
886
|
+
const changeHandler = () => emit("change", props.model);
|
|
887
|
+
return (_ctx, _cache) => {
|
|
888
|
+
return vue.unref(items) && vue.unref(items).length ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCard), {
|
|
889
|
+
key: 0,
|
|
890
|
+
class: "box-card m-form-panel",
|
|
891
|
+
"body-style": { display: expand.value ? "block" : "none" }
|
|
892
|
+
}, {
|
|
893
|
+
header: vue.withCtx(() => [
|
|
894
|
+
vue.createElementVNode("div", _hoisted_1$7, [
|
|
895
|
+
vue.createElementVNode("a", {
|
|
896
|
+
href: "javascript:",
|
|
897
|
+
style: { "width": "100%", "display": "block" },
|
|
898
|
+
onClick: _cache[0] || (_cache[0] = ($event) => expand.value = !expand.value)
|
|
899
|
+
}, [
|
|
900
|
+
vue.createVNode(vue.unref(design.TMagicIcon), null, {
|
|
901
|
+
default: vue.withCtx(() => [
|
|
902
|
+
expand.value ? (vue.openBlock(), vue.createBlock(vue.unref(iconsVue.CaretBottom), { key: 0 })) : (vue.openBlock(), vue.createBlock(vue.unref(iconsVue.CaretRight), { key: 1 }))
|
|
903
|
+
]),
|
|
904
|
+
_: 1
|
|
905
|
+
}),
|
|
906
|
+
vue.createTextVNode(" " + vue.toDisplayString(filter(__props.config.title)) + " ", 1),
|
|
907
|
+
__props.config && __props.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
908
|
+
key: 0,
|
|
909
|
+
innerHTML: __props.config.extra,
|
|
910
|
+
class: "m-form-tip"
|
|
911
|
+
}, null, 8, _hoisted_2$3)) : vue.createCommentVNode("", true)
|
|
912
|
+
])
|
|
913
|
+
])
|
|
914
|
+
]),
|
|
915
|
+
default: vue.withCtx(() => [
|
|
916
|
+
vue.createElementVNode("div", null, [
|
|
917
|
+
vue.renderSlot(_ctx.$slots, "default"),
|
|
918
|
+
__props.config.schematic ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$3, [
|
|
919
|
+
vue.createElementVNode("div", _hoisted_4$2, [
|
|
920
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(items), (item, index) => {
|
|
921
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$v, {
|
|
922
|
+
key: item[vue.unref(mForm)?.keyProp || "__key"] ?? index,
|
|
923
|
+
config: item,
|
|
924
|
+
model: __props.name ? __props.model[__props.name] : __props.model,
|
|
925
|
+
prop: __props.prop,
|
|
926
|
+
size: __props.size,
|
|
927
|
+
disabled: __props.disabled,
|
|
928
|
+
"label-width": __props.config.labelWidth || __props.labelWidth,
|
|
929
|
+
onChange: changeHandler
|
|
930
|
+
}, null, 8, ["config", "model", "prop", "size", "disabled", "label-width"]);
|
|
931
|
+
}), 128))
|
|
932
|
+
]),
|
|
933
|
+
vue.createElementVNode("img", {
|
|
934
|
+
class: "m-form-schematic",
|
|
935
|
+
src: __props.config.schematic
|
|
936
|
+
}, null, 8, _hoisted_5$1)
|
|
937
|
+
])) : (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 1 }, vue.renderList(vue.unref(items), (item, index) => {
|
|
938
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$v, {
|
|
939
|
+
key: item[vue.unref(mForm)?.keyProp || "__key"] ?? index,
|
|
940
|
+
config: item,
|
|
941
|
+
model: __props.name ? __props.model[__props.name] : __props.model,
|
|
942
|
+
prop: __props.prop,
|
|
943
|
+
size: __props.size,
|
|
944
|
+
disabled: __props.disabled,
|
|
945
|
+
"label-width": __props.config.labelWidth || __props.labelWidth,
|
|
946
|
+
onChange: changeHandler
|
|
947
|
+
}, null, 8, ["config", "model", "prop", "size", "disabled", "label-width"]);
|
|
948
|
+
}), 128))
|
|
949
|
+
])
|
|
950
|
+
]),
|
|
951
|
+
_: 3
|
|
952
|
+
}, 8, ["body-style"])) : vue.createCommentVNode("", true);
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
const __default__$q = vue.defineComponent({
|
|
958
|
+
name: "MFormCol"
|
|
959
|
+
});
|
|
960
|
+
const _sfc_main$q = /* @__PURE__ */ vue.defineComponent({
|
|
961
|
+
...__default__$q,
|
|
962
|
+
props: {
|
|
963
|
+
model: null,
|
|
964
|
+
config: null,
|
|
965
|
+
labelWidth: null,
|
|
966
|
+
expandMore: { type: Boolean },
|
|
967
|
+
span: null,
|
|
968
|
+
size: null,
|
|
969
|
+
prop: null,
|
|
970
|
+
disabled: { type: Boolean }
|
|
971
|
+
},
|
|
972
|
+
emits: ["change"],
|
|
973
|
+
setup(__props, { emit }) {
|
|
974
|
+
const props = __props;
|
|
975
|
+
const mForm = vue.inject("mForm");
|
|
976
|
+
const display$1 = vue.computed(() => display(mForm, props.config.display, props));
|
|
977
|
+
const changeHandler = () => emit("change", props.model);
|
|
978
|
+
return (_ctx, _cache) => {
|
|
979
|
+
return vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCol), { span: __props.span }, {
|
|
980
|
+
default: vue.withCtx(() => [
|
|
981
|
+
vue.createVNode(_sfc_main$v, {
|
|
982
|
+
model: __props.model,
|
|
983
|
+
config: __props.config,
|
|
984
|
+
prop: __props.prop,
|
|
985
|
+
"label-width": __props.config.labelWidth || __props.labelWidth,
|
|
986
|
+
"expand-more": __props.expandMore,
|
|
987
|
+
size: __props.size,
|
|
988
|
+
disabled: __props.disabled,
|
|
989
|
+
onChange: changeHandler
|
|
990
|
+
}, null, 8, ["model", "config", "prop", "label-width", "expand-more", "size", "disabled"])
|
|
991
|
+
]),
|
|
992
|
+
_: 1
|
|
993
|
+
}, 8, ["span"])), [
|
|
994
|
+
[vue.vShow, vue.unref(display$1) && __props.config.type !== "hidden"]
|
|
995
|
+
]);
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
const __default__$p = vue.defineComponent({
|
|
1001
|
+
name: "MFormRow"
|
|
1002
|
+
});
|
|
1003
|
+
const _sfc_main$p = /* @__PURE__ */ vue.defineComponent({
|
|
1004
|
+
...__default__$p,
|
|
1005
|
+
props: {
|
|
1006
|
+
model: null,
|
|
1007
|
+
config: null,
|
|
1008
|
+
name: null,
|
|
1009
|
+
labelWidth: null,
|
|
1010
|
+
prop: null,
|
|
1011
|
+
size: null,
|
|
1012
|
+
expandMore: { type: Boolean },
|
|
1013
|
+
disabled: { type: Boolean }
|
|
1014
|
+
},
|
|
1015
|
+
emits: ["change"],
|
|
1016
|
+
setup(__props, { emit }) {
|
|
1017
|
+
const props = __props;
|
|
1018
|
+
const mForm = vue.inject("mForm");
|
|
1019
|
+
const changeHandler = () => emit("change", props.name ? props.model[props.name] : props.model);
|
|
1020
|
+
return (_ctx, _cache) => {
|
|
1021
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicRow), { gutter: 10 }, {
|
|
1022
|
+
default: vue.withCtx(() => [
|
|
1023
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.config.items, (col, index) => {
|
|
1024
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$q, {
|
|
1025
|
+
key: col[vue.unref(mForm)?.keyProp || "__key"] ?? index,
|
|
1026
|
+
span: col.span || __props.config.span || 24 / __props.config.items.length,
|
|
1027
|
+
config: col,
|
|
1028
|
+
labelWidth: __props.config.labelWidth || __props.labelWidth,
|
|
1029
|
+
expandMore: __props.expandMore,
|
|
1030
|
+
model: __props.name ? __props.model[__props.name] : __props.model,
|
|
1031
|
+
prop: __props.prop,
|
|
1032
|
+
size: __props.size,
|
|
1033
|
+
disabled: __props.disabled,
|
|
1034
|
+
onChange: changeHandler
|
|
1035
|
+
}, null, 8, ["span", "config", "labelWidth", "expandMore", "model", "prop", "size", "disabled"]);
|
|
1036
|
+
}), 128))
|
|
1037
|
+
]),
|
|
1038
|
+
_: 1
|
|
1039
|
+
});
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
const __default__$o = vue.defineComponent({
|
|
1045
|
+
name: "MFormStep"
|
|
1046
|
+
});
|
|
1047
|
+
const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
|
|
1048
|
+
...__default__$o,
|
|
1049
|
+
props: {
|
|
1050
|
+
model: null,
|
|
1051
|
+
config: null,
|
|
1052
|
+
stepActive: { default: 1 },
|
|
1053
|
+
labelWidth: null,
|
|
1054
|
+
size: null,
|
|
1055
|
+
disabled: { type: Boolean }
|
|
1056
|
+
},
|
|
1057
|
+
emits: ["change"],
|
|
1058
|
+
setup(__props, { emit }) {
|
|
1059
|
+
const props = __props;
|
|
1060
|
+
const mForm = vue.inject("mForm");
|
|
1061
|
+
const active = vue.ref(1);
|
|
1062
|
+
vue.watchEffect(() => {
|
|
1063
|
+
active.value = props.stepActive;
|
|
1064
|
+
});
|
|
1065
|
+
const stepClick = (index) => {
|
|
1066
|
+
active.value = index + 1;
|
|
1067
|
+
mForm?.$emit("update:stepActive", active.value);
|
|
1068
|
+
};
|
|
1069
|
+
const changeHandler = () => {
|
|
1070
|
+
emit("change", props.model);
|
|
1071
|
+
};
|
|
1072
|
+
return (_ctx, _cache) => {
|
|
1073
|
+
return vue.openBlock(), vue.createElementBlock("div", null, [
|
|
1074
|
+
vue.createVNode(vue.unref(design.TMagicSteps), {
|
|
1075
|
+
active: active.value,
|
|
1076
|
+
"align-center": "",
|
|
1077
|
+
space: __props.config.space
|
|
1078
|
+
}, {
|
|
1079
|
+
default: vue.withCtx(() => [
|
|
1080
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.config.items, (item, index) => {
|
|
1081
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicStep), {
|
|
1082
|
+
key: item.__key,
|
|
1083
|
+
title: item.title,
|
|
1084
|
+
active: active.value,
|
|
1085
|
+
onClick: ($event) => stepClick(index)
|
|
1086
|
+
}, null, 8, ["title", "active", "onClick"]);
|
|
1087
|
+
}), 128))
|
|
1088
|
+
]),
|
|
1089
|
+
_: 1
|
|
1090
|
+
}, 8, ["active", "space"]),
|
|
1091
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.config.items, (step, index) => {
|
|
1092
|
+
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
|
|
1093
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(step.items, (item) => {
|
|
1094
|
+
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
|
|
1095
|
+
item ? vue.withDirectives((vue.openBlock(), vue.createBlock(_sfc_main$v, {
|
|
1096
|
+
key: item[vue.unref(mForm)?.keyProp || "__key"],
|
|
1097
|
+
config: item,
|
|
1098
|
+
model: step.name ? __props.model[step.name] : __props.model,
|
|
1099
|
+
prop: `${step.name}`,
|
|
1100
|
+
size: __props.size,
|
|
1101
|
+
disabled: __props.disabled,
|
|
1102
|
+
"label-width": __props.config.labelWidth || __props.labelWidth,
|
|
1103
|
+
onChange: changeHandler
|
|
1104
|
+
}, null, 8, ["config", "model", "prop", "size", "disabled", "label-width"])), [
|
|
1105
|
+
[vue.vShow, active.value - 1 === index]
|
|
1106
|
+
]) : vue.createCommentVNode("", true)
|
|
1107
|
+
], 64);
|
|
1108
|
+
}), 256))
|
|
1109
|
+
], 64);
|
|
1110
|
+
}), 256))
|
|
1111
|
+
]);
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
|
|
1116
|
+
const _hoisted_1$6 = ["innerHTML"];
|
|
1117
|
+
const _hoisted_2$2 = { class: "el-form-item__content" };
|
|
1118
|
+
const _hoisted_3$2 = ["innerHTML"];
|
|
1119
|
+
const _hoisted_4$1 = /* @__PURE__ */ vue.createTextVNode("\u6DFB\u52A0");
|
|
1120
|
+
const _hoisted_5 = /* @__PURE__ */ vue.createTextVNode(" \xA0 ");
|
|
1121
|
+
const _hoisted_6 = /* @__PURE__ */ vue.createTextVNode("\u5C55\u5F00\u914D\u7F6E");
|
|
1122
|
+
const _hoisted_7 = /* @__PURE__ */ vue.createTextVNode("\u5BFC\u5165EXCEL");
|
|
1123
|
+
const _hoisted_8 = /* @__PURE__ */ vue.createTextVNode("\xA0 ");
|
|
1124
|
+
const _hoisted_9 = /* @__PURE__ */ vue.createTextVNode("\u6E05\u7A7A");
|
|
1125
|
+
const _hoisted_10 = {
|
|
1126
|
+
key: 1,
|
|
1127
|
+
class: "bottom",
|
|
1128
|
+
style: { "text-align": "right" }
|
|
1129
|
+
};
|
|
1130
|
+
const __default__$n = vue.defineComponent({
|
|
1131
|
+
name: "MFormTable"
|
|
1132
|
+
});
|
|
1133
|
+
const _sfc_main$n = /* @__PURE__ */ vue.defineComponent({
|
|
1134
|
+
...__default__$n,
|
|
1135
|
+
props: {
|
|
1136
|
+
model: null,
|
|
1137
|
+
config: null,
|
|
1138
|
+
name: null,
|
|
1139
|
+
prop: { default: "" },
|
|
1140
|
+
labelWidth: null,
|
|
1141
|
+
sort: { type: Boolean },
|
|
1142
|
+
disabled: { type: Boolean },
|
|
1143
|
+
sortKey: { default: "" },
|
|
1144
|
+
text: null,
|
|
1145
|
+
size: null,
|
|
1146
|
+
enableToggleMode: { type: Boolean, default: true },
|
|
1147
|
+
showIndex: { type: Boolean, default: true }
|
|
1148
|
+
},
|
|
1149
|
+
emits: ["change", "select"],
|
|
1150
|
+
setup(__props, { expose, emit }) {
|
|
1151
|
+
const props = __props;
|
|
1152
|
+
let timer = null;
|
|
1153
|
+
const mForm = vue.inject("mForm");
|
|
1154
|
+
const tMagicTable = vue.ref();
|
|
1155
|
+
const excelBtn = vue.ref();
|
|
1156
|
+
const mTable = vue.ref();
|
|
1157
|
+
const pagesize = vue.ref(10);
|
|
1158
|
+
const pagecontext = vue.ref(0);
|
|
1159
|
+
const updateKey = vue.ref(1);
|
|
1160
|
+
const isFullscreen = vue.ref(false);
|
|
1161
|
+
const modelName = vue.computed(() => props.name || props.config.name || "");
|
|
1162
|
+
const data = vue.computed(
|
|
1163
|
+
() => props.config.pagination ? props.model[modelName.value].filter(
|
|
1164
|
+
(item, index) => index >= pagecontext.value * pagesize.value && index + 1 <= (pagecontext.value + 1) * pagesize.value
|
|
1165
|
+
) : props.model[modelName.value]
|
|
1166
|
+
);
|
|
1167
|
+
const sortChange = ({ prop, order }) => {
|
|
1168
|
+
if (order === "ascending") {
|
|
1169
|
+
props.model[modelName.value] = props.model[modelName.value].sort((a, b) => a[prop] - b[prop]);
|
|
1170
|
+
} else if (order === "descending") {
|
|
1171
|
+
props.model[modelName.value] = props.model[modelName.value].sort((a, b) => b[prop] - a[prop]);
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
const foreUpdate = () => {
|
|
1175
|
+
updateKey.value += 1;
|
|
1176
|
+
setTimeout(() => rowDrop());
|
|
1177
|
+
};
|
|
1178
|
+
const swapArray = (index1, index2) => {
|
|
1179
|
+
[props.model[modelName.value][index1]] = props.model[modelName.value].splice(
|
|
1180
|
+
index2,
|
|
1181
|
+
1,
|
|
1182
|
+
props.model[modelName.value][index1]
|
|
1183
|
+
);
|
|
1184
|
+
if (props.sortKey) {
|
|
1185
|
+
for (let i = props.model[modelName.value].length - 1, v = 0; i >= 0; i--, v++) {
|
|
1186
|
+
props.model[modelName.value][v][props.sortKey] = i;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1190
|
+
};
|
|
1191
|
+
const rowDrop = () => {
|
|
1192
|
+
const tableEl = tMagicTable.value?.instance.$el;
|
|
1193
|
+
const tBodyEl = tableEl?.querySelector(".el-table__body > tbody");
|
|
1194
|
+
if (tBodyEl) {
|
|
1195
|
+
const sortable = Sortable__default.default.create(tBodyEl, {
|
|
1196
|
+
onEnd: ({ newIndex, oldIndex }) => {
|
|
1197
|
+
if (typeof newIndex === "undefined")
|
|
1198
|
+
return;
|
|
1199
|
+
if (typeof oldIndex === "undefined")
|
|
1200
|
+
return;
|
|
1201
|
+
swapArray(newIndex, oldIndex);
|
|
1202
|
+
emit("change", props.model[modelName.value]);
|
|
1203
|
+
foreUpdate();
|
|
1204
|
+
sortable.destroy();
|
|
1205
|
+
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1206
|
+
utils.sleep(1e3).then(() => {
|
|
1207
|
+
const elTrs = tableEl.querySelectorAll(".el-table__body > tbody > tr");
|
|
1208
|
+
if (elTrs?.[newIndex]) {
|
|
1209
|
+
elTrs[newIndex].style.backgroundColor = "rgba(243, 89, 59, 0.2)";
|
|
1210
|
+
utils.sleep(1e3).then(() => {
|
|
1211
|
+
elTrs[newIndex].style.backgroundColor = "";
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
const newHandler = async (row) => {
|
|
1220
|
+
if (props.config.max && props.model[modelName.value].length >= props.config.max) {
|
|
1221
|
+
design.tMagicMessage.error(`\u6700\u591A\u65B0\u589E\u914D\u7F6E\u4E0D\u80FD\u8D85\u8FC7${props.config.max}\u6761`);
|
|
1222
|
+
return;
|
|
1223
|
+
}
|
|
1224
|
+
const columns = props.config.items;
|
|
1225
|
+
const enumValues = props.config.enum || [];
|
|
1226
|
+
let enumV = [];
|
|
1227
|
+
const { length } = props.model[modelName.value];
|
|
1228
|
+
const key = props.config.key || "id";
|
|
1229
|
+
let inputs = {};
|
|
1230
|
+
if (enumValues.length) {
|
|
1231
|
+
if (length >= enumValues.length) {
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
enumV = enumValues.filter((item) => {
|
|
1235
|
+
let i = 0;
|
|
1236
|
+
for (; i < length; i++) {
|
|
1237
|
+
if (item[key] === props.model[modelName.value][i][key]) {
|
|
1238
|
+
break;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
return i === length;
|
|
1242
|
+
});
|
|
1243
|
+
if (enumV.length > 0) {
|
|
1244
|
+
inputs = enumV[0];
|
|
1245
|
+
}
|
|
1246
|
+
} else if (Array.isArray(row)) {
|
|
1247
|
+
columns.forEach((column, index) => {
|
|
1248
|
+
column.name && (inputs[column.name] = row[index]);
|
|
1249
|
+
});
|
|
1250
|
+
} else {
|
|
1251
|
+
if (typeof props.config.defaultAdd === "function") {
|
|
1252
|
+
inputs = await props.config.defaultAdd(mForm, {
|
|
1253
|
+
model: props.model[modelName.value],
|
|
1254
|
+
formValue: mForm?.values
|
|
1255
|
+
});
|
|
1256
|
+
} else if (props.config.defaultAdd) {
|
|
1257
|
+
inputs = props.config.defaultAdd;
|
|
1258
|
+
}
|
|
1259
|
+
inputs = await initValue(mForm, {
|
|
1260
|
+
config: columns,
|
|
1261
|
+
initValues: inputs
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
if (props.sortKey && length) {
|
|
1265
|
+
inputs[props.sortKey] = props.model[modelName.value][length - 1][props.sortKey] - 1;
|
|
1266
|
+
}
|
|
1267
|
+
props.model[modelName.value].push(inputs);
|
|
1268
|
+
emit("change", props.model[modelName.value]);
|
|
1269
|
+
};
|
|
1270
|
+
if (!globalThis.XLSX) {
|
|
1271
|
+
utils.asyncLoadJs("https://cdn.bootcdn.net/ajax/libs/xlsx/0.17.0/xlsx.full.min.js");
|
|
1272
|
+
}
|
|
1273
|
+
vue.onMounted(() => {
|
|
1274
|
+
if (props.config.defautSort) {
|
|
1275
|
+
sortChange(props.config.defautSort);
|
|
1276
|
+
} else if (props.config.defaultSort) {
|
|
1277
|
+
sortChange(props.config.defaultSort);
|
|
1278
|
+
}
|
|
1279
|
+
if (props.sort && props.sortKey) {
|
|
1280
|
+
props.model[modelName.value].sort((a, b) => b[props.sortKey] - a[props.sortKey]);
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
vue.watchEffect(() => {
|
|
1284
|
+
if (props.config.dropSort) {
|
|
1285
|
+
rowDrop();
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
const addable = vue.computed(() => {
|
|
1289
|
+
if (!props.model[modelName.value].length) {
|
|
1290
|
+
return true;
|
|
1291
|
+
}
|
|
1292
|
+
if (typeof props.config.addable === "function") {
|
|
1293
|
+
return props.config.addable(mForm, {
|
|
1294
|
+
model: props.model[modelName.value],
|
|
1295
|
+
formValue: mForm?.values,
|
|
1296
|
+
prop: props.prop
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
return typeof props.config.addable === "undefined" ? true : props.config.addable;
|
|
1300
|
+
});
|
|
1301
|
+
const selection = vue.computed(() => {
|
|
1302
|
+
if (typeof props.config.selection === "function") {
|
|
1303
|
+
return props.config.selection(mForm, { model: props.model[modelName.value] });
|
|
1304
|
+
}
|
|
1305
|
+
return props.config.selection;
|
|
1306
|
+
});
|
|
1307
|
+
const importable = vue.computed(() => {
|
|
1308
|
+
if (typeof props.config.importable === "function") {
|
|
1309
|
+
return props.config.importable(mForm, {
|
|
1310
|
+
formValue: mForm?.values,
|
|
1311
|
+
model: props.model[modelName.value]
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
return typeof props.config.importable === "undefined" ? false : props.config.importable;
|
|
1315
|
+
});
|
|
1316
|
+
const display$1 = (fuc) => display(mForm, fuc, props);
|
|
1317
|
+
const itemExtra = (fuc, index) => {
|
|
1318
|
+
if (typeof fuc === "function") {
|
|
1319
|
+
return fuc(mForm, {
|
|
1320
|
+
values: mForm?.initValues,
|
|
1321
|
+
model: props.model,
|
|
1322
|
+
formValue: mForm ? mForm.values : props.model,
|
|
1323
|
+
prop: props.prop,
|
|
1324
|
+
index
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
return fuc;
|
|
1328
|
+
};
|
|
1329
|
+
const removeHandler = (index) => {
|
|
1330
|
+
if (props.disabled)
|
|
1331
|
+
return;
|
|
1332
|
+
props.model[modelName.value].splice(index, 1);
|
|
1333
|
+
emit("change", props.model[modelName.value]);
|
|
1334
|
+
};
|
|
1335
|
+
const selectHandle = (selection2, row) => {
|
|
1336
|
+
if (typeof props.config.selection === "string" && props.config.selection === "single") {
|
|
1337
|
+
tMagicTable.value?.clearSelection();
|
|
1338
|
+
tMagicTable.value?.toggleRowSelection(row, true);
|
|
1339
|
+
}
|
|
1340
|
+
emit("select", selection2, row);
|
|
1341
|
+
if (typeof props.config.onSelect === "function") {
|
|
1342
|
+
props.config.onSelect(mForm, { selection: selection2, row, config: props.config });
|
|
1343
|
+
}
|
|
1344
|
+
};
|
|
1345
|
+
const toggleRowSelection = (row, selected) => {
|
|
1346
|
+
tMagicTable.value?.toggleRowSelection.call(tMagicTable.value, row, selected);
|
|
1347
|
+
};
|
|
1348
|
+
const makeConfig = (config, row) => {
|
|
1349
|
+
const newConfig = lodashEs.cloneDeep(config);
|
|
1350
|
+
if (typeof config.itemsFunction === "function") {
|
|
1351
|
+
newConfig.items = config.itemsFunction(row);
|
|
1352
|
+
}
|
|
1353
|
+
delete newConfig.display;
|
|
1354
|
+
return newConfig;
|
|
1355
|
+
};
|
|
1356
|
+
const upHandler = (index) => {
|
|
1357
|
+
if (timer) {
|
|
1358
|
+
clearTimeout(timer);
|
|
1359
|
+
}
|
|
1360
|
+
timer = setTimeout(() => {
|
|
1361
|
+
swapArray(index, index - 1);
|
|
1362
|
+
}, 300);
|
|
1363
|
+
};
|
|
1364
|
+
const topHandler = (index) => {
|
|
1365
|
+
if (timer) {
|
|
1366
|
+
clearTimeout(timer);
|
|
1367
|
+
}
|
|
1368
|
+
const moveNum = index;
|
|
1369
|
+
for (let i = 0; i < moveNum; i++) {
|
|
1370
|
+
swapArray(index, index - 1);
|
|
1371
|
+
index -= 1;
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
const downHandler = (index) => {
|
|
1375
|
+
if (timer) {
|
|
1376
|
+
clearTimeout(timer);
|
|
1377
|
+
}
|
|
1378
|
+
timer = setTimeout(() => {
|
|
1379
|
+
swapArray(index, index + 1);
|
|
1380
|
+
}, 300);
|
|
1381
|
+
};
|
|
1382
|
+
const bottomHandler = (index) => {
|
|
1383
|
+
if (timer) {
|
|
1384
|
+
clearTimeout(timer);
|
|
1385
|
+
}
|
|
1386
|
+
const moveNum = props.model[modelName.value].length - 1 - index;
|
|
1387
|
+
for (let i = 0; i < moveNum; i++) {
|
|
1388
|
+
swapArray(index, index + 1);
|
|
1389
|
+
index += 1;
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
const showDelete = (index) => {
|
|
1393
|
+
const deleteFunc = props.config.delete;
|
|
1394
|
+
if (deleteFunc && typeof deleteFunc === "function") {
|
|
1395
|
+
return deleteFunc(props.model[modelName.value], index, mForm?.values);
|
|
1396
|
+
}
|
|
1397
|
+
return true;
|
|
1398
|
+
};
|
|
1399
|
+
const clearHandler = () => {
|
|
1400
|
+
const len = props.model[modelName.value].length;
|
|
1401
|
+
props.model[modelName.value].splice(0, len);
|
|
1402
|
+
mForm?.$emit("field-change", props.prop, props.model[modelName.value]);
|
|
1403
|
+
};
|
|
1404
|
+
const excelHandler = (file) => {
|
|
1405
|
+
if (!file || !file.raw) {
|
|
1406
|
+
return false;
|
|
1407
|
+
}
|
|
1408
|
+
const reader = new FileReader();
|
|
1409
|
+
reader.onload = () => {
|
|
1410
|
+
const data2 = reader.result;
|
|
1411
|
+
const pdata = globalThis.XLSX.read(data2, { type: "array" });
|
|
1412
|
+
pdata.SheetNames.forEach((sheetName) => {
|
|
1413
|
+
const arr = globalThis.XLSX.utils.sheet_to_json(pdata.Sheets[sheetName], { header: 1 });
|
|
1414
|
+
if (arr?.[0]) {
|
|
1415
|
+
arr.forEach((row) => {
|
|
1416
|
+
newHandler(row);
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
setTimeout(() => {
|
|
1420
|
+
excelBtn.value?.clearFiles();
|
|
1421
|
+
}, 300);
|
|
1422
|
+
});
|
|
1423
|
+
};
|
|
1424
|
+
reader.readAsArrayBuffer(file.raw);
|
|
1425
|
+
return false;
|
|
1426
|
+
};
|
|
1427
|
+
const handleSizeChange = (val) => {
|
|
1428
|
+
pagesize.value = val;
|
|
1429
|
+
};
|
|
1430
|
+
const handleCurrentChange = (val) => {
|
|
1431
|
+
pagecontext.value = val - 1;
|
|
1432
|
+
};
|
|
1433
|
+
const toggleMode = () => {
|
|
1434
|
+
const calcLabelWidth = (label) => {
|
|
1435
|
+
if (!label)
|
|
1436
|
+
return "0px";
|
|
1437
|
+
const zhLength = label.match(/[^\x00-\xff]/g)?.length || 0;
|
|
1438
|
+
const chLength = label.length - zhLength;
|
|
1439
|
+
return `${Math.max(chLength * 8 + zhLength * 20, 80)}px`;
|
|
1440
|
+
};
|
|
1441
|
+
props.config.type = "groupList";
|
|
1442
|
+
props.config.enableToggleMode = true;
|
|
1443
|
+
props.config.tableItems = props.config.items;
|
|
1444
|
+
props.config.items = props.config.groupItems || props.config.items.map((item) => {
|
|
1445
|
+
const text = item.text || item.label;
|
|
1446
|
+
const labelWidth = calcLabelWidth(text);
|
|
1447
|
+
return {
|
|
1448
|
+
...item,
|
|
1449
|
+
text,
|
|
1450
|
+
labelWidth,
|
|
1451
|
+
span: item.span || 12
|
|
1452
|
+
};
|
|
1453
|
+
});
|
|
1454
|
+
};
|
|
1455
|
+
const toggleFullscreen = () => {
|
|
1456
|
+
if (isFullscreen.value) {
|
|
1457
|
+
mTable.value?.classList.remove("fixed");
|
|
1458
|
+
isFullscreen.value = false;
|
|
1459
|
+
} else {
|
|
1460
|
+
mTable.value?.classList.add("fixed");
|
|
1461
|
+
isFullscreen.value = true;
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
const getProp = (index) => {
|
|
1465
|
+
const { prop } = vue.toRefs(props);
|
|
1466
|
+
return `${prop.value}${prop.value ? "." : ""}${index + 1 + pagecontext.value * pagesize.value - 1}`;
|
|
1467
|
+
};
|
|
1468
|
+
expose({
|
|
1469
|
+
toggleRowSelection
|
|
1470
|
+
});
|
|
1471
|
+
return (_ctx, _cache) => {
|
|
1472
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
1473
|
+
ref_key: "mTable",
|
|
1474
|
+
ref: mTable,
|
|
1475
|
+
class: vue.normalizeClass(["m-fields-table", { "m-fields-table-item-extra": __props.config.itemExtra }])
|
|
1476
|
+
}, [
|
|
1477
|
+
__props.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
1478
|
+
key: 0,
|
|
1479
|
+
style: { "color": "rgba(0, 0, 0, 0.45)" },
|
|
1480
|
+
innerHTML: __props.config.extra
|
|
1481
|
+
}, null, 8, _hoisted_1$6)) : vue.createCommentVNode("", true),
|
|
1482
|
+
vue.createElementVNode("div", _hoisted_2$2, [
|
|
1483
|
+
vue.createVNode(vue.unref(design.TMagicTooltip), {
|
|
1484
|
+
content: "\u62D6\u62FD\u53EF\u6392\u5E8F",
|
|
1485
|
+
placement: "left-start",
|
|
1486
|
+
disabled: __props.config.dropSort !== true
|
|
1487
|
+
}, {
|
|
1488
|
+
default: vue.withCtx(() => [
|
|
1489
|
+
__props.model[vue.unref(modelName)] ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTable), {
|
|
1490
|
+
ref_key: "tMagicTable",
|
|
1491
|
+
ref: tMagicTable,
|
|
1492
|
+
style: { "width": "100%" },
|
|
1493
|
+
"row-key": __props.config.rowKey || "id",
|
|
1494
|
+
data: vue.unref(data),
|
|
1495
|
+
border: __props.config.border,
|
|
1496
|
+
"max-height": __props.config.maxHeight,
|
|
1497
|
+
"default-expand-all": true,
|
|
1498
|
+
key: updateKey.value,
|
|
1499
|
+
onSelect: selectHandle,
|
|
1500
|
+
onSortChange: sortChange
|
|
1501
|
+
}, {
|
|
1502
|
+
default: vue.withCtx(() => [
|
|
1503
|
+
__props.config.itemExtra ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
|
|
1504
|
+
key: 0,
|
|
1505
|
+
fixed: "left",
|
|
1506
|
+
width: "30",
|
|
1507
|
+
type: "expand"
|
|
1508
|
+
}, {
|
|
1509
|
+
default: vue.withCtx((scope) => [
|
|
1510
|
+
vue.createElementVNode("span", {
|
|
1511
|
+
innerHTML: itemExtra(__props.config.itemExtra, scope.$index),
|
|
1512
|
+
class: "m-form-tip"
|
|
1513
|
+
}, null, 8, _hoisted_3$2)
|
|
1514
|
+
]),
|
|
1515
|
+
_: 1
|
|
1516
|
+
})) : vue.createCommentVNode("", true),
|
|
1517
|
+
vue.createVNode(vue.unref(design.TMagicTableColumn), {
|
|
1518
|
+
label: "\u64CD\u4F5C",
|
|
1519
|
+
width: "55",
|
|
1520
|
+
align: "center",
|
|
1521
|
+
fixed: __props.config.fixed === false ? void 0 : "left"
|
|
1522
|
+
}, {
|
|
1523
|
+
default: vue.withCtx((scope) => [
|
|
1524
|
+
vue.withDirectives(vue.createVNode(vue.unref(design.TMagicIcon), {
|
|
1525
|
+
class: "m-table-delete-icon",
|
|
1526
|
+
onClick: ($event) => removeHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
|
|
1527
|
+
}, {
|
|
1528
|
+
default: vue.withCtx(() => [
|
|
1529
|
+
vue.createVNode(vue.unref(iconsVue.Delete))
|
|
1530
|
+
]),
|
|
1531
|
+
_: 2
|
|
1532
|
+
}, 1032, ["onClick"]), [
|
|
1533
|
+
[vue.vShow, showDelete(scope.$index + 1 + pagecontext.value * pagesize.value - 1)]
|
|
1534
|
+
])
|
|
1535
|
+
]),
|
|
1536
|
+
_: 1
|
|
1537
|
+
}, 8, ["fixed"]),
|
|
1538
|
+
__props.sort && __props.model[vue.unref(modelName)] && __props.model[vue.unref(modelName)].length > 1 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
|
|
1539
|
+
key: 1,
|
|
1540
|
+
label: "\u6392\u5E8F",
|
|
1541
|
+
width: "60"
|
|
1542
|
+
}, {
|
|
1543
|
+
default: vue.withCtx((scope) => [
|
|
1544
|
+
scope.$index + 1 + pagecontext.value * pagesize.value - 1 !== 0 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
1545
|
+
key: 0,
|
|
1546
|
+
content: "\u70B9\u51FB\u4E0A\u79FB\uFF0C\u53CC\u51FB\u7F6E\u9876",
|
|
1547
|
+
placement: "top"
|
|
1548
|
+
}, {
|
|
1549
|
+
default: vue.withCtx(() => [
|
|
1550
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
1551
|
+
plain: "",
|
|
1552
|
+
size: "small",
|
|
1553
|
+
type: "primary",
|
|
1554
|
+
icon: vue.unref(iconsVue.ArrowUp),
|
|
1555
|
+
disabled: __props.disabled,
|
|
1556
|
+
text: "",
|
|
1557
|
+
onClick: ($event) => upHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1),
|
|
1558
|
+
onDblclick: ($event) => topHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
|
|
1559
|
+
}, null, 8, ["icon", "disabled", "onClick", "onDblclick"])
|
|
1560
|
+
]),
|
|
1561
|
+
_: 2
|
|
1562
|
+
}, 1024)) : vue.createCommentVNode("", true),
|
|
1563
|
+
scope.$index + 1 + pagecontext.value * pagesize.value - 1 !== __props.model[vue.unref(modelName)].length - 1 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTooltip), {
|
|
1564
|
+
key: 1,
|
|
1565
|
+
content: "\u70B9\u51FB\u4E0B\u79FB\uFF0C\u53CC\u51FB\u7F6E\u5E95",
|
|
1566
|
+
placement: "top"
|
|
1567
|
+
}, {
|
|
1568
|
+
default: vue.withCtx(() => [
|
|
1569
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
1570
|
+
plain: "",
|
|
1571
|
+
size: "small",
|
|
1572
|
+
type: "primary",
|
|
1573
|
+
icon: vue.unref(iconsVue.ArrowDown),
|
|
1574
|
+
disabled: __props.disabled,
|
|
1575
|
+
text: "",
|
|
1576
|
+
onClick: ($event) => downHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1),
|
|
1577
|
+
onDblclick: ($event) => bottomHandler(scope.$index + 1 + pagecontext.value * pagesize.value - 1)
|
|
1578
|
+
}, null, 8, ["icon", "disabled", "onClick", "onDblclick"])
|
|
1579
|
+
]),
|
|
1580
|
+
_: 2
|
|
1581
|
+
}, 1024)) : vue.createCommentVNode("", true)
|
|
1582
|
+
]),
|
|
1583
|
+
_: 1
|
|
1584
|
+
})) : vue.createCommentVNode("", true),
|
|
1585
|
+
vue.unref(selection) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
|
|
1586
|
+
key: 2,
|
|
1587
|
+
align: "center",
|
|
1588
|
+
"header-align": "center",
|
|
1589
|
+
type: "selection",
|
|
1590
|
+
width: "45"
|
|
1591
|
+
})) : vue.createCommentVNode("", true),
|
|
1592
|
+
__props.showIndex && __props.config.showIndex ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
|
|
1593
|
+
key: 3,
|
|
1594
|
+
width: "60",
|
|
1595
|
+
label: "\u5E8F\u53F7"
|
|
1596
|
+
}, {
|
|
1597
|
+
default: vue.withCtx((scope) => [
|
|
1598
|
+
vue.createTextVNode(vue.toDisplayString(scope.$index + 1 + pagecontext.value * pagesize.value), 1)
|
|
1599
|
+
]),
|
|
1600
|
+
_: 1
|
|
1601
|
+
})) : vue.createCommentVNode("", true),
|
|
1602
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.config.items, (column, index) => {
|
|
1603
|
+
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
|
|
1604
|
+
column.type !== "hidden" && display$1(column.display) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTableColumn), {
|
|
1605
|
+
prop: column.name,
|
|
1606
|
+
width: column.width,
|
|
1607
|
+
label: column.label,
|
|
1608
|
+
sortable: column.sortable,
|
|
1609
|
+
"sort-orders": ["ascending", "descending"],
|
|
1610
|
+
key: column[vue.unref(mForm)?.keyProp || "__key"] ?? index,
|
|
1611
|
+
"class-name": __props.config.dropSort === true ? "el-table__column--dropable" : ""
|
|
1612
|
+
}, {
|
|
1613
|
+
default: vue.withCtx((scope) => [
|
|
1614
|
+
scope.$index > -1 ? (vue.openBlock(), vue.createBlock(_sfc_main$v, {
|
|
1615
|
+
key: 0,
|
|
1616
|
+
labelWidth: "0",
|
|
1617
|
+
disabled: __props.disabled,
|
|
1618
|
+
prop: getProp(scope.$index),
|
|
1619
|
+
rules: column.rules,
|
|
1620
|
+
config: makeConfig(column, scope.row),
|
|
1621
|
+
model: scope.row,
|
|
1622
|
+
size: __props.size,
|
|
1623
|
+
onChange: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("change", __props.model[vue.unref(modelName)]))
|
|
1624
|
+
}, null, 8, ["disabled", "prop", "rules", "config", "model", "size"])) : vue.createCommentVNode("", true)
|
|
1625
|
+
]),
|
|
1626
|
+
_: 2
|
|
1627
|
+
}, 1032, ["prop", "width", "label", "sortable", "class-name"])) : vue.createCommentVNode("", true)
|
|
1628
|
+
], 64);
|
|
1629
|
+
}), 256))
|
|
1630
|
+
]),
|
|
1631
|
+
_: 1
|
|
1632
|
+
}, 8, ["row-key", "data", "border", "max-height"])) : vue.createCommentVNode("", true)
|
|
1633
|
+
]),
|
|
1634
|
+
_: 1
|
|
1635
|
+
}, 8, ["disabled"]),
|
|
1636
|
+
vue.renderSlot(_ctx.$slots, "default"),
|
|
1637
|
+
vue.unref(addable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1638
|
+
key: 0,
|
|
1639
|
+
size: "small",
|
|
1640
|
+
type: "primary",
|
|
1641
|
+
disabled: __props.disabled,
|
|
1642
|
+
plain: "",
|
|
1643
|
+
onClick: _cache[1] || (_cache[1] = ($event) => newHandler())
|
|
1644
|
+
}, {
|
|
1645
|
+
default: vue.withCtx(() => [
|
|
1646
|
+
_hoisted_4$1
|
|
1647
|
+
]),
|
|
1648
|
+
_: 1
|
|
1649
|
+
}, 8, ["disabled"])) : vue.createCommentVNode("", true),
|
|
1650
|
+
_hoisted_5,
|
|
1651
|
+
__props.enableToggleMode && !isFullscreen.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1652
|
+
key: 1,
|
|
1653
|
+
icon: vue.unref(iconsVue.Grid),
|
|
1654
|
+
size: "small",
|
|
1655
|
+
type: "primary",
|
|
1656
|
+
onClick: toggleMode
|
|
1657
|
+
}, {
|
|
1658
|
+
default: vue.withCtx(() => [
|
|
1659
|
+
_hoisted_6
|
|
1660
|
+
]),
|
|
1661
|
+
_: 1
|
|
1662
|
+
}, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
1663
|
+
__props.config.enableFullscreen !== false ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1664
|
+
key: 2,
|
|
1665
|
+
icon: vue.unref(iconsVue.FullScreen),
|
|
1666
|
+
size: "small",
|
|
1667
|
+
type: "primary",
|
|
1668
|
+
onClick: toggleFullscreen
|
|
1669
|
+
}, {
|
|
1670
|
+
default: vue.withCtx(() => [
|
|
1671
|
+
vue.createTextVNode(vue.toDisplayString(isFullscreen.value ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F\u7F16\u8F91"), 1)
|
|
1672
|
+
]),
|
|
1673
|
+
_: 1
|
|
1674
|
+
}, 8, ["icon"])) : vue.createCommentVNode("", true),
|
|
1675
|
+
vue.unref(importable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicUpload), {
|
|
1676
|
+
key: 3,
|
|
1677
|
+
style: { "display": "inline-block" },
|
|
1678
|
+
ref_key: "excelBtn",
|
|
1679
|
+
ref: excelBtn,
|
|
1680
|
+
action: "/noop",
|
|
1681
|
+
disabled: __props.disabled,
|
|
1682
|
+
"on-change": excelHandler,
|
|
1683
|
+
"auto-upload": false
|
|
1684
|
+
}, {
|
|
1685
|
+
default: vue.withCtx(() => [
|
|
1686
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
1687
|
+
size: "small",
|
|
1688
|
+
type: "success",
|
|
1689
|
+
disabled: __props.disabled,
|
|
1690
|
+
plain: ""
|
|
1691
|
+
}, {
|
|
1692
|
+
default: vue.withCtx(() => [
|
|
1693
|
+
_hoisted_7
|
|
1694
|
+
]),
|
|
1695
|
+
_: 1
|
|
1696
|
+
}, 8, ["disabled"])
|
|
1697
|
+
]),
|
|
1698
|
+
_: 1
|
|
1699
|
+
}, 8, ["disabled"])) : vue.createCommentVNode("", true),
|
|
1700
|
+
_hoisted_8,
|
|
1701
|
+
vue.unref(importable) ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1702
|
+
key: 4,
|
|
1703
|
+
size: "small",
|
|
1704
|
+
type: "warning",
|
|
1705
|
+
disabled: __props.disabled,
|
|
1706
|
+
plain: "",
|
|
1707
|
+
onClick: _cache[2] || (_cache[2] = ($event) => clearHandler())
|
|
1708
|
+
}, {
|
|
1709
|
+
default: vue.withCtx(() => [
|
|
1710
|
+
_hoisted_9
|
|
1711
|
+
]),
|
|
1712
|
+
_: 1
|
|
1713
|
+
}, 8, ["disabled"])) : vue.createCommentVNode("", true)
|
|
1714
|
+
]),
|
|
1715
|
+
__props.config.pagination ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_10, [
|
|
1716
|
+
vue.createVNode(vue.unref(design.TMagicPagination), {
|
|
1717
|
+
layout: "total, sizes, prev, pager, next, jumper",
|
|
1718
|
+
"hide-on-single-page": __props.model[vue.unref(modelName)].length < pagesize.value,
|
|
1719
|
+
"current-page": pagecontext.value + 1,
|
|
1720
|
+
"page-sizes": [pagesize.value, 60, 120, 300],
|
|
1721
|
+
"page-size": pagesize.value,
|
|
1722
|
+
total: __props.model[vue.unref(modelName)].length,
|
|
1723
|
+
onSizeChange: handleSizeChange,
|
|
1724
|
+
onCurrentChange: handleCurrentChange
|
|
1725
|
+
}, null, 8, ["hide-on-single-page", "current-page", "page-sizes", "page-size", "total"])
|
|
1726
|
+
])) : vue.createCommentVNode("", true)
|
|
1727
|
+
], 2);
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1731
|
+
|
|
1732
|
+
const __default__$m = vue.defineComponent({
|
|
1733
|
+
name: "MFormTabs"
|
|
1734
|
+
});
|
|
1735
|
+
const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
|
|
1736
|
+
...__default__$m,
|
|
1737
|
+
props: {
|
|
1738
|
+
model: null,
|
|
1739
|
+
config: null,
|
|
1740
|
+
name: null,
|
|
1741
|
+
size: null,
|
|
1742
|
+
labelWidth: null,
|
|
1743
|
+
prop: null,
|
|
1744
|
+
expandMore: { type: Boolean },
|
|
1745
|
+
disabled: { type: Boolean }
|
|
1746
|
+
},
|
|
1747
|
+
emits: ["change"],
|
|
1748
|
+
setup(__props, { emit }) {
|
|
1749
|
+
const props = __props;
|
|
1750
|
+
const uiComponent = design.getConfig("components").tabPane;
|
|
1751
|
+
const getActive = (mForm2, props2, activeTabName2) => {
|
|
1752
|
+
const { config, model, prop } = props2;
|
|
1753
|
+
const { active } = config;
|
|
1754
|
+
if (typeof active === "function")
|
|
1755
|
+
return active(mForm2, { model, formValue: mForm2?.values, prop });
|
|
1756
|
+
if (+activeTabName2 >= props2.config.items.length)
|
|
1757
|
+
return "0";
|
|
1758
|
+
if (typeof active !== "undefined")
|
|
1759
|
+
return active;
|
|
1760
|
+
return "0";
|
|
1761
|
+
};
|
|
1762
|
+
const tabClick = (mForm2, tab, props2) => {
|
|
1763
|
+
const { config, model, prop } = props2;
|
|
1764
|
+
tab.name = tab.paneName;
|
|
1765
|
+
if (typeof config.onTabClick === "function") {
|
|
1766
|
+
config.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
|
|
1767
|
+
}
|
|
1768
|
+
const tabConfig = config.items.find((item) => tab.name === item.status);
|
|
1769
|
+
if (tabConfig && typeof tabConfig.onTabClick === "function") {
|
|
1770
|
+
tabConfig.onTabClick(mForm2, tab, { model, formValue: mForm2?.values, prop, config });
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
const mForm = vue.inject("mForm");
|
|
1774
|
+
const activeTabName = vue.ref(getActive(mForm, props, ""));
|
|
1775
|
+
const tabs = vue.computed(() => {
|
|
1776
|
+
if (props.config.dynamic) {
|
|
1777
|
+
if (!props.config.name)
|
|
1778
|
+
throw new Error("dynamic tab \u5FC5\u987B\u914D\u7F6Ename");
|
|
1779
|
+
return props.model[props.config.name] || [];
|
|
1780
|
+
}
|
|
1781
|
+
return props.config.items;
|
|
1782
|
+
});
|
|
1783
|
+
const filter = (config) => filterFunction(mForm, config, props);
|
|
1784
|
+
vue.watchEffect(() => {
|
|
1785
|
+
if (typeof props.config.activeChange === "function") {
|
|
1786
|
+
props.config.activeChange(mForm, activeTabName.value, {
|
|
1787
|
+
model: props.model,
|
|
1788
|
+
prop: props.prop
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
const tabItems = (tab) => props.config.dynamic ? props.config.items : tab.items;
|
|
1793
|
+
const tabClickHandler = (tab) => tabClick(mForm, tab, props);
|
|
1794
|
+
const onTabAdd = () => {
|
|
1795
|
+
if (!props.config.name)
|
|
1796
|
+
throw new Error("dynamic tab \u5FC5\u987B\u914D\u7F6Ename");
|
|
1797
|
+
if (typeof props.config.onTabAdd === "function") {
|
|
1798
|
+
props.config.onTabAdd(mForm, {
|
|
1799
|
+
model: props.model,
|
|
1800
|
+
prop: props.prop,
|
|
1801
|
+
config: props.config
|
|
1802
|
+
});
|
|
1803
|
+
} else if (tabs.value.length > 0) {
|
|
1804
|
+
const newObj = lodashEs.cloneDeep(tabs.value[0]);
|
|
1805
|
+
newObj.title = `\u6807\u7B7E${tabs.value.length + 1}`;
|
|
1806
|
+
props.model[props.config.name].push(newObj);
|
|
1807
|
+
}
|
|
1808
|
+
emit("change", props.model);
|
|
1809
|
+
mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
|
|
1810
|
+
};
|
|
1811
|
+
const onTabRemove = (tabName) => {
|
|
1812
|
+
if (!props.config.name)
|
|
1813
|
+
throw new Error("dynamic tab \u5FC5\u987B\u914D\u7F6Ename");
|
|
1814
|
+
if (typeof props.config.onTabRemove === "function") {
|
|
1815
|
+
props.config.onTabRemove(mForm, tabName, {
|
|
1816
|
+
model: props.model,
|
|
1817
|
+
prop: props.prop,
|
|
1818
|
+
config: props.config
|
|
1819
|
+
});
|
|
1820
|
+
} else {
|
|
1821
|
+
props.model[props.config.name].splice(+tabName, 1);
|
|
1822
|
+
if (tabName < activeTabName.value || activeTabName.value >= props.model[props.config.name].length) {
|
|
1823
|
+
activeTabName.value = (+activeTabName.value - 1).toString();
|
|
1824
|
+
tabClick(mForm, { name: activeTabName.value }, props);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
emit("change", props.model);
|
|
1828
|
+
mForm?.$emit("field-change", props.prop, props.model[props.config.name]);
|
|
1829
|
+
};
|
|
1830
|
+
const display$1 = (displayConfig) => display(mForm, displayConfig, props);
|
|
1831
|
+
const changeHandler = () => {
|
|
1832
|
+
emit("change", props.model);
|
|
1833
|
+
if (typeof props.config.onChange === "function") {
|
|
1834
|
+
props.config.onChange(mForm, { model: props.model, prop: props.prop, config: props.config });
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
return (_ctx, _cache) => {
|
|
1838
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTabs), {
|
|
1839
|
+
modelValue: activeTabName.value,
|
|
1840
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabName.value = $event),
|
|
1841
|
+
class: vue.normalizeClass(__props.config.dynamic ? "magic-form-dynamic-tab" : "magic-form-tab"),
|
|
1842
|
+
type: __props.config.tabType,
|
|
1843
|
+
editable: __props.config.editable || false,
|
|
1844
|
+
"tab-position": __props.config.tabPosition || "top",
|
|
1845
|
+
onTabClick: tabClickHandler,
|
|
1846
|
+
onTabAdd,
|
|
1847
|
+
onTabRemove
|
|
1848
|
+
}, {
|
|
1849
|
+
default: vue.withCtx(() => [
|
|
1850
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(tabs), (tab, tabIndex) => {
|
|
1851
|
+
return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
|
|
1852
|
+
display$1(tab.display) && tabItems(tab).length ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(uiComponent).component), {
|
|
1853
|
+
key: tab[vue.unref(mForm)?.keyProp || "__key"] ?? tabIndex,
|
|
1854
|
+
name: filter(tab.status) || tabIndex.toString(),
|
|
1855
|
+
label: filter(tab.title),
|
|
1856
|
+
lazy: tab.lazy || false
|
|
1857
|
+
}, {
|
|
1858
|
+
default: vue.withCtx(() => [
|
|
1859
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(tabItems(tab), (item) => {
|
|
1860
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$v, {
|
|
1861
|
+
key: item[vue.unref(mForm)?.keyProp || "__key"],
|
|
1862
|
+
config: item,
|
|
1863
|
+
disabled: __props.disabled,
|
|
1864
|
+
model: __props.config.dynamic ? (__props.name ? __props.model[__props.name] : __props.model)[tabIndex] : tab.name ? (__props.name ? __props.model[__props.name] : __props.model)[tab.name] : __props.name ? __props.model[__props.name] : __props.model,
|
|
1865
|
+
prop: __props.config.dynamic ? `${__props.prop}${__props.prop ? "." : ""}${String(tabIndex)}` : __props.prop,
|
|
1866
|
+
size: __props.size,
|
|
1867
|
+
"label-width": tab.labelWidth || __props.labelWidth,
|
|
1868
|
+
"expand-more": __props.expandMore,
|
|
1869
|
+
onChange: changeHandler
|
|
1870
|
+
}, null, 8, ["config", "disabled", "model", "prop", "size", "label-width", "expand-more"]);
|
|
1871
|
+
}), 128))
|
|
1872
|
+
]),
|
|
1873
|
+
_: 2
|
|
1874
|
+
}, 1032, ["name", "label", "lazy"])) : vue.createCommentVNode("", true)
|
|
1875
|
+
], 64);
|
|
1876
|
+
}), 256))
|
|
1877
|
+
]),
|
|
1878
|
+
_: 1
|
|
1879
|
+
}, 8, ["modelValue", "class", "type", "editable", "tab-position"]);
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
|
|
1884
|
+
let $MAGIC_FORM = {};
|
|
1885
|
+
const setConfig = (option) => {
|
|
1886
|
+
$MAGIC_FORM = option;
|
|
1887
|
+
};
|
|
1888
|
+
const getConfig = (key) => $MAGIC_FORM[key];
|
|
1889
|
+
|
|
1890
|
+
const useAddField = (prop) => {
|
|
1891
|
+
if (!prop)
|
|
1892
|
+
return;
|
|
1893
|
+
const mForm = vue.inject("mForm");
|
|
1894
|
+
const instance = vue.getCurrentInstance();
|
|
1895
|
+
vue.watch(
|
|
1896
|
+
() => instance?.proxy,
|
|
1897
|
+
(vm) => {
|
|
1898
|
+
if (vm) {
|
|
1899
|
+
mForm?.setField(prop, vm);
|
|
1900
|
+
} else {
|
|
1901
|
+
mForm?.deleteField(prop);
|
|
1902
|
+
}
|
|
1903
|
+
},
|
|
1904
|
+
{
|
|
1905
|
+
immediate: true
|
|
1906
|
+
}
|
|
1907
|
+
);
|
|
1908
|
+
};
|
|
1909
|
+
|
|
1910
|
+
const __default__$l = vue.defineComponent({
|
|
1911
|
+
name: "MFormCascader"
|
|
1912
|
+
});
|
|
1913
|
+
const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
|
|
1914
|
+
...__default__$l,
|
|
1915
|
+
props: {
|
|
1916
|
+
config: null,
|
|
1917
|
+
model: null,
|
|
1918
|
+
initValues: null,
|
|
1919
|
+
values: null,
|
|
1920
|
+
name: null,
|
|
1921
|
+
prop: null,
|
|
1922
|
+
disabled: { type: Boolean },
|
|
1923
|
+
size: null
|
|
1924
|
+
},
|
|
1925
|
+
emits: ["change"],
|
|
1926
|
+
setup(__props, { emit }) {
|
|
1927
|
+
const props = __props;
|
|
1928
|
+
const mForm = vue.inject("mForm");
|
|
1929
|
+
useAddField(props.prop);
|
|
1930
|
+
const requestFunc = getConfig("request");
|
|
1931
|
+
const tMagicCascader = vue.ref();
|
|
1932
|
+
const options = Array.isArray(props.config.options) ? vue.ref(props.config.options) : vue.ref([]);
|
|
1933
|
+
const remoteData = vue.ref(null);
|
|
1934
|
+
const setRemoteOptions = async function() {
|
|
1935
|
+
const { config } = props;
|
|
1936
|
+
const { option } = config;
|
|
1937
|
+
if (!option)
|
|
1938
|
+
return;
|
|
1939
|
+
let { body } = option;
|
|
1940
|
+
const postOptions = {
|
|
1941
|
+
url: option.url,
|
|
1942
|
+
cache: option.cache,
|
|
1943
|
+
timeout: option.timeout,
|
|
1944
|
+
data: {}
|
|
1945
|
+
};
|
|
1946
|
+
if (body && mForm) {
|
|
1947
|
+
if (typeof body === "function" && props.model && mForm) {
|
|
1948
|
+
body = body(mForm, {
|
|
1949
|
+
model: props.model,
|
|
1950
|
+
formValue: mForm.values,
|
|
1951
|
+
formValues: mForm.values,
|
|
1952
|
+
config: props.config
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
postOptions.data = body;
|
|
1956
|
+
}
|
|
1957
|
+
const res = await requestFunc(postOptions);
|
|
1958
|
+
remoteData.value = res[option.root];
|
|
1959
|
+
if (remoteData.value && typeof option?.item === "function") {
|
|
1960
|
+
options.value = option.item(res[option.root]);
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
if (typeof props.config.options === "function" && props.model && mForm) {
|
|
1964
|
+
vue.watchEffect(
|
|
1965
|
+
() => options.value = props.config.options(mForm, { model: props.model, formValues: mForm.values })
|
|
1966
|
+
);
|
|
1967
|
+
} else if (!props.config.options || !props.config.options.length || props.config.remote) {
|
|
1968
|
+
Promise.resolve(setRemoteOptions());
|
|
1969
|
+
}
|
|
1970
|
+
const changeHandler = (value) => {
|
|
1971
|
+
if (!tMagicCascader.value)
|
|
1972
|
+
return;
|
|
1973
|
+
tMagicCascader.value.setQuery("");
|
|
1974
|
+
tMagicCascader.value.setPreviousQuery(null);
|
|
1975
|
+
emit("change", value);
|
|
1976
|
+
};
|
|
1977
|
+
return (_ctx, _cache) => {
|
|
1978
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCascader), {
|
|
1979
|
+
modelValue: __props.model[__props.name],
|
|
1980
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
1981
|
+
ref_key: "tMagicCascader",
|
|
1982
|
+
ref: tMagicCascader,
|
|
1983
|
+
style: { "width": "100%" },
|
|
1984
|
+
clearable: "",
|
|
1985
|
+
filterable: "",
|
|
1986
|
+
size: __props.size,
|
|
1987
|
+
placeholder: __props.config.placeholder,
|
|
1988
|
+
disabled: __props.disabled,
|
|
1989
|
+
options: vue.unref(options),
|
|
1990
|
+
props: { multiple: __props.config.multiple },
|
|
1991
|
+
onChange: changeHandler
|
|
1992
|
+
}, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "props"]);
|
|
1993
|
+
};
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
|
|
1997
|
+
const __default__$k = vue.defineComponent({
|
|
1998
|
+
name: "MFormCheckbox"
|
|
1999
|
+
});
|
|
2000
|
+
const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
|
|
2001
|
+
...__default__$k,
|
|
2002
|
+
props: {
|
|
2003
|
+
config: null,
|
|
2004
|
+
model: null,
|
|
2005
|
+
initValues: null,
|
|
2006
|
+
values: null,
|
|
2007
|
+
name: null,
|
|
2008
|
+
prop: null,
|
|
2009
|
+
disabled: { type: Boolean },
|
|
2010
|
+
size: null
|
|
2011
|
+
},
|
|
2012
|
+
emits: ["change"],
|
|
2013
|
+
setup(__props, { emit }) {
|
|
2014
|
+
const props = __props;
|
|
2015
|
+
useAddField(props.prop);
|
|
2016
|
+
const activeValue = vue.computed(() => {
|
|
2017
|
+
if (typeof props.config.activeValue === "undefined") {
|
|
2018
|
+
if (props.config.filter === "number") {
|
|
2019
|
+
return 1;
|
|
2020
|
+
}
|
|
2021
|
+
} else {
|
|
2022
|
+
return props.config.activeValue;
|
|
2023
|
+
}
|
|
2024
|
+
return void 0;
|
|
2025
|
+
});
|
|
2026
|
+
const inactiveValue = vue.computed(() => {
|
|
2027
|
+
if (typeof props.config.inactiveValue === "undefined") {
|
|
2028
|
+
if (props.config.filter === "number") {
|
|
2029
|
+
return 0;
|
|
2030
|
+
}
|
|
2031
|
+
} else {
|
|
2032
|
+
return props.config.inactiveValue;
|
|
2033
|
+
}
|
|
2034
|
+
return void 0;
|
|
2035
|
+
});
|
|
2036
|
+
const changeHandler = (value) => {
|
|
2037
|
+
emit("change", value);
|
|
2038
|
+
};
|
|
2039
|
+
return (_ctx, _cache) => {
|
|
2040
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCheckbox), {
|
|
2041
|
+
modelValue: __props.model[__props.name],
|
|
2042
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
2043
|
+
size: __props.size,
|
|
2044
|
+
trueLabel: vue.unref(activeValue),
|
|
2045
|
+
falseLabel: vue.unref(inactiveValue),
|
|
2046
|
+
disabled: __props.disabled,
|
|
2047
|
+
onChange: changeHandler
|
|
2048
|
+
}, {
|
|
2049
|
+
default: vue.withCtx(() => [
|
|
2050
|
+
vue.createTextVNode(vue.toDisplayString(__props.config.text), 1)
|
|
2051
|
+
]),
|
|
2052
|
+
_: 1
|
|
2053
|
+
}, 8, ["modelValue", "size", "trueLabel", "falseLabel", "disabled"]);
|
|
2054
|
+
};
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2057
|
+
|
|
2058
|
+
const __default__$j = vue.defineComponent({
|
|
2059
|
+
name: "MFormCheckGroup"
|
|
2060
|
+
});
|
|
2061
|
+
const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
|
|
2062
|
+
...__default__$j,
|
|
2063
|
+
props: {
|
|
2064
|
+
config: null,
|
|
2065
|
+
model: null,
|
|
2066
|
+
initValues: null,
|
|
2067
|
+
values: null,
|
|
2068
|
+
name: null,
|
|
2069
|
+
prop: null,
|
|
2070
|
+
disabled: { type: Boolean },
|
|
2071
|
+
size: null
|
|
2072
|
+
},
|
|
2073
|
+
emits: ["change"],
|
|
2074
|
+
setup(__props, { emit }) {
|
|
2075
|
+
const props = __props;
|
|
2076
|
+
useAddField(props.prop);
|
|
2077
|
+
if (props.model && !props.model[props.name]) {
|
|
2078
|
+
props.model[props.name] = [];
|
|
2079
|
+
}
|
|
2080
|
+
const changeHandler = (v) => {
|
|
2081
|
+
emit("change", v);
|
|
2082
|
+
};
|
|
2083
|
+
const mForm = vue.inject("mForm");
|
|
2084
|
+
const options = vue.computed(() => {
|
|
2085
|
+
if (Array.isArray(props.config.options))
|
|
2086
|
+
return props.config.options;
|
|
2087
|
+
if (typeof props.config.options === "function")
|
|
2088
|
+
return filterFunction(mForm, props.config.options, props);
|
|
2089
|
+
return [];
|
|
2090
|
+
});
|
|
2091
|
+
return (_ctx, _cache) => {
|
|
2092
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCheckboxGroup), {
|
|
2093
|
+
modelValue: __props.model[__props.name],
|
|
2094
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
2095
|
+
size: __props.size,
|
|
2096
|
+
disabled: __props.disabled,
|
|
2097
|
+
onChange: changeHandler
|
|
2098
|
+
}, {
|
|
2099
|
+
default: vue.withCtx(() => [
|
|
2100
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(options), (option) => {
|
|
2101
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCheckbox), {
|
|
2102
|
+
label: option.value,
|
|
2103
|
+
key: option.value,
|
|
2104
|
+
disabled: option.disabled
|
|
2105
|
+
}, {
|
|
2106
|
+
default: vue.withCtx(() => [
|
|
2107
|
+
vue.createTextVNode(vue.toDisplayString(option.text), 1)
|
|
2108
|
+
]),
|
|
2109
|
+
_: 2
|
|
2110
|
+
}, 1032, ["label", "disabled"]);
|
|
2111
|
+
}), 128))
|
|
2112
|
+
]),
|
|
2113
|
+
_: 1
|
|
2114
|
+
}, 8, ["modelValue", "size", "disabled"]);
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
|
|
2119
|
+
const __default__$i = vue.defineComponent({
|
|
2120
|
+
name: "MFormColorPicker"
|
|
2121
|
+
});
|
|
2122
|
+
const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
|
|
2123
|
+
...__default__$i,
|
|
2124
|
+
props: {
|
|
2125
|
+
config: null,
|
|
2126
|
+
model: null,
|
|
2127
|
+
initValues: null,
|
|
2128
|
+
values: null,
|
|
2129
|
+
name: null,
|
|
2130
|
+
prop: null,
|
|
2131
|
+
disabled: { type: Boolean },
|
|
2132
|
+
size: null
|
|
2133
|
+
},
|
|
2134
|
+
emits: ["change"],
|
|
2135
|
+
setup(__props, { emit }) {
|
|
2136
|
+
const props = __props;
|
|
2137
|
+
useAddField(props.prop);
|
|
2138
|
+
const changeHandler = (value) => emit("change", value);
|
|
2139
|
+
return (_ctx, _cache) => {
|
|
2140
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicColorPicker), {
|
|
2141
|
+
modelValue: __props.model[__props.name],
|
|
2142
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
2143
|
+
size: __props.size,
|
|
2144
|
+
disabled: __props.disabled,
|
|
2145
|
+
showAlpha: true,
|
|
2146
|
+
onChange: changeHandler
|
|
2147
|
+
}, null, 8, ["modelValue", "size", "disabled"]);
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
});
|
|
2151
|
+
|
|
2152
|
+
const __default__$h = vue.defineComponent({
|
|
2153
|
+
name: "MFormDate"
|
|
2154
|
+
});
|
|
2155
|
+
const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
|
|
2156
|
+
...__default__$h,
|
|
2157
|
+
props: {
|
|
2158
|
+
config: null,
|
|
2159
|
+
model: null,
|
|
2160
|
+
initValues: null,
|
|
2161
|
+
values: null,
|
|
2162
|
+
name: null,
|
|
2163
|
+
prop: null,
|
|
2164
|
+
disabled: { type: Boolean },
|
|
2165
|
+
size: null
|
|
2166
|
+
},
|
|
2167
|
+
emits: ["change"],
|
|
2168
|
+
setup(__props, { emit }) {
|
|
2169
|
+
const props = __props;
|
|
2170
|
+
useAddField(props.prop);
|
|
2171
|
+
props.model[props.name] = utils.datetimeFormatter(props.model[props.name], "");
|
|
2172
|
+
const changeHandler = (v) => {
|
|
2173
|
+
emit("change", v);
|
|
2174
|
+
};
|
|
2175
|
+
return (_ctx, _cache) => {
|
|
2176
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDatePicker), {
|
|
2177
|
+
modelValue: __props.model[__props.name],
|
|
2178
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
2179
|
+
type: "date",
|
|
2180
|
+
size: __props.size,
|
|
2181
|
+
placeholder: __props.config.placeholder,
|
|
2182
|
+
disabled: __props.disabled,
|
|
2183
|
+
format: __props.config.format,
|
|
2184
|
+
"value-format": __props.config.valueFormat || "YYYY-MM-DD HH:mm:ss",
|
|
2185
|
+
onChange: changeHandler
|
|
2186
|
+
}, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format"]);
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
|
|
2191
|
+
const __default__$g = vue.defineComponent({
|
|
2192
|
+
name: "MFormDateRange"
|
|
2193
|
+
});
|
|
2194
|
+
const _sfc_main$g = /* @__PURE__ */ vue.defineComponent({
|
|
2195
|
+
...__default__$g,
|
|
2196
|
+
props: {
|
|
2197
|
+
config: null,
|
|
2198
|
+
model: null,
|
|
2199
|
+
initValues: null,
|
|
2200
|
+
values: null,
|
|
2201
|
+
name: null,
|
|
2202
|
+
prop: null,
|
|
2203
|
+
disabled: { type: Boolean },
|
|
2204
|
+
size: null
|
|
2205
|
+
},
|
|
2206
|
+
emits: ["change"],
|
|
2207
|
+
setup(__props, { emit }) {
|
|
2208
|
+
const props = __props;
|
|
2209
|
+
useAddField(props.prop);
|
|
2210
|
+
const { names } = props.config;
|
|
2211
|
+
const value = vue.ref([]);
|
|
2212
|
+
if (props.model !== void 0) {
|
|
2213
|
+
if (names?.length) {
|
|
2214
|
+
vue.watch(
|
|
2215
|
+
[() => props.model[names[0]], () => props.model[names[1]]],
|
|
2216
|
+
([start, end], [preStart, preEnd]) => {
|
|
2217
|
+
if (!value.value) {
|
|
2218
|
+
value.value = [];
|
|
2219
|
+
}
|
|
2220
|
+
if (!start || !end)
|
|
2221
|
+
value.value = [];
|
|
2222
|
+
if (start !== preStart)
|
|
2223
|
+
value.value[0] = new Date(start);
|
|
2224
|
+
if (end !== preEnd)
|
|
2225
|
+
value.value[1] = new Date(end);
|
|
2226
|
+
},
|
|
2227
|
+
{
|
|
2228
|
+
immediate: true
|
|
2229
|
+
}
|
|
2230
|
+
);
|
|
2231
|
+
} else if (props.name && props.model[props.name]) {
|
|
2232
|
+
vue.watch(
|
|
2233
|
+
() => props.model[props.name],
|
|
2234
|
+
(start, preStart) => {
|
|
2235
|
+
if (start !== preStart)
|
|
2236
|
+
value.value = start.map((item) => item ? new Date(item) : void 0);
|
|
2237
|
+
},
|
|
2238
|
+
{
|
|
2239
|
+
immediate: true
|
|
2240
|
+
}
|
|
2241
|
+
);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
const setValue = (v) => {
|
|
2245
|
+
names?.forEach((item, index) => {
|
|
2246
|
+
if (!props.model) {
|
|
2247
|
+
return;
|
|
2248
|
+
}
|
|
2249
|
+
if (Array.isArray(v)) {
|
|
2250
|
+
props.model[item] = utils.datetimeFormatter(v[index]?.toString(), "");
|
|
2251
|
+
} else {
|
|
2252
|
+
props.model[item] = void 0;
|
|
2253
|
+
}
|
|
2254
|
+
});
|
|
2255
|
+
};
|
|
2256
|
+
const changeHandler = (v) => {
|
|
2257
|
+
const value2 = v || [];
|
|
2258
|
+
if (props.name) {
|
|
2259
|
+
emit(
|
|
2260
|
+
"change",
|
|
2261
|
+
value2.map((item) => {
|
|
2262
|
+
if (item)
|
|
2263
|
+
return utils.datetimeFormatter(item, "");
|
|
2264
|
+
return void 0;
|
|
2265
|
+
})
|
|
2266
|
+
);
|
|
2267
|
+
} else {
|
|
2268
|
+
if (names?.length) {
|
|
2269
|
+
setValue(value2);
|
|
2270
|
+
}
|
|
2271
|
+
emit("change", value2);
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
return (_ctx, _cache) => {
|
|
2275
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDatePicker), {
|
|
2276
|
+
modelValue: value.value,
|
|
2277
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
|
|
2278
|
+
type: "datetimerange",
|
|
2279
|
+
"range-separator": "-",
|
|
2280
|
+
"start-placeholder": "\u5F00\u59CB\u65E5\u671F",
|
|
2281
|
+
"end-placeholder": "\u7ED3\u675F\u65E5\u671F",
|
|
2282
|
+
size: __props.size,
|
|
2283
|
+
"unlink-panels": true,
|
|
2284
|
+
disabled: __props.disabled,
|
|
2285
|
+
"default-time": __props.config.defaultTime,
|
|
2286
|
+
onChange: changeHandler
|
|
2287
|
+
}, null, 8, ["modelValue", "size", "disabled", "default-time"]);
|
|
2288
|
+
};
|
|
2289
|
+
}
|
|
2290
|
+
});
|
|
2291
|
+
|
|
2292
|
+
const __default__$f = vue.defineComponent({
|
|
2293
|
+
name: "MFormDateTime"
|
|
2294
|
+
});
|
|
2295
|
+
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
2296
|
+
...__default__$f,
|
|
2297
|
+
props: {
|
|
2298
|
+
config: null,
|
|
2299
|
+
model: null,
|
|
2300
|
+
initValues: null,
|
|
2301
|
+
values: null,
|
|
2302
|
+
name: null,
|
|
2303
|
+
prop: null,
|
|
2304
|
+
disabled: { type: Boolean },
|
|
2305
|
+
size: null
|
|
2306
|
+
},
|
|
2307
|
+
emits: ["change"],
|
|
2308
|
+
setup(__props, { emit }) {
|
|
2309
|
+
const props = __props;
|
|
2310
|
+
useAddField(props.prop);
|
|
2311
|
+
const value = props.model?.[props.name].toString();
|
|
2312
|
+
if (props.model) {
|
|
2313
|
+
if (value === "Invalid Date") {
|
|
2314
|
+
props.model[props.name] = "";
|
|
2315
|
+
} else {
|
|
2316
|
+
props.model[props.name] = utils.datetimeFormatter(props.model[props.name], "", props.config.valueFormat);
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
const changeHandler = (v) => {
|
|
2320
|
+
emit("change", v);
|
|
2321
|
+
};
|
|
2322
|
+
return (_ctx, _cache) => {
|
|
2323
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDatePicker), {
|
|
2324
|
+
modelValue: __props.model[__props.name],
|
|
2325
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
2326
|
+
"popper-class": "magic-datetime-picker-popper",
|
|
2327
|
+
type: "datetime",
|
|
2328
|
+
size: __props.size,
|
|
2329
|
+
placeholder: __props.config.placeholder,
|
|
2330
|
+
disabled: __props.disabled,
|
|
2331
|
+
format: __props.config.format || "YYYY-MM-DD HH:mm:ss",
|
|
2332
|
+
"value-format": __props.config.valueFormat || "YYYY-MM-DD HH:mm:ss",
|
|
2333
|
+
"default-time": __props.config.defaultTime,
|
|
2334
|
+
onChange: changeHandler
|
|
2335
|
+
}, null, 8, ["modelValue", "size", "placeholder", "disabled", "format", "value-format", "default-time"]);
|
|
2336
|
+
};
|
|
2337
|
+
}
|
|
2338
|
+
});
|
|
2339
|
+
|
|
2340
|
+
const _hoisted_1$5 = { key: 0 };
|
|
2341
|
+
const __default__$e = vue.defineComponent({
|
|
2342
|
+
name: "MFormDisplay"
|
|
2343
|
+
});
|
|
2344
|
+
const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
|
|
2345
|
+
...__default__$e,
|
|
2346
|
+
props: {
|
|
2347
|
+
config: null,
|
|
2348
|
+
model: null,
|
|
2349
|
+
initValues: null,
|
|
2350
|
+
values: null,
|
|
2351
|
+
name: null,
|
|
2352
|
+
prop: null
|
|
2353
|
+
},
|
|
2354
|
+
setup(__props) {
|
|
2355
|
+
const props = __props;
|
|
2356
|
+
if (props.config.initValue && props.model) {
|
|
2357
|
+
props.model[props.name] = props.config.initValue;
|
|
2358
|
+
}
|
|
2359
|
+
useAddField(props.prop);
|
|
2360
|
+
return (_ctx, _cache) => {
|
|
2361
|
+
return __props.model ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1$5, vue.toDisplayString(__props.model[__props.name]), 1)) : vue.createCommentVNode("", true);
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
|
|
2366
|
+
const _hoisted_1$4 = { class: "m-fields-dynamic-field" };
|
|
2367
|
+
const __default__$d = vue.defineComponent({
|
|
2368
|
+
name: "MFormDynamicField"
|
|
2369
|
+
});
|
|
2370
|
+
const _sfc_main$d = /* @__PURE__ */ vue.defineComponent({
|
|
2371
|
+
...__default__$d,
|
|
2372
|
+
props: {
|
|
2373
|
+
config: null,
|
|
2374
|
+
model: null,
|
|
2375
|
+
initValues: null,
|
|
2376
|
+
values: null,
|
|
2377
|
+
name: null,
|
|
2378
|
+
prop: null,
|
|
2379
|
+
disabled: { type: Boolean },
|
|
2380
|
+
size: null
|
|
2381
|
+
},
|
|
2382
|
+
emits: ["change"],
|
|
2383
|
+
setup(__props, { emit }) {
|
|
2384
|
+
const props = __props;
|
|
2385
|
+
useAddField(props.prop);
|
|
2386
|
+
const request = getConfig("request");
|
|
2387
|
+
const fieldMap = vue.reactive({
|
|
2388
|
+
value: {}
|
|
2389
|
+
});
|
|
2390
|
+
const fieldLabelMap = vue.reactive({
|
|
2391
|
+
value: {}
|
|
2392
|
+
});
|
|
2393
|
+
const changeFieldMap = async () => {
|
|
2394
|
+
if (typeof props.config.returnFields !== "function" || !props.model)
|
|
2395
|
+
return;
|
|
2396
|
+
const fields = await props.config.returnFields(props.config, props.model, request);
|
|
2397
|
+
fieldMap.value = {};
|
|
2398
|
+
fieldLabelMap.value = {};
|
|
2399
|
+
fields.forEach((v) => {
|
|
2400
|
+
if (typeof v !== "object" || v.name === void 0)
|
|
2401
|
+
return;
|
|
2402
|
+
let oldVal = props.model?.[v.name] || "";
|
|
2403
|
+
if (!oldVal && v.defaultValue !== void 0) {
|
|
2404
|
+
oldVal = v.defaultValue;
|
|
2405
|
+
emit("change", oldVal, v.name);
|
|
2406
|
+
}
|
|
2407
|
+
fieldMap.value[v.name] = oldVal;
|
|
2408
|
+
fieldLabelMap.value[v.name] = v.label || "";
|
|
2409
|
+
});
|
|
2410
|
+
};
|
|
2411
|
+
const unwatch = vue.watch(
|
|
2412
|
+
() => props.model?.[props.config.dynamicKey],
|
|
2413
|
+
(val) => {
|
|
2414
|
+
if (val !== "") {
|
|
2415
|
+
changeFieldMap();
|
|
2416
|
+
}
|
|
2417
|
+
},
|
|
2418
|
+
{
|
|
2419
|
+
immediate: true
|
|
2420
|
+
}
|
|
2421
|
+
);
|
|
2422
|
+
vue.onBeforeUnmount(() => {
|
|
2423
|
+
if (typeof unwatch === "function") {
|
|
2424
|
+
unwatch();
|
|
2425
|
+
}
|
|
2426
|
+
});
|
|
2427
|
+
const inputChangeHandler = (key) => {
|
|
2428
|
+
emit("change", fieldMap.value[key], key);
|
|
2429
|
+
};
|
|
2430
|
+
return (_ctx, _cache) => {
|
|
2431
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
|
|
2432
|
+
vue.createVNode(vue.unref(design.TMagicForm), { size: "small" }, {
|
|
2433
|
+
default: vue.withCtx(() => [
|
|
2434
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(Object.keys(fieldMap.value), (key) => {
|
|
2435
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicFormItem), {
|
|
2436
|
+
key,
|
|
2437
|
+
label: fieldLabelMap.value[key]
|
|
2438
|
+
}, {
|
|
2439
|
+
default: vue.withCtx(() => [
|
|
2440
|
+
vue.createVNode(vue.unref(design.TMagicInput), {
|
|
2441
|
+
modelValue: fieldMap.value[key],
|
|
2442
|
+
"onUpdate:modelValue": ($event) => fieldMap.value[key] = $event,
|
|
2443
|
+
placeholder: fieldLabelMap.value[key],
|
|
2444
|
+
onChange: ($event) => inputChangeHandler(key)
|
|
2445
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "onChange"])
|
|
2446
|
+
]),
|
|
2447
|
+
_: 2
|
|
2448
|
+
}, 1032, ["label"]);
|
|
2449
|
+
}), 128))
|
|
2450
|
+
]),
|
|
2451
|
+
_: 1
|
|
2452
|
+
})
|
|
2453
|
+
]);
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
});
|
|
2457
|
+
|
|
2458
|
+
const __default__$c = vue.defineComponent({
|
|
2459
|
+
name: "MFormHidden"
|
|
2460
|
+
});
|
|
2461
|
+
const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
2462
|
+
...__default__$c,
|
|
2463
|
+
props: {
|
|
2464
|
+
config: null,
|
|
2465
|
+
model: null,
|
|
2466
|
+
initValues: null,
|
|
2467
|
+
values: null,
|
|
2468
|
+
name: null,
|
|
2469
|
+
prop: null
|
|
2470
|
+
},
|
|
2471
|
+
setup(__props) {
|
|
2472
|
+
const props = __props;
|
|
2473
|
+
useAddField(props.prop);
|
|
2474
|
+
return (_ctx, _cache) => {
|
|
2475
|
+
return __props.model ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("input", {
|
|
2476
|
+
key: 0,
|
|
2477
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
2478
|
+
type: "hidden"
|
|
2479
|
+
}, null, 512)), [
|
|
2480
|
+
[vue.vModelText, __props.model[__props.name]]
|
|
2481
|
+
]) : vue.createCommentVNode("", true);
|
|
2482
|
+
};
|
|
2483
|
+
}
|
|
2484
|
+
});
|
|
2485
|
+
|
|
2486
|
+
const __default__$b = vue.defineComponent({
|
|
2487
|
+
name: "MForm"
|
|
2488
|
+
});
|
|
2489
|
+
const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
|
|
2490
|
+
...__default__$b,
|
|
2491
|
+
props: {
|
|
2492
|
+
config: { default: () => [] },
|
|
2493
|
+
initValues: { default: () => ({}) },
|
|
2494
|
+
parentValues: { default: () => ({}) },
|
|
2495
|
+
labelWidth: { default: "200px" },
|
|
2496
|
+
disabled: { type: Boolean, default: false },
|
|
2497
|
+
height: { default: "auto" },
|
|
2498
|
+
stepActive: { default: 1 },
|
|
2499
|
+
size: null,
|
|
2500
|
+
inline: { type: Boolean, default: false },
|
|
2501
|
+
labelPosition: { default: "right" },
|
|
2502
|
+
keyProp: { default: "__key" },
|
|
2503
|
+
popperClass: null
|
|
2504
|
+
},
|
|
2505
|
+
emits: ["change", "field-input", "field-change"],
|
|
2506
|
+
setup(__props, { expose, emit }) {
|
|
2507
|
+
const props = __props;
|
|
2508
|
+
const tMagicForm = vue.ref();
|
|
2509
|
+
const initialized = vue.ref(false);
|
|
2510
|
+
const values = vue.ref({});
|
|
2511
|
+
const fields = /* @__PURE__ */ new Map();
|
|
2512
|
+
const requestFuc = getConfig("request");
|
|
2513
|
+
const formState = vue.reactive({
|
|
2514
|
+
keyProp: props.keyProp,
|
|
2515
|
+
popperClass: props.popperClass,
|
|
2516
|
+
config: props.config,
|
|
2517
|
+
initValues: props.initValues,
|
|
2518
|
+
parentValues: props.parentValues,
|
|
2519
|
+
values,
|
|
2520
|
+
$emit: emit,
|
|
2521
|
+
fields,
|
|
2522
|
+
setField: (prop, field) => fields.set(prop, field),
|
|
2523
|
+
getField: (prop) => fields.get(prop),
|
|
2524
|
+
deleteField: (prop) => fields.delete(prop),
|
|
2525
|
+
post: (options) => {
|
|
2526
|
+
if (requestFuc) {
|
|
2527
|
+
return requestFuc({
|
|
2528
|
+
...options,
|
|
2529
|
+
method: "POST"
|
|
2530
|
+
});
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
});
|
|
2534
|
+
vue.watchEffect(() => {
|
|
2535
|
+
formState.initValues = props.initValues;
|
|
2536
|
+
formState.config = props.config;
|
|
2537
|
+
formState.keyProp = props.keyProp;
|
|
2538
|
+
formState.popperClass = props.popperClass;
|
|
2539
|
+
formState.parentValues = props.parentValues;
|
|
2540
|
+
});
|
|
2541
|
+
vue.provide("mForm", formState);
|
|
2542
|
+
vue.watch(
|
|
2543
|
+
[() => props.config, () => props.initValues],
|
|
2544
|
+
([config], [preConfig]) => {
|
|
2545
|
+
if (!isEqual__default.default(vue.toRaw(config), vue.toRaw(preConfig))) {
|
|
2546
|
+
initialized.value = false;
|
|
2547
|
+
}
|
|
2548
|
+
initValue(formState, {
|
|
2549
|
+
initValues: props.initValues,
|
|
2550
|
+
config: props.config
|
|
2551
|
+
}).then((value) => {
|
|
2552
|
+
values.value = value;
|
|
2553
|
+
initialized.value = true;
|
|
2554
|
+
});
|
|
2555
|
+
},
|
|
2556
|
+
{ immediate: true }
|
|
2557
|
+
);
|
|
2558
|
+
const changeHandler = () => {
|
|
2559
|
+
emit("change", values.value);
|
|
2560
|
+
};
|
|
2561
|
+
expose({
|
|
2562
|
+
values,
|
|
2563
|
+
formState,
|
|
2564
|
+
initialized,
|
|
2565
|
+
changeHandler,
|
|
2566
|
+
resetForm: () => tMagicForm.value?.resetFields(),
|
|
2567
|
+
submitForm: async (native) => {
|
|
2568
|
+
try {
|
|
2569
|
+
await tMagicForm.value?.validate();
|
|
2570
|
+
return native ? values.value : cloneDeep__default.default(vue.toRaw(values.value));
|
|
2571
|
+
} catch (invalidFields) {
|
|
2572
|
+
const error = [];
|
|
2573
|
+
Object.entries(invalidFields).forEach(([, ValidateError]) => {
|
|
2574
|
+
ValidateError.forEach(({ field, message }) => {
|
|
2575
|
+
if (field && message)
|
|
2576
|
+
error.push(`${field} -> ${message}`);
|
|
2577
|
+
if (field && !message)
|
|
2578
|
+
error.push(`${field} -> \u51FA\u73B0\u9519\u8BEF`);
|
|
2579
|
+
if (!field && message)
|
|
2580
|
+
error.push(`${message}`);
|
|
2581
|
+
});
|
|
2582
|
+
});
|
|
2583
|
+
throw new Error(error.join("<br>"));
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
return (_ctx, _cache) => {
|
|
2588
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicForm), {
|
|
2589
|
+
class: "m-form",
|
|
2590
|
+
ref_key: "tMagicForm",
|
|
2591
|
+
ref: tMagicForm,
|
|
2592
|
+
model: values.value,
|
|
2593
|
+
"label-width": __props.labelWidth,
|
|
2594
|
+
style: vue.normalizeStyle(`height: ${__props.height}`),
|
|
2595
|
+
inline: __props.inline,
|
|
2596
|
+
"label-position": __props.labelPosition
|
|
2597
|
+
}, {
|
|
2598
|
+
default: vue.withCtx(() => [
|
|
2599
|
+
initialized.value && Array.isArray(__props.config) ? (vue.openBlock(true), vue.createElementBlock(vue.Fragment, { key: 0 }, vue.renderList(__props.config, (item, index) => {
|
|
2600
|
+
return vue.openBlock(), vue.createBlock(_sfc_main$v, {
|
|
2601
|
+
disabled: __props.disabled,
|
|
2602
|
+
key: item[__props.keyProp] ?? index,
|
|
2603
|
+
config: item,
|
|
2604
|
+
model: values.value,
|
|
2605
|
+
"label-width": item.labelWidth || __props.labelWidth,
|
|
2606
|
+
"step-active": __props.stepActive,
|
|
2607
|
+
size: __props.size,
|
|
2608
|
+
onChange: changeHandler
|
|
2609
|
+
}, null, 8, ["disabled", "config", "model", "label-width", "step-active", "size"]);
|
|
2610
|
+
}), 128)) : vue.createCommentVNode("", true)
|
|
2611
|
+
]),
|
|
2612
|
+
_: 1
|
|
2613
|
+
}, 8, ["model", "label-width", "style", "inline", "label-position"]);
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
});
|
|
2617
|
+
|
|
2618
|
+
const _hoisted_1$3 = { style: { "min-height": "1px" } };
|
|
2619
|
+
const _hoisted_2$1 = /* @__PURE__ */ vue.createTextVNode("\u53D6 \u6D88");
|
|
2620
|
+
const _hoisted_3$1 = /* @__PURE__ */ vue.createTextVNode("\u4E0A\u4E00\u6B65");
|
|
2621
|
+
const _hoisted_4 = /* @__PURE__ */ vue.createTextVNode("\u4E0B\u4E00\u6B65");
|
|
2622
|
+
const __default__$a = vue.defineComponent({
|
|
2623
|
+
name: "MFormDialog"
|
|
2624
|
+
});
|
|
2625
|
+
const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
|
|
2626
|
+
...__default__$a,
|
|
2627
|
+
props: {
|
|
2628
|
+
config: { default: () => [] },
|
|
2629
|
+
values: { default: () => ({}) },
|
|
2630
|
+
parentValues: null,
|
|
2631
|
+
width: null,
|
|
2632
|
+
labelWidth: null,
|
|
2633
|
+
fullscreen: { type: Boolean },
|
|
2634
|
+
disabled: { type: Boolean },
|
|
2635
|
+
title: null,
|
|
2636
|
+
zIndex: null,
|
|
2637
|
+
size: null,
|
|
2638
|
+
confirmText: { default: "\u786E\u5B9A" }
|
|
2639
|
+
},
|
|
2640
|
+
emits: ["close", "submit", "error", "change"],
|
|
2641
|
+
setup(__props, { expose, emit }) {
|
|
2642
|
+
const props = __props;
|
|
2643
|
+
const form = vue.ref();
|
|
2644
|
+
const dialogVisible = vue.ref(false);
|
|
2645
|
+
const saveFetch = vue.ref(false);
|
|
2646
|
+
const stepActive = vue.ref(1);
|
|
2647
|
+
const bodyHeight = vue.ref(`${document.body.clientHeight - 194}px`);
|
|
2648
|
+
const stepCount = vue.computed(() => {
|
|
2649
|
+
const { length } = props.config;
|
|
2650
|
+
for (let index = 0; index < length; index++) {
|
|
2651
|
+
if (props.config[index].type === "step") {
|
|
2652
|
+
return props.config[index].items.length;
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
return 0;
|
|
2656
|
+
});
|
|
2657
|
+
const hasStep = vue.computed(() => {
|
|
2658
|
+
const { length } = props.config;
|
|
2659
|
+
for (let index = 0; index < length; index++) {
|
|
2660
|
+
if (props.config[index].type === "step") {
|
|
2661
|
+
return true;
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
return false;
|
|
2665
|
+
});
|
|
2666
|
+
const cancel = () => {
|
|
2667
|
+
dialogVisible.value = false;
|
|
2668
|
+
};
|
|
2669
|
+
const closeHandler = () => {
|
|
2670
|
+
stepActive.value = 1;
|
|
2671
|
+
emit("close");
|
|
2672
|
+
};
|
|
2673
|
+
const save = async () => {
|
|
2674
|
+
try {
|
|
2675
|
+
const values = await form.value?.submitForm();
|
|
2676
|
+
emit("submit", values);
|
|
2677
|
+
} catch (e) {
|
|
2678
|
+
emit("error", e);
|
|
2679
|
+
}
|
|
2680
|
+
};
|
|
2681
|
+
const preStep = () => {
|
|
2682
|
+
stepActive.value -= 1;
|
|
2683
|
+
};
|
|
2684
|
+
const nextStep = () => {
|
|
2685
|
+
stepActive.value += 1;
|
|
2686
|
+
};
|
|
2687
|
+
const changeHandler = (value) => {
|
|
2688
|
+
emit("change", value);
|
|
2689
|
+
};
|
|
2690
|
+
expose({
|
|
2691
|
+
form,
|
|
2692
|
+
saveFetch,
|
|
2693
|
+
dialogVisible,
|
|
2694
|
+
cancel,
|
|
2695
|
+
save
|
|
2696
|
+
});
|
|
2697
|
+
return (_ctx, _cache) => {
|
|
2698
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicDialog), {
|
|
2699
|
+
modelValue: dialogVisible.value,
|
|
2700
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => dialogVisible.value = $event),
|
|
2701
|
+
class: "m-form-dialog",
|
|
2702
|
+
top: "20px",
|
|
2703
|
+
"append-to-body": "",
|
|
2704
|
+
title: __props.title,
|
|
2705
|
+
width: __props.width,
|
|
2706
|
+
zIndex: __props.zIndex,
|
|
2707
|
+
fullscreen: __props.fullscreen,
|
|
2708
|
+
"close-on-click-modal": false,
|
|
2709
|
+
onClose: closeHandler
|
|
2710
|
+
}, {
|
|
2711
|
+
footer: vue.withCtx(() => [
|
|
2712
|
+
vue.createVNode(vue.unref(design.TMagicRow), { class: "dialog-footer" }, {
|
|
2713
|
+
default: vue.withCtx(() => [
|
|
2714
|
+
vue.createVNode(vue.unref(design.TMagicCol), {
|
|
2715
|
+
span: 12,
|
|
2716
|
+
style: { "text-align": "left" }
|
|
2717
|
+
}, {
|
|
2718
|
+
default: vue.withCtx(() => [
|
|
2719
|
+
vue.createElementVNode("div", _hoisted_1$3, [
|
|
2720
|
+
vue.renderSlot(_ctx.$slots, "left")
|
|
2721
|
+
])
|
|
2722
|
+
]),
|
|
2723
|
+
_: 3
|
|
2724
|
+
}),
|
|
2725
|
+
vue.createVNode(vue.unref(design.TMagicCol), { span: 12 }, {
|
|
2726
|
+
default: vue.withCtx(() => [
|
|
2727
|
+
vue.renderSlot(_ctx.$slots, "footer", {}, () => [
|
|
2728
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
2729
|
+
onClick: cancel,
|
|
2730
|
+
size: "small"
|
|
2731
|
+
}, {
|
|
2732
|
+
default: vue.withCtx(() => [
|
|
2733
|
+
_hoisted_2$1
|
|
2734
|
+
]),
|
|
2735
|
+
_: 1
|
|
2736
|
+
}),
|
|
2737
|
+
vue.unref(hasStep) && stepActive.value > 1 ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
2738
|
+
key: 0,
|
|
2739
|
+
type: "info",
|
|
2740
|
+
size: "small",
|
|
2741
|
+
onClick: preStep
|
|
2742
|
+
}, {
|
|
2743
|
+
default: vue.withCtx(() => [
|
|
2744
|
+
_hoisted_3$1
|
|
2745
|
+
]),
|
|
2746
|
+
_: 1
|
|
2747
|
+
})) : vue.createCommentVNode("", true),
|
|
2748
|
+
vue.unref(hasStep) && vue.unref(stepCount) > stepActive.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
2749
|
+
key: 1,
|
|
2750
|
+
type: "info",
|
|
2751
|
+
size: "small",
|
|
2752
|
+
onClick: nextStep
|
|
2753
|
+
}, {
|
|
2754
|
+
default: vue.withCtx(() => [
|
|
2755
|
+
_hoisted_4
|
|
2756
|
+
]),
|
|
2757
|
+
_: 1
|
|
2758
|
+
})) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
2759
|
+
key: 2,
|
|
2760
|
+
type: "primary",
|
|
2761
|
+
size: "small",
|
|
2762
|
+
loading: saveFetch.value,
|
|
2763
|
+
onClick: save
|
|
2764
|
+
}, {
|
|
2765
|
+
default: vue.withCtx(() => [
|
|
2766
|
+
vue.createTextVNode(vue.toDisplayString(__props.confirmText), 1)
|
|
2767
|
+
]),
|
|
2768
|
+
_: 1
|
|
2769
|
+
}, 8, ["loading"]))
|
|
2770
|
+
])
|
|
2771
|
+
]),
|
|
2772
|
+
_: 3
|
|
2773
|
+
})
|
|
2774
|
+
]),
|
|
2775
|
+
_: 3
|
|
2776
|
+
})
|
|
2777
|
+
]),
|
|
2778
|
+
default: vue.withCtx(() => [
|
|
2779
|
+
dialogVisible.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
2780
|
+
key: 0,
|
|
2781
|
+
class: "m-dialog-body",
|
|
2782
|
+
style: vue.normalizeStyle(`max-height: ${bodyHeight.value}; overflow-y: auto; overflow-x: hidden;`)
|
|
2783
|
+
}, [
|
|
2784
|
+
vue.createVNode(_sfc_main$b, {
|
|
2785
|
+
modelValue: stepActive.value,
|
|
2786
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => stepActive.value = $event),
|
|
2787
|
+
ref_key: "form",
|
|
2788
|
+
ref: form,
|
|
2789
|
+
size: __props.size,
|
|
2790
|
+
disabled: __props.disabled,
|
|
2791
|
+
config: __props.config,
|
|
2792
|
+
"init-values": __props.values,
|
|
2793
|
+
"parent-values": __props.parentValues,
|
|
2794
|
+
"label-width": __props.labelWidth,
|
|
2795
|
+
onChange: changeHandler
|
|
2796
|
+
}, null, 8, ["modelValue", "size", "disabled", "config", "init-values", "parent-values", "label-width"]),
|
|
2797
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
2798
|
+
], 4)) : vue.createCommentVNode("", true)
|
|
2799
|
+
]),
|
|
2800
|
+
_: 3
|
|
2801
|
+
}, 8, ["modelValue", "title", "width", "zIndex", "fullscreen"]);
|
|
2802
|
+
};
|
|
2803
|
+
}
|
|
2804
|
+
});
|
|
2805
|
+
|
|
2806
|
+
const _hoisted_1$2 = ["href"];
|
|
2807
|
+
const _hoisted_2 = {
|
|
2808
|
+
key: 2,
|
|
2809
|
+
class: "m-fields-link"
|
|
2810
|
+
};
|
|
2811
|
+
const _hoisted_3 = /* @__PURE__ */ vue.createTextVNode("\u70B9\u51FB\u7F16\u8F91");
|
|
2812
|
+
const __default__$9 = vue.defineComponent({
|
|
2813
|
+
name: "MFormLink"
|
|
2814
|
+
});
|
|
2815
|
+
const _sfc_main$9 = /* @__PURE__ */ vue.defineComponent({
|
|
2816
|
+
...__default__$9,
|
|
2817
|
+
props: {
|
|
2818
|
+
config: null,
|
|
2819
|
+
model: null,
|
|
2820
|
+
initValues: null,
|
|
2821
|
+
values: null,
|
|
2822
|
+
name: null,
|
|
2823
|
+
prop: null,
|
|
2824
|
+
disabled: { type: Boolean },
|
|
2825
|
+
size: null
|
|
2826
|
+
},
|
|
2827
|
+
emits: ["change"],
|
|
2828
|
+
setup(__props, { emit }) {
|
|
2829
|
+
const props = __props;
|
|
2830
|
+
useAddField(props.prop);
|
|
2831
|
+
const formValue = vue.ref({});
|
|
2832
|
+
const editor = vue.ref();
|
|
2833
|
+
const mForm = vue.inject("mForm");
|
|
2834
|
+
const href = vue.computed(() => {
|
|
2835
|
+
if (typeof props.config.href === "function" && props.model) {
|
|
2836
|
+
return props.config.href(props.model);
|
|
2837
|
+
}
|
|
2838
|
+
return props.config.href || props.model?.[props.name];
|
|
2839
|
+
});
|
|
2840
|
+
const init = () => {
|
|
2841
|
+
formValue.value = props.model?.[props.name] || {};
|
|
2842
|
+
};
|
|
2843
|
+
const formConfig = vue.computed(() => {
|
|
2844
|
+
if (typeof props.config.form === "function") {
|
|
2845
|
+
return props.config.form(mForm, {
|
|
2846
|
+
model: props.model || {},
|
|
2847
|
+
values: props.values || {}
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
return props.config.form;
|
|
2851
|
+
});
|
|
2852
|
+
const displayText = vue.computed(() => {
|
|
2853
|
+
if (typeof props.config.displayText === "function") {
|
|
2854
|
+
return props.config.displayText(mForm, { model: props.model || {} });
|
|
2855
|
+
}
|
|
2856
|
+
if (props.config.displayText) {
|
|
2857
|
+
return props.config.displayText;
|
|
2858
|
+
}
|
|
2859
|
+
return "\u8DF3\u8F6C";
|
|
2860
|
+
});
|
|
2861
|
+
const editHandler = () => {
|
|
2862
|
+
init();
|
|
2863
|
+
editor.value && (editor.value.dialogVisible = true);
|
|
2864
|
+
};
|
|
2865
|
+
const action = (data) => {
|
|
2866
|
+
if (props.model) {
|
|
2867
|
+
props.model[props.name] = data;
|
|
2868
|
+
formValue.value = data;
|
|
2869
|
+
emit("change", props.model[props.name]);
|
|
2870
|
+
}
|
|
2871
|
+
editor.value && (editor.value.dialogVisible = false);
|
|
2872
|
+
};
|
|
2873
|
+
return (_ctx, _cache) => {
|
|
2874
|
+
return __props.config.href && !__props.disabled ? (vue.openBlock(), vue.createElementBlock("a", {
|
|
2875
|
+
key: 0,
|
|
2876
|
+
target: "_blank",
|
|
2877
|
+
href: vue.unref(href),
|
|
2878
|
+
style: vue.normalizeStyle(__props.config.css || {})
|
|
2879
|
+
}, vue.toDisplayString(vue.unref(displayText)), 13, _hoisted_1$2)) : __props.config.href && __props.disabled ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
2880
|
+
key: 1,
|
|
2881
|
+
style: vue.normalizeStyle(__props.config.disabledCss || {})
|
|
2882
|
+
}, vue.toDisplayString(vue.unref(displayText)), 5)) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [
|
|
2883
|
+
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
2884
|
+
text: true,
|
|
2885
|
+
type: "primary",
|
|
2886
|
+
onClick: editHandler
|
|
2887
|
+
}, {
|
|
2888
|
+
default: vue.withCtx(() => [
|
|
2889
|
+
_hoisted_3
|
|
2890
|
+
]),
|
|
2891
|
+
_: 1
|
|
2892
|
+
}),
|
|
2893
|
+
vue.createVNode(_sfc_main$a, {
|
|
2894
|
+
ref_key: "editor",
|
|
2895
|
+
ref: editor,
|
|
2896
|
+
title: __props.config.formTitle || "\u7F16\u8F91\u6269\u5C55\u914D\u7F6E",
|
|
2897
|
+
width: __props.config.formWidth,
|
|
2898
|
+
values: formValue.value,
|
|
2899
|
+
config: vue.unref(formConfig),
|
|
2900
|
+
parentValues: __props.values,
|
|
2901
|
+
fullscreen: __props.config.fullscreen,
|
|
2902
|
+
onSubmit: action
|
|
2903
|
+
}, null, 8, ["title", "width", "values", "config", "parentValues", "fullscreen"])
|
|
2904
|
+
]));
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
});
|
|
2908
|
+
|
|
2909
|
+
const __default__$8 = vue.defineComponent({
|
|
2910
|
+
name: "MFormNumber"
|
|
2911
|
+
});
|
|
2912
|
+
const _sfc_main$8 = /* @__PURE__ */ vue.defineComponent({
|
|
2913
|
+
...__default__$8,
|
|
2914
|
+
props: {
|
|
2915
|
+
config: null,
|
|
2916
|
+
model: null,
|
|
2917
|
+
initValues: null,
|
|
2918
|
+
values: null,
|
|
2919
|
+
name: null,
|
|
2920
|
+
prop: null,
|
|
2921
|
+
disabled: { type: Boolean },
|
|
2922
|
+
size: null
|
|
2923
|
+
},
|
|
2924
|
+
emits: ["change", "input"],
|
|
2925
|
+
setup(__props, { emit }) {
|
|
2926
|
+
const props = __props;
|
|
2927
|
+
useAddField(props.prop);
|
|
2928
|
+
const mForm = vue.inject("mForm");
|
|
2929
|
+
const changeHandler = (value) => {
|
|
2930
|
+
emit("change", value);
|
|
2931
|
+
};
|
|
2932
|
+
const inputHandler = (v) => {
|
|
2933
|
+
emit("input", v);
|
|
2934
|
+
mForm?.$emit("field-input", props.prop, v);
|
|
2935
|
+
};
|
|
2936
|
+
return (_ctx, _cache) => {
|
|
2937
|
+
return __props.model ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInputNumber), {
|
|
2938
|
+
key: 0,
|
|
2939
|
+
modelValue: __props.model[__props.name],
|
|
2940
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
2941
|
+
clearable: "",
|
|
2942
|
+
"controls-position": "right",
|
|
2943
|
+
size: __props.size,
|
|
2944
|
+
max: __props.config.max,
|
|
2945
|
+
min: __props.config.min,
|
|
2946
|
+
step: __props.config.step,
|
|
2947
|
+
placeholder: __props.config.placeholder,
|
|
2948
|
+
disabled: __props.disabled,
|
|
2949
|
+
onChange: changeHandler,
|
|
2950
|
+
onInput: inputHandler
|
|
2951
|
+
}, null, 8, ["modelValue", "size", "max", "min", "step", "placeholder", "disabled"])) : vue.createCommentVNode("", true);
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2954
|
+
});
|
|
2955
|
+
|
|
2956
|
+
const __default__$7 = vue.defineComponent({
|
|
2957
|
+
name: "MFormRadioGroup"
|
|
2958
|
+
});
|
|
2959
|
+
const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
2960
|
+
...__default__$7,
|
|
2961
|
+
props: {
|
|
2962
|
+
config: null,
|
|
2963
|
+
model: null,
|
|
2964
|
+
initValues: null,
|
|
2965
|
+
values: null,
|
|
2966
|
+
name: null,
|
|
2967
|
+
prop: null,
|
|
2968
|
+
disabled: { type: Boolean },
|
|
2969
|
+
size: null
|
|
2970
|
+
},
|
|
2971
|
+
emits: ["change"],
|
|
2972
|
+
setup(__props, { emit }) {
|
|
2973
|
+
const props = __props;
|
|
2974
|
+
const changeHandler = (value) => {
|
|
2975
|
+
emit("change", value);
|
|
2976
|
+
};
|
|
2977
|
+
useAddField(props.prop);
|
|
2978
|
+
return (_ctx, _cache) => {
|
|
2979
|
+
return __props.model ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicRadioGroup), {
|
|
2980
|
+
key: 0,
|
|
2981
|
+
modelValue: __props.model[__props.name],
|
|
2982
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
2983
|
+
size: __props.size,
|
|
2984
|
+
disabled: __props.disabled,
|
|
2985
|
+
onChange: changeHandler
|
|
2986
|
+
}, {
|
|
2987
|
+
default: vue.withCtx(() => [
|
|
2988
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.config.options, (option) => {
|
|
2989
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicRadio), {
|
|
2990
|
+
label: option.value,
|
|
2991
|
+
key: `${option.value}`
|
|
2992
|
+
}, {
|
|
2993
|
+
default: vue.withCtx(() => [
|
|
2994
|
+
vue.createTextVNode(vue.toDisplayString(option.text), 1)
|
|
2995
|
+
]),
|
|
2996
|
+
_: 2
|
|
2997
|
+
}, 1032, ["label"]);
|
|
2998
|
+
}), 128))
|
|
2999
|
+
]),
|
|
3000
|
+
_: 1
|
|
3001
|
+
}, 8, ["modelValue", "size", "disabled"])) : vue.createCommentVNode("", true);
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
});
|
|
3005
|
+
|
|
3006
|
+
const __default__$6 = vue.defineComponent({
|
|
3007
|
+
name: "MFormSelectOptionGroups"
|
|
3008
|
+
});
|
|
3009
|
+
const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
3010
|
+
...__default__$6,
|
|
3011
|
+
props: {
|
|
3012
|
+
options: null
|
|
3013
|
+
},
|
|
3014
|
+
setup(__props) {
|
|
3015
|
+
const uiComponent = design.getConfig("components").option;
|
|
3016
|
+
return (_ctx, _cache) => {
|
|
3017
|
+
return vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.options, (group, index) => {
|
|
3018
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicOptionGroup), {
|
|
3019
|
+
key: index,
|
|
3020
|
+
label: group.label,
|
|
3021
|
+
disabled: group.disabled
|
|
3022
|
+
}, {
|
|
3023
|
+
default: vue.withCtx(() => [
|
|
3024
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group.options, (item, index2) => {
|
|
3025
|
+
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(uiComponent).component), {
|
|
3026
|
+
key: index2,
|
|
3027
|
+
label: item.label || item.text,
|
|
3028
|
+
value: item.value,
|
|
3029
|
+
disabled: item.disabled
|
|
3030
|
+
}, null, 8, ["label", "value", "disabled"]);
|
|
3031
|
+
}), 128))
|
|
3032
|
+
]),
|
|
3033
|
+
_: 2
|
|
3034
|
+
}, 1032, ["label", "disabled"]);
|
|
3035
|
+
}), 128);
|
|
3036
|
+
};
|
|
3037
|
+
}
|
|
3038
|
+
});
|
|
3039
|
+
|
|
3040
|
+
const __default__$5 = vue.defineComponent({
|
|
3041
|
+
name: "MFormSelectOptions"
|
|
3042
|
+
});
|
|
3043
|
+
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3044
|
+
...__default__$5,
|
|
3045
|
+
props: {
|
|
3046
|
+
options: null,
|
|
3047
|
+
valueKey: null
|
|
3048
|
+
},
|
|
3049
|
+
setup(__props) {
|
|
3050
|
+
return (_ctx, _cache) => {
|
|
3051
|
+
return vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.options, (option) => {
|
|
3052
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicOption), {
|
|
3053
|
+
label: option.text,
|
|
3054
|
+
value: option.value,
|
|
3055
|
+
key: __props.valueKey ? option.value[__props.valueKey] : option.value,
|
|
3056
|
+
disabled: option.disabled
|
|
3057
|
+
}, null, 8, ["label", "value", "disabled"]);
|
|
3058
|
+
}), 128);
|
|
3059
|
+
};
|
|
3060
|
+
}
|
|
3061
|
+
});
|
|
3062
|
+
|
|
3063
|
+
const _hoisted_1$1 = { key: 2 };
|
|
3064
|
+
const __default__$4 = vue.defineComponent({
|
|
3065
|
+
name: "MFormSelect"
|
|
3066
|
+
});
|
|
3067
|
+
const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
3068
|
+
...__default__$4,
|
|
3069
|
+
props: {
|
|
3070
|
+
config: null,
|
|
3071
|
+
model: null,
|
|
3072
|
+
initValues: null,
|
|
3073
|
+
values: null,
|
|
3074
|
+
name: null,
|
|
3075
|
+
prop: null,
|
|
3076
|
+
disabled: { type: Boolean },
|
|
3077
|
+
size: null
|
|
3078
|
+
},
|
|
3079
|
+
emits: ["change"],
|
|
3080
|
+
setup(__props, { emit }) {
|
|
3081
|
+
const props = __props;
|
|
3082
|
+
if (!props.model)
|
|
3083
|
+
throw new Error("\u4E0D\u80FD\u6CA1\u6709model");
|
|
3084
|
+
useAddField(props.prop);
|
|
3085
|
+
const tMagicSelect = vue.ref();
|
|
3086
|
+
const mForm = vue.inject("mForm");
|
|
3087
|
+
const options = vue.ref([]);
|
|
3088
|
+
const localOptions = vue.ref([]);
|
|
3089
|
+
const loading = vue.ref(false);
|
|
3090
|
+
const moreLoadingVisible = vue.ref(false);
|
|
3091
|
+
const total = vue.ref(0);
|
|
3092
|
+
const pgIndex = vue.ref(0);
|
|
3093
|
+
const pgSize = vue.ref(20);
|
|
3094
|
+
const query = vue.ref("");
|
|
3095
|
+
const remoteData = vue.ref([]);
|
|
3096
|
+
const remote = vue.ref(true);
|
|
3097
|
+
const equalValue = (value, v) => {
|
|
3098
|
+
if (typeof v === "object") {
|
|
3099
|
+
const key = props.config.valueKey || "value";
|
|
3100
|
+
return v[key] === value[key];
|
|
3101
|
+
}
|
|
3102
|
+
return value === v;
|
|
3103
|
+
};
|
|
3104
|
+
const mapOptions = (data) => {
|
|
3105
|
+
const { option } = props.config;
|
|
3106
|
+
const { text } = option;
|
|
3107
|
+
const { value } = option;
|
|
3108
|
+
return data.map((item) => ({
|
|
3109
|
+
text: typeof text === "function" ? text(item) : item[text || "text"],
|
|
3110
|
+
value: typeof value === "function" ? value(item) : item[value || "value"]
|
|
3111
|
+
}));
|
|
3112
|
+
};
|
|
3113
|
+
const getOptions = async () => {
|
|
3114
|
+
if (!props.model)
|
|
3115
|
+
return [];
|
|
3116
|
+
if (localOptions.value.length) {
|
|
3117
|
+
return localOptions.value;
|
|
3118
|
+
}
|
|
3119
|
+
loading.value = true;
|
|
3120
|
+
let items = [];
|
|
3121
|
+
const { config } = props;
|
|
3122
|
+
const { option } = config;
|
|
3123
|
+
let { body } = option;
|
|
3124
|
+
let postOptions = {
|
|
3125
|
+
method: option.method || "POST",
|
|
3126
|
+
url: option.url,
|
|
3127
|
+
cache: option.cache,
|
|
3128
|
+
timeout: option.timeout,
|
|
3129
|
+
mode: option.mode,
|
|
3130
|
+
headers: option.headers || {},
|
|
3131
|
+
json: option.json || false
|
|
3132
|
+
};
|
|
3133
|
+
if (body) {
|
|
3134
|
+
if (typeof body === "function") {
|
|
3135
|
+
body = body(mForm, {
|
|
3136
|
+
model: props.model,
|
|
3137
|
+
formValue: mForm?.values,
|
|
3138
|
+
formValues: mForm?.values,
|
|
3139
|
+
config: props.config
|
|
3140
|
+
});
|
|
3141
|
+
}
|
|
3142
|
+
body.query = query.value;
|
|
3143
|
+
body.pgSize = pgSize.value;
|
|
3144
|
+
body.pgIndex = pgIndex.value;
|
|
3145
|
+
postOptions.data = body;
|
|
3146
|
+
}
|
|
3147
|
+
const requestFuc = getConfig("request");
|
|
3148
|
+
if (typeof option.beforeRequest === "function") {
|
|
3149
|
+
postOptions = option.beforeRequest(mForm, postOptions, {
|
|
3150
|
+
model: props.model,
|
|
3151
|
+
formValue: mForm?.values
|
|
3152
|
+
});
|
|
3153
|
+
}
|
|
3154
|
+
if (option.method?.toLocaleLowerCase() === "jsonp") {
|
|
3155
|
+
postOptions.jsonpCallback = option.jsonpCallback || "callback";
|
|
3156
|
+
}
|
|
3157
|
+
let res = await requestFuc(postOptions);
|
|
3158
|
+
if (typeof option.afterRequest === "function") {
|
|
3159
|
+
res = option.afterRequest(mForm, res, {
|
|
3160
|
+
model: props.model,
|
|
3161
|
+
formValue: mForm?.values,
|
|
3162
|
+
formValues: mForm?.values,
|
|
3163
|
+
config: props.config
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
const optionsData = res[option.root];
|
|
3167
|
+
if (res.total > 0) {
|
|
3168
|
+
total.value = res.total;
|
|
3169
|
+
}
|
|
3170
|
+
remoteData.value = remoteData.value.concat(optionsData);
|
|
3171
|
+
if (optionsData) {
|
|
3172
|
+
if (typeof option.item === "function") {
|
|
3173
|
+
items = option.item(optionsData);
|
|
3174
|
+
} else if (optionsData.map) {
|
|
3175
|
+
items = mapOptions(optionsData);
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
loading.value = false;
|
|
3179
|
+
const selectedOptions = [];
|
|
3180
|
+
if (props.config.multiple && props.model[props.name]) {
|
|
3181
|
+
options.value.forEach((o) => {
|
|
3182
|
+
const isInclude = props.model?.[props.name].includes(o.value);
|
|
3183
|
+
if (isInclude && !items.find((op) => op.value === o.value)) {
|
|
3184
|
+
selectedOptions.push(o);
|
|
3185
|
+
}
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
return pgIndex.value === 0 ? selectedOptions.concat(items) : options.value.concat(items);
|
|
3189
|
+
};
|
|
3190
|
+
const getInitLocalOption = async () => {
|
|
3191
|
+
if (!props.model)
|
|
3192
|
+
return [];
|
|
3193
|
+
const value = props.model[props.name];
|
|
3194
|
+
const { config } = props;
|
|
3195
|
+
localOptions.value = await getOptions();
|
|
3196
|
+
remote.value = false;
|
|
3197
|
+
if (config.group) {
|
|
3198
|
+
if (config.multiple && value.findIndex) {
|
|
3199
|
+
return localOptions.value.filter(
|
|
3200
|
+
(group) => group.options.findIndex((item) => value.find((v) => equalValue(item.value, v)) > -1) > -1
|
|
3201
|
+
);
|
|
3202
|
+
}
|
|
3203
|
+
return localOptions.value.filter(
|
|
3204
|
+
(group) => group.options.findIndex((item) => equalValue(item.value, value)) > -1
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
3207
|
+
if (config.multiple && value.findIndex) {
|
|
3208
|
+
return localOptions.value.filter((item) => value.findIndex((v) => equalValue(item.value, v)) > -1);
|
|
3209
|
+
}
|
|
3210
|
+
return localOptions.value.filter((item) => equalValue(item.value, value));
|
|
3211
|
+
};
|
|
3212
|
+
const getInitOption = async () => {
|
|
3213
|
+
if (!props.model)
|
|
3214
|
+
return [];
|
|
3215
|
+
const { config } = props;
|
|
3216
|
+
const { option } = config;
|
|
3217
|
+
let options2 = [];
|
|
3218
|
+
let url = option.initUrl;
|
|
3219
|
+
if (!url) {
|
|
3220
|
+
return getInitLocalOption();
|
|
3221
|
+
}
|
|
3222
|
+
if (typeof url === "function") {
|
|
3223
|
+
url = await url(mForm, { model: props.model, formValue: mForm?.values });
|
|
3224
|
+
}
|
|
3225
|
+
const postOptions = {
|
|
3226
|
+
method: option.method || "POST",
|
|
3227
|
+
url,
|
|
3228
|
+
data: {
|
|
3229
|
+
id: props.model[props.name]
|
|
3230
|
+
},
|
|
3231
|
+
mode: option.mode,
|
|
3232
|
+
headers: option.headers || {},
|
|
3233
|
+
json: option.json || false
|
|
3234
|
+
};
|
|
3235
|
+
if (option.method?.toLocaleLowerCase() === "jsonp") {
|
|
3236
|
+
postOptions.jsonpCallback = option.jsonpCallback || "callback";
|
|
3237
|
+
}
|
|
3238
|
+
const requestFuc = getConfig("request");
|
|
3239
|
+
const res = await requestFuc(postOptions);
|
|
3240
|
+
let initData = res[option.root];
|
|
3241
|
+
if (initData) {
|
|
3242
|
+
if (!Array.isArray(initData)) {
|
|
3243
|
+
initData = [initData];
|
|
3244
|
+
}
|
|
3245
|
+
if (typeof option.item === "function") {
|
|
3246
|
+
options2 = option.item(initData);
|
|
3247
|
+
} else if (initData.map) {
|
|
3248
|
+
options2 = mapOptions(initData);
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
return options2;
|
|
3252
|
+
};
|
|
3253
|
+
if (typeof props.config.options === "function") {
|
|
3254
|
+
vue.watchEffect(() => {
|
|
3255
|
+
typeof props.config.options === "function" && Promise.resolve(
|
|
3256
|
+
props.config.options(mForm, {
|
|
3257
|
+
model: props.model,
|
|
3258
|
+
prop: props.prop,
|
|
3259
|
+
formValues: mForm?.values,
|
|
3260
|
+
formValue: mForm?.values,
|
|
3261
|
+
config: props.config
|
|
3262
|
+
})
|
|
3263
|
+
).then((data) => {
|
|
3264
|
+
options.value = data;
|
|
3265
|
+
});
|
|
3266
|
+
});
|
|
3267
|
+
} else if (Array.isArray(props.config.options)) {
|
|
3268
|
+
vue.watchEffect(() => {
|
|
3269
|
+
options.value = props.config.options;
|
|
3270
|
+
});
|
|
3271
|
+
} else if (props.config.option) {
|
|
3272
|
+
vue.onBeforeMount(() => {
|
|
3273
|
+
if (!props.model)
|
|
3274
|
+
return;
|
|
3275
|
+
const v = props.model[props.name];
|
|
3276
|
+
if (Array.isArray(v) ? v.length : typeof v !== "undefined") {
|
|
3277
|
+
getInitOption().then((data) => {
|
|
3278
|
+
options.value = data;
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
props.config.remote && vue.onMounted(async () => {
|
|
3284
|
+
await vue.nextTick();
|
|
3285
|
+
tMagicSelect.value?.scrollbarWrap?.addEventListener("scroll", async (e) => {
|
|
3286
|
+
const el = e.currentTarget;
|
|
3287
|
+
if (moreLoadingVisible.value) {
|
|
3288
|
+
return;
|
|
3289
|
+
}
|
|
3290
|
+
if (el.scrollHeight - el.clientHeight - el.scrollTop > 1) {
|
|
3291
|
+
return;
|
|
3292
|
+
}
|
|
3293
|
+
if (total.value <= options.value.length) {
|
|
3294
|
+
return;
|
|
3295
|
+
}
|
|
3296
|
+
moreLoadingVisible.value = true;
|
|
3297
|
+
pgIndex.value += 1;
|
|
3298
|
+
options.value = await getOptions();
|
|
3299
|
+
moreLoadingVisible.value = false;
|
|
3300
|
+
});
|
|
3301
|
+
});
|
|
3302
|
+
const popperClass = mForm?.popperClass;
|
|
3303
|
+
const changeHandler = (value) => {
|
|
3304
|
+
emit("change", value);
|
|
3305
|
+
};
|
|
3306
|
+
const visibleHandler = async (visible) => {
|
|
3307
|
+
if (!visible)
|
|
3308
|
+
return;
|
|
3309
|
+
if (!props.config.remote)
|
|
3310
|
+
return;
|
|
3311
|
+
if (query.value && tMagicSelect.value) {
|
|
3312
|
+
tMagicSelect.value.setQuery(query.value);
|
|
3313
|
+
tMagicSelect.value.setPreviousQuery(query.value);
|
|
3314
|
+
tMagicSelect.value.setSelectedLabel(query.value);
|
|
3315
|
+
} else if (options.value.length <= (props.config.multiple ? props.model?.[props.name].length : 1)) {
|
|
3316
|
+
options.value = await getOptions();
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
const remoteMethod = async (q) => {
|
|
3320
|
+
if (!localOptions.value.length) {
|
|
3321
|
+
query.value = q;
|
|
3322
|
+
pgIndex.value = 0;
|
|
3323
|
+
options.value = await getOptions();
|
|
3324
|
+
if (props.config.multiple)
|
|
3325
|
+
setTimeout(() => {
|
|
3326
|
+
tMagicSelect.value?.setSelected();
|
|
3327
|
+
}, 0);
|
|
3328
|
+
}
|
|
3329
|
+
};
|
|
3330
|
+
const itemOptions = options;
|
|
3331
|
+
const groupOptions = options;
|
|
3332
|
+
return (_ctx, _cache) => {
|
|
3333
|
+
const _directive_loading = vue.resolveDirective("loading");
|
|
3334
|
+
return __props.model ? vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(design.TMagicSelect), {
|
|
3335
|
+
key: 0,
|
|
3336
|
+
modelValue: __props.model[__props.name],
|
|
3337
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
3338
|
+
class: "m-select",
|
|
3339
|
+
ref_key: "tMagicSelect",
|
|
3340
|
+
ref: tMagicSelect,
|
|
3341
|
+
clearable: "",
|
|
3342
|
+
filterable: "",
|
|
3343
|
+
"popper-class": `m-select-popper ${vue.unref(popperClass)}`,
|
|
3344
|
+
size: __props.size,
|
|
3345
|
+
remote: remote.value,
|
|
3346
|
+
placeholder: __props.config.placeholder,
|
|
3347
|
+
multiple: __props.config.multiple,
|
|
3348
|
+
"value-key": __props.config.valueKey || "value",
|
|
3349
|
+
"allow-create": __props.config.allowCreate,
|
|
3350
|
+
disabled: __props.disabled,
|
|
3351
|
+
"remote-method": __props.config.remote && remoteMethod,
|
|
3352
|
+
onChange: changeHandler,
|
|
3353
|
+
onVisibleChange: visibleHandler
|
|
3354
|
+
}, {
|
|
3355
|
+
default: vue.withCtx(() => [
|
|
3356
|
+
__props.config.group ? (vue.openBlock(), vue.createBlock(_sfc_main$6, {
|
|
3357
|
+
key: 0,
|
|
3358
|
+
options: vue.unref(groupOptions)
|
|
3359
|
+
}, null, 8, ["options"])) : (vue.openBlock(), vue.createBlock(_sfc_main$5, {
|
|
3360
|
+
key: 1,
|
|
3361
|
+
options: vue.unref(itemOptions)
|
|
3362
|
+
}, null, 8, ["options"])),
|
|
3363
|
+
moreLoadingVisible.value ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, null, 512)), [
|
|
3364
|
+
[_directive_loading, true]
|
|
3365
|
+
]) : vue.createCommentVNode("", true)
|
|
3366
|
+
]),
|
|
3367
|
+
_: 1
|
|
3368
|
+
}, 8, ["modelValue", "popper-class", "size", "remote", "placeholder", "multiple", "value-key", "allow-create", "disabled", "remote-method"])), [
|
|
3369
|
+
[_directive_loading, loading.value]
|
|
3370
|
+
]) : vue.createCommentVNode("", true);
|
|
3371
|
+
};
|
|
3372
|
+
}
|
|
3373
|
+
});
|
|
3374
|
+
|
|
3375
|
+
const __default__$3 = vue.defineComponent({
|
|
3376
|
+
name: "MFormSwitch"
|
|
3377
|
+
});
|
|
3378
|
+
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
3379
|
+
...__default__$3,
|
|
3380
|
+
props: {
|
|
3381
|
+
config: null,
|
|
3382
|
+
model: null,
|
|
3383
|
+
initValues: null,
|
|
3384
|
+
values: null,
|
|
3385
|
+
name: null,
|
|
3386
|
+
prop: null,
|
|
3387
|
+
disabled: { type: Boolean },
|
|
3388
|
+
size: null
|
|
3389
|
+
},
|
|
3390
|
+
emits: ["change"],
|
|
3391
|
+
setup(__props, { emit }) {
|
|
3392
|
+
const props = __props;
|
|
3393
|
+
useAddField(props.prop);
|
|
3394
|
+
const changeHandler = (value) => {
|
|
3395
|
+
emit("change", value);
|
|
3396
|
+
};
|
|
3397
|
+
const activeValue = vue.computed(() => {
|
|
3398
|
+
if (typeof props.config.activeValue === "undefined") {
|
|
3399
|
+
if (props.config.filter === "number") {
|
|
3400
|
+
return 1;
|
|
3401
|
+
}
|
|
3402
|
+
} else {
|
|
3403
|
+
return props.config.activeValue;
|
|
3404
|
+
}
|
|
3405
|
+
return true;
|
|
3406
|
+
});
|
|
3407
|
+
const inactiveValue = vue.computed(() => {
|
|
3408
|
+
if (typeof props.config.inactiveValue === "undefined") {
|
|
3409
|
+
if (props.config.filter === "number") {
|
|
3410
|
+
return 0;
|
|
3411
|
+
}
|
|
3412
|
+
} else {
|
|
3413
|
+
return props.config.inactiveValue;
|
|
3414
|
+
}
|
|
3415
|
+
return false;
|
|
3416
|
+
});
|
|
3417
|
+
return (_ctx, _cache) => {
|
|
3418
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicSwitch), {
|
|
3419
|
+
modelValue: __props.model[__props.name],
|
|
3420
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
3421
|
+
size: __props.size,
|
|
3422
|
+
activeValue: vue.unref(activeValue),
|
|
3423
|
+
inactiveValue: vue.unref(inactiveValue),
|
|
3424
|
+
disabled: __props.disabled,
|
|
3425
|
+
onChange: changeHandler
|
|
3426
|
+
}, null, 8, ["modelValue", "size", "activeValue", "inactiveValue", "disabled"]);
|
|
3427
|
+
};
|
|
3428
|
+
}
|
|
3429
|
+
});
|
|
3430
|
+
|
|
3431
|
+
const _hoisted_1 = { key: 0 };
|
|
3432
|
+
const __default__$2 = vue.defineComponent({
|
|
3433
|
+
name: "MFormText"
|
|
3434
|
+
});
|
|
3435
|
+
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
3436
|
+
...__default__$2,
|
|
3437
|
+
props: {
|
|
3438
|
+
config: null,
|
|
3439
|
+
model: null,
|
|
3440
|
+
initValues: null,
|
|
3441
|
+
values: null,
|
|
3442
|
+
name: null,
|
|
3443
|
+
prop: null,
|
|
3444
|
+
disabled: { type: Boolean },
|
|
3445
|
+
size: null
|
|
3446
|
+
},
|
|
3447
|
+
emits: ["change", "input"],
|
|
3448
|
+
setup(__props, { emit }) {
|
|
3449
|
+
const props = __props;
|
|
3450
|
+
useAddField(props.prop);
|
|
3451
|
+
const mForm = vue.inject("mForm");
|
|
3452
|
+
const changeHandler = (value) => {
|
|
3453
|
+
emit("change", value);
|
|
3454
|
+
};
|
|
3455
|
+
const inputHandler = (v) => {
|
|
3456
|
+
emit("input", v);
|
|
3457
|
+
mForm?.$emit("field-input", props.prop, v);
|
|
3458
|
+
};
|
|
3459
|
+
const buttonClickHandler = () => {
|
|
3460
|
+
if (typeof props.config.append === "string")
|
|
3461
|
+
return;
|
|
3462
|
+
if (props.config.append?.handler) {
|
|
3463
|
+
props.config.append.handler(mForm, {
|
|
3464
|
+
model: props.model,
|
|
3465
|
+
values: mForm?.values
|
|
3466
|
+
});
|
|
3467
|
+
}
|
|
3468
|
+
};
|
|
3469
|
+
const keyUpHandler = ($event) => {
|
|
3470
|
+
if (!props.model)
|
|
3471
|
+
return;
|
|
3472
|
+
if (!props.name)
|
|
3473
|
+
return;
|
|
3474
|
+
const arrowUp = $event.key === "ArrowUp";
|
|
3475
|
+
const arrowDown = $event.key === "ArrowDown";
|
|
3476
|
+
if (!arrowUp && !arrowDown) {
|
|
3477
|
+
return;
|
|
3478
|
+
}
|
|
3479
|
+
const value = props.model[props.name];
|
|
3480
|
+
let num;
|
|
3481
|
+
let unit;
|
|
3482
|
+
if (utils.isNumber(value)) {
|
|
3483
|
+
num = +value;
|
|
3484
|
+
} else {
|
|
3485
|
+
value.replace(/^([0-9.]+)([a-z%]+)$/, ($0, $1, $2) => {
|
|
3486
|
+
num = +$1;
|
|
3487
|
+
unit = $2;
|
|
3488
|
+
});
|
|
3489
|
+
}
|
|
3490
|
+
if (num === void 0) {
|
|
3491
|
+
return;
|
|
3492
|
+
}
|
|
3493
|
+
const ctrl = navigator.platform.match("Mac") ? $event.metaKey : $event.ctrlKey;
|
|
3494
|
+
const shift = $event.shiftKey;
|
|
3495
|
+
const alt = $event.altKey;
|
|
3496
|
+
if (arrowUp) {
|
|
3497
|
+
if (ctrl) {
|
|
3498
|
+
num += 100;
|
|
3499
|
+
} else if (alt) {
|
|
3500
|
+
num = (num * 1e4 + 1e3) / 1e4;
|
|
3501
|
+
} else if (shift) {
|
|
3502
|
+
num = num + 10;
|
|
3503
|
+
} else {
|
|
3504
|
+
num += 1;
|
|
3505
|
+
}
|
|
3506
|
+
} else if (arrowDown) {
|
|
3507
|
+
if (ctrl) {
|
|
3508
|
+
num -= 100;
|
|
3509
|
+
} else if (alt) {
|
|
3510
|
+
num = (num * 1e4 - 1e3) / 1e4;
|
|
3511
|
+
} else if (shift) {
|
|
3512
|
+
num -= 10;
|
|
3513
|
+
} else {
|
|
3514
|
+
num -= 1;
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
props.model[props.name] = `${num}${unit || ""}`;
|
|
3518
|
+
emit("change", props.model[props.name]);
|
|
3519
|
+
};
|
|
3520
|
+
return (_ctx, _cache) => {
|
|
3521
|
+
const _component_el_button = vue.resolveComponent("el-button");
|
|
3522
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInput), {
|
|
3523
|
+
modelValue: __props.model[__props.name],
|
|
3524
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
3525
|
+
clearable: "",
|
|
3526
|
+
size: __props.size,
|
|
3527
|
+
placeholder: __props.config.placeholder,
|
|
3528
|
+
disabled: __props.disabled,
|
|
3529
|
+
onChange: changeHandler,
|
|
3530
|
+
onInput: inputHandler,
|
|
3531
|
+
onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
|
|
3532
|
+
}, vue.createSlots({ _: 2 }, [
|
|
3533
|
+
__props.config.append ? {
|
|
3534
|
+
name: "append",
|
|
3535
|
+
fn: vue.withCtx(() => [
|
|
3536
|
+
typeof __props.config.append === "string" ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1, vue.toDisplayString(__props.config.append), 1)) : vue.createCommentVNode("", true),
|
|
3537
|
+
typeof __props.config.append === "object" && __props.config.append.type === "button" ? (vue.openBlock(), vue.createBlock(_component_el_button, {
|
|
3538
|
+
key: 1,
|
|
3539
|
+
style: { "color": "#409eff" },
|
|
3540
|
+
size: __props.size,
|
|
3541
|
+
onClick: vue.withModifiers(buttonClickHandler, ["prevent"])
|
|
3542
|
+
}, {
|
|
3543
|
+
default: vue.withCtx(() => [
|
|
3544
|
+
vue.createTextVNode(vue.toDisplayString(__props.config.append.text), 1)
|
|
3545
|
+
]),
|
|
3546
|
+
_: 1
|
|
3547
|
+
}, 8, ["size", "onClick"])) : vue.createCommentVNode("", true)
|
|
3548
|
+
])
|
|
3549
|
+
} : void 0
|
|
3550
|
+
]), 1032, ["modelValue", "size", "placeholder", "disabled"]);
|
|
3551
|
+
};
|
|
3552
|
+
}
|
|
3553
|
+
});
|
|
3554
|
+
|
|
3555
|
+
const __default__$1 = vue.defineComponent({
|
|
3556
|
+
name: "MFormTextarea"
|
|
3557
|
+
});
|
|
3558
|
+
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
3559
|
+
...__default__$1,
|
|
3560
|
+
props: {
|
|
3561
|
+
config: null,
|
|
3562
|
+
model: null,
|
|
3563
|
+
initValues: null,
|
|
3564
|
+
values: null,
|
|
3565
|
+
name: null,
|
|
3566
|
+
prop: null,
|
|
3567
|
+
disabled: { type: Boolean },
|
|
3568
|
+
size: null
|
|
3569
|
+
},
|
|
3570
|
+
emits: ["change", "input"],
|
|
3571
|
+
setup(__props, { emit }) {
|
|
3572
|
+
const props = __props;
|
|
3573
|
+
useAddField(props.prop);
|
|
3574
|
+
const mForm = vue.inject("mForm");
|
|
3575
|
+
const changeHandler = (value) => {
|
|
3576
|
+
emit("change", value);
|
|
3577
|
+
};
|
|
3578
|
+
const inputHandler = (v) => {
|
|
3579
|
+
emit("input", v);
|
|
3580
|
+
mForm?.$emit("field-input", props.prop, v);
|
|
3581
|
+
};
|
|
3582
|
+
return (_ctx, _cache) => {
|
|
3583
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicInput), {
|
|
3584
|
+
modelValue: __props.model[__props.name],
|
|
3585
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
3586
|
+
type: "textarea",
|
|
3587
|
+
size: __props.size,
|
|
3588
|
+
clearable: "",
|
|
3589
|
+
placeholder: __props.config.placeholder,
|
|
3590
|
+
disabled: __props.disabled,
|
|
3591
|
+
onChange: changeHandler,
|
|
3592
|
+
onInput: inputHandler
|
|
3593
|
+
}, null, 8, ["modelValue", "size", "placeholder", "disabled"]);
|
|
3594
|
+
};
|
|
3595
|
+
}
|
|
3596
|
+
});
|
|
3597
|
+
|
|
3598
|
+
const __default__ = vue.defineComponent({
|
|
3599
|
+
name: "MFormTime"
|
|
3600
|
+
});
|
|
3601
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
3602
|
+
...__default__,
|
|
3603
|
+
props: {
|
|
3604
|
+
config: null,
|
|
3605
|
+
model: null,
|
|
3606
|
+
initValues: null,
|
|
3607
|
+
values: null,
|
|
3608
|
+
name: null,
|
|
3609
|
+
prop: null,
|
|
3610
|
+
disabled: { type: Boolean },
|
|
3611
|
+
size: null
|
|
3612
|
+
},
|
|
3613
|
+
emits: ["change"],
|
|
3614
|
+
setup(__props, { emit }) {
|
|
3615
|
+
const props = __props;
|
|
3616
|
+
useAddField(props.prop);
|
|
3617
|
+
const changeHandler = (v) => {
|
|
3618
|
+
emit("change", v);
|
|
3619
|
+
};
|
|
3620
|
+
return (_ctx, _cache) => {
|
|
3621
|
+
return vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTimePicker), {
|
|
3622
|
+
modelValue: __props.model[__props.name],
|
|
3623
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.model[__props.name] = $event),
|
|
3624
|
+
"value-format": __props.config.valueFormat || "HH:mm:ss",
|
|
3625
|
+
format: __props.config.format || "HH:mm:ss",
|
|
3626
|
+
size: __props.size,
|
|
3627
|
+
placeholder: __props.config.placeholder,
|
|
3628
|
+
disabled: __props.disabled,
|
|
3629
|
+
onChange: changeHandler
|
|
3630
|
+
}, null, 8, ["modelValue", "value-format", "format", "size", "placeholder", "disabled"]);
|
|
3631
|
+
};
|
|
3632
|
+
}
|
|
3633
|
+
});
|
|
3634
|
+
|
|
3635
|
+
const index$1 = '';
|
|
3636
|
+
|
|
3637
|
+
const defaultInstallOpt = {};
|
|
3638
|
+
const install = (app, opt) => {
|
|
3639
|
+
const option = Object.assign(defaultInstallOpt, opt);
|
|
3640
|
+
app.config.globalProperties.$MAGIC_FORM = option;
|
|
3641
|
+
setConfig(option);
|
|
3642
|
+
app.component("m-form", _sfc_main$b);
|
|
3643
|
+
app.component("m-form-dialog", _sfc_main$a);
|
|
3644
|
+
app.component("m-form-container", _sfc_main$v);
|
|
3645
|
+
app.component("m-form-fieldset", _sfc_main$u);
|
|
3646
|
+
app.component("m-form-group-list", _sfc_main$s);
|
|
3647
|
+
app.component("m-form-panel", _sfc_main$r);
|
|
3648
|
+
app.component("m-form-row", _sfc_main$p);
|
|
3649
|
+
app.component("m-form-step", _sfc_main$o);
|
|
3650
|
+
app.component("m-form-table", _sfc_main$n);
|
|
3651
|
+
app.component("m-form-tab", _sfc_main$m);
|
|
3652
|
+
app.component("m-fields-text", _sfc_main$2);
|
|
3653
|
+
app.component("m-fields-number", _sfc_main$8);
|
|
3654
|
+
app.component("m-fields-textarea", _sfc_main$1);
|
|
3655
|
+
app.component("m-fields-hidden", _sfc_main$c);
|
|
3656
|
+
app.component("m-fields-date", _sfc_main$h);
|
|
3657
|
+
app.component("m-fields-datetime", _sfc_main$f);
|
|
3658
|
+
app.component("m-fields-daterange", _sfc_main$g);
|
|
3659
|
+
app.component("m-fields-time", _sfc_main);
|
|
3660
|
+
app.component("m-fields-checkbox", _sfc_main$k);
|
|
3661
|
+
app.component("m-fields-switch", _sfc_main$3);
|
|
3662
|
+
app.component("m-fields-color-picker", _sfc_main$i);
|
|
3663
|
+
app.component("m-fields-checkbox-group", _sfc_main$j);
|
|
3664
|
+
app.component("m-fields-radio-group", _sfc_main$7);
|
|
3665
|
+
app.component("m-fields-display", _sfc_main$e);
|
|
3666
|
+
app.component("m-fields-link", _sfc_main$9);
|
|
3667
|
+
app.component("m-fields-select", _sfc_main$4);
|
|
3668
|
+
app.component("m-fields-cascader", _sfc_main$l);
|
|
3669
|
+
app.component("m-fields-dynamic-field", _sfc_main$d);
|
|
3670
|
+
};
|
|
3671
|
+
const index = {
|
|
3672
|
+
install
|
|
3673
|
+
};
|
|
3674
|
+
|
|
3675
|
+
exports.MCascader = _sfc_main$l;
|
|
3676
|
+
exports.MCheckbox = _sfc_main$k;
|
|
3677
|
+
exports.MCheckboxGroup = _sfc_main$j;
|
|
3678
|
+
exports.MColorPicker = _sfc_main$i;
|
|
3679
|
+
exports.MContainer = _sfc_main$v;
|
|
3680
|
+
exports.MDate = _sfc_main$h;
|
|
3681
|
+
exports.MDateTime = _sfc_main$f;
|
|
3682
|
+
exports.MDaterange = _sfc_main$g;
|
|
3683
|
+
exports.MDisplay = _sfc_main$e;
|
|
3684
|
+
exports.MDynamicField = _sfc_main$d;
|
|
3685
|
+
exports.MFieldset = _sfc_main$u;
|
|
3686
|
+
exports.MForm = _sfc_main$b;
|
|
3687
|
+
exports.MFormDialog = _sfc_main$a;
|
|
3688
|
+
exports.MGroupList = _sfc_main$s;
|
|
3689
|
+
exports.MHidden = _sfc_main$c;
|
|
3690
|
+
exports.MLink = _sfc_main$9;
|
|
3691
|
+
exports.MNumber = _sfc_main$8;
|
|
3692
|
+
exports.MPanel = _sfc_main$r;
|
|
3693
|
+
exports.MRadioGroup = _sfc_main$7;
|
|
3694
|
+
exports.MRow = _sfc_main$p;
|
|
3695
|
+
exports.MSelect = _sfc_main$4;
|
|
3696
|
+
exports.MSwitch = _sfc_main$3;
|
|
3697
|
+
exports.MTable = _sfc_main$n;
|
|
3698
|
+
exports.MTabs = _sfc_main$m;
|
|
3699
|
+
exports.MText = _sfc_main$2;
|
|
3700
|
+
exports.MTextarea = _sfc_main$1;
|
|
3701
|
+
exports.MTime = _sfc_main;
|
|
3702
|
+
exports.createValues = createValues;
|
|
3703
|
+
exports.default = index;
|
|
3704
|
+
exports.display = display;
|
|
3705
|
+
exports.filterFunction = filterFunction;
|
|
3706
|
+
exports.getRules = getRules;
|
|
3707
|
+
exports.initValue = initValue;
|
|
3708
|
+
exports.useAddField = useAddField;
|
|
3709
|
+
|
|
3710
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
3711
|
+
|
|
3712
|
+
}));
|
|
3713
|
+
//# sourceMappingURL=tmagic-form.umd.cjs.map
|