knt-shared 1.1.7 → 1.2.1
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/components/Form/componentMap.d.ts +581 -1
- package/dist/components/Form/componentMap.d.ts.map +1 -1
- package/dist/components/Modal/BasicModal.vue.d.ts +1 -1
- package/dist/components/Upload/BasicUpload.vue.d.ts +138 -0
- package/dist/components/Upload/BasicUpload.vue.d.ts.map +1 -0
- package/dist/components/Upload/index.d.ts +7 -0
- package/dist/components/Upload/index.d.ts.map +1 -0
- package/dist/components/Upload/types.d.ts +217 -0
- package/dist/components/Upload/types.d.ts.map +1 -0
- package/dist/components/Upload/useUpload.d.ts +27 -0
- package/dist/components/Upload/useUpload.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs.js +1862 -1084
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1865 -1087
- package/dist/index.esm.js.map +1 -1
- package/dist/style.css +42 -9
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,1151 +1,1838 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Transfer, Mention, Upload, Rate, Slider, Switch, RangePicker, TimePicker, DatePicker, TreeSelect, Cascader, CheckboxGroup, Checkbox, RadioGroup, Radio, Select, AutoComplete, Textarea, InputPassword, InputNumber, Input
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
CheckboxGroup,
|
|
14
|
-
Cascader,
|
|
15
|
-
TreeSelect,
|
|
16
|
-
DatePicker,
|
|
17
|
-
TimePicker,
|
|
18
|
-
RangePicker,
|
|
19
|
-
Switch,
|
|
20
|
-
Slider,
|
|
21
|
-
Rate,
|
|
22
|
-
Upload,
|
|
23
|
-
Mention,
|
|
24
|
-
Transfer
|
|
25
|
-
};
|
|
26
|
-
const customComponentMap = /* @__PURE__ */ new Map();
|
|
27
|
-
function registerComponent(name, component) {
|
|
28
|
-
customComponentMap.set(name, component);
|
|
29
|
-
}
|
|
30
|
-
function getComponent(name) {
|
|
31
|
-
if (typeof name === "string") {
|
|
32
|
-
if (name in componentMap) {
|
|
33
|
-
return componentMap[name];
|
|
34
|
-
}
|
|
35
|
-
return customComponentMap.get(name);
|
|
1
|
+
import { getCurrentInstance, inject, defineComponent, computed, createElementBlock, openBlock, normalizeStyle, normalizeClass, createElementVNode, ref, unref, watch, onMounted, nextTick, resolveComponent, createVNode, mergeProps, createSlots, withCtx, renderSlot, createBlock, createCommentVNode, toDisplayString, createTextVNode, reactive, onBeforeUnmount, normalizeProps, guardReactiveProps, Fragment, renderList, resolveDynamicComponent, withDirectives, vShow, withModifiers, h, onUnmounted } from "vue";
|
|
2
|
+
import { Message, Transfer, Mention, Upload, Rate, Slider, Switch, RangePicker, TimePicker, DatePicker, TreeSelect, Cascader, CheckboxGroup, Checkbox, RadioGroup, Radio, Select, AutoComplete, Textarea, InputPassword, InputNumber, Input } from "@arco-design/web-vue";
|
|
3
|
+
const configProviderInjectionKey = Symbol("ArcoConfigProvider");
|
|
4
|
+
const CLASS_PREFIX = "arco";
|
|
5
|
+
const GLOBAL_CONFIG_NAME = "$arco";
|
|
6
|
+
const getPrefixCls = (componentName) => {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
const instance = getCurrentInstance();
|
|
9
|
+
const configProvider = inject(configProviderInjectionKey, void 0);
|
|
10
|
+
const prefix = (_c = (_b = configProvider == null ? void 0 : configProvider.prefixCls) != null ? _b : (_a = instance == null ? void 0 : instance.appContext.config.globalProperties[GLOBAL_CONFIG_NAME]) == null ? void 0 : _a.classPrefix) != null ? _c : CLASS_PREFIX;
|
|
11
|
+
{
|
|
12
|
+
return `${prefix}-${componentName}`;
|
|
36
13
|
}
|
|
37
|
-
|
|
14
|
+
};
|
|
15
|
+
const opt = Object.prototype.toString;
|
|
16
|
+
function isNumber(obj) {
|
|
17
|
+
return opt.call(obj) === "[object Number]" && obj === obj;
|
|
38
18
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"Textarea",
|
|
43
|
-
"AutoComplete"
|
|
44
|
-
]);
|
|
45
|
-
const componentsNeedSelectPlaceholder = /* @__PURE__ */ new Set([
|
|
46
|
-
"Select",
|
|
47
|
-
"DatePicker",
|
|
48
|
-
"TimePicker",
|
|
49
|
-
"RangePicker",
|
|
50
|
-
"Cascader",
|
|
51
|
-
"TreeSelect"
|
|
52
|
-
]);
|
|
53
|
-
function getPlaceholder(component, label) {
|
|
54
|
-
if (componentsNeedPlaceholder.has(component)) {
|
|
55
|
-
return `请输入${label}`;
|
|
56
|
-
}
|
|
57
|
-
if (componentsNeedSelectPlaceholder.has(component)) {
|
|
58
|
-
return `请选择${label}`;
|
|
19
|
+
var _export_sfc$1 = (sfc, props) => {
|
|
20
|
+
for (const [key, val] of props) {
|
|
21
|
+
sfc[key] = val;
|
|
59
22
|
}
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
const _sfc_main$
|
|
63
|
-
|
|
64
|
-
name: "BasicForm",
|
|
65
|
-
inheritAttrs: false
|
|
66
|
-
},
|
|
67
|
-
__name: "BasicForm",
|
|
23
|
+
return sfc;
|
|
24
|
+
};
|
|
25
|
+
const _sfc_main$c = defineComponent({
|
|
26
|
+
name: "IconPlus",
|
|
68
27
|
props: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
28
|
+
size: {
|
|
29
|
+
type: [Number, String]
|
|
30
|
+
},
|
|
31
|
+
strokeWidth: {
|
|
32
|
+
type: Number,
|
|
33
|
+
default: 4
|
|
34
|
+
},
|
|
35
|
+
strokeLinecap: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "butt",
|
|
38
|
+
validator: (value) => {
|
|
39
|
+
return ["butt", "round", "square"].includes(value);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
strokeLinejoin: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: "miter",
|
|
45
|
+
validator: (value) => {
|
|
46
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
rotate: Number,
|
|
50
|
+
spin: Boolean
|
|
88
51
|
},
|
|
89
|
-
emits:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return
|
|
104
|
-
layout: propsData.layout,
|
|
105
|
-
size: propsData.size,
|
|
106
|
-
disabled: propsData.disabled,
|
|
107
|
-
labelAlign: propsData.labelAlign,
|
|
108
|
-
autoLabelWidth: propsData.autoLabelWidth,
|
|
109
|
-
labelWidth: propsData.labelWidth,
|
|
110
|
-
labelColProps: propsData.labelColProps,
|
|
111
|
-
wrapperColProps: propsData.wrapperColProps
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
const getRow = computed(() => {
|
|
115
|
-
return {
|
|
116
|
-
gutter: 24
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
const getActionProps = computed(() => {
|
|
120
|
-
const propsData = unref(getProps);
|
|
121
|
-
return {
|
|
122
|
-
showActionButtons: propsData.showActionButtons !== false,
|
|
123
|
-
showSubmitButton: propsData.showSubmitButton !== false,
|
|
124
|
-
showResetButton: propsData.showResetButton !== false,
|
|
125
|
-
submitButtonText: propsData.submitButtonText || "提交",
|
|
126
|
-
resetButtonText: propsData.resetButtonText || "重置",
|
|
127
|
-
actionColOptions: propsData.actionColOptions || { span: 24 },
|
|
128
|
-
actionFormItemProps: propsData.actionFormItemProps || {}
|
|
129
|
-
};
|
|
52
|
+
emits: {
|
|
53
|
+
click: (ev) => true
|
|
54
|
+
},
|
|
55
|
+
setup(props, { emit }) {
|
|
56
|
+
const prefixCls = getPrefixCls("icon");
|
|
57
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-plus`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
58
|
+
const innerStyle = computed(() => {
|
|
59
|
+
const styles = {};
|
|
60
|
+
if (props.size) {
|
|
61
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
62
|
+
}
|
|
63
|
+
if (props.rotate) {
|
|
64
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
65
|
+
}
|
|
66
|
+
return styles;
|
|
130
67
|
});
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
if (!schemas.length) return;
|
|
134
|
-
const schemaFields = new Set(schemas.map((s) => s.field));
|
|
135
|
-
Object.keys(formModel).forEach((key) => {
|
|
136
|
-
if (!schemaFields.has(key)) {
|
|
137
|
-
delete formModel[key];
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
schemas.forEach((schema) => {
|
|
141
|
-
if (!(schema.field in formModel)) {
|
|
142
|
-
formModel[schema.field] = schema.defaultValue !== void 0 ? schema.defaultValue : void 0;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
68
|
+
const onClick = (ev) => {
|
|
69
|
+
emit("click", ev);
|
|
145
70
|
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (typeof schema.show === "boolean") return schema.show;
|
|
151
|
-
return schema.show(formModel);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
const getColProps = (schema) => {
|
|
155
|
-
const propsData = unref(getProps);
|
|
156
|
-
return schema.colProps || propsData.baseColProps || { span: 24 };
|
|
71
|
+
return {
|
|
72
|
+
cls,
|
|
73
|
+
innerStyle,
|
|
74
|
+
onClick
|
|
157
75
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const _hoisted_1$b = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
79
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
80
|
+
return openBlock(), createElementBlock("svg", {
|
|
81
|
+
viewBox: "0 0 48 48",
|
|
82
|
+
fill: "none",
|
|
83
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
84
|
+
stroke: "currentColor",
|
|
85
|
+
class: normalizeClass(_ctx.cls),
|
|
86
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
87
|
+
"stroke-width": _ctx.strokeWidth,
|
|
88
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
89
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
90
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
91
|
+
}, _cache[1] || (_cache[1] = [
|
|
92
|
+
createElementVNode("path", { d: "M5 24h38M24 5v38" }, null, -1)
|
|
93
|
+
]), 14, _hoisted_1$b);
|
|
94
|
+
}
|
|
95
|
+
var _IconPlus = /* @__PURE__ */ _export_sfc$1(_sfc_main$c, [["render", _sfc_render$7]]);
|
|
96
|
+
const IconPlus = Object.assign(_IconPlus, {
|
|
97
|
+
install: (app, options) => {
|
|
98
|
+
var _a;
|
|
99
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
100
|
+
app.component(iconPrefix + _IconPlus.name, _IconPlus);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const _sfc_main$b = defineComponent({
|
|
104
|
+
name: "IconQuestionCircle",
|
|
105
|
+
props: {
|
|
106
|
+
size: {
|
|
107
|
+
type: [Number, String]
|
|
108
|
+
},
|
|
109
|
+
strokeWidth: {
|
|
110
|
+
type: Number,
|
|
111
|
+
default: 4
|
|
112
|
+
},
|
|
113
|
+
strokeLinecap: {
|
|
114
|
+
type: String,
|
|
115
|
+
default: "butt",
|
|
116
|
+
validator: (value) => {
|
|
117
|
+
return ["butt", "round", "square"].includes(value);
|
|
163
118
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
disabled,
|
|
171
|
-
help: schema.help,
|
|
172
|
-
extra: schema.extra,
|
|
173
|
-
required: schema.required,
|
|
174
|
-
...propsData.baseFormItemProps || {},
|
|
175
|
-
...schema.formItemProps || {}
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
const getPlaceholderText = (schema) => {
|
|
179
|
-
var _a;
|
|
180
|
-
const propsData = unref(getProps);
|
|
181
|
-
if ((_a = schema.componentProps) == null ? void 0 : _a.placeholder) {
|
|
182
|
-
return schema.componentProps.placeholder;
|
|
119
|
+
},
|
|
120
|
+
strokeLinejoin: {
|
|
121
|
+
type: String,
|
|
122
|
+
default: "miter",
|
|
123
|
+
validator: (value) => {
|
|
124
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
183
125
|
}
|
|
184
|
-
|
|
185
|
-
|
|
126
|
+
},
|
|
127
|
+
rotate: Number,
|
|
128
|
+
spin: Boolean
|
|
129
|
+
},
|
|
130
|
+
emits: {
|
|
131
|
+
click: (ev) => true
|
|
132
|
+
},
|
|
133
|
+
setup(props, { emit }) {
|
|
134
|
+
const prefixCls = getPrefixCls("icon");
|
|
135
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-question-circle`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
136
|
+
const innerStyle = computed(() => {
|
|
137
|
+
const styles = {};
|
|
138
|
+
if (props.size) {
|
|
139
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
186
140
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
};
|
|
190
|
-
const handleSubmit = async (data) => {
|
|
191
|
-
try {
|
|
192
|
-
submitLoading.value = true;
|
|
193
|
-
if (!data) {
|
|
194
|
-
try {
|
|
195
|
-
await validate();
|
|
196
|
-
const values = getFieldsValue();
|
|
197
|
-
emit("submit", values);
|
|
198
|
-
return values;
|
|
199
|
-
} catch (error) {
|
|
200
|
-
console.warn("表单验证失败:", error);
|
|
201
|
-
throw error;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (data.errors) {
|
|
205
|
-
console.warn("表单验证失败:", data.errors);
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
emit("submit", data.values);
|
|
209
|
-
return data.values;
|
|
210
|
-
} finally {
|
|
211
|
-
submitLoading.value = false;
|
|
141
|
+
if (props.rotate) {
|
|
142
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
212
143
|
}
|
|
144
|
+
return styles;
|
|
145
|
+
});
|
|
146
|
+
const onClick = (ev) => {
|
|
147
|
+
emit("click", ev);
|
|
213
148
|
};
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
};
|
|
219
|
-
const getFieldsValue = () => {
|
|
220
|
-
return { ...formModel };
|
|
221
|
-
};
|
|
222
|
-
const setFieldsValue = (values) => {
|
|
223
|
-
Object.keys(values).forEach((key) => {
|
|
224
|
-
const schemas = internalSchemas.value.length > 0 ? internalSchemas.value : props.schemas || [];
|
|
225
|
-
const hasField = schemas.some((s) => s.field === key);
|
|
226
|
-
if (hasField) {
|
|
227
|
-
formModel[key] = values[key];
|
|
228
|
-
} else {
|
|
229
|
-
console.warn(`字段 "${key}" 不在表单 schema 中`);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
149
|
+
return {
|
|
150
|
+
cls,
|
|
151
|
+
innerStyle,
|
|
152
|
+
onClick
|
|
232
153
|
};
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
const _hoisted_1$a = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
157
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
158
|
+
return openBlock(), createElementBlock("svg", {
|
|
159
|
+
viewBox: "0 0 48 48",
|
|
160
|
+
fill: "none",
|
|
161
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
162
|
+
stroke: "currentColor",
|
|
163
|
+
class: normalizeClass(_ctx.cls),
|
|
164
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
165
|
+
"stroke-width": _ctx.strokeWidth,
|
|
166
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
167
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
168
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
169
|
+
}, _cache[1] || (_cache[1] = [
|
|
170
|
+
createElementVNode("path", { d: "M42 24c0 9.941-8.059 18-18 18S6 33.941 6 24 14.059 6 24 6s18 8.059 18 18Z" }, null, -1),
|
|
171
|
+
createElementVNode("path", { d: "M24.006 31v4.008m0-6.008L24 28c0-3 3-4 4.78-6.402C30.558 19.195 28.288 15 23.987 15c-4.014 0-5.382 2.548-5.388 4.514v.465" }, null, -1)
|
|
172
|
+
]), 14, _hoisted_1$a);
|
|
173
|
+
}
|
|
174
|
+
var _IconQuestionCircle = /* @__PURE__ */ _export_sfc$1(_sfc_main$b, [["render", _sfc_render$6]]);
|
|
175
|
+
const IconQuestionCircle = Object.assign(_IconQuestionCircle, {
|
|
176
|
+
install: (app, options) => {
|
|
177
|
+
var _a;
|
|
178
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
179
|
+
app.component(iconPrefix + _IconQuestionCircle.name, _IconQuestionCircle);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
const _sfc_main$a = defineComponent({
|
|
183
|
+
name: "IconRefresh",
|
|
184
|
+
props: {
|
|
185
|
+
size: {
|
|
186
|
+
type: [Number, String]
|
|
187
|
+
},
|
|
188
|
+
strokeWidth: {
|
|
189
|
+
type: Number,
|
|
190
|
+
default: 4
|
|
191
|
+
},
|
|
192
|
+
strokeLinecap: {
|
|
193
|
+
type: String,
|
|
194
|
+
default: "butt",
|
|
195
|
+
validator: (value) => {
|
|
196
|
+
return ["butt", "round", "square"].includes(value);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
strokeLinejoin: {
|
|
200
|
+
type: String,
|
|
201
|
+
default: "miter",
|
|
202
|
+
validator: (value) => {
|
|
203
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
rotate: Number,
|
|
207
|
+
spin: Boolean
|
|
208
|
+
},
|
|
209
|
+
emits: {
|
|
210
|
+
click: (ev) => true
|
|
211
|
+
},
|
|
212
|
+
setup(props, { emit }) {
|
|
213
|
+
const prefixCls = getPrefixCls("icon");
|
|
214
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-refresh`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
215
|
+
const innerStyle = computed(() => {
|
|
216
|
+
const styles = {};
|
|
217
|
+
if (props.size) {
|
|
218
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
219
|
+
}
|
|
220
|
+
if (props.rotate) {
|
|
221
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
222
|
+
}
|
|
223
|
+
return styles;
|
|
224
|
+
});
|
|
225
|
+
const onClick = (ev) => {
|
|
226
|
+
emit("click", ev);
|
|
236
227
|
};
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
228
|
+
return {
|
|
229
|
+
cls,
|
|
230
|
+
innerStyle,
|
|
231
|
+
onClick
|
|
240
232
|
};
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
const _hoisted_1$9 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
236
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
237
|
+
return openBlock(), createElementBlock("svg", {
|
|
238
|
+
viewBox: "0 0 48 48",
|
|
239
|
+
fill: "none",
|
|
240
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
241
|
+
stroke: "currentColor",
|
|
242
|
+
class: normalizeClass(_ctx.cls),
|
|
243
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
244
|
+
"stroke-width": _ctx.strokeWidth,
|
|
245
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
246
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
247
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
248
|
+
}, _cache[1] || (_cache[1] = [
|
|
249
|
+
createElementVNode("path", { d: "M38.837 18C36.463 12.136 30.715 8 24 8 15.163 8 8 15.163 8 24s7.163 16 16 16c7.455 0 13.72-5.1 15.496-12M40 8v10H30" }, null, -1)
|
|
250
|
+
]), 14, _hoisted_1$9);
|
|
251
|
+
}
|
|
252
|
+
var _IconRefresh = /* @__PURE__ */ _export_sfc$1(_sfc_main$a, [["render", _sfc_render$5]]);
|
|
253
|
+
const IconRefresh = Object.assign(_IconRefresh, {
|
|
254
|
+
install: (app, options) => {
|
|
255
|
+
var _a;
|
|
256
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
257
|
+
app.component(iconPrefix + _IconRefresh.name, _IconRefresh);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
const _sfc_main$9 = defineComponent({
|
|
261
|
+
name: "IconSettings",
|
|
262
|
+
props: {
|
|
263
|
+
size: {
|
|
264
|
+
type: [Number, String]
|
|
265
|
+
},
|
|
266
|
+
strokeWidth: {
|
|
267
|
+
type: Number,
|
|
268
|
+
default: 4
|
|
269
|
+
},
|
|
270
|
+
strokeLinecap: {
|
|
271
|
+
type: String,
|
|
272
|
+
default: "butt",
|
|
273
|
+
validator: (value) => {
|
|
274
|
+
return ["butt", "round", "square"].includes(value);
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
strokeLinejoin: {
|
|
278
|
+
type: String,
|
|
279
|
+
default: "miter",
|
|
280
|
+
validator: (value) => {
|
|
281
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
rotate: Number,
|
|
285
|
+
spin: Boolean
|
|
286
|
+
},
|
|
287
|
+
emits: {
|
|
288
|
+
click: (ev) => true
|
|
289
|
+
},
|
|
290
|
+
setup(props, { emit }) {
|
|
291
|
+
const prefixCls = getPrefixCls("icon");
|
|
292
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-settings`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
293
|
+
const innerStyle = computed(() => {
|
|
294
|
+
const styles = {};
|
|
295
|
+
if (props.size) {
|
|
296
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
297
|
+
}
|
|
298
|
+
if (props.rotate) {
|
|
299
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
300
|
+
}
|
|
301
|
+
return styles;
|
|
302
|
+
});
|
|
303
|
+
const onClick = (ev) => {
|
|
304
|
+
emit("click", ev);
|
|
244
305
|
};
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
(s) => s.field === item.field
|
|
250
|
-
);
|
|
251
|
-
if (index !== -1) {
|
|
252
|
-
const oldSchema = internalSchemas.value[index];
|
|
253
|
-
internalSchemas.value[index] = { ...oldSchema, ...item };
|
|
254
|
-
if (item.defaultValue !== void 0 && formModel[item.field] === oldSchema.defaultValue) {
|
|
255
|
-
formModel[item.field] = item.defaultValue;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
});
|
|
306
|
+
return {
|
|
307
|
+
cls,
|
|
308
|
+
innerStyle,
|
|
309
|
+
onClick
|
|
259
310
|
};
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
const _hoisted_1$8 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
314
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
315
|
+
return openBlock(), createElementBlock("svg", {
|
|
316
|
+
viewBox: "0 0 48 48",
|
|
317
|
+
fill: "none",
|
|
318
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
319
|
+
stroke: "currentColor",
|
|
320
|
+
class: normalizeClass(_ctx.cls),
|
|
321
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
322
|
+
"stroke-width": _ctx.strokeWidth,
|
|
323
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
324
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
325
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
326
|
+
}, _cache[1] || (_cache[1] = [
|
|
327
|
+
createElementVNode("path", { d: "M18.797 6.732A1 1 0 0 1 19.76 6h8.48a1 1 0 0 1 .964.732l1.285 4.628a1 1 0 0 0 1.213.7l4.651-1.2a1 1 0 0 1 1.116.468l4.24 7.344a1 1 0 0 1-.153 1.2L38.193 23.3a1 1 0 0 0 0 1.402l3.364 3.427a1 1 0 0 1 .153 1.2l-4.24 7.344a1 1 0 0 1-1.116.468l-4.65-1.2a1 1 0 0 0-1.214.7l-1.285 4.628a1 1 0 0 1-.964.732h-8.48a1 1 0 0 1-.963-.732L17.51 36.64a1 1 0 0 0-1.213-.7l-4.65 1.2a1 1 0 0 1-1.116-.468l-4.24-7.344a1 1 0 0 1 .153-1.2L9.809 24.7a1 1 0 0 0 0-1.402l-3.364-3.427a1 1 0 0 1-.153-1.2l4.24-7.344a1 1 0 0 1 1.116-.468l4.65 1.2a1 1 0 0 0 1.213-.7l1.286-4.628Z" }, null, -1),
|
|
328
|
+
createElementVNode("path", { d: "M30 24a6 6 0 1 1-12 0 6 6 0 0 1 12 0Z" }, null, -1)
|
|
329
|
+
]), 14, _hoisted_1$8);
|
|
330
|
+
}
|
|
331
|
+
var _IconSettings = /* @__PURE__ */ _export_sfc$1(_sfc_main$9, [["render", _sfc_render$4]]);
|
|
332
|
+
const IconSettings = Object.assign(_IconSettings, {
|
|
333
|
+
install: (app, options) => {
|
|
334
|
+
var _a;
|
|
335
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
336
|
+
app.component(iconPrefix + _IconSettings.name, _IconSettings);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
const _sfc_main$8 = defineComponent({
|
|
340
|
+
name: "IconUpload",
|
|
341
|
+
props: {
|
|
342
|
+
size: {
|
|
343
|
+
type: [Number, String]
|
|
344
|
+
},
|
|
345
|
+
strokeWidth: {
|
|
346
|
+
type: Number,
|
|
347
|
+
default: 4
|
|
348
|
+
},
|
|
349
|
+
strokeLinecap: {
|
|
350
|
+
type: String,
|
|
351
|
+
default: "butt",
|
|
352
|
+
validator: (value) => {
|
|
353
|
+
return ["butt", "round", "square"].includes(value);
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
strokeLinejoin: {
|
|
357
|
+
type: String,
|
|
358
|
+
default: "miter",
|
|
359
|
+
validator: (value) => {
|
|
360
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
rotate: Number,
|
|
364
|
+
spin: Boolean
|
|
365
|
+
},
|
|
366
|
+
emits: {
|
|
367
|
+
click: (ev) => true
|
|
368
|
+
},
|
|
369
|
+
setup(props, { emit }) {
|
|
370
|
+
const prefixCls = getPrefixCls("icon");
|
|
371
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-upload`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
372
|
+
const innerStyle = computed(() => {
|
|
373
|
+
const styles = {};
|
|
374
|
+
if (props.size) {
|
|
375
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
376
|
+
}
|
|
377
|
+
if (props.rotate) {
|
|
378
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
379
|
+
}
|
|
380
|
+
return styles;
|
|
381
|
+
});
|
|
382
|
+
const onClick = (ev) => {
|
|
383
|
+
emit("click", ev);
|
|
269
384
|
};
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
385
|
+
return {
|
|
386
|
+
cls,
|
|
387
|
+
innerStyle,
|
|
388
|
+
onClick
|
|
274
389
|
};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
const _hoisted_1$7 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
393
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
394
|
+
return openBlock(), createElementBlock("svg", {
|
|
395
|
+
viewBox: "0 0 48 48",
|
|
396
|
+
fill: "none",
|
|
397
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
398
|
+
stroke: "currentColor",
|
|
399
|
+
class: normalizeClass(_ctx.cls),
|
|
400
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
401
|
+
"stroke-width": _ctx.strokeWidth,
|
|
402
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
403
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
404
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
405
|
+
}, _cache[1] || (_cache[1] = [
|
|
406
|
+
createElementVNode("path", { d: "M14.93 17.071 24.001 8l9.071 9.071m-9.07 16.071v-25M40 35v6H8v-6" }, null, -1)
|
|
407
|
+
]), 14, _hoisted_1$7);
|
|
408
|
+
}
|
|
409
|
+
var _IconUpload = /* @__PURE__ */ _export_sfc$1(_sfc_main$8, [["render", _sfc_render$3]]);
|
|
410
|
+
const IconUpload = Object.assign(_IconUpload, {
|
|
411
|
+
install: (app, options) => {
|
|
412
|
+
var _a;
|
|
413
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
414
|
+
app.component(iconPrefix + _IconUpload.name, _IconUpload);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
const _sfc_main$7 = defineComponent({
|
|
418
|
+
name: "IconLineHeight",
|
|
419
|
+
props: {
|
|
420
|
+
size: {
|
|
421
|
+
type: [Number, String]
|
|
422
|
+
},
|
|
423
|
+
strokeWidth: {
|
|
424
|
+
type: Number,
|
|
425
|
+
default: 4
|
|
426
|
+
},
|
|
427
|
+
strokeLinecap: {
|
|
428
|
+
type: String,
|
|
429
|
+
default: "butt",
|
|
430
|
+
validator: (value) => {
|
|
431
|
+
return ["butt", "round", "square"].includes(value);
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
strokeLinejoin: {
|
|
435
|
+
type: String,
|
|
436
|
+
default: "miter",
|
|
437
|
+
validator: (value) => {
|
|
438
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
rotate: Number,
|
|
442
|
+
spin: Boolean
|
|
443
|
+
},
|
|
444
|
+
emits: {
|
|
445
|
+
click: (ev) => true
|
|
446
|
+
},
|
|
447
|
+
setup(props, { emit }) {
|
|
448
|
+
const prefixCls = getPrefixCls("icon");
|
|
449
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-line-height`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
450
|
+
const innerStyle = computed(() => {
|
|
451
|
+
const styles = {};
|
|
452
|
+
if (props.size) {
|
|
453
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
454
|
+
}
|
|
455
|
+
if (props.rotate) {
|
|
456
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
457
|
+
}
|
|
458
|
+
return styles;
|
|
459
|
+
});
|
|
460
|
+
const onClick = (ev) => {
|
|
461
|
+
emit("click", ev);
|
|
278
462
|
};
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
463
|
+
return {
|
|
464
|
+
cls,
|
|
465
|
+
innerStyle,
|
|
466
|
+
onClick
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
const _hoisted_1$6 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
471
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
472
|
+
return openBlock(), createElementBlock("svg", {
|
|
473
|
+
viewBox: "0 0 48 48",
|
|
474
|
+
fill: "none",
|
|
475
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
476
|
+
stroke: "currentColor",
|
|
477
|
+
class: normalizeClass(_ctx.cls),
|
|
478
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
479
|
+
"stroke-width": _ctx.strokeWidth,
|
|
480
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
481
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
482
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
483
|
+
}, _cache[1] || (_cache[1] = [
|
|
484
|
+
createElementVNode("path", { d: "M4 8h14.5M33 8H18.5m0 0v34" }, null, -1),
|
|
485
|
+
createElementVNode("path", {
|
|
486
|
+
d: "M39 9.5 37 13h4l-2-3.5ZM39 38.5 37 35h4l-2 3.5Z",
|
|
487
|
+
fill: "currentColor",
|
|
488
|
+
stroke: "none"
|
|
489
|
+
}, null, -1),
|
|
490
|
+
createElementVNode("path", { d: "M39 13h2l-2-3.5-2 3.5h2Zm0 0v22m0 0h2l-2 3.5-2-3.5h2Z" }, null, -1)
|
|
491
|
+
]), 14, _hoisted_1$6);
|
|
492
|
+
}
|
|
493
|
+
var _IconLineHeight = /* @__PURE__ */ _export_sfc$1(_sfc_main$7, [["render", _sfc_render$2]]);
|
|
494
|
+
const IconLineHeight = Object.assign(_IconLineHeight, {
|
|
495
|
+
install: (app, options) => {
|
|
496
|
+
var _a;
|
|
497
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
498
|
+
app.component(iconPrefix + _IconLineHeight.name, _IconLineHeight);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
const _sfc_main$6 = defineComponent({
|
|
502
|
+
name: "IconFullscreenExit",
|
|
503
|
+
props: {
|
|
504
|
+
size: {
|
|
505
|
+
type: [Number, String]
|
|
506
|
+
},
|
|
507
|
+
strokeWidth: {
|
|
508
|
+
type: Number,
|
|
509
|
+
default: 4
|
|
510
|
+
},
|
|
511
|
+
strokeLinecap: {
|
|
512
|
+
type: String,
|
|
513
|
+
default: "butt",
|
|
514
|
+
validator: (value) => {
|
|
515
|
+
return ["butt", "round", "square"].includes(value);
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
strokeLinejoin: {
|
|
519
|
+
type: String,
|
|
520
|
+
default: "miter",
|
|
521
|
+
validator: (value) => {
|
|
522
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
rotate: Number,
|
|
526
|
+
spin: Boolean
|
|
527
|
+
},
|
|
528
|
+
emits: {
|
|
529
|
+
click: (ev) => true
|
|
530
|
+
},
|
|
531
|
+
setup(props, { emit }) {
|
|
532
|
+
const prefixCls = getPrefixCls("icon");
|
|
533
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-fullscreen-exit`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
534
|
+
const innerStyle = computed(() => {
|
|
535
|
+
const styles = {};
|
|
536
|
+
if (props.size) {
|
|
537
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
538
|
+
}
|
|
539
|
+
if (props.rotate) {
|
|
540
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
284
541
|
}
|
|
542
|
+
return styles;
|
|
543
|
+
});
|
|
544
|
+
const onClick = (ev) => {
|
|
545
|
+
emit("click", ev);
|
|
285
546
|
};
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
element.scrollIntoView(options);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
547
|
+
return {
|
|
548
|
+
cls,
|
|
549
|
+
innerStyle,
|
|
550
|
+
onClick
|
|
293
551
|
};
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
const _hoisted_1$5 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
555
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
556
|
+
return openBlock(), createElementBlock("svg", {
|
|
557
|
+
viewBox: "0 0 48 48",
|
|
558
|
+
fill: "none",
|
|
559
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
560
|
+
stroke: "currentColor",
|
|
561
|
+
class: normalizeClass(_ctx.cls),
|
|
562
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
563
|
+
"stroke-width": _ctx.strokeWidth,
|
|
564
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
565
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
566
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
567
|
+
}, _cache[1] || (_cache[1] = [
|
|
568
|
+
createElementVNode("path", { d: "M35 6v8a1 1 0 0 0 1 1h8M13 6v8a1 1 0 0 1-1 1H4m31 27v-8a1 1 0 0 1 1-1h8m-31 9v-8a1 1 0 0 0-1-1H4" }, null, -1)
|
|
569
|
+
]), 14, _hoisted_1$5);
|
|
570
|
+
}
|
|
571
|
+
var _IconFullscreenExit = /* @__PURE__ */ _export_sfc$1(_sfc_main$6, [["render", _sfc_render$1]]);
|
|
572
|
+
const IconFullscreenExit = Object.assign(_IconFullscreenExit, {
|
|
573
|
+
install: (app, options) => {
|
|
574
|
+
var _a;
|
|
575
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
576
|
+
app.component(iconPrefix + _IconFullscreenExit.name, _IconFullscreenExit);
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
const _sfc_main$5 = defineComponent({
|
|
580
|
+
name: "IconFullscreen",
|
|
581
|
+
props: {
|
|
582
|
+
size: {
|
|
583
|
+
type: [Number, String]
|
|
584
|
+
},
|
|
585
|
+
strokeWidth: {
|
|
586
|
+
type: Number,
|
|
587
|
+
default: 4
|
|
588
|
+
},
|
|
589
|
+
strokeLinecap: {
|
|
590
|
+
type: String,
|
|
591
|
+
default: "butt",
|
|
592
|
+
validator: (value) => {
|
|
593
|
+
return ["butt", "round", "square"].includes(value);
|
|
594
|
+
}
|
|
595
|
+
},
|
|
596
|
+
strokeLinejoin: {
|
|
597
|
+
type: String,
|
|
598
|
+
default: "miter",
|
|
599
|
+
validator: (value) => {
|
|
600
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
rotate: Number,
|
|
604
|
+
spin: Boolean
|
|
605
|
+
},
|
|
606
|
+
emits: {
|
|
607
|
+
click: (ev) => true
|
|
608
|
+
},
|
|
609
|
+
setup(props, { emit }) {
|
|
610
|
+
const prefixCls = getPrefixCls("icon");
|
|
611
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-fullscreen`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
612
|
+
const innerStyle = computed(() => {
|
|
613
|
+
const styles = {};
|
|
614
|
+
if (props.size) {
|
|
615
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
616
|
+
}
|
|
617
|
+
if (props.rotate) {
|
|
618
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
619
|
+
}
|
|
620
|
+
return styles;
|
|
313
621
|
});
|
|
314
|
-
const
|
|
315
|
-
()
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
622
|
+
const onClick = (ev) => {
|
|
623
|
+
emit("click", ev);
|
|
624
|
+
};
|
|
625
|
+
return {
|
|
626
|
+
cls,
|
|
627
|
+
innerStyle,
|
|
628
|
+
onClick
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
const _hoisted_1$4 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
633
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
634
|
+
return openBlock(), createElementBlock("svg", {
|
|
635
|
+
viewBox: "0 0 48 48",
|
|
636
|
+
fill: "none",
|
|
637
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
638
|
+
stroke: "currentColor",
|
|
639
|
+
class: normalizeClass(_ctx.cls),
|
|
640
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
641
|
+
"stroke-width": _ctx.strokeWidth,
|
|
642
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
643
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
644
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
645
|
+
}, _cache[1] || (_cache[1] = [
|
|
646
|
+
createElementVNode("path", { d: "M42 17V9a1 1 0 0 0-1-1h-8M6 17V9a1 1 0 0 1 1-1h8m27 23v8a1 1 0 0 1-1 1h-8M6 31v8a1 1 0 0 0 1 1h8" }, null, -1)
|
|
647
|
+
]), 14, _hoisted_1$4);
|
|
648
|
+
}
|
|
649
|
+
var _IconFullscreen = /* @__PURE__ */ _export_sfc$1(_sfc_main$5, [["render", _sfc_render]]);
|
|
650
|
+
const IconFullscreen = Object.assign(_IconFullscreen, {
|
|
651
|
+
install: (app, options) => {
|
|
652
|
+
var _a;
|
|
653
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
654
|
+
app.component(iconPrefix + _IconFullscreen.name, _IconFullscreen);
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
const _hoisted_1$3 = { class: "basic-upload" };
|
|
658
|
+
const _hoisted_2$3 = {
|
|
659
|
+
key: 0,
|
|
660
|
+
class: "upload-text"
|
|
661
|
+
};
|
|
662
|
+
const _hoisted_3$2 = { class: "upload-tip" };
|
|
663
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
664
|
+
...{
|
|
665
|
+
name: "BasicUpload",
|
|
666
|
+
inheritAttrs: false
|
|
667
|
+
},
|
|
668
|
+
__name: "BasicUpload",
|
|
669
|
+
props: {
|
|
670
|
+
modelValue: {},
|
|
671
|
+
accept: { default: "image/*" },
|
|
672
|
+
maxSize: { default: 30 },
|
|
673
|
+
maxCount: { default: 1 },
|
|
674
|
+
multiple: { type: Boolean, default: false },
|
|
675
|
+
disabled: { type: Boolean, default: false },
|
|
676
|
+
readonly: { type: Boolean, default: false },
|
|
677
|
+
listType: { default: "picture-card" },
|
|
678
|
+
action: {},
|
|
679
|
+
headers: {},
|
|
680
|
+
data: {},
|
|
681
|
+
name: { default: "file" },
|
|
682
|
+
withCredentials: { type: Boolean, default: false },
|
|
683
|
+
customRequest: {},
|
|
684
|
+
beforeUpload: {},
|
|
685
|
+
onSuccess: {},
|
|
686
|
+
onError: {},
|
|
687
|
+
onProgress: {},
|
|
688
|
+
onRemove: {},
|
|
689
|
+
onPreview: {},
|
|
690
|
+
showFileList: { type: Boolean, default: true },
|
|
691
|
+
showRemoveButton: { type: Boolean, default: true },
|
|
692
|
+
showDownloadButton: { type: Boolean, default: false },
|
|
693
|
+
showPreviewButton: { type: Boolean, default: true },
|
|
694
|
+
showUploadButton: { type: Boolean, default: true },
|
|
695
|
+
tip: {},
|
|
696
|
+
cardSize: {},
|
|
697
|
+
imagePreview: { type: Boolean, default: true },
|
|
698
|
+
imageCrop: { type: Boolean, default: false },
|
|
699
|
+
imageCompress: { type: Boolean, default: false },
|
|
700
|
+
compressOptions: {},
|
|
701
|
+
draggable: { type: Boolean, default: false },
|
|
702
|
+
directory: { type: Boolean, default: false },
|
|
703
|
+
autoUpload: { type: Boolean, default: true },
|
|
704
|
+
resultType: { default: "fileList" },
|
|
705
|
+
uploadButtonText: {},
|
|
706
|
+
uploadButtonType: { default: "primary" }
|
|
707
|
+
},
|
|
708
|
+
emits: ["register", "update:modelValue", "change", "success", "error", "progress", "remove", "preview", "exceed"],
|
|
709
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
710
|
+
const props = __props;
|
|
711
|
+
const emit = __emit;
|
|
712
|
+
const uploadRef = ref();
|
|
713
|
+
const fileListRef = ref([]);
|
|
714
|
+
const propsRef = ref({});
|
|
715
|
+
const hasShownActionError = ref(false);
|
|
716
|
+
const isInternalUpdate = ref(false);
|
|
717
|
+
const processedFiles = ref(/* @__PURE__ */ new Map());
|
|
718
|
+
const getProps = computed(() => {
|
|
719
|
+
return { ...props, ...unref(propsRef) };
|
|
720
|
+
});
|
|
721
|
+
const hideUploadButton = computed(() => {
|
|
722
|
+
const propsData = unref(getProps);
|
|
723
|
+
if (!propsData.showUploadButton) return true;
|
|
724
|
+
if (propsData.readonly) return true;
|
|
725
|
+
if (propsData.maxCount && fileListRef.value.length >= propsData.maxCount) {
|
|
726
|
+
return true;
|
|
727
|
+
}
|
|
728
|
+
return false;
|
|
729
|
+
});
|
|
730
|
+
const getBindValue = computed(() => {
|
|
731
|
+
const propsData = unref(getProps);
|
|
732
|
+
return {
|
|
733
|
+
...propsData,
|
|
734
|
+
disabled: propsData.disabled || propsData.readonly,
|
|
735
|
+
showRemoveButton: propsData.showRemoveButton && !propsData.readonly,
|
|
736
|
+
showUploadButton: !hideUploadButton.value,
|
|
737
|
+
// 只有在没有自定义预览时才启用 imagePreview
|
|
738
|
+
imagePreview: propsData.imagePreview && !propsData.onPreview,
|
|
739
|
+
onRemove: async (fileItem) => {
|
|
740
|
+
if (propsData.onRemove) {
|
|
741
|
+
const canRemove = await propsData.onRemove(fileItem);
|
|
742
|
+
if (!canRemove) return false;
|
|
743
|
+
}
|
|
744
|
+
emit("remove", fileItem);
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
});
|
|
749
|
+
const validateFileSize = (file) => {
|
|
750
|
+
const propsData = unref(getProps);
|
|
751
|
+
if (!propsData.maxSize) return true;
|
|
752
|
+
const maxSizeInBytes = propsData.maxSize * 1024 * 1024;
|
|
753
|
+
if (file.size > maxSizeInBytes) {
|
|
754
|
+
Message.error(`文件大小不能超过 ${propsData.maxSize}MB`);
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
return true;
|
|
758
|
+
};
|
|
759
|
+
const validateFileType = (file) => {
|
|
760
|
+
var _a;
|
|
761
|
+
const propsData = unref(getProps);
|
|
762
|
+
if (!propsData.accept) return true;
|
|
763
|
+
const acceptTypes = propsData.accept.split(",").map((type) => type.trim());
|
|
764
|
+
const fileExtension = `.${(_a = file.name.split(".").pop()) == null ? void 0 : _a.toLowerCase()}`;
|
|
765
|
+
const fileMimeType = file.type;
|
|
766
|
+
const isValid = acceptTypes.some((type) => {
|
|
767
|
+
if (type.startsWith(".")) {
|
|
768
|
+
return fileExtension === type.toLowerCase();
|
|
769
|
+
}
|
|
770
|
+
if (type.includes("*")) {
|
|
771
|
+
const [mainType] = type.split("/");
|
|
772
|
+
return fileMimeType.startsWith(mainType);
|
|
773
|
+
}
|
|
774
|
+
return fileMimeType === type;
|
|
775
|
+
});
|
|
776
|
+
if (!isValid) {
|
|
777
|
+
Message.error(`不支持的文件类型: ${file.name}`);
|
|
778
|
+
return false;
|
|
779
|
+
}
|
|
780
|
+
return true;
|
|
781
|
+
};
|
|
782
|
+
const handleBeforeUpload = async (file) => {
|
|
783
|
+
const propsData = unref(getProps);
|
|
784
|
+
if (!validateFileSize(file)) {
|
|
785
|
+
return false;
|
|
786
|
+
}
|
|
787
|
+
if (!validateFileType(file)) {
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
if (propsData.maxCount && fileListRef.value.length >= propsData.maxCount) {
|
|
791
|
+
Message.error(`最多只能上传 ${propsData.maxCount} 个文件`);
|
|
792
|
+
emit("exceed", [file], fileListRef.value);
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
if (propsData.beforeUpload) {
|
|
796
|
+
try {
|
|
797
|
+
const result = await propsData.beforeUpload(file);
|
|
798
|
+
return result;
|
|
799
|
+
} catch (error) {
|
|
800
|
+
console.error("beforeUpload error:", error);
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
return true;
|
|
805
|
+
};
|
|
806
|
+
const handleCustomRequest = (options) => {
|
|
807
|
+
const propsData = unref(getProps);
|
|
808
|
+
if (propsData.customRequest) {
|
|
809
|
+
const customOptions = {
|
|
810
|
+
file: options.fileItem.file,
|
|
811
|
+
fileItem: options.fileItem,
|
|
812
|
+
onProgress: (percent, event) => {
|
|
813
|
+
options.onProgress(percent, event);
|
|
814
|
+
},
|
|
815
|
+
onSuccess: (response) => {
|
|
816
|
+
options.onSuccess(response);
|
|
817
|
+
},
|
|
818
|
+
onError: (error) => {
|
|
819
|
+
options.onError(error);
|
|
820
|
+
},
|
|
821
|
+
headers: propsData.headers,
|
|
822
|
+
data: propsData.data,
|
|
823
|
+
name: propsData.name,
|
|
824
|
+
action: propsData.action,
|
|
825
|
+
withCredentials: propsData.withCredentials
|
|
826
|
+
};
|
|
827
|
+
return propsData.customRequest(customOptions);
|
|
828
|
+
}
|
|
829
|
+
return defaultUpload(options);
|
|
830
|
+
};
|
|
831
|
+
const extractUrlFromResponse = (response) => {
|
|
832
|
+
const urlPaths = ["url", "data.pathUrl", "data.url", "data.path", "pathUrl", "path"];
|
|
833
|
+
for (const path of urlPaths) {
|
|
834
|
+
const value = path.split(".").reduce((obj, key) => obj == null ? void 0 : obj[key], response);
|
|
835
|
+
if (value && typeof value === "string") {
|
|
836
|
+
return value;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (response.data && typeof response.data === "string") {
|
|
840
|
+
return response.data;
|
|
841
|
+
}
|
|
842
|
+
return null;
|
|
843
|
+
};
|
|
844
|
+
const isDev = false;
|
|
845
|
+
const logger = {
|
|
846
|
+
debug: (...args) => isDev,
|
|
847
|
+
warn: (...args) => console.warn("[BasicUpload]", ...args),
|
|
848
|
+
error: (...args) => console.error("[BasicUpload]", ...args)
|
|
849
|
+
};
|
|
850
|
+
const defaultUpload = (options) => {
|
|
851
|
+
const propsData = unref(getProps);
|
|
852
|
+
const { fileItem, onProgress, onSuccess, onError } = options;
|
|
853
|
+
if (!propsData.action) {
|
|
854
|
+
if (!hasShownActionError.value) {
|
|
855
|
+
Message.error("请配置上传地址 action");
|
|
856
|
+
hasShownActionError.value = true;
|
|
857
|
+
setTimeout(() => {
|
|
858
|
+
hasShownActionError.value = false;
|
|
859
|
+
}, 3e3);
|
|
860
|
+
}
|
|
861
|
+
onError(new Error("上传地址未配置"));
|
|
862
|
+
return {
|
|
863
|
+
abort() {
|
|
864
|
+
xhr.abort();
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
const formData = new FormData();
|
|
869
|
+
formData.append(propsData.name || "file", fileItem.file);
|
|
870
|
+
if (propsData.data) {
|
|
871
|
+
Object.keys(propsData.data).forEach((key) => {
|
|
872
|
+
formData.append(key, propsData.data[key]);
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
const xhr = new XMLHttpRequest();
|
|
876
|
+
xhr.upload.addEventListener("progress", (e) => {
|
|
877
|
+
if (e.lengthComputable) {
|
|
878
|
+
const percent = Math.round(e.loaded / e.total * 100);
|
|
879
|
+
onProgress(percent, e);
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
xhr.addEventListener("load", () => {
|
|
883
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
884
|
+
try {
|
|
885
|
+
const response = JSON.parse(xhr.responseText);
|
|
886
|
+
const { code, message, data } = response;
|
|
887
|
+
if (code !== 200) {
|
|
888
|
+
const errorMsg = message ? `上传失败: ${message}` : "上传失败";
|
|
889
|
+
onError(new Error(errorMsg));
|
|
890
|
+
Message.error(errorMsg);
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
const extractedUrl = extractUrlFromResponse(response);
|
|
894
|
+
const normalizedResponse = extractedUrl ? { url: extractedUrl, name: fileItem.name, ...data } : response;
|
|
895
|
+
if (!extractedUrl) {
|
|
896
|
+
logger.warn("响应中未找到 URL 字段,可能导致上传状态异常");
|
|
897
|
+
}
|
|
898
|
+
Message.success(`${fileItem.name} 上传成功`);
|
|
899
|
+
onSuccess(normalizedResponse);
|
|
900
|
+
} catch (error) {
|
|
901
|
+
onSuccess({ data: xhr.responseText });
|
|
902
|
+
}
|
|
903
|
+
} else {
|
|
904
|
+
const errorMsg = `上传失败: HTTP ${xhr.status}`;
|
|
905
|
+
Message.error(errorMsg);
|
|
906
|
+
onError(new Error(errorMsg));
|
|
907
|
+
}
|
|
908
|
+
});
|
|
909
|
+
xhr.addEventListener("error", () => {
|
|
910
|
+
logger.error("上传网络错误");
|
|
911
|
+
onError(new Error("网络错误"));
|
|
912
|
+
});
|
|
913
|
+
xhr.addEventListener("abort", () => {
|
|
914
|
+
onError(new Error("上传已取消"));
|
|
915
|
+
});
|
|
916
|
+
xhr.open("POST", propsData.action);
|
|
917
|
+
if (propsData.headers) {
|
|
918
|
+
Object.keys(propsData.headers).forEach((key) => {
|
|
919
|
+
xhr.setRequestHeader(key, propsData.headers[key]);
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
if (propsData.withCredentials) {
|
|
923
|
+
xhr.withCredentials = true;
|
|
924
|
+
}
|
|
925
|
+
xhr.send(formData);
|
|
926
|
+
return {
|
|
927
|
+
abort() {
|
|
928
|
+
xhr.abort();
|
|
320
929
|
}
|
|
930
|
+
};
|
|
931
|
+
};
|
|
932
|
+
const handleChange = (fileList, currentFile) => {
|
|
933
|
+
if (isInternalUpdate.value) return;
|
|
934
|
+
const oldLength = fileListRef.value.length;
|
|
935
|
+
const newLength = fileList.length;
|
|
936
|
+
fileListRef.value = fileList;
|
|
937
|
+
emit("change", fileList);
|
|
938
|
+
const isRemove = newLength < oldLength;
|
|
939
|
+
const fileKey = currentFile.uid;
|
|
940
|
+
const lastStatus = processedFiles.value.get(fileKey);
|
|
941
|
+
if (currentFile.status === "done" && lastStatus !== "done" && !isRemove) {
|
|
942
|
+
processedFiles.value.set(fileKey, "done");
|
|
943
|
+
emit("success", currentFile.response, currentFile);
|
|
944
|
+
} else if (currentFile.status === "error" && lastStatus !== "error") {
|
|
945
|
+
processedFiles.value.set(fileKey, "error");
|
|
946
|
+
const error = new Error("上传失败");
|
|
947
|
+
emit("error", error, currentFile);
|
|
948
|
+
}
|
|
949
|
+
if (isRemove) {
|
|
950
|
+
const fileUids = new Set(fileList.map((f) => f.uid));
|
|
951
|
+
processedFiles.value.forEach((_, uid) => {
|
|
952
|
+
if (!fileUids.has(uid)) {
|
|
953
|
+
processedFiles.value.delete(uid);
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
updateModelValue(fileList);
|
|
958
|
+
};
|
|
959
|
+
const handleProgress = (currentFile, event) => {
|
|
960
|
+
const percent = currentFile.percent || 0;
|
|
961
|
+
emit("progress", percent, currentFile);
|
|
962
|
+
};
|
|
963
|
+
const handlePreview = (fileItem) => {
|
|
964
|
+
const propsData = unref(getProps);
|
|
965
|
+
if (propsData.onPreview) {
|
|
966
|
+
propsData.onPreview(fileItem);
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
const updateModelValue = (fileList) => {
|
|
971
|
+
var _a;
|
|
972
|
+
const propsData = unref(getProps);
|
|
973
|
+
isInternalUpdate.value = true;
|
|
974
|
+
switch (propsData.resultType) {
|
|
975
|
+
case "fileList":
|
|
976
|
+
emit("update:modelValue", fileList);
|
|
977
|
+
break;
|
|
978
|
+
case "url":
|
|
979
|
+
if (propsData.multiple) {
|
|
980
|
+
const urls2 = fileList.filter((file) => file.status === "done" && file.url).map((file) => file.url);
|
|
981
|
+
emit("update:modelValue", urls2);
|
|
982
|
+
} else {
|
|
983
|
+
const url = ((_a = fileList.find((file) => file.status === "done")) == null ? void 0 : _a.url) || "";
|
|
984
|
+
emit("update:modelValue", url);
|
|
985
|
+
}
|
|
986
|
+
break;
|
|
987
|
+
case "string":
|
|
988
|
+
const urls = fileList.filter((file) => file.status === "done" && file.url).map((file) => file.url);
|
|
989
|
+
emit("update:modelValue", urls.join(","));
|
|
990
|
+
break;
|
|
991
|
+
default:
|
|
992
|
+
emit("update:modelValue", fileList);
|
|
993
|
+
}
|
|
994
|
+
nextTick(() => {
|
|
995
|
+
setTimeout(() => {
|
|
996
|
+
isInternalUpdate.value = false;
|
|
997
|
+
}, 50);
|
|
998
|
+
});
|
|
999
|
+
};
|
|
1000
|
+
const parseModelValue = (value) => {
|
|
1001
|
+
if (!value) return [];
|
|
1002
|
+
if (Array.isArray(value) && value.length > 0 && typeof value[0] === "object") {
|
|
1003
|
+
return value;
|
|
1004
|
+
}
|
|
1005
|
+
if (Array.isArray(value)) {
|
|
1006
|
+
return value.map((url, index) => ({
|
|
1007
|
+
uid: `${Date.now()}-${index}`,
|
|
1008
|
+
name: url.split("/").pop() || `file-${index}`,
|
|
1009
|
+
url,
|
|
1010
|
+
status: "done"
|
|
1011
|
+
}));
|
|
1012
|
+
}
|
|
1013
|
+
if (typeof value === "string") {
|
|
1014
|
+
const urls = value.split(",").filter(Boolean);
|
|
1015
|
+
return urls.map((url, index) => ({
|
|
1016
|
+
uid: `${Date.now()}-${index}`,
|
|
1017
|
+
name: url.split("/").pop() || `file-${index}`,
|
|
1018
|
+
url: url.trim(),
|
|
1019
|
+
status: "done"
|
|
1020
|
+
}));
|
|
1021
|
+
}
|
|
1022
|
+
return [];
|
|
1023
|
+
};
|
|
1024
|
+
const submit = () => {
|
|
1025
|
+
var _a, _b;
|
|
1026
|
+
(_b = (_a = uploadRef.value) == null ? void 0 : _a.submit) == null ? void 0 : _b.call(_a);
|
|
1027
|
+
};
|
|
1028
|
+
const abort = (fileItem) => {
|
|
1029
|
+
var _a, _b;
|
|
1030
|
+
(_b = (_a = uploadRef.value) == null ? void 0 : _a.abort) == null ? void 0 : _b.call(_a, fileItem);
|
|
1031
|
+
};
|
|
1032
|
+
const clearFiles = () => {
|
|
1033
|
+
fileListRef.value = [];
|
|
1034
|
+
processedFiles.value.clear();
|
|
1035
|
+
emit("update:modelValue", []);
|
|
1036
|
+
emit("change", []);
|
|
1037
|
+
};
|
|
1038
|
+
const getFileList = () => {
|
|
1039
|
+
return fileListRef.value;
|
|
1040
|
+
};
|
|
1041
|
+
const upload = (fileItem) => {
|
|
1042
|
+
var _a, _b;
|
|
1043
|
+
(_b = (_a = uploadRef.value) == null ? void 0 : _a.upload) == null ? void 0 : _b.call(_a, fileItem);
|
|
1044
|
+
};
|
|
1045
|
+
const setProps = (uploadProps) => {
|
|
1046
|
+
propsRef.value = { ...unref(propsRef), ...uploadProps };
|
|
1047
|
+
};
|
|
1048
|
+
const setFileList = (files) => {
|
|
1049
|
+
fileListRef.value = files;
|
|
1050
|
+
updateModelValue(files);
|
|
1051
|
+
};
|
|
1052
|
+
const addFile = (file) => {
|
|
1053
|
+
fileListRef.value.push(file);
|
|
1054
|
+
updateModelValue(fileListRef.value);
|
|
1055
|
+
};
|
|
1056
|
+
const removeFile = (fileItem) => {
|
|
1057
|
+
const index = fileListRef.value.findIndex((item) => item.uid === fileItem.uid);
|
|
1058
|
+
if (index !== -1) {
|
|
1059
|
+
fileListRef.value.splice(index, 1);
|
|
1060
|
+
updateModelValue(fileListRef.value);
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
const updateFile = (fileItem) => {
|
|
1064
|
+
const index = fileListRef.value.findIndex((item) => item.uid === fileItem.uid);
|
|
1065
|
+
if (index !== -1) {
|
|
1066
|
+
fileListRef.value[index] = { ...fileListRef.value[index], ...fileItem };
|
|
1067
|
+
updateModelValue(fileListRef.value);
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
__expose({
|
|
1071
|
+
submit,
|
|
1072
|
+
abort,
|
|
1073
|
+
clearFiles,
|
|
1074
|
+
getFileList,
|
|
1075
|
+
upload,
|
|
1076
|
+
setProps,
|
|
1077
|
+
setFileList,
|
|
1078
|
+
addFile,
|
|
1079
|
+
removeFile,
|
|
1080
|
+
updateFile
|
|
1081
|
+
});
|
|
1082
|
+
watch(
|
|
1083
|
+
() => props.modelValue,
|
|
1084
|
+
(val, oldVal) => {
|
|
1085
|
+
if (isInternalUpdate.value) return;
|
|
1086
|
+
fileListRef.value = parseModelValue(val);
|
|
321
1087
|
},
|
|
322
1088
|
{ immediate: true }
|
|
323
1089
|
);
|
|
324
1090
|
onMounted(() => {
|
|
325
1091
|
nextTick(() => {
|
|
326
1092
|
emit("register", {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
validate,
|
|
333
|
-
clearValidate,
|
|
334
|
-
updateSchema,
|
|
335
|
-
removeSchema,
|
|
336
|
-
getSchema,
|
|
337
|
-
resetSchema,
|
|
1093
|
+
submit,
|
|
1094
|
+
abort,
|
|
1095
|
+
clearFiles,
|
|
1096
|
+
getFileList,
|
|
1097
|
+
upload,
|
|
338
1098
|
setProps,
|
|
339
|
-
|
|
340
|
-
|
|
1099
|
+
setFileList,
|
|
1100
|
+
addFile,
|
|
1101
|
+
removeFile,
|
|
1102
|
+
updateFile
|
|
341
1103
|
});
|
|
342
1104
|
});
|
|
343
1105
|
});
|
|
344
|
-
onBeforeUnmount(() => {
|
|
345
|
-
stopSchemasWatch();
|
|
346
|
-
Object.keys(formModel).forEach((key) => {
|
|
347
|
-
delete formModel[key];
|
|
348
|
-
});
|
|
349
|
-
internalSchemas.value = [];
|
|
350
|
-
dynamicProps.value = {};
|
|
351
|
-
});
|
|
352
1106
|
return (_ctx, _cache) => {
|
|
353
|
-
const _component_a_form_item = resolveComponent("a-form-item");
|
|
354
|
-
const _component_a_col = resolveComponent("a-col");
|
|
355
1107
|
const _component_a_button = resolveComponent("a-button");
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
1108
|
+
const _component_a_upload = resolveComponent("a-upload");
|
|
1109
|
+
return openBlock(), createElementBlock("div", _hoisted_1$3, [
|
|
1110
|
+
createVNode(_component_a_upload, mergeProps({
|
|
1111
|
+
ref_key: "uploadRef",
|
|
1112
|
+
ref: uploadRef
|
|
1113
|
+
}, getBindValue.value, {
|
|
1114
|
+
"file-list": fileListRef.value,
|
|
1115
|
+
"custom-request": handleCustomRequest,
|
|
1116
|
+
onChange: handleChange,
|
|
1117
|
+
onBeforeUpload: handleBeforeUpload,
|
|
1118
|
+
onProgress: handleProgress,
|
|
1119
|
+
onPreview: handlePreview
|
|
1120
|
+
}), createSlots({ _: 2 }, [
|
|
1121
|
+
!hideUploadButton.value ? {
|
|
1122
|
+
name: "upload-button",
|
|
1123
|
+
fn: withCtx(() => [
|
|
1124
|
+
renderSlot(_ctx.$slots, "upload-button", {}, () => [
|
|
1125
|
+
getProps.value.listType === "picture-card" ? (openBlock(), createElementBlock("div", {
|
|
1126
|
+
key: 0,
|
|
1127
|
+
class: "upload-card-button",
|
|
1128
|
+
style: normalizeStyle({
|
|
1129
|
+
width: `${getProps.value.cardSize || 80}px`,
|
|
1130
|
+
height: `${getProps.value.cardSize || 80}px`
|
|
1131
|
+
})
|
|
1132
|
+
}, [
|
|
1133
|
+
createVNode(unref(IconPlus), { size: 16 }),
|
|
1134
|
+
getProps.value.uploadButtonText ? (openBlock(), createElementBlock("div", _hoisted_2$3, toDisplayString(getProps.value.uploadButtonText), 1)) : createCommentVNode("", true)
|
|
1135
|
+
], 4)) : (openBlock(), createBlock(_component_a_button, {
|
|
1136
|
+
key: 1,
|
|
1137
|
+
type: getProps.value.uploadButtonType || "primary"
|
|
1138
|
+
}, {
|
|
1139
|
+
icon: withCtx(() => [
|
|
1140
|
+
createVNode(unref(IconUpload))
|
|
1141
|
+
]),
|
|
376
1142
|
default: withCtx(() => [
|
|
377
|
-
|
|
378
|
-
key: 1,
|
|
379
|
-
ref_for: true
|
|
380
|
-
}, getFormItemBindValue(schema)), {
|
|
381
|
-
default: withCtx(() => [
|
|
382
|
-
schema.renderComponentContent ? (openBlock(), createBlock(resolveDynamicComponent(schema.renderComponentContent(schema, formModel)), { key: 0 })) : (openBlock(), createBlock(resolveDynamicComponent(unref(getComponent)(schema.component)), mergeProps({
|
|
383
|
-
key: 1,
|
|
384
|
-
modelValue: formModel[schema.field],
|
|
385
|
-
"onUpdate:modelValue": ($event) => formModel[schema.field] = $event,
|
|
386
|
-
placeholder: getPlaceholderText(schema)
|
|
387
|
-
}, { ref_for: true }, schema.componentProps), null, 16, ["modelValue", "onUpdate:modelValue", "placeholder"]))
|
|
388
|
-
]),
|
|
389
|
-
_: 2
|
|
390
|
-
}, 1040))
|
|
1143
|
+
createTextVNode(" " + toDisplayString(getProps.value.uploadButtonText || "上传文件"), 1)
|
|
391
1144
|
]),
|
|
392
|
-
_:
|
|
393
|
-
},
|
|
394
|
-
|
|
395
|
-
getActionProps.value.showActionButtons ? (openBlock(), createBlock(_component_a_col, normalizeProps(mergeProps({ key: 0 }, getActionProps.value.actionColOptions)), {
|
|
396
|
-
default: withCtx(() => [
|
|
397
|
-
createVNode(_component_a_form_item, normalizeProps(guardReactiveProps(getActionProps.value.actionFormItemProps)), {
|
|
398
|
-
default: withCtx(() => [
|
|
399
|
-
createVNode(_component_a_space, null, {
|
|
400
|
-
default: withCtx(() => [
|
|
401
|
-
getActionProps.value.showSubmitButton ? (openBlock(), createBlock(_component_a_button, {
|
|
402
|
-
key: 0,
|
|
403
|
-
type: "primary",
|
|
404
|
-
"html-type": "submit",
|
|
405
|
-
loading: submitLoading.value
|
|
406
|
-
}, {
|
|
407
|
-
default: withCtx(() => [
|
|
408
|
-
createTextVNode(toDisplayString(getActionProps.value.submitButtonText), 1)
|
|
409
|
-
]),
|
|
410
|
-
_: 1
|
|
411
|
-
}, 8, ["loading"])) : createCommentVNode("", true),
|
|
412
|
-
getActionProps.value.showResetButton ? (openBlock(), createBlock(_component_a_button, {
|
|
413
|
-
key: 1,
|
|
414
|
-
onClick: handleReset
|
|
415
|
-
}, {
|
|
416
|
-
default: withCtx(() => [
|
|
417
|
-
createTextVNode(toDisplayString(getActionProps.value.resetButtonText), 1)
|
|
418
|
-
]),
|
|
419
|
-
_: 1
|
|
420
|
-
})) : createCommentVNode("", true),
|
|
421
|
-
renderSlot(_ctx.$slots, "actions")
|
|
422
|
-
]),
|
|
423
|
-
_: 3
|
|
424
|
-
})
|
|
425
|
-
]),
|
|
426
|
-
_: 3
|
|
427
|
-
}, 16)
|
|
428
|
-
]),
|
|
429
|
-
_: 3
|
|
430
|
-
}, 16)) : createCommentVNode("", true)
|
|
1145
|
+
_: 1
|
|
1146
|
+
}, 8, ["type"]))
|
|
1147
|
+
], true)
|
|
431
1148
|
]),
|
|
432
|
-
|
|
433
|
-
},
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
1149
|
+
key: "0"
|
|
1150
|
+
} : void 0,
|
|
1151
|
+
_ctx.$slots.default ? {
|
|
1152
|
+
name: "default",
|
|
1153
|
+
fn: withCtx(() => [
|
|
1154
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
1155
|
+
]),
|
|
1156
|
+
key: "1"
|
|
1157
|
+
} : void 0,
|
|
1158
|
+
getProps.value.tip || _ctx.$slots.tip ? {
|
|
1159
|
+
name: "tip",
|
|
1160
|
+
fn: withCtx(() => [
|
|
1161
|
+
renderSlot(_ctx.$slots, "tip", {}, () => [
|
|
1162
|
+
createElementVNode("div", _hoisted_3$2, toDisplayString(getProps.value.tip), 1)
|
|
1163
|
+
], true)
|
|
1164
|
+
]),
|
|
1165
|
+
key: "2"
|
|
1166
|
+
} : void 0,
|
|
1167
|
+
_ctx.$slots.file ? {
|
|
1168
|
+
name: "file",
|
|
1169
|
+
fn: withCtx(({ file }) => [
|
|
1170
|
+
renderSlot(_ctx.$slots, "file", { file }, void 0, true)
|
|
1171
|
+
]),
|
|
1172
|
+
key: "3"
|
|
1173
|
+
} : void 0
|
|
1174
|
+
]), 1040, ["file-list"])
|
|
1175
|
+
]);
|
|
437
1176
|
};
|
|
438
1177
|
}
|
|
439
1178
|
});
|
|
440
|
-
|
|
441
|
-
const
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
if (
|
|
479
|
-
return
|
|
480
|
-
}
|
|
481
|
-
return { ...formModel };
|
|
482
|
-
};
|
|
483
|
-
const setFieldsValue = async (values) => {
|
|
484
|
-
const form = getFormSafe();
|
|
485
|
-
if (!form) return;
|
|
486
|
-
if (form.setFieldsValue) {
|
|
487
|
-
await form.setFieldsValue(values);
|
|
488
|
-
} else {
|
|
489
|
-
Object.keys(values).forEach((key) => {
|
|
490
|
-
formModel[key] = values[key];
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
const resetFields = async () => {
|
|
495
|
-
var _a;
|
|
496
|
-
const form = getFormSafe();
|
|
497
|
-
if (!form) return;
|
|
498
|
-
if (form.resetFields) {
|
|
499
|
-
await form.resetFields();
|
|
500
|
-
} else if ((_a = form.formRef) == null ? void 0 : _a.value) {
|
|
501
|
-
await form.formRef.value.resetFields();
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
const validate = async (nameList) => {
|
|
505
|
-
var _a;
|
|
506
|
-
const form = getFormSafe();
|
|
507
|
-
if (!form) return Promise.reject("表单实例不存在");
|
|
508
|
-
if (form.validate) {
|
|
509
|
-
return await form.validate(nameList);
|
|
510
|
-
} else if ((_a = form.formRef) == null ? void 0 : _a.value) {
|
|
511
|
-
return await form.formRef.value.validate(nameList);
|
|
512
|
-
}
|
|
513
|
-
return Promise.resolve(void 0);
|
|
514
|
-
};
|
|
515
|
-
const validateFields = async (nameList) => {
|
|
516
|
-
return await validate(nameList);
|
|
517
|
-
};
|
|
518
|
-
const clearValidate = async (field) => {
|
|
519
|
-
var _a;
|
|
520
|
-
const form = getFormSafe();
|
|
521
|
-
if (!form) return;
|
|
522
|
-
if (form.clearValidate) {
|
|
523
|
-
await form.clearValidate(field);
|
|
524
|
-
} else if ((_a = form.formRef) == null ? void 0 : _a.value) {
|
|
525
|
-
await form.formRef.value.clearValidate(field);
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
const submit = async () => {
|
|
529
|
-
const form = getFormSafe();
|
|
530
|
-
if (!form) return;
|
|
531
|
-
if (form.handleSubmit) {
|
|
532
|
-
return await form.handleSubmit();
|
|
533
|
-
}
|
|
534
|
-
await validate();
|
|
535
|
-
return getFieldsValue();
|
|
536
|
-
};
|
|
537
|
-
const updateSchema = async (schema) => {
|
|
538
|
-
const form = getFormSafe();
|
|
539
|
-
if (!form) return;
|
|
540
|
-
const schemaList = Array.isArray(schema) ? schema : [schema];
|
|
541
|
-
if (form.updateSchema) {
|
|
542
|
-
await form.updateSchema(schemaList);
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
const resetSchema = async (schemas) => {
|
|
546
|
-
const form = getFormSafe();
|
|
547
|
-
if (!form) return;
|
|
548
|
-
if (form.resetSchema) {
|
|
549
|
-
await form.resetSchema(schemas);
|
|
1179
|
+
const _export_sfc = (sfc, props) => {
|
|
1180
|
+
const target = sfc.__vccOpts || sfc;
|
|
1181
|
+
for (const [key, val] of props) {
|
|
1182
|
+
target[key] = val;
|
|
1183
|
+
}
|
|
1184
|
+
return target;
|
|
1185
|
+
};
|
|
1186
|
+
const BasicUpload = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-10587859"]]);
|
|
1187
|
+
const componentMap = {
|
|
1188
|
+
Input,
|
|
1189
|
+
InputNumber,
|
|
1190
|
+
InputPassword,
|
|
1191
|
+
Textarea,
|
|
1192
|
+
AutoComplete,
|
|
1193
|
+
Select,
|
|
1194
|
+
Radio,
|
|
1195
|
+
RadioGroup,
|
|
1196
|
+
Checkbox,
|
|
1197
|
+
CheckboxGroup,
|
|
1198
|
+
Cascader,
|
|
1199
|
+
TreeSelect,
|
|
1200
|
+
DatePicker,
|
|
1201
|
+
TimePicker,
|
|
1202
|
+
RangePicker,
|
|
1203
|
+
Switch,
|
|
1204
|
+
Slider,
|
|
1205
|
+
Rate,
|
|
1206
|
+
Upload,
|
|
1207
|
+
BasicUpload,
|
|
1208
|
+
Mention,
|
|
1209
|
+
Transfer
|
|
1210
|
+
};
|
|
1211
|
+
const customComponentMap = /* @__PURE__ */ new Map();
|
|
1212
|
+
function registerComponent(name, component) {
|
|
1213
|
+
customComponentMap.set(name, component);
|
|
1214
|
+
}
|
|
1215
|
+
function getComponent(name) {
|
|
1216
|
+
if (typeof name === "string") {
|
|
1217
|
+
if (name in componentMap) {
|
|
1218
|
+
return componentMap[name];
|
|
550
1219
|
}
|
|
551
|
-
|
|
552
|
-
const removeSchemaByField = async (field) => {
|
|
553
|
-
const form = getFormSafe();
|
|
554
|
-
if (!form) return;
|
|
555
|
-
const fields = Array.isArray(field) ? field : [field];
|
|
556
|
-
if (form.removeSchema) {
|
|
557
|
-
await form.removeSchema(fields);
|
|
558
|
-
}
|
|
559
|
-
fields.forEach((f) => {
|
|
560
|
-
if (f in formModel) {
|
|
561
|
-
delete formModel[f];
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
};
|
|
565
|
-
const appendSchemaByField = async (schema, prefixField, first = false) => {
|
|
566
|
-
var _a;
|
|
567
|
-
const form = getFormSafe();
|
|
568
|
-
if (!form) return;
|
|
569
|
-
const currentSchemas = ((_a = form.getSchema) == null ? void 0 : _a.call(form)) || [];
|
|
570
|
-
const schemas = Array.isArray(currentSchemas) ? [...currentSchemas] : [];
|
|
571
|
-
const schemaList = Array.isArray(schema) ? schema : [schema];
|
|
572
|
-
if (prefixField) {
|
|
573
|
-
const index = schemas.findIndex((s) => s.field === prefixField);
|
|
574
|
-
if (index === -1) {
|
|
575
|
-
console.warn(`字段 "${prefixField}" 不存在,无法插入 schema`);
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
const insertIndex = first ? index : index + 1;
|
|
579
|
-
schemas.splice(insertIndex, 0, ...schemaList);
|
|
580
|
-
} else {
|
|
581
|
-
if (first) {
|
|
582
|
-
schemas.unshift(...schemaList);
|
|
583
|
-
} else {
|
|
584
|
-
schemas.push(...schemaList);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
if (form.resetSchema) {
|
|
588
|
-
await form.resetSchema(schemas);
|
|
589
|
-
}
|
|
590
|
-
schemaList.forEach((s) => {
|
|
591
|
-
if (s.defaultValue !== void 0) {
|
|
592
|
-
formModel[s.field] = s.defaultValue;
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
};
|
|
596
|
-
const getSchema = (field) => {
|
|
597
|
-
const form = getFormSafe();
|
|
598
|
-
if (!form) return void 0;
|
|
599
|
-
if (form.getSchema) {
|
|
600
|
-
return form.getSchema(field);
|
|
601
|
-
}
|
|
602
|
-
return void 0;
|
|
603
|
-
};
|
|
604
|
-
const setProps = async (formProps) => {
|
|
605
|
-
propsRef.value = { ...propsRef.value, ...formProps };
|
|
606
|
-
const form = getFormSafe();
|
|
607
|
-
if (!form) {
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
if (form.setProps) {
|
|
611
|
-
await form.setProps(formProps);
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
const scrollToField = async (name, options2) => {
|
|
615
|
-
const form = getFormSafe();
|
|
616
|
-
if (!form) return;
|
|
617
|
-
if (form.scrollToField) {
|
|
618
|
-
await form.scrollToField(name, options2);
|
|
619
|
-
}
|
|
620
|
-
};
|
|
621
|
-
const formMethods = {
|
|
622
|
-
getFieldsValue,
|
|
623
|
-
setFieldsValue,
|
|
624
|
-
resetFields,
|
|
625
|
-
validate,
|
|
626
|
-
validateFields,
|
|
627
|
-
clearValidate,
|
|
628
|
-
submit,
|
|
629
|
-
updateSchema,
|
|
630
|
-
resetSchema,
|
|
631
|
-
removeSchemaByField,
|
|
632
|
-
appendSchemaByField,
|
|
633
|
-
getSchema,
|
|
634
|
-
setProps,
|
|
635
|
-
scrollToField,
|
|
636
|
-
formModel,
|
|
637
|
-
formRef,
|
|
638
|
-
getForm
|
|
639
|
-
};
|
|
640
|
-
return [register, formMethods];
|
|
641
|
-
}
|
|
642
|
-
function createFormSchema(schemas) {
|
|
643
|
-
return schemas.map((schema, index) => ({
|
|
644
|
-
key: schema.key || `${schema.field}_${index}`,
|
|
645
|
-
...schema
|
|
646
|
-
}));
|
|
647
|
-
}
|
|
648
|
-
function mergeFormSchemas(...schemas) {
|
|
649
|
-
return schemas.flat();
|
|
650
|
-
}
|
|
651
|
-
const configProviderInjectionKey = Symbol("ArcoConfigProvider");
|
|
652
|
-
const CLASS_PREFIX = "arco";
|
|
653
|
-
const GLOBAL_CONFIG_NAME = "$arco";
|
|
654
|
-
const getPrefixCls = (componentName) => {
|
|
655
|
-
var _a, _b, _c;
|
|
656
|
-
const instance = getCurrentInstance();
|
|
657
|
-
const configProvider = inject(configProviderInjectionKey, void 0);
|
|
658
|
-
const prefix = (_c = (_b = configProvider == null ? void 0 : configProvider.prefixCls) != null ? _b : (_a = instance == null ? void 0 : instance.appContext.config.globalProperties[GLOBAL_CONFIG_NAME]) == null ? void 0 : _a.classPrefix) != null ? _c : CLASS_PREFIX;
|
|
659
|
-
{
|
|
660
|
-
return `${prefix}-${componentName}`;
|
|
1220
|
+
return customComponentMap.get(name);
|
|
661
1221
|
}
|
|
662
|
-
|
|
663
|
-
const opt = Object.prototype.toString;
|
|
664
|
-
function isNumber(obj) {
|
|
665
|
-
return opt.call(obj) === "[object Number]" && obj === obj;
|
|
1222
|
+
return name;
|
|
666
1223
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
1224
|
+
const componentsNeedPlaceholder = /* @__PURE__ */ new Set([
|
|
1225
|
+
"Input",
|
|
1226
|
+
"InputPassword",
|
|
1227
|
+
"Textarea",
|
|
1228
|
+
"AutoComplete"
|
|
1229
|
+
]);
|
|
1230
|
+
const componentsNeedSelectPlaceholder = /* @__PURE__ */ new Set([
|
|
1231
|
+
"Select",
|
|
1232
|
+
"DatePicker",
|
|
1233
|
+
"TimePicker",
|
|
1234
|
+
"RangePicker",
|
|
1235
|
+
"Cascader",
|
|
1236
|
+
"TreeSelect"
|
|
1237
|
+
]);
|
|
1238
|
+
function getPlaceholder(component, label) {
|
|
1239
|
+
if (componentsNeedPlaceholder.has(component)) {
|
|
1240
|
+
return `请输入${label}`;
|
|
670
1241
|
}
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
const _sfc_main$8 = defineComponent({
|
|
674
|
-
name: "IconQuestionCircle",
|
|
675
|
-
props: {
|
|
676
|
-
size: {
|
|
677
|
-
type: [Number, String]
|
|
678
|
-
},
|
|
679
|
-
strokeWidth: {
|
|
680
|
-
type: Number,
|
|
681
|
-
default: 4
|
|
682
|
-
},
|
|
683
|
-
strokeLinecap: {
|
|
684
|
-
type: String,
|
|
685
|
-
default: "butt",
|
|
686
|
-
validator: (value) => {
|
|
687
|
-
return ["butt", "round", "square"].includes(value);
|
|
688
|
-
}
|
|
689
|
-
},
|
|
690
|
-
strokeLinejoin: {
|
|
691
|
-
type: String,
|
|
692
|
-
default: "miter",
|
|
693
|
-
validator: (value) => {
|
|
694
|
-
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
695
|
-
}
|
|
696
|
-
},
|
|
697
|
-
rotate: Number,
|
|
698
|
-
spin: Boolean
|
|
699
|
-
},
|
|
700
|
-
emits: {
|
|
701
|
-
click: (ev) => true
|
|
702
|
-
},
|
|
703
|
-
setup(props, { emit }) {
|
|
704
|
-
const prefixCls = getPrefixCls("icon");
|
|
705
|
-
const cls = computed(() => [prefixCls, `${prefixCls}-question-circle`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
706
|
-
const innerStyle = computed(() => {
|
|
707
|
-
const styles = {};
|
|
708
|
-
if (props.size) {
|
|
709
|
-
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
710
|
-
}
|
|
711
|
-
if (props.rotate) {
|
|
712
|
-
styles.transform = `rotate(${props.rotate}deg)`;
|
|
713
|
-
}
|
|
714
|
-
return styles;
|
|
715
|
-
});
|
|
716
|
-
const onClick = (ev) => {
|
|
717
|
-
emit("click", ev);
|
|
718
|
-
};
|
|
719
|
-
return {
|
|
720
|
-
cls,
|
|
721
|
-
innerStyle,
|
|
722
|
-
onClick
|
|
723
|
-
};
|
|
1242
|
+
if (componentsNeedSelectPlaceholder.has(component)) {
|
|
1243
|
+
return `请选择${label}`;
|
|
724
1244
|
}
|
|
725
|
-
|
|
726
|
-
const _hoisted_1$8 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
727
|
-
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
728
|
-
return openBlock(), createElementBlock("svg", {
|
|
729
|
-
viewBox: "0 0 48 48",
|
|
730
|
-
fill: "none",
|
|
731
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
732
|
-
stroke: "currentColor",
|
|
733
|
-
class: normalizeClass(_ctx.cls),
|
|
734
|
-
style: normalizeStyle(_ctx.innerStyle),
|
|
735
|
-
"stroke-width": _ctx.strokeWidth,
|
|
736
|
-
"stroke-linecap": _ctx.strokeLinecap,
|
|
737
|
-
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
738
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
739
|
-
}, _cache[1] || (_cache[1] = [
|
|
740
|
-
createElementVNode("path", { d: "M42 24c0 9.941-8.059 18-18 18S6 33.941 6 24 14.059 6 24 6s18 8.059 18 18Z" }, null, -1),
|
|
741
|
-
createElementVNode("path", { d: "M24.006 31v4.008m0-6.008L24 28c0-3 3-4 4.78-6.402C30.558 19.195 28.288 15 23.987 15c-4.014 0-5.382 2.548-5.388 4.514v.465" }, null, -1)
|
|
742
|
-
]), 14, _hoisted_1$8);
|
|
1245
|
+
return "";
|
|
743
1246
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
749
|
-
app.component(iconPrefix + _IconQuestionCircle.name, _IconQuestionCircle);
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
const _sfc_main$7 = defineComponent({
|
|
753
|
-
name: "IconRefresh",
|
|
754
|
-
props: {
|
|
755
|
-
size: {
|
|
756
|
-
type: [Number, String]
|
|
757
|
-
},
|
|
758
|
-
strokeWidth: {
|
|
759
|
-
type: Number,
|
|
760
|
-
default: 4
|
|
761
|
-
},
|
|
762
|
-
strokeLinecap: {
|
|
763
|
-
type: String,
|
|
764
|
-
default: "butt",
|
|
765
|
-
validator: (value) => {
|
|
766
|
-
return ["butt", "round", "square"].includes(value);
|
|
767
|
-
}
|
|
768
|
-
},
|
|
769
|
-
strokeLinejoin: {
|
|
770
|
-
type: String,
|
|
771
|
-
default: "miter",
|
|
772
|
-
validator: (value) => {
|
|
773
|
-
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
774
|
-
}
|
|
775
|
-
},
|
|
776
|
-
rotate: Number,
|
|
777
|
-
spin: Boolean
|
|
778
|
-
},
|
|
779
|
-
emits: {
|
|
780
|
-
click: (ev) => true
|
|
1247
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
1248
|
+
...{
|
|
1249
|
+
name: "BasicForm",
|
|
1250
|
+
inheritAttrs: false
|
|
781
1251
|
},
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
1252
|
+
__name: "BasicForm",
|
|
1253
|
+
props: {
|
|
1254
|
+
schemas: { default: () => [] },
|
|
1255
|
+
layout: { default: "horizontal" },
|
|
1256
|
+
size: {},
|
|
1257
|
+
disabled: { type: Boolean, default: false },
|
|
1258
|
+
labelAlign: { default: "right" },
|
|
1259
|
+
autoLabelWidth: { type: Boolean },
|
|
1260
|
+
labelWidth: {},
|
|
1261
|
+
labelColProps: {},
|
|
1262
|
+
wrapperColProps: {},
|
|
1263
|
+
baseColProps: { default: () => ({ span: 24 }) },
|
|
1264
|
+
baseFormItemProps: {},
|
|
1265
|
+
actionColOptions: { default: () => ({ span: 24 }) },
|
|
1266
|
+
actionFormItemProps: {},
|
|
1267
|
+
autoSetPlaceHolder: { type: Boolean, default: true },
|
|
1268
|
+
showSubmitButton: { type: Boolean, default: true },
|
|
1269
|
+
showResetButton: { type: Boolean, default: true },
|
|
1270
|
+
submitButtonText: { default: "提交" },
|
|
1271
|
+
resetButtonText: { default: "重置" },
|
|
1272
|
+
showActionButtons: { type: Boolean, default: true }
|
|
1273
|
+
},
|
|
1274
|
+
emits: ["register", "submit", "reset", "validate"],
|
|
1275
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1276
|
+
const props = __props;
|
|
1277
|
+
const emit = __emit;
|
|
1278
|
+
const formRef = ref();
|
|
1279
|
+
const formModel = reactive({});
|
|
1280
|
+
const submitLoading = ref(false);
|
|
1281
|
+
const internalSchemas = ref([]);
|
|
1282
|
+
const dynamicProps = ref({});
|
|
1283
|
+
const getProps = computed(() => {
|
|
1284
|
+
return { ...props, ...dynamicProps.value };
|
|
794
1285
|
});
|
|
795
|
-
const
|
|
796
|
-
|
|
1286
|
+
const getBindValue = computed(() => {
|
|
1287
|
+
const propsData = unref(getProps);
|
|
1288
|
+
return {
|
|
1289
|
+
layout: propsData.layout,
|
|
1290
|
+
size: propsData.size,
|
|
1291
|
+
disabled: propsData.disabled,
|
|
1292
|
+
labelAlign: propsData.labelAlign,
|
|
1293
|
+
autoLabelWidth: propsData.autoLabelWidth,
|
|
1294
|
+
labelWidth: propsData.labelWidth,
|
|
1295
|
+
labelColProps: propsData.labelColProps,
|
|
1296
|
+
wrapperColProps: propsData.wrapperColProps
|
|
1297
|
+
};
|
|
1298
|
+
});
|
|
1299
|
+
const getRow = computed(() => {
|
|
1300
|
+
return {
|
|
1301
|
+
gutter: 24
|
|
1302
|
+
};
|
|
1303
|
+
});
|
|
1304
|
+
const getActionProps = computed(() => {
|
|
1305
|
+
const propsData = unref(getProps);
|
|
1306
|
+
return {
|
|
1307
|
+
showActionButtons: propsData.showActionButtons !== false,
|
|
1308
|
+
showSubmitButton: propsData.showSubmitButton !== false,
|
|
1309
|
+
showResetButton: propsData.showResetButton !== false,
|
|
1310
|
+
submitButtonText: propsData.submitButtonText || "提交",
|
|
1311
|
+
resetButtonText: propsData.resetButtonText || "重置",
|
|
1312
|
+
actionColOptions: propsData.actionColOptions || { span: 24 },
|
|
1313
|
+
actionFormItemProps: propsData.actionFormItemProps || {}
|
|
1314
|
+
};
|
|
1315
|
+
});
|
|
1316
|
+
const initFormModel = () => {
|
|
1317
|
+
const schemas = internalSchemas.value.length > 0 ? internalSchemas.value : props.schemas || [];
|
|
1318
|
+
if (!schemas.length) return;
|
|
1319
|
+
const schemaFields = new Set(schemas.map((s) => s.field));
|
|
1320
|
+
Object.keys(formModel).forEach((key) => {
|
|
1321
|
+
if (!schemaFields.has(key)) {
|
|
1322
|
+
delete formModel[key];
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
schemas.forEach((schema) => {
|
|
1326
|
+
if (!(schema.field in formModel)) {
|
|
1327
|
+
formModel[schema.field] = schema.defaultValue !== void 0 ? schema.defaultValue : void 0;
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
797
1330
|
};
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
1331
|
+
const getVisibleSchemas = computed(() => {
|
|
1332
|
+
const schemas = internalSchemas.value.length > 0 ? internalSchemas.value : props.schemas || [];
|
|
1333
|
+
return schemas.filter((schema) => {
|
|
1334
|
+
if (schema.show === void 0) return true;
|
|
1335
|
+
if (typeof schema.show === "boolean") return schema.show;
|
|
1336
|
+
return schema.show(formModel);
|
|
1337
|
+
});
|
|
1338
|
+
});
|
|
1339
|
+
const getColProps = (schema) => {
|
|
1340
|
+
const propsData = unref(getProps);
|
|
1341
|
+
return schema.colProps || propsData.baseColProps || { span: 24 };
|
|
802
1342
|
};
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
viewBox: "0 0 48 48",
|
|
809
|
-
fill: "none",
|
|
810
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
811
|
-
stroke: "currentColor",
|
|
812
|
-
class: normalizeClass(_ctx.cls),
|
|
813
|
-
style: normalizeStyle(_ctx.innerStyle),
|
|
814
|
-
"stroke-width": _ctx.strokeWidth,
|
|
815
|
-
"stroke-linecap": _ctx.strokeLinecap,
|
|
816
|
-
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
817
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
818
|
-
}, _cache[1] || (_cache[1] = [
|
|
819
|
-
createElementVNode("path", { d: "M38.837 18C36.463 12.136 30.715 8 24 8 15.163 8 8 15.163 8 24s7.163 16 16 16c7.455 0 13.72-5.1 15.496-12M40 8v10H30" }, null, -1)
|
|
820
|
-
]), 14, _hoisted_1$7);
|
|
821
|
-
}
|
|
822
|
-
var _IconRefresh = /* @__PURE__ */ _export_sfc$1(_sfc_main$7, [["render", _sfc_render$4]]);
|
|
823
|
-
const IconRefresh = Object.assign(_IconRefresh, {
|
|
824
|
-
install: (app, options) => {
|
|
825
|
-
var _a;
|
|
826
|
-
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
827
|
-
app.component(iconPrefix + _IconRefresh.name, _IconRefresh);
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
const _sfc_main$6 = defineComponent({
|
|
831
|
-
name: "IconSettings",
|
|
832
|
-
props: {
|
|
833
|
-
size: {
|
|
834
|
-
type: [Number, String]
|
|
835
|
-
},
|
|
836
|
-
strokeWidth: {
|
|
837
|
-
type: Number,
|
|
838
|
-
default: 4
|
|
839
|
-
},
|
|
840
|
-
strokeLinecap: {
|
|
841
|
-
type: String,
|
|
842
|
-
default: "butt",
|
|
843
|
-
validator: (value) => {
|
|
844
|
-
return ["butt", "round", "square"].includes(value);
|
|
1343
|
+
const getFormItemBindValue = (schema) => {
|
|
1344
|
+
const propsData = unref(getProps);
|
|
1345
|
+
let disabled = propsData.disabled;
|
|
1346
|
+
if (schema.disabled !== void 0) {
|
|
1347
|
+
disabled = typeof schema.disabled === "boolean" ? schema.disabled : schema.disabled(formModel);
|
|
845
1348
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
1349
|
+
return {
|
|
1350
|
+
field: schema.field,
|
|
1351
|
+
label: schema.label,
|
|
1352
|
+
labelColProps: schema.labelColProps || propsData.labelColProps,
|
|
1353
|
+
wrapperColProps: schema.wrapperColProps || propsData.wrapperColProps,
|
|
1354
|
+
rules: schema.rules,
|
|
1355
|
+
disabled,
|
|
1356
|
+
help: schema.help,
|
|
1357
|
+
extra: schema.extra,
|
|
1358
|
+
required: schema.required,
|
|
1359
|
+
...propsData.baseFormItemProps || {},
|
|
1360
|
+
...schema.formItemProps || {}
|
|
1361
|
+
};
|
|
1362
|
+
};
|
|
1363
|
+
const getPlaceholderText = (schema) => {
|
|
1364
|
+
var _a;
|
|
1365
|
+
const propsData = unref(getProps);
|
|
1366
|
+
if ((_a = schema.componentProps) == null ? void 0 : _a.placeholder) {
|
|
1367
|
+
return schema.componentProps.placeholder;
|
|
852
1368
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
spin: Boolean
|
|
856
|
-
},
|
|
857
|
-
emits: {
|
|
858
|
-
click: (ev) => true
|
|
859
|
-
},
|
|
860
|
-
setup(props, { emit }) {
|
|
861
|
-
const prefixCls = getPrefixCls("icon");
|
|
862
|
-
const cls = computed(() => [prefixCls, `${prefixCls}-settings`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
863
|
-
const innerStyle = computed(() => {
|
|
864
|
-
const styles = {};
|
|
865
|
-
if (props.size) {
|
|
866
|
-
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
1369
|
+
if (!propsData.autoSetPlaceHolder) {
|
|
1370
|
+
return "";
|
|
867
1371
|
}
|
|
868
|
-
|
|
869
|
-
|
|
1372
|
+
const componentType = typeof schema.component === "string" ? schema.component : "";
|
|
1373
|
+
return getPlaceholder(componentType, schema.label);
|
|
1374
|
+
};
|
|
1375
|
+
const handleSubmit = async (data) => {
|
|
1376
|
+
try {
|
|
1377
|
+
submitLoading.value = true;
|
|
1378
|
+
if (!data) {
|
|
1379
|
+
try {
|
|
1380
|
+
await validate();
|
|
1381
|
+
const values = getFieldsValue();
|
|
1382
|
+
emit("submit", values);
|
|
1383
|
+
return values;
|
|
1384
|
+
} catch (error) {
|
|
1385
|
+
console.warn("表单验证失败:", error);
|
|
1386
|
+
throw error;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
if (data.errors) {
|
|
1390
|
+
console.warn("表单验证失败:", data.errors);
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
emit("submit", data.values);
|
|
1394
|
+
return data.values;
|
|
1395
|
+
} finally {
|
|
1396
|
+
submitLoading.value = false;
|
|
870
1397
|
}
|
|
871
|
-
return styles;
|
|
872
|
-
});
|
|
873
|
-
const onClick = (ev) => {
|
|
874
|
-
emit("click", ev);
|
|
875
1398
|
};
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
1399
|
+
const handleReset = () => {
|
|
1400
|
+
var _a;
|
|
1401
|
+
(_a = formRef.value) == null ? void 0 : _a.resetFields();
|
|
1402
|
+
emit("reset");
|
|
1403
|
+
};
|
|
1404
|
+
const getFieldsValue = () => {
|
|
1405
|
+
return { ...formModel };
|
|
1406
|
+
};
|
|
1407
|
+
const setFieldsValue = (values) => {
|
|
1408
|
+
Object.keys(values).forEach((key) => {
|
|
1409
|
+
const schemas = internalSchemas.value.length > 0 ? internalSchemas.value : props.schemas || [];
|
|
1410
|
+
const hasField = schemas.some((s) => s.field === key);
|
|
1411
|
+
if (hasField) {
|
|
1412
|
+
formModel[key] = values[key];
|
|
1413
|
+
} else {
|
|
1414
|
+
console.warn(`字段 "${key}" 不在表单 schema 中`);
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
};
|
|
1418
|
+
const resetFields = () => {
|
|
1419
|
+
var _a;
|
|
1420
|
+
(_a = formRef.value) == null ? void 0 : _a.resetFields();
|
|
1421
|
+
};
|
|
1422
|
+
const validate = async () => {
|
|
1423
|
+
var _a;
|
|
1424
|
+
return (_a = formRef.value) == null ? void 0 : _a.validate();
|
|
1425
|
+
};
|
|
1426
|
+
const clearValidate = (field) => {
|
|
1427
|
+
var _a;
|
|
1428
|
+
(_a = formRef.value) == null ? void 0 : _a.clearValidate(field);
|
|
1429
|
+
};
|
|
1430
|
+
const updateSchema = (schema) => {
|
|
1431
|
+
const schemas = Array.isArray(schema) ? schema : [schema];
|
|
1432
|
+
schemas.forEach((item) => {
|
|
1433
|
+
const index = internalSchemas.value.findIndex(
|
|
1434
|
+
(s) => s.field === item.field
|
|
1435
|
+
);
|
|
1436
|
+
if (index !== -1) {
|
|
1437
|
+
const oldSchema = internalSchemas.value[index];
|
|
1438
|
+
internalSchemas.value[index] = { ...oldSchema, ...item };
|
|
1439
|
+
if (item.defaultValue !== void 0 && formModel[item.field] === oldSchema.defaultValue) {
|
|
1440
|
+
formModel[item.field] = item.defaultValue;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
};
|
|
1445
|
+
const removeSchema = (field) => {
|
|
1446
|
+
const fields = Array.isArray(field) ? field : [field];
|
|
1447
|
+
fields.forEach((f) => {
|
|
1448
|
+
const index = internalSchemas.value.findIndex((s) => s.field === f);
|
|
1449
|
+
if (index !== -1) {
|
|
1450
|
+
internalSchemas.value.splice(index, 1);
|
|
1451
|
+
delete formModel[f];
|
|
1452
|
+
}
|
|
1453
|
+
});
|
|
1454
|
+
};
|
|
1455
|
+
const getSchema = (field) => {
|
|
1456
|
+
const schemas = internalSchemas.value.length > 0 ? internalSchemas.value : props.schemas || [];
|
|
1457
|
+
if (!field) return schemas;
|
|
1458
|
+
return schemas.find((s) => s.field === field);
|
|
1459
|
+
};
|
|
1460
|
+
const resetSchema = (schemas) => {
|
|
1461
|
+
internalSchemas.value = [...schemas];
|
|
1462
|
+
initFormModel();
|
|
1463
|
+
};
|
|
1464
|
+
const setProps = (formProps) => {
|
|
1465
|
+
dynamicProps.value = { ...dynamicProps.value, ...formProps };
|
|
1466
|
+
if (formProps.schemas && Array.isArray(formProps.schemas)) {
|
|
1467
|
+
internalSchemas.value = [...formProps.schemas];
|
|
1468
|
+
initFormModel();
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
const scrollToField = (name, options) => {
|
|
1472
|
+
nextTick(() => {
|
|
1473
|
+
const element = document.querySelector(`[data-field="${name}"]`);
|
|
1474
|
+
if (element) {
|
|
1475
|
+
element.scrollIntoView(options);
|
|
1476
|
+
}
|
|
1477
|
+
});
|
|
1478
|
+
};
|
|
1479
|
+
__expose({
|
|
1480
|
+
formRef,
|
|
1481
|
+
formModel,
|
|
1482
|
+
handleSubmit,
|
|
1483
|
+
getVisibleSchemas: () => getVisibleSchemas.value,
|
|
1484
|
+
getColProps,
|
|
1485
|
+
getFormItemBindValue,
|
|
1486
|
+
getPlaceholderText,
|
|
1487
|
+
getFieldsValue,
|
|
1488
|
+
setFieldsValue,
|
|
1489
|
+
resetFields,
|
|
1490
|
+
validate,
|
|
1491
|
+
clearValidate,
|
|
1492
|
+
updateSchema,
|
|
1493
|
+
removeSchema,
|
|
1494
|
+
getSchema,
|
|
1495
|
+
resetSchema,
|
|
1496
|
+
setProps,
|
|
1497
|
+
scrollToField
|
|
1498
|
+
});
|
|
1499
|
+
const stopSchemasWatch = watch(
|
|
1500
|
+
() => props.schemas,
|
|
1501
|
+
(newSchemas) => {
|
|
1502
|
+
if (newSchemas) {
|
|
1503
|
+
internalSchemas.value = [...newSchemas];
|
|
1504
|
+
initFormModel();
|
|
1505
|
+
}
|
|
1506
|
+
},
|
|
1507
|
+
{ immediate: true }
|
|
1508
|
+
);
|
|
1509
|
+
onMounted(() => {
|
|
1510
|
+
nextTick(() => {
|
|
1511
|
+
emit("register", {
|
|
1512
|
+
formRef,
|
|
1513
|
+
formModel,
|
|
1514
|
+
getFieldsValue,
|
|
1515
|
+
setFieldsValue,
|
|
1516
|
+
resetFields,
|
|
1517
|
+
validate,
|
|
1518
|
+
clearValidate,
|
|
1519
|
+
updateSchema,
|
|
1520
|
+
removeSchema,
|
|
1521
|
+
getSchema,
|
|
1522
|
+
resetSchema,
|
|
1523
|
+
setProps,
|
|
1524
|
+
scrollToField,
|
|
1525
|
+
handleSubmit
|
|
1526
|
+
});
|
|
1527
|
+
});
|
|
1528
|
+
});
|
|
1529
|
+
onBeforeUnmount(() => {
|
|
1530
|
+
stopSchemasWatch();
|
|
1531
|
+
Object.keys(formModel).forEach((key) => {
|
|
1532
|
+
delete formModel[key];
|
|
1533
|
+
});
|
|
1534
|
+
internalSchemas.value = [];
|
|
1535
|
+
dynamicProps.value = {};
|
|
1536
|
+
});
|
|
1537
|
+
return (_ctx, _cache) => {
|
|
1538
|
+
const _component_a_form_item = resolveComponent("a-form-item");
|
|
1539
|
+
const _component_a_col = resolveComponent("a-col");
|
|
1540
|
+
const _component_a_button = resolveComponent("a-button");
|
|
1541
|
+
const _component_a_space = resolveComponent("a-space");
|
|
1542
|
+
const _component_a_row = resolveComponent("a-row");
|
|
1543
|
+
const _component_a_form = resolveComponent("a-form");
|
|
1544
|
+
return openBlock(), createBlock(_component_a_form, mergeProps({
|
|
1545
|
+
ref_key: "formRef",
|
|
1546
|
+
ref: formRef
|
|
1547
|
+
}, getBindValue.value, {
|
|
1548
|
+
model: formModel,
|
|
1549
|
+
onSubmit: handleSubmit
|
|
1550
|
+
}), {
|
|
1551
|
+
default: withCtx(() => [
|
|
1552
|
+
createVNode(_component_a_row, normalizeProps(guardReactiveProps(getRow.value)), {
|
|
1553
|
+
default: withCtx(() => [
|
|
1554
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(getVisibleSchemas.value, (schema) => {
|
|
1555
|
+
return openBlock(), createBlock(_component_a_col, mergeProps({
|
|
1556
|
+
key: schema.key || schema.field,
|
|
1557
|
+
ref_for: true
|
|
1558
|
+
}, getColProps(schema), {
|
|
1559
|
+
"data-field": schema.field
|
|
1560
|
+
}), {
|
|
1561
|
+
default: withCtx(() => [
|
|
1562
|
+
schema.render ? (openBlock(), createBlock(resolveDynamicComponent(schema.render(schema, formModel)), { key: 0 })) : (openBlock(), createBlock(_component_a_form_item, mergeProps({
|
|
1563
|
+
key: 1,
|
|
1564
|
+
ref_for: true
|
|
1565
|
+
}, getFormItemBindValue(schema)), {
|
|
1566
|
+
default: withCtx(() => [
|
|
1567
|
+
schema.renderComponentContent ? (openBlock(), createBlock(resolveDynamicComponent(schema.renderComponentContent(schema, formModel)), { key: 0 })) : (openBlock(), createBlock(resolveDynamicComponent(unref(getComponent)(schema.component)), mergeProps({
|
|
1568
|
+
key: 1,
|
|
1569
|
+
modelValue: formModel[schema.field],
|
|
1570
|
+
"onUpdate:modelValue": ($event) => formModel[schema.field] = $event,
|
|
1571
|
+
placeholder: getPlaceholderText(schema)
|
|
1572
|
+
}, { ref_for: true }, schema.componentProps), null, 16, ["modelValue", "onUpdate:modelValue", "placeholder"]))
|
|
1573
|
+
]),
|
|
1574
|
+
_: 2
|
|
1575
|
+
}, 1040))
|
|
1576
|
+
]),
|
|
1577
|
+
_: 2
|
|
1578
|
+
}, 1040, ["data-field"]);
|
|
1579
|
+
}), 128)),
|
|
1580
|
+
getActionProps.value.showActionButtons ? (openBlock(), createBlock(_component_a_col, normalizeProps(mergeProps({ key: 0 }, getActionProps.value.actionColOptions)), {
|
|
1581
|
+
default: withCtx(() => [
|
|
1582
|
+
createVNode(_component_a_form_item, normalizeProps(guardReactiveProps(getActionProps.value.actionFormItemProps)), {
|
|
1583
|
+
default: withCtx(() => [
|
|
1584
|
+
createVNode(_component_a_space, null, {
|
|
1585
|
+
default: withCtx(() => [
|
|
1586
|
+
getActionProps.value.showSubmitButton ? (openBlock(), createBlock(_component_a_button, {
|
|
1587
|
+
key: 0,
|
|
1588
|
+
type: "primary",
|
|
1589
|
+
"html-type": "submit",
|
|
1590
|
+
loading: submitLoading.value
|
|
1591
|
+
}, {
|
|
1592
|
+
default: withCtx(() => [
|
|
1593
|
+
createTextVNode(toDisplayString(getActionProps.value.submitButtonText), 1)
|
|
1594
|
+
]),
|
|
1595
|
+
_: 1
|
|
1596
|
+
}, 8, ["loading"])) : createCommentVNode("", true),
|
|
1597
|
+
getActionProps.value.showResetButton ? (openBlock(), createBlock(_component_a_button, {
|
|
1598
|
+
key: 1,
|
|
1599
|
+
onClick: handleReset
|
|
1600
|
+
}, {
|
|
1601
|
+
default: withCtx(() => [
|
|
1602
|
+
createTextVNode(toDisplayString(getActionProps.value.resetButtonText), 1)
|
|
1603
|
+
]),
|
|
1604
|
+
_: 1
|
|
1605
|
+
})) : createCommentVNode("", true),
|
|
1606
|
+
renderSlot(_ctx.$slots, "actions")
|
|
1607
|
+
]),
|
|
1608
|
+
_: 3
|
|
1609
|
+
})
|
|
1610
|
+
]),
|
|
1611
|
+
_: 3
|
|
1612
|
+
}, 16)
|
|
1613
|
+
]),
|
|
1614
|
+
_: 3
|
|
1615
|
+
}, 16)) : createCommentVNode("", true)
|
|
1616
|
+
]),
|
|
1617
|
+
_: 3
|
|
1618
|
+
}, 16)
|
|
1619
|
+
]),
|
|
1620
|
+
_: 3
|
|
1621
|
+
}, 16, ["model"]);
|
|
880
1622
|
};
|
|
881
1623
|
}
|
|
882
1624
|
});
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
895
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
896
|
-
}, _cache[1] || (_cache[1] = [
|
|
897
|
-
createElementVNode("path", { d: "M18.797 6.732A1 1 0 0 1 19.76 6h8.48a1 1 0 0 1 .964.732l1.285 4.628a1 1 0 0 0 1.213.7l4.651-1.2a1 1 0 0 1 1.116.468l4.24 7.344a1 1 0 0 1-.153 1.2L38.193 23.3a1 1 0 0 0 0 1.402l3.364 3.427a1 1 0 0 1 .153 1.2l-4.24 7.344a1 1 0 0 1-1.116.468l-4.65-1.2a1 1 0 0 0-1.214.7l-1.285 4.628a1 1 0 0 1-.964.732h-8.48a1 1 0 0 1-.963-.732L17.51 36.64a1 1 0 0 0-1.213-.7l-4.65 1.2a1 1 0 0 1-1.116-.468l-4.24-7.344a1 1 0 0 1 .153-1.2L9.809 24.7a1 1 0 0 0 0-1.402l-3.364-3.427a1 1 0 0 1-.153-1.2l4.24-7.344a1 1 0 0 1 1.116-.468l4.65 1.2a1 1 0 0 0 1.213-.7l1.286-4.628Z" }, null, -1),
|
|
898
|
-
createElementVNode("path", { d: "M30 24a6 6 0 1 1-12 0 6 6 0 0 1 12 0Z" }, null, -1)
|
|
899
|
-
]), 14, _hoisted_1$6);
|
|
900
|
-
}
|
|
901
|
-
var _IconSettings = /* @__PURE__ */ _export_sfc$1(_sfc_main$6, [["render", _sfc_render$3]]);
|
|
902
|
-
const IconSettings = Object.assign(_IconSettings, {
|
|
903
|
-
install: (app, options) => {
|
|
904
|
-
var _a;
|
|
905
|
-
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
906
|
-
app.component(iconPrefix + _IconSettings.name, _IconSettings);
|
|
907
|
-
}
|
|
908
|
-
});
|
|
909
|
-
const _sfc_main$5 = defineComponent({
|
|
910
|
-
name: "IconLineHeight",
|
|
911
|
-
props: {
|
|
912
|
-
size: {
|
|
913
|
-
type: [Number, String]
|
|
914
|
-
},
|
|
915
|
-
strokeWidth: {
|
|
916
|
-
type: Number,
|
|
917
|
-
default: 4
|
|
918
|
-
},
|
|
919
|
-
strokeLinecap: {
|
|
920
|
-
type: String,
|
|
921
|
-
default: "butt",
|
|
922
|
-
validator: (value) => {
|
|
923
|
-
return ["butt", "round", "square"].includes(value);
|
|
924
|
-
}
|
|
925
|
-
},
|
|
926
|
-
strokeLinejoin: {
|
|
927
|
-
type: String,
|
|
928
|
-
default: "miter",
|
|
929
|
-
validator: (value) => {
|
|
930
|
-
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
931
|
-
}
|
|
932
|
-
},
|
|
933
|
-
rotate: Number,
|
|
934
|
-
spin: Boolean
|
|
935
|
-
},
|
|
936
|
-
emits: {
|
|
937
|
-
click: (ev) => true
|
|
938
|
-
},
|
|
939
|
-
setup(props, { emit }) {
|
|
940
|
-
const prefixCls = getPrefixCls("icon");
|
|
941
|
-
const cls = computed(() => [prefixCls, `${prefixCls}-line-height`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
942
|
-
const innerStyle = computed(() => {
|
|
943
|
-
const styles = {};
|
|
944
|
-
if (props.size) {
|
|
945
|
-
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
946
|
-
}
|
|
947
|
-
if (props.rotate) {
|
|
948
|
-
styles.transform = `rotate(${props.rotate}deg)`;
|
|
1625
|
+
function useForm(options = {}) {
|
|
1626
|
+
const formRef = ref(null);
|
|
1627
|
+
const formModel = reactive({});
|
|
1628
|
+
const loadedRef = ref(false);
|
|
1629
|
+
const propsRef = ref({});
|
|
1630
|
+
const initFormModel = () => {
|
|
1631
|
+
var _a, _b;
|
|
1632
|
+
const schemas = unref(((_b = (_a = formRef.value) == null ? void 0 : _a.getSchema) == null ? void 0 : _b.call(_a)) || options.schemas || []);
|
|
1633
|
+
schemas.forEach((schema) => {
|
|
1634
|
+
if (schema.defaultValue !== void 0) {
|
|
1635
|
+
formModel[schema.field] = schema.defaultValue;
|
|
949
1636
|
}
|
|
950
|
-
return styles;
|
|
951
1637
|
});
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
}
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1638
|
+
};
|
|
1639
|
+
const register = async (formInstance) => {
|
|
1640
|
+
await nextTick();
|
|
1641
|
+
formRef.value = formInstance;
|
|
1642
|
+
loadedRef.value = true;
|
|
1643
|
+
if (options && Object.keys(options).length > 0) {
|
|
1644
|
+
await setProps(options);
|
|
1645
|
+
}
|
|
1646
|
+
initFormModel();
|
|
1647
|
+
};
|
|
1648
|
+
const getForm = () => {
|
|
1649
|
+
const form = unref(formRef);
|
|
1650
|
+
if (!form) {
|
|
1651
|
+
const error = "表单实例尚未注册,请确保组件已挂载并正确使用 @register";
|
|
1652
|
+
console.error(error);
|
|
1653
|
+
throw new Error(error);
|
|
1654
|
+
}
|
|
1655
|
+
return form;
|
|
1656
|
+
};
|
|
1657
|
+
const getFormSafe = () => {
|
|
1658
|
+
return unref(formRef);
|
|
1659
|
+
};
|
|
1660
|
+
const getFieldsValue = () => {
|
|
1661
|
+
const form = getFormSafe();
|
|
1662
|
+
if (!form) return {};
|
|
1663
|
+
if (form.getFieldsValue) {
|
|
1664
|
+
return form.getFieldsValue();
|
|
1665
|
+
}
|
|
1666
|
+
return { ...formModel };
|
|
1667
|
+
};
|
|
1668
|
+
const setFieldsValue = async (values) => {
|
|
1669
|
+
const form = getFormSafe();
|
|
1670
|
+
if (!form) return;
|
|
1671
|
+
if (form.setFieldsValue) {
|
|
1672
|
+
await form.setFieldsValue(values);
|
|
1673
|
+
} else {
|
|
1674
|
+
Object.keys(values).forEach((key) => {
|
|
1675
|
+
formModel[key] = values[key];
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
const resetFields = async () => {
|
|
988
1680
|
var _a;
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1681
|
+
const form = getFormSafe();
|
|
1682
|
+
if (!form) return;
|
|
1683
|
+
if (form.resetFields) {
|
|
1684
|
+
await form.resetFields();
|
|
1685
|
+
} else if ((_a = form.formRef) == null ? void 0 : _a.value) {
|
|
1686
|
+
await form.formRef.value.resetFields();
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
const validate = async (nameList) => {
|
|
1690
|
+
var _a;
|
|
1691
|
+
const form = getFormSafe();
|
|
1692
|
+
if (!form) return Promise.reject("表单实例不存在");
|
|
1693
|
+
if (form.validate) {
|
|
1694
|
+
return await form.validate(nameList);
|
|
1695
|
+
} else if ((_a = form.formRef) == null ? void 0 : _a.value) {
|
|
1696
|
+
return await form.formRef.value.validate(nameList);
|
|
1697
|
+
}
|
|
1698
|
+
return Promise.resolve(void 0);
|
|
1699
|
+
};
|
|
1700
|
+
const validateFields = async (nameList) => {
|
|
1701
|
+
return await validate(nameList);
|
|
1702
|
+
};
|
|
1703
|
+
const clearValidate = async (field) => {
|
|
1704
|
+
var _a;
|
|
1705
|
+
const form = getFormSafe();
|
|
1706
|
+
if (!form) return;
|
|
1707
|
+
if (form.clearValidate) {
|
|
1708
|
+
await form.clearValidate(field);
|
|
1709
|
+
} else if ((_a = form.formRef) == null ? void 0 : _a.value) {
|
|
1710
|
+
await form.formRef.value.clearValidate(field);
|
|
1711
|
+
}
|
|
1712
|
+
};
|
|
1713
|
+
const submit = async () => {
|
|
1714
|
+
const form = getFormSafe();
|
|
1715
|
+
if (!form) return;
|
|
1716
|
+
if (form.handleSubmit) {
|
|
1717
|
+
return await form.handleSubmit();
|
|
1718
|
+
}
|
|
1719
|
+
await validate();
|
|
1720
|
+
return getFieldsValue();
|
|
1721
|
+
};
|
|
1722
|
+
const updateSchema = async (schema) => {
|
|
1723
|
+
const form = getFormSafe();
|
|
1724
|
+
if (!form) return;
|
|
1725
|
+
const schemaList = Array.isArray(schema) ? schema : [schema];
|
|
1726
|
+
if (form.updateSchema) {
|
|
1727
|
+
await form.updateSchema(schemaList);
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
const resetSchema = async (schemas) => {
|
|
1731
|
+
const form = getFormSafe();
|
|
1732
|
+
if (!form) return;
|
|
1733
|
+
if (form.resetSchema) {
|
|
1734
|
+
await form.resetSchema(schemas);
|
|
1735
|
+
}
|
|
1736
|
+
};
|
|
1737
|
+
const removeSchemaByField = async (field) => {
|
|
1738
|
+
const form = getFormSafe();
|
|
1739
|
+
if (!form) return;
|
|
1740
|
+
const fields = Array.isArray(field) ? field : [field];
|
|
1741
|
+
if (form.removeSchema) {
|
|
1742
|
+
await form.removeSchema(fields);
|
|
1743
|
+
}
|
|
1744
|
+
fields.forEach((f) => {
|
|
1745
|
+
if (f in formModel) {
|
|
1746
|
+
delete formModel[f];
|
|
1033
1747
|
}
|
|
1034
|
-
return styles;
|
|
1035
1748
|
});
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
};
|
|
1039
|
-
return {
|
|
1040
|
-
cls,
|
|
1041
|
-
innerStyle,
|
|
1042
|
-
onClick
|
|
1043
|
-
};
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
const _hoisted_1$4 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
1047
|
-
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1048
|
-
return openBlock(), createElementBlock("svg", {
|
|
1049
|
-
viewBox: "0 0 48 48",
|
|
1050
|
-
fill: "none",
|
|
1051
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1052
|
-
stroke: "currentColor",
|
|
1053
|
-
class: normalizeClass(_ctx.cls),
|
|
1054
|
-
style: normalizeStyle(_ctx.innerStyle),
|
|
1055
|
-
"stroke-width": _ctx.strokeWidth,
|
|
1056
|
-
"stroke-linecap": _ctx.strokeLinecap,
|
|
1057
|
-
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
1058
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
1059
|
-
}, _cache[1] || (_cache[1] = [
|
|
1060
|
-
createElementVNode("path", { d: "M35 6v8a1 1 0 0 0 1 1h8M13 6v8a1 1 0 0 1-1 1H4m31 27v-8a1 1 0 0 1 1-1h8m-31 9v-8a1 1 0 0 0-1-1H4" }, null, -1)
|
|
1061
|
-
]), 14, _hoisted_1$4);
|
|
1062
|
-
}
|
|
1063
|
-
var _IconFullscreenExit = /* @__PURE__ */ _export_sfc$1(_sfc_main$4, [["render", _sfc_render$1]]);
|
|
1064
|
-
const IconFullscreenExit = Object.assign(_IconFullscreenExit, {
|
|
1065
|
-
install: (app, options) => {
|
|
1749
|
+
};
|
|
1750
|
+
const appendSchemaByField = async (schema, prefixField, first = false) => {
|
|
1066
1751
|
var _a;
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
strokeWidth: {
|
|
1078
|
-
type: Number,
|
|
1079
|
-
default: 4
|
|
1080
|
-
},
|
|
1081
|
-
strokeLinecap: {
|
|
1082
|
-
type: String,
|
|
1083
|
-
default: "butt",
|
|
1084
|
-
validator: (value) => {
|
|
1085
|
-
return ["butt", "round", "square"].includes(value);
|
|
1086
|
-
}
|
|
1087
|
-
},
|
|
1088
|
-
strokeLinejoin: {
|
|
1089
|
-
type: String,
|
|
1090
|
-
default: "miter",
|
|
1091
|
-
validator: (value) => {
|
|
1092
|
-
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
1752
|
+
const form = getFormSafe();
|
|
1753
|
+
if (!form) return;
|
|
1754
|
+
const currentSchemas = ((_a = form.getSchema) == null ? void 0 : _a.call(form)) || [];
|
|
1755
|
+
const schemas = Array.isArray(currentSchemas) ? [...currentSchemas] : [];
|
|
1756
|
+
const schemaList = Array.isArray(schema) ? schema : [schema];
|
|
1757
|
+
if (prefixField) {
|
|
1758
|
+
const index = schemas.findIndex((s) => s.field === prefixField);
|
|
1759
|
+
if (index === -1) {
|
|
1760
|
+
console.warn(`字段 "${prefixField}" 不存在,无法插入 schema`);
|
|
1761
|
+
return;
|
|
1093
1762
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
setup(props, { emit }) {
|
|
1102
|
-
const prefixCls = getPrefixCls("icon");
|
|
1103
|
-
const cls = computed(() => [prefixCls, `${prefixCls}-fullscreen`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
1104
|
-
const innerStyle = computed(() => {
|
|
1105
|
-
const styles = {};
|
|
1106
|
-
if (props.size) {
|
|
1107
|
-
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
1763
|
+
const insertIndex = first ? index : index + 1;
|
|
1764
|
+
schemas.splice(insertIndex, 0, ...schemaList);
|
|
1765
|
+
} else {
|
|
1766
|
+
if (first) {
|
|
1767
|
+
schemas.unshift(...schemaList);
|
|
1768
|
+
} else {
|
|
1769
|
+
schemas.push(...schemaList);
|
|
1108
1770
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1771
|
+
}
|
|
1772
|
+
if (form.resetSchema) {
|
|
1773
|
+
await form.resetSchema(schemas);
|
|
1774
|
+
}
|
|
1775
|
+
schemaList.forEach((s) => {
|
|
1776
|
+
if (s.defaultValue !== void 0) {
|
|
1777
|
+
formModel[s.field] = s.defaultValue;
|
|
1111
1778
|
}
|
|
1112
|
-
return styles;
|
|
1113
1779
|
});
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
return
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1780
|
+
};
|
|
1781
|
+
const getSchema = (field) => {
|
|
1782
|
+
const form = getFormSafe();
|
|
1783
|
+
if (!form) return void 0;
|
|
1784
|
+
if (form.getSchema) {
|
|
1785
|
+
return form.getSchema(field);
|
|
1786
|
+
}
|
|
1787
|
+
return void 0;
|
|
1788
|
+
};
|
|
1789
|
+
const setProps = async (formProps) => {
|
|
1790
|
+
propsRef.value = { ...propsRef.value, ...formProps };
|
|
1791
|
+
const form = getFormSafe();
|
|
1792
|
+
if (!form) {
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1795
|
+
if (form.setProps) {
|
|
1796
|
+
await form.setProps(formProps);
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
const scrollToField = async (name, options2) => {
|
|
1800
|
+
const form = getFormSafe();
|
|
1801
|
+
if (!form) return;
|
|
1802
|
+
if (form.scrollToField) {
|
|
1803
|
+
await form.scrollToField(name, options2);
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
const formMethods = {
|
|
1807
|
+
getFieldsValue,
|
|
1808
|
+
setFieldsValue,
|
|
1809
|
+
resetFields,
|
|
1810
|
+
validate,
|
|
1811
|
+
validateFields,
|
|
1812
|
+
clearValidate,
|
|
1813
|
+
submit,
|
|
1814
|
+
updateSchema,
|
|
1815
|
+
resetSchema,
|
|
1816
|
+
removeSchemaByField,
|
|
1817
|
+
appendSchemaByField,
|
|
1818
|
+
getSchema,
|
|
1819
|
+
setProps,
|
|
1820
|
+
scrollToField,
|
|
1821
|
+
formModel,
|
|
1822
|
+
formRef,
|
|
1823
|
+
getForm
|
|
1824
|
+
};
|
|
1825
|
+
return [register, formMethods];
|
|
1826
|
+
}
|
|
1827
|
+
function createFormSchema(schemas) {
|
|
1828
|
+
return schemas.map((schema, index) => ({
|
|
1829
|
+
key: schema.key || `${schema.field}_${index}`,
|
|
1830
|
+
...schema
|
|
1831
|
+
}));
|
|
1832
|
+
}
|
|
1833
|
+
function mergeFormSchemas(...schemas) {
|
|
1834
|
+
return schemas.flat();
|
|
1140
1835
|
}
|
|
1141
|
-
var _IconFullscreen = /* @__PURE__ */ _export_sfc$1(_sfc_main$3, [["render", _sfc_render]]);
|
|
1142
|
-
const IconFullscreen = Object.assign(_IconFullscreen, {
|
|
1143
|
-
install: (app, options) => {
|
|
1144
|
-
var _a;
|
|
1145
|
-
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
1146
|
-
app.component(iconPrefix + _IconFullscreen.name, _IconFullscreen);
|
|
1147
|
-
}
|
|
1148
|
-
});
|
|
1149
1836
|
function debounce(func, wait = 300, immediate = false) {
|
|
1150
1837
|
let timeout = null;
|
|
1151
1838
|
const debounced = function(...args) {
|
|
@@ -1500,7 +2187,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1500
2187
|
const indexColumn = {
|
|
1501
2188
|
title: "序号",
|
|
1502
2189
|
dataIndex: "__index__",
|
|
1503
|
-
width:
|
|
2190
|
+
width: 60,
|
|
1504
2191
|
align: "center",
|
|
1505
2192
|
fixed: "left",
|
|
1506
2193
|
slotName: "__index__",
|
|
@@ -2095,7 +2782,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2095
2782
|
const _component_a_table = resolveComponent("a-table");
|
|
2096
2783
|
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
2097
2784
|
getSearchConfig.value.show ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
|
|
2098
|
-
createVNode(unref(_sfc_main$
|
|
2785
|
+
createVNode(unref(_sfc_main$3), mergeProps({
|
|
2099
2786
|
ref_key: "searchFormRef",
|
|
2100
2787
|
ref: searchFormRef
|
|
2101
2788
|
}, getSearchFormProps.value, {
|
|
@@ -2381,14 +3068,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2381
3068
|
};
|
|
2382
3069
|
}
|
|
2383
3070
|
});
|
|
2384
|
-
const
|
|
2385
|
-
const target = sfc.__vccOpts || sfc;
|
|
2386
|
-
for (const [key, val] of props) {
|
|
2387
|
-
target[key] = val;
|
|
2388
|
-
}
|
|
2389
|
-
return target;
|
|
2390
|
-
};
|
|
2391
|
-
const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-f0b71ff8"]]);
|
|
3071
|
+
const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-04667d35"]]);
|
|
2392
3072
|
function useTable(options = {}) {
|
|
2393
3073
|
const tableRef = ref(null);
|
|
2394
3074
|
const formRef = ref(null);
|
|
@@ -3418,6 +4098,102 @@ function useDescription(props) {
|
|
|
3418
4098
|
}
|
|
3419
4099
|
];
|
|
3420
4100
|
}
|
|
4101
|
+
function useUpload(props) {
|
|
4102
|
+
const uploadRef = ref(null);
|
|
4103
|
+
const fileListRef = ref((props == null ? void 0 : props.defaultFileList) || []);
|
|
4104
|
+
const register = (uploadInstance) => {
|
|
4105
|
+
uploadRef.value = uploadInstance;
|
|
4106
|
+
if ((props == null ? void 0 : props.defaultFileList) && props.defaultFileList.length > 0) {
|
|
4107
|
+
uploadInstance.setFileList(props.defaultFileList);
|
|
4108
|
+
}
|
|
4109
|
+
if (props && Object.keys(props).length > 0) {
|
|
4110
|
+
const { defaultFileList, ...restProps } = props;
|
|
4111
|
+
if (Object.keys(restProps).length > 0) {
|
|
4112
|
+
setProps(restProps);
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
};
|
|
4116
|
+
const getUpload = () => {
|
|
4117
|
+
const upload2 = unref(uploadRef);
|
|
4118
|
+
if (!upload2) {
|
|
4119
|
+
throw new Error('Upload 实例未注册,请确保在组件上使用 @register="register"');
|
|
4120
|
+
}
|
|
4121
|
+
return upload2;
|
|
4122
|
+
};
|
|
4123
|
+
const submit = () => {
|
|
4124
|
+
getUpload().submit();
|
|
4125
|
+
};
|
|
4126
|
+
const abort = (fileItem) => {
|
|
4127
|
+
getUpload().abort(fileItem);
|
|
4128
|
+
};
|
|
4129
|
+
const clearFiles = () => {
|
|
4130
|
+
getUpload().clearFiles();
|
|
4131
|
+
fileListRef.value = [];
|
|
4132
|
+
};
|
|
4133
|
+
const getFileList = () => {
|
|
4134
|
+
return getUpload().getFileList();
|
|
4135
|
+
};
|
|
4136
|
+
const upload = (fileItem) => {
|
|
4137
|
+
getUpload().upload(fileItem);
|
|
4138
|
+
};
|
|
4139
|
+
const setFileList = (files) => {
|
|
4140
|
+
fileListRef.value = files;
|
|
4141
|
+
const upload2 = getUpload();
|
|
4142
|
+
if (upload2.setFileList) {
|
|
4143
|
+
upload2.setFileList(files);
|
|
4144
|
+
}
|
|
4145
|
+
};
|
|
4146
|
+
const addFile = (file) => {
|
|
4147
|
+
fileListRef.value.push(file);
|
|
4148
|
+
const upload2 = getUpload();
|
|
4149
|
+
if (upload2.addFile) {
|
|
4150
|
+
upload2.addFile(file);
|
|
4151
|
+
}
|
|
4152
|
+
};
|
|
4153
|
+
const removeFile = (fileItem) => {
|
|
4154
|
+
const index = fileListRef.value.findIndex(
|
|
4155
|
+
(item) => item.uid === fileItem.uid
|
|
4156
|
+
);
|
|
4157
|
+
if (index !== -1) {
|
|
4158
|
+
fileListRef.value.splice(index, 1);
|
|
4159
|
+
}
|
|
4160
|
+
const upload2 = getUpload();
|
|
4161
|
+
if (upload2.removeFile) {
|
|
4162
|
+
upload2.removeFile(fileItem);
|
|
4163
|
+
}
|
|
4164
|
+
};
|
|
4165
|
+
const updateFile = (fileItem) => {
|
|
4166
|
+
const index = fileListRef.value.findIndex(
|
|
4167
|
+
(item) => item.uid === fileItem.uid
|
|
4168
|
+
);
|
|
4169
|
+
if (index !== -1) {
|
|
4170
|
+
fileListRef.value[index] = { ...fileListRef.value[index], ...fileItem };
|
|
4171
|
+
}
|
|
4172
|
+
const upload2 = getUpload();
|
|
4173
|
+
if (upload2.updateFile) {
|
|
4174
|
+
upload2.updateFile(fileItem);
|
|
4175
|
+
}
|
|
4176
|
+
};
|
|
4177
|
+
const setProps = (uploadProps) => {
|
|
4178
|
+
getUpload().setProps(uploadProps);
|
|
4179
|
+
};
|
|
4180
|
+
const methods = {
|
|
4181
|
+
get fileList() {
|
|
4182
|
+
return fileListRef.value;
|
|
4183
|
+
},
|
|
4184
|
+
submit,
|
|
4185
|
+
abort,
|
|
4186
|
+
upload,
|
|
4187
|
+
clearFiles,
|
|
4188
|
+
getFileList,
|
|
4189
|
+
setFileList,
|
|
4190
|
+
addFile,
|
|
4191
|
+
removeFile,
|
|
4192
|
+
updateFile,
|
|
4193
|
+
setProps
|
|
4194
|
+
};
|
|
4195
|
+
return [register, methods];
|
|
4196
|
+
}
|
|
3421
4197
|
function formatDate(date, format = "YYYY-MM-DD HH:mm:ss") {
|
|
3422
4198
|
const d = typeof date === "number" ? new Date(date) : date;
|
|
3423
4199
|
const year = d.getFullYear();
|
|
@@ -3498,9 +4274,10 @@ function useToggle(initialValue = false) {
|
|
|
3498
4274
|
}
|
|
3499
4275
|
export {
|
|
3500
4276
|
BasicDescription,
|
|
3501
|
-
_sfc_main$
|
|
4277
|
+
_sfc_main$3 as BasicForm,
|
|
3502
4278
|
BasicModal,
|
|
3503
4279
|
BasicTable,
|
|
4280
|
+
BasicUpload,
|
|
3504
4281
|
componentMap,
|
|
3505
4282
|
createFormSchema,
|
|
3506
4283
|
createTableColumns,
|
|
@@ -3524,6 +4301,7 @@ export {
|
|
|
3524
4301
|
useModal,
|
|
3525
4302
|
useModalInner,
|
|
3526
4303
|
useTable,
|
|
3527
|
-
useToggle
|
|
4304
|
+
useToggle,
|
|
4305
|
+
useUpload
|
|
3528
4306
|
};
|
|
3529
4307
|
//# sourceMappingURL=index.esm.js.map
|