knt-shared 1.0.0 → 1.1.0
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/README.md +390 -135
- package/dist/components/Description/BasicDescription.vue.d.ts +63 -0
- package/dist/components/Description/BasicDescription.vue.d.ts.map +1 -0
- package/dist/components/Description/index.d.ts +5 -0
- package/dist/components/Description/index.d.ts.map +1 -0
- package/dist/components/Description/types.d.ts +97 -0
- package/dist/components/Description/types.d.ts.map +1 -0
- package/dist/components/Description/useDescription.d.ts +10 -0
- package/dist/components/Description/useDescription.d.ts.map +1 -0
- package/dist/components/Form/componentMap.d.ts +691 -5
- package/dist/components/Form/componentMap.d.ts.map +1 -1
- package/dist/components/Form/types.d.ts +6 -3
- package/dist/components/Form/types.d.ts.map +1 -1
- package/dist/components/Form/useForm.d.ts.map +1 -1
- package/dist/components/Modal/BasicModal.vue.d.ts +118 -0
- package/dist/components/Modal/BasicModal.vue.d.ts.map +1 -0
- package/dist/components/Modal/index.d.ts +5 -0
- package/dist/components/Modal/index.d.ts.map +1 -0
- package/dist/components/Modal/types.d.ts +163 -0
- package/dist/components/Modal/types.d.ts.map +1 -0
- package/dist/components/Modal/useModal.d.ts +10 -0
- package/dist/components/Modal/useModal.d.ts.map +1 -0
- package/dist/components/Modal/useModalInner.d.ts +10 -0
- package/dist/components/Modal/useModalInner.d.ts.map +1 -0
- package/dist/components/Table/BasicTable.vue.d.ts +123 -0
- package/dist/components/Table/BasicTable.vue.d.ts.map +1 -0
- package/dist/components/Table/index.d.ts +7 -0
- package/dist/components/Table/index.d.ts.map +1 -0
- package/dist/components/Table/types.d.ts +337 -0
- package/dist/components/Table/types.d.ts.map +1 -0
- package/dist/components/Table/useTable.d.ts +23 -0
- package/dist/components/Table/useTable.d.ts.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs.js +2845 -121
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +2847 -123
- package/dist/index.esm.js.map +1 -1
- package/dist/style.css +98 -0
- package/dist/utils/debounce.d.ts +23 -0
- package/dist/utils/debounce.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -10
- package/dist/components/Form/BasicForm.vue.d.ts +0 -117
- package/dist/components/Form/BasicForm.vue.d.ts.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
import { defineComponent, ref, reactive, computed, unref, watch, onMounted, nextTick, onBeforeUnmount, resolveComponent, createBlock, openBlock, mergeProps, withCtx, createVNode, normalizeProps, guardReactiveProps, createElementBlock, createCommentVNode, Fragment, renderList, resolveDynamicComponent, renderSlot, createTextVNode, toDisplayString } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
const componentMap =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { defineComponent, ref, reactive, computed, unref, watch, onMounted, nextTick, onBeforeUnmount, resolveComponent, createBlock, openBlock, mergeProps, withCtx, createVNode, normalizeProps, guardReactiveProps, createElementBlock, createCommentVNode, Fragment, renderList, resolveDynamicComponent, renderSlot, createTextVNode, toDisplayString, getCurrentInstance, inject, normalizeStyle, normalizeClass, createElementVNode, withDirectives, createSlots, vShow, withModifiers, h, onUnmounted } from "vue";
|
|
2
|
+
import { Transfer, Mention, Upload, Rate, Slider, Switch, RangePicker, TimePicker, DatePicker, TreeSelect, Cascader, CheckboxGroup, Checkbox, RadioGroup, Radio, Select, AutoComplete, Textarea, InputPassword, InputNumber, Input, Message } from "@arco-design/web-vue";
|
|
3
|
+
const componentMap = {
|
|
4
|
+
Input,
|
|
5
|
+
InputNumber,
|
|
6
|
+
InputPassword,
|
|
7
|
+
Textarea,
|
|
8
|
+
AutoComplete,
|
|
9
|
+
Select,
|
|
10
|
+
Radio,
|
|
11
|
+
RadioGroup,
|
|
12
|
+
Checkbox,
|
|
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();
|
|
25
27
|
function registerComponent(name, component) {
|
|
26
|
-
|
|
28
|
+
customComponentMap.set(name, component);
|
|
27
29
|
}
|
|
28
30
|
function getComponent(name) {
|
|
29
31
|
if (typeof name === "string") {
|
|
30
|
-
|
|
32
|
+
if (name in componentMap) {
|
|
33
|
+
return componentMap[name];
|
|
34
|
+
}
|
|
35
|
+
return customComponentMap.get(name);
|
|
31
36
|
}
|
|
32
37
|
return name;
|
|
33
38
|
}
|
|
@@ -54,7 +59,7 @@ function getPlaceholder(component, label) {
|
|
|
54
59
|
}
|
|
55
60
|
return "";
|
|
56
61
|
}
|
|
57
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
62
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
58
63
|
...{
|
|
59
64
|
name: "BasicForm",
|
|
60
65
|
inheritAttrs: false
|
|
@@ -73,6 +78,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
73
78
|
baseColProps: { default: () => ({ span: 24 }) },
|
|
74
79
|
baseFormItemProps: {},
|
|
75
80
|
actionColOptions: { default: () => ({ span: 24 }) },
|
|
81
|
+
actionFormItemProps: {},
|
|
76
82
|
autoSetPlaceHolder: { type: Boolean, default: true },
|
|
77
83
|
showSubmitButton: { type: Boolean, default: true },
|
|
78
84
|
showResetButton: { type: Boolean, default: true },
|
|
@@ -118,25 +124,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
118
124
|
showResetButton: propsData.showResetButton !== false,
|
|
119
125
|
submitButtonText: propsData.submitButtonText || "提交",
|
|
120
126
|
resetButtonText: propsData.resetButtonText || "重置",
|
|
121
|
-
actionColOptions: propsData.actionColOptions || { span: 24 }
|
|
127
|
+
actionColOptions: propsData.actionColOptions || { span: 24 },
|
|
128
|
+
actionFormItemProps: propsData.actionFormItemProps || {}
|
|
122
129
|
};
|
|
123
130
|
});
|
|
124
131
|
const initFormModel = () => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
132
|
+
const schemas = internalSchemas.value.length > 0 ? internalSchemas.value : props.schemas || [];
|
|
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;
|
|
129
143
|
}
|
|
130
144
|
});
|
|
131
145
|
};
|
|
132
|
-
const getVisibleSchemas = () => {
|
|
146
|
+
const getVisibleSchemas = computed(() => {
|
|
133
147
|
const schemas = internalSchemas.value.length > 0 ? internalSchemas.value : props.schemas || [];
|
|
134
148
|
return schemas.filter((schema) => {
|
|
135
149
|
if (schema.show === void 0) return true;
|
|
136
150
|
if (typeof schema.show === "boolean") return schema.show;
|
|
137
151
|
return schema.show(formModel);
|
|
138
152
|
});
|
|
139
|
-
};
|
|
153
|
+
});
|
|
140
154
|
const getColProps = (schema) => {
|
|
141
155
|
const propsData = unref(getProps);
|
|
142
156
|
return schema.colProps || propsData.baseColProps || { span: 24 };
|
|
@@ -173,14 +187,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
173
187
|
const componentType = typeof schema.component === "string" ? schema.component : "";
|
|
174
188
|
return getPlaceholder(componentType, schema.label);
|
|
175
189
|
};
|
|
176
|
-
const handleSubmit = async (
|
|
177
|
-
var _a;
|
|
190
|
+
const handleSubmit = async (data) => {
|
|
178
191
|
try {
|
|
179
192
|
submitLoading.value = true;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
193
|
+
if (data.errors) {
|
|
194
|
+
console.warn("表单验证失败:", data.errors);
|
|
195
|
+
return;
|
|
183
196
|
}
|
|
197
|
+
emit("submit", data.values);
|
|
184
198
|
} finally {
|
|
185
199
|
submitLoading.value = false;
|
|
186
200
|
}
|
|
@@ -195,8 +209,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
195
209
|
};
|
|
196
210
|
const setFieldsValue = (values) => {
|
|
197
211
|
Object.keys(values).forEach((key) => {
|
|
198
|
-
|
|
212
|
+
const schemas = internalSchemas.value.length > 0 ? internalSchemas.value : props.schemas || [];
|
|
213
|
+
const hasField = schemas.some((s) => s.field === key);
|
|
214
|
+
if (hasField) {
|
|
199
215
|
formModel[key] = values[key];
|
|
216
|
+
} else {
|
|
217
|
+
console.warn(`字段 "${key}" 不在表单 schema 中`);
|
|
200
218
|
}
|
|
201
219
|
});
|
|
202
220
|
};
|
|
@@ -215,9 +233,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
215
233
|
const updateSchema = (schema) => {
|
|
216
234
|
const schemas = Array.isArray(schema) ? schema : [schema];
|
|
217
235
|
schemas.forEach((item) => {
|
|
218
|
-
const index = internalSchemas.value.findIndex(
|
|
236
|
+
const index = internalSchemas.value.findIndex(
|
|
237
|
+
(s) => s.field === item.field
|
|
238
|
+
);
|
|
219
239
|
if (index !== -1) {
|
|
220
|
-
|
|
240
|
+
const oldSchema = internalSchemas.value[index];
|
|
241
|
+
internalSchemas.value[index] = { ...oldSchema, ...item };
|
|
242
|
+
if (item.defaultValue !== void 0 && formModel[item.field] === oldSchema.defaultValue) {
|
|
243
|
+
formModel[item.field] = item.defaultValue;
|
|
244
|
+
}
|
|
221
245
|
}
|
|
222
246
|
});
|
|
223
247
|
};
|
|
@@ -259,7 +283,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
259
283
|
formRef,
|
|
260
284
|
formModel,
|
|
261
285
|
handleSubmit,
|
|
262
|
-
getVisibleSchemas,
|
|
286
|
+
getVisibleSchemas: () => getVisibleSchemas.value,
|
|
263
287
|
getColProps,
|
|
264
288
|
getFormItemBindValue,
|
|
265
289
|
getPlaceholderText,
|
|
@@ -283,7 +307,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
283
307
|
initFormModel();
|
|
284
308
|
}
|
|
285
309
|
},
|
|
286
|
-
{ immediate: true
|
|
310
|
+
{ immediate: true }
|
|
287
311
|
);
|
|
288
312
|
onMounted(() => {
|
|
289
313
|
nextTick(() => {
|
|
@@ -330,11 +354,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
330
354
|
default: withCtx(() => [
|
|
331
355
|
createVNode(_component_a_row, normalizeProps(guardReactiveProps(getRow.value)), {
|
|
332
356
|
default: withCtx(() => [
|
|
333
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(getVisibleSchemas
|
|
357
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(getVisibleSchemas.value, (schema) => {
|
|
334
358
|
return openBlock(), createBlock(_component_a_col, mergeProps({
|
|
335
359
|
key: schema.key || schema.field,
|
|
336
360
|
ref_for: true
|
|
337
|
-
}, getColProps(schema)
|
|
361
|
+
}, getColProps(schema), {
|
|
362
|
+
"data-field": schema.field
|
|
363
|
+
}), {
|
|
338
364
|
default: withCtx(() => [
|
|
339
365
|
schema.render ? (openBlock(), createBlock(resolveDynamicComponent(schema.render(schema, formModel)), { key: 0 })) : (openBlock(), createBlock(_component_a_form_item, mergeProps({
|
|
340
366
|
key: 1,
|
|
@@ -352,11 +378,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
352
378
|
}, 1040))
|
|
353
379
|
]),
|
|
354
380
|
_: 2
|
|
355
|
-
}, 1040);
|
|
381
|
+
}, 1040, ["data-field"]);
|
|
356
382
|
}), 128)),
|
|
357
383
|
getActionProps.value.showActionButtons ? (openBlock(), createBlock(_component_a_col, normalizeProps(mergeProps({ key: 0 }, getActionProps.value.actionColOptions)), {
|
|
358
384
|
default: withCtx(() => [
|
|
359
|
-
createVNode(_component_a_form_item,
|
|
385
|
+
createVNode(_component_a_form_item, normalizeProps(guardReactiveProps(getActionProps.value.actionFormItemProps)), {
|
|
360
386
|
default: withCtx(() => [
|
|
361
387
|
createVNode(_component_a_space, null, {
|
|
362
388
|
default: withCtx(() => [
|
|
@@ -386,7 +412,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
386
412
|
})
|
|
387
413
|
]),
|
|
388
414
|
_: 3
|
|
389
|
-
})
|
|
415
|
+
}, 16)
|
|
390
416
|
]),
|
|
391
417
|
_: 3
|
|
392
418
|
}, 16)) : createCommentVNode("", true)
|
|
@@ -425,12 +451,17 @@ function useForm(options = {}) {
|
|
|
425
451
|
const getForm = () => {
|
|
426
452
|
const form = unref(formRef);
|
|
427
453
|
if (!form) {
|
|
428
|
-
|
|
454
|
+
const error = "表单实例尚未注册,请确保组件已挂载并正确使用 @register";
|
|
455
|
+
console.error(error);
|
|
456
|
+
throw new Error(error);
|
|
429
457
|
}
|
|
430
458
|
return form;
|
|
431
459
|
};
|
|
460
|
+
const getFormSafe = () => {
|
|
461
|
+
return unref(formRef);
|
|
462
|
+
};
|
|
432
463
|
const getFieldsValue = () => {
|
|
433
|
-
const form =
|
|
464
|
+
const form = getFormSafe();
|
|
434
465
|
if (!form) return {};
|
|
435
466
|
if (form.getFieldsValue) {
|
|
436
467
|
return form.getFieldsValue();
|
|
@@ -438,7 +469,7 @@ function useForm(options = {}) {
|
|
|
438
469
|
return { ...formModel };
|
|
439
470
|
};
|
|
440
471
|
const setFieldsValue = async (values) => {
|
|
441
|
-
const form =
|
|
472
|
+
const form = getFormSafe();
|
|
442
473
|
if (!form) return;
|
|
443
474
|
if (form.setFieldsValue) {
|
|
444
475
|
await form.setFieldsValue(values);
|
|
@@ -450,7 +481,7 @@ function useForm(options = {}) {
|
|
|
450
481
|
};
|
|
451
482
|
const resetFields = async () => {
|
|
452
483
|
var _a;
|
|
453
|
-
const form =
|
|
484
|
+
const form = getFormSafe();
|
|
454
485
|
if (!form) return;
|
|
455
486
|
if (form.resetFields) {
|
|
456
487
|
await form.resetFields();
|
|
@@ -460,7 +491,7 @@ function useForm(options = {}) {
|
|
|
460
491
|
};
|
|
461
492
|
const validate = async (nameList) => {
|
|
462
493
|
var _a;
|
|
463
|
-
const form =
|
|
494
|
+
const form = getFormSafe();
|
|
464
495
|
if (!form) return Promise.reject("表单实例不存在");
|
|
465
496
|
if (form.validate) {
|
|
466
497
|
return await form.validate(nameList);
|
|
@@ -474,7 +505,7 @@ function useForm(options = {}) {
|
|
|
474
505
|
};
|
|
475
506
|
const clearValidate = async (field) => {
|
|
476
507
|
var _a;
|
|
477
|
-
const form =
|
|
508
|
+
const form = getFormSafe();
|
|
478
509
|
if (!form) return;
|
|
479
510
|
if (form.clearValidate) {
|
|
480
511
|
await form.clearValidate(field);
|
|
@@ -483,7 +514,7 @@ function useForm(options = {}) {
|
|
|
483
514
|
}
|
|
484
515
|
};
|
|
485
516
|
const submit = async () => {
|
|
486
|
-
const form =
|
|
517
|
+
const form = getFormSafe();
|
|
487
518
|
if (!form) return;
|
|
488
519
|
if (form.handleSubmit) {
|
|
489
520
|
return await form.handleSubmit();
|
|
@@ -492,7 +523,7 @@ function useForm(options = {}) {
|
|
|
492
523
|
return getFieldsValue();
|
|
493
524
|
};
|
|
494
525
|
const updateSchema = async (schema) => {
|
|
495
|
-
const form =
|
|
526
|
+
const form = getFormSafe();
|
|
496
527
|
if (!form) return;
|
|
497
528
|
const schemaList = Array.isArray(schema) ? schema : [schema];
|
|
498
529
|
if (form.updateSchema) {
|
|
@@ -500,14 +531,14 @@ function useForm(options = {}) {
|
|
|
500
531
|
}
|
|
501
532
|
};
|
|
502
533
|
const resetSchema = async (schemas) => {
|
|
503
|
-
const form =
|
|
534
|
+
const form = getFormSafe();
|
|
504
535
|
if (!form) return;
|
|
505
536
|
if (form.resetSchema) {
|
|
506
537
|
await form.resetSchema(schemas);
|
|
507
538
|
}
|
|
508
539
|
};
|
|
509
540
|
const removeSchemaByField = async (field) => {
|
|
510
|
-
const form =
|
|
541
|
+
const form = getFormSafe();
|
|
511
542
|
if (!form) return;
|
|
512
543
|
const fields = Array.isArray(field) ? field : [field];
|
|
513
544
|
if (form.removeSchema) {
|
|
@@ -521,16 +552,19 @@ function useForm(options = {}) {
|
|
|
521
552
|
};
|
|
522
553
|
const appendSchemaByField = async (schema, prefixField, first = false) => {
|
|
523
554
|
var _a;
|
|
524
|
-
const form =
|
|
555
|
+
const form = getFormSafe();
|
|
525
556
|
if (!form) return;
|
|
526
|
-
const
|
|
557
|
+
const currentSchemas = ((_a = form.getSchema) == null ? void 0 : _a.call(form)) || [];
|
|
558
|
+
const schemas = Array.isArray(currentSchemas) ? [...currentSchemas] : [];
|
|
527
559
|
const schemaList = Array.isArray(schema) ? schema : [schema];
|
|
528
560
|
if (prefixField) {
|
|
529
561
|
const index = schemas.findIndex((s) => s.field === prefixField);
|
|
530
|
-
if (index
|
|
531
|
-
|
|
532
|
-
|
|
562
|
+
if (index === -1) {
|
|
563
|
+
console.warn(`字段 "${prefixField}" 不存在,无法插入 schema`);
|
|
564
|
+
return;
|
|
533
565
|
}
|
|
566
|
+
const insertIndex = first ? index : index + 1;
|
|
567
|
+
schemas.splice(insertIndex, 0, ...schemaList);
|
|
534
568
|
} else {
|
|
535
569
|
if (first) {
|
|
536
570
|
schemas.unshift(...schemaList);
|
|
@@ -538,8 +572,8 @@ function useForm(options = {}) {
|
|
|
538
572
|
schemas.push(...schemaList);
|
|
539
573
|
}
|
|
540
574
|
}
|
|
541
|
-
if (form.
|
|
542
|
-
await form.
|
|
575
|
+
if (form.resetSchema) {
|
|
576
|
+
await form.resetSchema(schemas);
|
|
543
577
|
}
|
|
544
578
|
schemaList.forEach((s) => {
|
|
545
579
|
if (s.defaultValue !== void 0) {
|
|
@@ -548,7 +582,7 @@ function useForm(options = {}) {
|
|
|
548
582
|
});
|
|
549
583
|
};
|
|
550
584
|
const getSchema = (field) => {
|
|
551
|
-
const form =
|
|
585
|
+
const form = getFormSafe();
|
|
552
586
|
if (!form) return void 0;
|
|
553
587
|
if (form.getSchema) {
|
|
554
588
|
return form.getSchema(field);
|
|
@@ -557,7 +591,7 @@ function useForm(options = {}) {
|
|
|
557
591
|
};
|
|
558
592
|
const setProps = async (formProps) => {
|
|
559
593
|
propsRef.value = { ...propsRef.value, ...formProps };
|
|
560
|
-
const form =
|
|
594
|
+
const form = getFormSafe();
|
|
561
595
|
if (!form) {
|
|
562
596
|
return;
|
|
563
597
|
}
|
|
@@ -566,7 +600,7 @@ function useForm(options = {}) {
|
|
|
566
600
|
}
|
|
567
601
|
};
|
|
568
602
|
const scrollToField = async (name, options2) => {
|
|
569
|
-
const form =
|
|
603
|
+
const form = getFormSafe();
|
|
570
604
|
if (!form) return;
|
|
571
605
|
if (form.scrollToField) {
|
|
572
606
|
await form.scrollToField(name, options2);
|
|
@@ -602,70 +636,553 @@ function createFormSchema(schemas) {
|
|
|
602
636
|
function mergeFormSchemas(...schemas) {
|
|
603
637
|
return schemas.flat();
|
|
604
638
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
const
|
|
611
|
-
const
|
|
612
|
-
const
|
|
613
|
-
|
|
639
|
+
const configProviderInjectionKey = Symbol("ArcoConfigProvider");
|
|
640
|
+
const CLASS_PREFIX = "arco";
|
|
641
|
+
const GLOBAL_CONFIG_NAME = "$arco";
|
|
642
|
+
const getPrefixCls = (componentName) => {
|
|
643
|
+
var _a, _b, _c;
|
|
644
|
+
const instance = getCurrentInstance();
|
|
645
|
+
const configProvider = inject(configProviderInjectionKey, void 0);
|
|
646
|
+
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;
|
|
647
|
+
{
|
|
648
|
+
return `${prefix}-${componentName}`;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
const opt = Object.prototype.toString;
|
|
652
|
+
function isNumber(obj) {
|
|
653
|
+
return opt.call(obj) === "[object Number]" && obj === obj;
|
|
614
654
|
}
|
|
615
|
-
|
|
616
|
-
|
|
655
|
+
var _export_sfc$1 = (sfc, props) => {
|
|
656
|
+
for (const [key, val] of props) {
|
|
657
|
+
sfc[key] = val;
|
|
658
|
+
}
|
|
659
|
+
return sfc;
|
|
660
|
+
};
|
|
661
|
+
const _sfc_main$8 = defineComponent({
|
|
662
|
+
name: "IconQuestionCircle",
|
|
663
|
+
props: {
|
|
664
|
+
size: {
|
|
665
|
+
type: [Number, String]
|
|
666
|
+
},
|
|
667
|
+
strokeWidth: {
|
|
668
|
+
type: Number,
|
|
669
|
+
default: 4
|
|
670
|
+
},
|
|
671
|
+
strokeLinecap: {
|
|
672
|
+
type: String,
|
|
673
|
+
default: "butt",
|
|
674
|
+
validator: (value) => {
|
|
675
|
+
return ["butt", "round", "square"].includes(value);
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
strokeLinejoin: {
|
|
679
|
+
type: String,
|
|
680
|
+
default: "miter",
|
|
681
|
+
validator: (value) => {
|
|
682
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
rotate: Number,
|
|
686
|
+
spin: Boolean
|
|
687
|
+
},
|
|
688
|
+
emits: {
|
|
689
|
+
click: (ev) => true
|
|
690
|
+
},
|
|
691
|
+
setup(props, { emit }) {
|
|
692
|
+
const prefixCls = getPrefixCls("icon");
|
|
693
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-question-circle`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
694
|
+
const innerStyle = computed(() => {
|
|
695
|
+
const styles = {};
|
|
696
|
+
if (props.size) {
|
|
697
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
698
|
+
}
|
|
699
|
+
if (props.rotate) {
|
|
700
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
701
|
+
}
|
|
702
|
+
return styles;
|
|
703
|
+
});
|
|
704
|
+
const onClick = (ev) => {
|
|
705
|
+
emit("click", ev);
|
|
706
|
+
};
|
|
707
|
+
return {
|
|
708
|
+
cls,
|
|
709
|
+
innerStyle,
|
|
710
|
+
onClick
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
const _hoisted_1$8 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
715
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
716
|
+
return openBlock(), createElementBlock("svg", {
|
|
717
|
+
viewBox: "0 0 48 48",
|
|
718
|
+
fill: "none",
|
|
719
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
720
|
+
stroke: "currentColor",
|
|
721
|
+
class: normalizeClass(_ctx.cls),
|
|
722
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
723
|
+
"stroke-width": _ctx.strokeWidth,
|
|
724
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
725
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
726
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
727
|
+
}, _cache[1] || (_cache[1] = [
|
|
728
|
+
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),
|
|
729
|
+
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)
|
|
730
|
+
]), 14, _hoisted_1$8);
|
|
617
731
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
732
|
+
var _IconQuestionCircle = /* @__PURE__ */ _export_sfc$1(_sfc_main$8, [["render", _sfc_render$5]]);
|
|
733
|
+
const IconQuestionCircle = Object.assign(_IconQuestionCircle, {
|
|
734
|
+
install: (app, options) => {
|
|
735
|
+
var _a;
|
|
736
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
737
|
+
app.component(iconPrefix + _IconQuestionCircle.name, _IconQuestionCircle);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
const _sfc_main$7 = defineComponent({
|
|
741
|
+
name: "IconRefresh",
|
|
742
|
+
props: {
|
|
743
|
+
size: {
|
|
744
|
+
type: [Number, String]
|
|
745
|
+
},
|
|
746
|
+
strokeWidth: {
|
|
747
|
+
type: Number,
|
|
748
|
+
default: 4
|
|
749
|
+
},
|
|
750
|
+
strokeLinecap: {
|
|
751
|
+
type: String,
|
|
752
|
+
default: "butt",
|
|
753
|
+
validator: (value) => {
|
|
754
|
+
return ["butt", "round", "square"].includes(value);
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
strokeLinejoin: {
|
|
758
|
+
type: String,
|
|
759
|
+
default: "miter",
|
|
760
|
+
validator: (value) => {
|
|
761
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
rotate: Number,
|
|
765
|
+
spin: Boolean
|
|
766
|
+
},
|
|
767
|
+
emits: {
|
|
768
|
+
click: (ev) => true
|
|
769
|
+
},
|
|
770
|
+
setup(props, { emit }) {
|
|
771
|
+
const prefixCls = getPrefixCls("icon");
|
|
772
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-refresh`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
773
|
+
const innerStyle = computed(() => {
|
|
774
|
+
const styles = {};
|
|
775
|
+
if (props.size) {
|
|
776
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
777
|
+
}
|
|
778
|
+
if (props.rotate) {
|
|
779
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
780
|
+
}
|
|
781
|
+
return styles;
|
|
782
|
+
});
|
|
783
|
+
const onClick = (ev) => {
|
|
784
|
+
emit("click", ev);
|
|
785
|
+
};
|
|
786
|
+
return {
|
|
787
|
+
cls,
|
|
788
|
+
innerStyle,
|
|
789
|
+
onClick
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
const _hoisted_1$7 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
794
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
795
|
+
return openBlock(), createElementBlock("svg", {
|
|
796
|
+
viewBox: "0 0 48 48",
|
|
797
|
+
fill: "none",
|
|
798
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
799
|
+
stroke: "currentColor",
|
|
800
|
+
class: normalizeClass(_ctx.cls),
|
|
801
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
802
|
+
"stroke-width": _ctx.strokeWidth,
|
|
803
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
804
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
805
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
806
|
+
}, _cache[1] || (_cache[1] = [
|
|
807
|
+
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)
|
|
808
|
+
]), 14, _hoisted_1$7);
|
|
624
809
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
810
|
+
var _IconRefresh = /* @__PURE__ */ _export_sfc$1(_sfc_main$7, [["render", _sfc_render$4]]);
|
|
811
|
+
const IconRefresh = Object.assign(_IconRefresh, {
|
|
812
|
+
install: (app, options) => {
|
|
813
|
+
var _a;
|
|
814
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
815
|
+
app.component(iconPrefix + _IconRefresh.name, _IconRefresh);
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
const _sfc_main$6 = defineComponent({
|
|
819
|
+
name: "IconSettings",
|
|
820
|
+
props: {
|
|
821
|
+
size: {
|
|
822
|
+
type: [Number, String]
|
|
823
|
+
},
|
|
824
|
+
strokeWidth: {
|
|
825
|
+
type: Number,
|
|
826
|
+
default: 4
|
|
827
|
+
},
|
|
828
|
+
strokeLinecap: {
|
|
829
|
+
type: String,
|
|
830
|
+
default: "butt",
|
|
831
|
+
validator: (value) => {
|
|
832
|
+
return ["butt", "round", "square"].includes(value);
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
strokeLinejoin: {
|
|
836
|
+
type: String,
|
|
837
|
+
default: "miter",
|
|
838
|
+
validator: (value) => {
|
|
839
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
rotate: Number,
|
|
843
|
+
spin: Boolean
|
|
844
|
+
},
|
|
845
|
+
emits: {
|
|
846
|
+
click: (ev) => true
|
|
847
|
+
},
|
|
848
|
+
setup(props, { emit }) {
|
|
849
|
+
const prefixCls = getPrefixCls("icon");
|
|
850
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-settings`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
851
|
+
const innerStyle = computed(() => {
|
|
852
|
+
const styles = {};
|
|
853
|
+
if (props.size) {
|
|
854
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
855
|
+
}
|
|
856
|
+
if (props.rotate) {
|
|
857
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
858
|
+
}
|
|
859
|
+
return styles;
|
|
860
|
+
});
|
|
861
|
+
const onClick = (ev) => {
|
|
862
|
+
emit("click", ev);
|
|
863
|
+
};
|
|
864
|
+
return {
|
|
865
|
+
cls,
|
|
866
|
+
innerStyle,
|
|
867
|
+
onClick
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
const _hoisted_1$6 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
872
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
873
|
+
return openBlock(), createElementBlock("svg", {
|
|
874
|
+
viewBox: "0 0 48 48",
|
|
875
|
+
fill: "none",
|
|
876
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
877
|
+
stroke: "currentColor",
|
|
878
|
+
class: normalizeClass(_ctx.cls),
|
|
879
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
880
|
+
"stroke-width": _ctx.strokeWidth,
|
|
881
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
882
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
883
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
884
|
+
}, _cache[1] || (_cache[1] = [
|
|
885
|
+
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),
|
|
886
|
+
createElementVNode("path", { d: "M30 24a6 6 0 1 1-12 0 6 6 0 0 1 12 0Z" }, null, -1)
|
|
887
|
+
]), 14, _hoisted_1$6);
|
|
628
888
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
889
|
+
var _IconSettings = /* @__PURE__ */ _export_sfc$1(_sfc_main$6, [["render", _sfc_render$3]]);
|
|
890
|
+
const IconSettings = Object.assign(_IconSettings, {
|
|
891
|
+
install: (app, options) => {
|
|
892
|
+
var _a;
|
|
893
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
894
|
+
app.component(iconPrefix + _IconSettings.name, _IconSettings);
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
const _sfc_main$5 = defineComponent({
|
|
898
|
+
name: "IconLineHeight",
|
|
899
|
+
props: {
|
|
900
|
+
size: {
|
|
901
|
+
type: [Number, String]
|
|
902
|
+
},
|
|
903
|
+
strokeWidth: {
|
|
904
|
+
type: Number,
|
|
905
|
+
default: 4
|
|
906
|
+
},
|
|
907
|
+
strokeLinecap: {
|
|
908
|
+
type: String,
|
|
909
|
+
default: "butt",
|
|
910
|
+
validator: (value) => {
|
|
911
|
+
return ["butt", "round", "square"].includes(value);
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
strokeLinejoin: {
|
|
915
|
+
type: String,
|
|
916
|
+
default: "miter",
|
|
917
|
+
validator: (value) => {
|
|
918
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
rotate: Number,
|
|
922
|
+
spin: Boolean
|
|
923
|
+
},
|
|
924
|
+
emits: {
|
|
925
|
+
click: (ev) => true
|
|
926
|
+
},
|
|
927
|
+
setup(props, { emit }) {
|
|
928
|
+
const prefixCls = getPrefixCls("icon");
|
|
929
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-line-height`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
930
|
+
const innerStyle = computed(() => {
|
|
931
|
+
const styles = {};
|
|
932
|
+
if (props.size) {
|
|
933
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
934
|
+
}
|
|
935
|
+
if (props.rotate) {
|
|
936
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
937
|
+
}
|
|
938
|
+
return styles;
|
|
939
|
+
});
|
|
940
|
+
const onClick = (ev) => {
|
|
941
|
+
emit("click", ev);
|
|
942
|
+
};
|
|
943
|
+
return {
|
|
944
|
+
cls,
|
|
945
|
+
innerStyle,
|
|
946
|
+
onClick
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
const _hoisted_1$5 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
951
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
952
|
+
return openBlock(), createElementBlock("svg", {
|
|
953
|
+
viewBox: "0 0 48 48",
|
|
954
|
+
fill: "none",
|
|
955
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
956
|
+
stroke: "currentColor",
|
|
957
|
+
class: normalizeClass(_ctx.cls),
|
|
958
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
959
|
+
"stroke-width": _ctx.strokeWidth,
|
|
960
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
961
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
962
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
963
|
+
}, _cache[1] || (_cache[1] = [
|
|
964
|
+
createElementVNode("path", { d: "M4 8h14.5M33 8H18.5m0 0v34" }, null, -1),
|
|
965
|
+
createElementVNode("path", {
|
|
966
|
+
d: "M39 9.5 37 13h4l-2-3.5ZM39 38.5 37 35h4l-2 3.5Z",
|
|
967
|
+
fill: "currentColor",
|
|
968
|
+
stroke: "none"
|
|
969
|
+
}, null, -1),
|
|
970
|
+
createElementVNode("path", { d: "M39 13h2l-2-3.5-2 3.5h2Zm0 0v22m0 0h2l-2 3.5-2-3.5h2Z" }, null, -1)
|
|
971
|
+
]), 14, _hoisted_1$5);
|
|
632
972
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
973
|
+
var _IconLineHeight = /* @__PURE__ */ _export_sfc$1(_sfc_main$5, [["render", _sfc_render$2]]);
|
|
974
|
+
const IconLineHeight = Object.assign(_IconLineHeight, {
|
|
975
|
+
install: (app, options) => {
|
|
976
|
+
var _a;
|
|
977
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
978
|
+
app.component(iconPrefix + _IconLineHeight.name, _IconLineHeight);
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
const _sfc_main$4 = defineComponent({
|
|
982
|
+
name: "IconFullscreenExit",
|
|
983
|
+
props: {
|
|
984
|
+
size: {
|
|
985
|
+
type: [Number, String]
|
|
986
|
+
},
|
|
987
|
+
strokeWidth: {
|
|
988
|
+
type: Number,
|
|
989
|
+
default: 4
|
|
990
|
+
},
|
|
991
|
+
strokeLinecap: {
|
|
992
|
+
type: String,
|
|
993
|
+
default: "butt",
|
|
994
|
+
validator: (value) => {
|
|
995
|
+
return ["butt", "round", "square"].includes(value);
|
|
996
|
+
}
|
|
997
|
+
},
|
|
998
|
+
strokeLinejoin: {
|
|
999
|
+
type: String,
|
|
1000
|
+
default: "miter",
|
|
1001
|
+
validator: (value) => {
|
|
1002
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
1003
|
+
}
|
|
1004
|
+
},
|
|
1005
|
+
rotate: Number,
|
|
1006
|
+
spin: Boolean
|
|
1007
|
+
},
|
|
1008
|
+
emits: {
|
|
1009
|
+
click: (ev) => true
|
|
1010
|
+
},
|
|
1011
|
+
setup(props, { emit }) {
|
|
1012
|
+
const prefixCls = getPrefixCls("icon");
|
|
1013
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-fullscreen-exit`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
1014
|
+
const innerStyle = computed(() => {
|
|
1015
|
+
const styles = {};
|
|
1016
|
+
if (props.size) {
|
|
1017
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
1018
|
+
}
|
|
1019
|
+
if (props.rotate) {
|
|
1020
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
1021
|
+
}
|
|
1022
|
+
return styles;
|
|
1023
|
+
});
|
|
1024
|
+
const onClick = (ev) => {
|
|
1025
|
+
emit("click", ev);
|
|
1026
|
+
};
|
|
1027
|
+
return {
|
|
1028
|
+
cls,
|
|
1029
|
+
innerStyle,
|
|
1030
|
+
onClick
|
|
1031
|
+
};
|
|
639
1032
|
}
|
|
1033
|
+
});
|
|
1034
|
+
const _hoisted_1$4 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
1035
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1036
|
+
return openBlock(), createElementBlock("svg", {
|
|
1037
|
+
viewBox: "0 0 48 48",
|
|
1038
|
+
fill: "none",
|
|
1039
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1040
|
+
stroke: "currentColor",
|
|
1041
|
+
class: normalizeClass(_ctx.cls),
|
|
1042
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
1043
|
+
"stroke-width": _ctx.strokeWidth,
|
|
1044
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
1045
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
1046
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
1047
|
+
}, _cache[1] || (_cache[1] = [
|
|
1048
|
+
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)
|
|
1049
|
+
]), 14, _hoisted_1$4);
|
|
640
1050
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
1051
|
+
var _IconFullscreenExit = /* @__PURE__ */ _export_sfc$1(_sfc_main$4, [["render", _sfc_render$1]]);
|
|
1052
|
+
const IconFullscreenExit = Object.assign(_IconFullscreenExit, {
|
|
1053
|
+
install: (app, options) => {
|
|
1054
|
+
var _a;
|
|
1055
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
1056
|
+
app.component(iconPrefix + _IconFullscreenExit.name, _IconFullscreenExit);
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1059
|
+
const _sfc_main$3 = defineComponent({
|
|
1060
|
+
name: "IconFullscreen",
|
|
1061
|
+
props: {
|
|
1062
|
+
size: {
|
|
1063
|
+
type: [Number, String]
|
|
1064
|
+
},
|
|
1065
|
+
strokeWidth: {
|
|
1066
|
+
type: Number,
|
|
1067
|
+
default: 4
|
|
1068
|
+
},
|
|
1069
|
+
strokeLinecap: {
|
|
1070
|
+
type: String,
|
|
1071
|
+
default: "butt",
|
|
1072
|
+
validator: (value) => {
|
|
1073
|
+
return ["butt", "round", "square"].includes(value);
|
|
1074
|
+
}
|
|
1075
|
+
},
|
|
1076
|
+
strokeLinejoin: {
|
|
1077
|
+
type: String,
|
|
1078
|
+
default: "miter",
|
|
1079
|
+
validator: (value) => {
|
|
1080
|
+
return ["arcs", "bevel", "miter", "miter-clip", "round"].includes(value);
|
|
1081
|
+
}
|
|
1082
|
+
},
|
|
1083
|
+
rotate: Number,
|
|
1084
|
+
spin: Boolean
|
|
1085
|
+
},
|
|
1086
|
+
emits: {
|
|
1087
|
+
click: (ev) => true
|
|
1088
|
+
},
|
|
1089
|
+
setup(props, { emit }) {
|
|
1090
|
+
const prefixCls = getPrefixCls("icon");
|
|
1091
|
+
const cls = computed(() => [prefixCls, `${prefixCls}-fullscreen`, { [`${prefixCls}-spin`]: props.spin }]);
|
|
1092
|
+
const innerStyle = computed(() => {
|
|
1093
|
+
const styles = {};
|
|
1094
|
+
if (props.size) {
|
|
1095
|
+
styles.fontSize = isNumber(props.size) ? `${props.size}px` : props.size;
|
|
1096
|
+
}
|
|
1097
|
+
if (props.rotate) {
|
|
1098
|
+
styles.transform = `rotate(${props.rotate}deg)`;
|
|
1099
|
+
}
|
|
1100
|
+
return styles;
|
|
1101
|
+
});
|
|
1102
|
+
const onClick = (ev) => {
|
|
1103
|
+
emit("click", ev);
|
|
1104
|
+
};
|
|
1105
|
+
return {
|
|
1106
|
+
cls,
|
|
1107
|
+
innerStyle,
|
|
1108
|
+
onClick
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
});
|
|
1112
|
+
const _hoisted_1$3 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
|
|
1113
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1114
|
+
return openBlock(), createElementBlock("svg", {
|
|
1115
|
+
viewBox: "0 0 48 48",
|
|
1116
|
+
fill: "none",
|
|
1117
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1118
|
+
stroke: "currentColor",
|
|
1119
|
+
class: normalizeClass(_ctx.cls),
|
|
1120
|
+
style: normalizeStyle(_ctx.innerStyle),
|
|
1121
|
+
"stroke-width": _ctx.strokeWidth,
|
|
1122
|
+
"stroke-linecap": _ctx.strokeLinecap,
|
|
1123
|
+
"stroke-linejoin": _ctx.strokeLinejoin,
|
|
1124
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
|
|
1125
|
+
}, _cache[1] || (_cache[1] = [
|
|
1126
|
+
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)
|
|
1127
|
+
]), 14, _hoisted_1$3);
|
|
644
1128
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
1129
|
+
var _IconFullscreen = /* @__PURE__ */ _export_sfc$1(_sfc_main$3, [["render", _sfc_render]]);
|
|
1130
|
+
const IconFullscreen = Object.assign(_IconFullscreen, {
|
|
1131
|
+
install: (app, options) => {
|
|
1132
|
+
var _a;
|
|
1133
|
+
const iconPrefix = (_a = options == null ? void 0 : options.iconPrefix) != null ? _a : "";
|
|
1134
|
+
app.component(iconPrefix + _IconFullscreen.name, _IconFullscreen);
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
function debounce(func, wait = 300, immediate = false) {
|
|
1138
|
+
let timeout = null;
|
|
1139
|
+
const debounced = function(...args) {
|
|
1140
|
+
const context = this;
|
|
1141
|
+
const later = () => {
|
|
1142
|
+
timeout = null;
|
|
1143
|
+
if (!immediate) {
|
|
1144
|
+
func.apply(context, args);
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1147
|
+
const callNow = immediate && !timeout;
|
|
1148
|
+
if (timeout) {
|
|
1149
|
+
clearTimeout(timeout);
|
|
1150
|
+
}
|
|
1151
|
+
timeout = setTimeout(later, wait);
|
|
1152
|
+
if (callNow) {
|
|
1153
|
+
func.apply(context, args);
|
|
651
1154
|
}
|
|
652
|
-
timer = setTimeout(() => {
|
|
653
|
-
debouncedValue.value = newValue;
|
|
654
|
-
}, delay);
|
|
655
1155
|
};
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
},
|
|
661
|
-
{ immediate: true }
|
|
662
|
-
);
|
|
663
|
-
onBeforeUnmount(() => {
|
|
664
|
-
if (timer) {
|
|
665
|
-
clearTimeout(timer);
|
|
1156
|
+
debounced.cancel = () => {
|
|
1157
|
+
if (timeout) {
|
|
1158
|
+
clearTimeout(timeout);
|
|
1159
|
+
timeout = null;
|
|
666
1160
|
}
|
|
667
|
-
}
|
|
668
|
-
return
|
|
1161
|
+
};
|
|
1162
|
+
return debounced;
|
|
1163
|
+
}
|
|
1164
|
+
function throttle(func, wait = 300) {
|
|
1165
|
+
let timeout = null;
|
|
1166
|
+
let previous = 0;
|
|
1167
|
+
return function(...args) {
|
|
1168
|
+
const context = this;
|
|
1169
|
+
const now = Date.now();
|
|
1170
|
+
const remaining = wait - (now - previous);
|
|
1171
|
+
if (remaining <= 0 || remaining > wait) {
|
|
1172
|
+
if (timeout) {
|
|
1173
|
+
clearTimeout(timeout);
|
|
1174
|
+
timeout = null;
|
|
1175
|
+
}
|
|
1176
|
+
previous = now;
|
|
1177
|
+
func.apply(context, args);
|
|
1178
|
+
} else if (!timeout) {
|
|
1179
|
+
timeout = setTimeout(() => {
|
|
1180
|
+
previous = Date.now();
|
|
1181
|
+
timeout = null;
|
|
1182
|
+
func.apply(context, args);
|
|
1183
|
+
}, remaining);
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
669
1186
|
}
|
|
670
1187
|
function useLocalStorage(key, initialValue) {
|
|
671
1188
|
let initialStoredValue;
|
|
@@ -699,6 +1216,2202 @@ function useLocalStorage(key, initialValue) {
|
|
|
699
1216
|
);
|
|
700
1217
|
return [storedValue, setValue];
|
|
701
1218
|
}
|
|
1219
|
+
const _hoisted_1$2 = { class: "basic-table-wrapper" };
|
|
1220
|
+
const _hoisted_2$2 = {
|
|
1221
|
+
key: 0,
|
|
1222
|
+
class: "basic-table-search"
|
|
1223
|
+
};
|
|
1224
|
+
const _hoisted_3$1 = {
|
|
1225
|
+
key: 1,
|
|
1226
|
+
class: "basic-table-toolbar"
|
|
1227
|
+
};
|
|
1228
|
+
const _hoisted_4$1 = { class: "toolbar-left" };
|
|
1229
|
+
const _hoisted_5$1 = {
|
|
1230
|
+
key: 0,
|
|
1231
|
+
class: "toolbar-title"
|
|
1232
|
+
};
|
|
1233
|
+
const _hoisted_6 = { class: "toolbar-right" };
|
|
1234
|
+
const _hoisted_7 = { class: "column-setting" };
|
|
1235
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
1236
|
+
...{
|
|
1237
|
+
name: "BasicTable"
|
|
1238
|
+
},
|
|
1239
|
+
__name: "BasicTable",
|
|
1240
|
+
props: {
|
|
1241
|
+
tableId: {},
|
|
1242
|
+
columns: { default: () => [] },
|
|
1243
|
+
data: { default: () => [] },
|
|
1244
|
+
loading: { type: Boolean, default: false },
|
|
1245
|
+
size: { default: "medium" },
|
|
1246
|
+
bordered: { type: Boolean, default: true },
|
|
1247
|
+
stripe: { type: Boolean, default: false },
|
|
1248
|
+
showHeader: { type: Boolean, default: true },
|
|
1249
|
+
rowKey: { type: [String, Function], default: "id" },
|
|
1250
|
+
rowSelection: {},
|
|
1251
|
+
expandable: {},
|
|
1252
|
+
scroll: {},
|
|
1253
|
+
draggable: {},
|
|
1254
|
+
pagination: { type: [Boolean, Object] },
|
|
1255
|
+
search: { type: [Boolean, Object] },
|
|
1256
|
+
toolbar: { type: [Boolean, Object] },
|
|
1257
|
+
immediate: { type: Boolean, default: true },
|
|
1258
|
+
api: {},
|
|
1259
|
+
beforeFetch: {},
|
|
1260
|
+
afterFetch: {},
|
|
1261
|
+
onFetchError: {},
|
|
1262
|
+
showIndexColumn: { type: Boolean, default: false },
|
|
1263
|
+
indexColumnProps: {},
|
|
1264
|
+
showActionColumn: { type: Boolean, default: false },
|
|
1265
|
+
actionColumn: {},
|
|
1266
|
+
emptyText: {},
|
|
1267
|
+
autoHeight: { type: Boolean, default: false },
|
|
1268
|
+
maxHeight: {},
|
|
1269
|
+
tableClass: {},
|
|
1270
|
+
tableStyle: {}
|
|
1271
|
+
},
|
|
1272
|
+
emits: ["register", "change", "select", "selectAll", "expand", "row-click", "row-dblclick", "cell-click", "search", "reset", "fetch-success", "fetch-error"],
|
|
1273
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1274
|
+
const DEBOUNCE_DELAY = {
|
|
1275
|
+
REFRESH: 300,
|
|
1276
|
+
SEARCH: 500
|
|
1277
|
+
};
|
|
1278
|
+
const ERROR_CODES = {
|
|
1279
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
1280
|
+
TIMEOUT: "TIMEOUT",
|
|
1281
|
+
INVALID_RESPONSE: "INVALID_RESPONSE",
|
|
1282
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
1283
|
+
};
|
|
1284
|
+
const props = __props;
|
|
1285
|
+
const emit = __emit;
|
|
1286
|
+
const tableRef = ref();
|
|
1287
|
+
const searchFormRef = ref();
|
|
1288
|
+
const innerPropsRef = ref({});
|
|
1289
|
+
const dataSource = ref([]);
|
|
1290
|
+
const loadingRef = ref(false);
|
|
1291
|
+
const tableSizeRef = ref(props.size);
|
|
1292
|
+
const isFullscreen = ref(false);
|
|
1293
|
+
const selectedRowKeys = ref([]);
|
|
1294
|
+
const selectedRows = ref([]);
|
|
1295
|
+
const getStorageKey = () => {
|
|
1296
|
+
return props.tableId ? `table-column-setting-${props.tableId}` : null;
|
|
1297
|
+
};
|
|
1298
|
+
const [storedColumns, setStoredColumns] = useLocalStorage(
|
|
1299
|
+
getStorageKey() || "table-column-setting-default",
|
|
1300
|
+
[]
|
|
1301
|
+
);
|
|
1302
|
+
const checkedColumns = ref(storedColumns.value);
|
|
1303
|
+
watch(checkedColumns, (newValue) => {
|
|
1304
|
+
if (getStorageKey()) {
|
|
1305
|
+
setStoredColumns(newValue);
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1308
|
+
const handleFullscreenChange = () => {
|
|
1309
|
+
isFullscreen.value = !!document.fullscreenElement;
|
|
1310
|
+
};
|
|
1311
|
+
const paginationRef = ref({
|
|
1312
|
+
current: 1,
|
|
1313
|
+
pageSize: 10,
|
|
1314
|
+
total: 0,
|
|
1315
|
+
showTotal: true,
|
|
1316
|
+
showJumper: true,
|
|
1317
|
+
showPageSize: true,
|
|
1318
|
+
pageSizeOptions: [5, 10, 20, 50, 100]
|
|
1319
|
+
});
|
|
1320
|
+
const searchParams = ref({});
|
|
1321
|
+
const getMergedProps = computed(() => {
|
|
1322
|
+
return { ...props, ...innerPropsRef.value };
|
|
1323
|
+
});
|
|
1324
|
+
const initPagination = () => {
|
|
1325
|
+
const mergedProps = getMergedProps.value;
|
|
1326
|
+
const pagination = mergedProps.pagination;
|
|
1327
|
+
if (pagination && typeof pagination === "object") {
|
|
1328
|
+
paginationRef.value = {
|
|
1329
|
+
...paginationRef.value,
|
|
1330
|
+
...pagination
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
watch(
|
|
1335
|
+
() => [props.data, props.loading],
|
|
1336
|
+
([data, loading]) => {
|
|
1337
|
+
if (data) {
|
|
1338
|
+
dataSource.value = data;
|
|
1339
|
+
if (paginationRef.value && !getMergedProps.value.api) {
|
|
1340
|
+
paginationRef.value.total = data.length;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
loadingRef.value = loading;
|
|
1344
|
+
},
|
|
1345
|
+
{ immediate: true }
|
|
1346
|
+
);
|
|
1347
|
+
watch(
|
|
1348
|
+
() => getMergedProps.value.pagination,
|
|
1349
|
+
(newPagination) => {
|
|
1350
|
+
if (newPagination && typeof newPagination === "object") {
|
|
1351
|
+
paginationRef.value = {
|
|
1352
|
+
...paginationRef.value,
|
|
1353
|
+
...newPagination
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
},
|
|
1357
|
+
{ immediate: true, deep: true }
|
|
1358
|
+
);
|
|
1359
|
+
const getToolbarConfig = computed(() => {
|
|
1360
|
+
const mergedProps = getMergedProps.value;
|
|
1361
|
+
const toolbar = mergedProps.toolbar;
|
|
1362
|
+
if (toolbar === false) {
|
|
1363
|
+
return { show: false };
|
|
1364
|
+
}
|
|
1365
|
+
return {
|
|
1366
|
+
show: true,
|
|
1367
|
+
showRefresh: true,
|
|
1368
|
+
showColumnSetting: true,
|
|
1369
|
+
showFullscreen: true,
|
|
1370
|
+
showDensity: true,
|
|
1371
|
+
...toolbar
|
|
1372
|
+
};
|
|
1373
|
+
});
|
|
1374
|
+
const getSearchConfig = computed(() => {
|
|
1375
|
+
const mergedProps = getMergedProps.value;
|
|
1376
|
+
const search = mergedProps.search;
|
|
1377
|
+
if (search === false) {
|
|
1378
|
+
return { show: false };
|
|
1379
|
+
}
|
|
1380
|
+
return {
|
|
1381
|
+
show: true,
|
|
1382
|
+
layout: "inline",
|
|
1383
|
+
showCollapse: true,
|
|
1384
|
+
defaultCollapseRows: 1,
|
|
1385
|
+
showResetButton: true,
|
|
1386
|
+
showSubmitButton: true,
|
|
1387
|
+
submitButtonText: "查询",
|
|
1388
|
+
resetButtonText: "重置",
|
|
1389
|
+
...search
|
|
1390
|
+
};
|
|
1391
|
+
});
|
|
1392
|
+
const getSearchFormProps = computed(() => {
|
|
1393
|
+
var _a, _b, _c;
|
|
1394
|
+
const config = getSearchConfig.value;
|
|
1395
|
+
const formProps = config.formProps || {};
|
|
1396
|
+
return {
|
|
1397
|
+
schemas: config.schemas || [],
|
|
1398
|
+
layout: config.layout,
|
|
1399
|
+
showSubmitButton: config.showSubmitButton,
|
|
1400
|
+
showResetButton: config.showResetButton,
|
|
1401
|
+
submitButtonText: config.submitButtonText,
|
|
1402
|
+
resetButtonText: config.resetButtonText,
|
|
1403
|
+
// 其他 formProps(先展开,后面会被覆盖)
|
|
1404
|
+
...formProps,
|
|
1405
|
+
// 合并 baseFormItemProps(保留默认值)
|
|
1406
|
+
baseFormItemProps: {
|
|
1407
|
+
...formProps.baseFormItemProps,
|
|
1408
|
+
style: {
|
|
1409
|
+
marginRight: 0,
|
|
1410
|
+
...((_a = formProps.baseFormItemProps) == null ? void 0 : _a.style) || {}
|
|
1411
|
+
}
|
|
1412
|
+
},
|
|
1413
|
+
// 合并 actionFormItemProps(保留默认值)
|
|
1414
|
+
actionFormItemProps: {
|
|
1415
|
+
...formProps.actionFormItemProps,
|
|
1416
|
+
style: {
|
|
1417
|
+
marginRight: 0,
|
|
1418
|
+
...((_b = formProps.actionFormItemProps) == null ? void 0 : _b.style) || {}
|
|
1419
|
+
}
|
|
1420
|
+
},
|
|
1421
|
+
// 合并 actionColOptions(保留默认值)
|
|
1422
|
+
actionColOptions: {
|
|
1423
|
+
...formProps.actionColOptions,
|
|
1424
|
+
style: {
|
|
1425
|
+
display: "flex",
|
|
1426
|
+
justifyContent: "flex-end",
|
|
1427
|
+
alignItems: "center",
|
|
1428
|
+
...((_c = formProps.actionColOptions) == null ? void 0 : _c.style) || {}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
};
|
|
1432
|
+
});
|
|
1433
|
+
const getPaginationConfig = computed(() => {
|
|
1434
|
+
const mergedProps = getMergedProps.value;
|
|
1435
|
+
if (mergedProps.pagination === false) {
|
|
1436
|
+
return false;
|
|
1437
|
+
}
|
|
1438
|
+
return {
|
|
1439
|
+
...mergedProps.pagination,
|
|
1440
|
+
...paginationRef.value
|
|
1441
|
+
};
|
|
1442
|
+
});
|
|
1443
|
+
const getRowSelectionConfig = computed(() => {
|
|
1444
|
+
const mergedProps = getMergedProps.value;
|
|
1445
|
+
if (!mergedProps.rowSelection) {
|
|
1446
|
+
return void 0;
|
|
1447
|
+
}
|
|
1448
|
+
return {
|
|
1449
|
+
selectedRowKeys: selectedRowKeys.value,
|
|
1450
|
+
...mergedProps.rowSelection
|
|
1451
|
+
};
|
|
1452
|
+
});
|
|
1453
|
+
const getScrollConfig = computed(() => {
|
|
1454
|
+
const mergedProps = getMergedProps.value;
|
|
1455
|
+
if (mergedProps.scroll) {
|
|
1456
|
+
return mergedProps.scroll;
|
|
1457
|
+
}
|
|
1458
|
+
if (mergedProps.autoHeight) {
|
|
1459
|
+
return { y: "auto" };
|
|
1460
|
+
}
|
|
1461
|
+
if (mergedProps.maxHeight) {
|
|
1462
|
+
return { y: mergedProps.maxHeight };
|
|
1463
|
+
}
|
|
1464
|
+
return void 0;
|
|
1465
|
+
});
|
|
1466
|
+
const getRowKeyProp = computed(() => {
|
|
1467
|
+
const mergedProps = getMergedProps.value;
|
|
1468
|
+
if (typeof mergedProps.rowKey === "string") {
|
|
1469
|
+
return mergedProps.rowKey;
|
|
1470
|
+
}
|
|
1471
|
+
return "id";
|
|
1472
|
+
});
|
|
1473
|
+
const getRowKey = (record) => {
|
|
1474
|
+
const mergedProps = getMergedProps.value;
|
|
1475
|
+
if (typeof mergedProps.rowKey === "function") {
|
|
1476
|
+
return mergedProps.rowKey(record);
|
|
1477
|
+
}
|
|
1478
|
+
return record[mergedProps.rowKey];
|
|
1479
|
+
};
|
|
1480
|
+
const getViewColumns = computed(() => {
|
|
1481
|
+
const mergedProps = getMergedProps.value;
|
|
1482
|
+
let columns = [...mergedProps.columns];
|
|
1483
|
+
if (mergedProps.showIndexColumn) {
|
|
1484
|
+
const indexColumn = {
|
|
1485
|
+
title: "序号",
|
|
1486
|
+
dataIndex: "__index__",
|
|
1487
|
+
width: 80,
|
|
1488
|
+
align: "center",
|
|
1489
|
+
fixed: "left",
|
|
1490
|
+
slotName: "__index__",
|
|
1491
|
+
...mergedProps.indexColumnProps
|
|
1492
|
+
};
|
|
1493
|
+
columns.unshift(indexColumn);
|
|
1494
|
+
}
|
|
1495
|
+
if (mergedProps.showActionColumn && mergedProps.actionColumn) {
|
|
1496
|
+
const actionColumn = {
|
|
1497
|
+
title: mergedProps.actionColumn.title || "操作",
|
|
1498
|
+
dataIndex: "action",
|
|
1499
|
+
width: mergedProps.actionColumn.width || 150,
|
|
1500
|
+
fixed: mergedProps.actionColumn.fixed || "right",
|
|
1501
|
+
align: "center",
|
|
1502
|
+
slotName: "action"
|
|
1503
|
+
};
|
|
1504
|
+
columns.push(actionColumn);
|
|
1505
|
+
}
|
|
1506
|
+
if (getToolbarConfig.value.showColumnSetting && checkedColumns.value.length > 0) {
|
|
1507
|
+
columns = columns.filter((col) => {
|
|
1508
|
+
if (col.dataIndex === "__index__" || col.dataIndex === "action") {
|
|
1509
|
+
return true;
|
|
1510
|
+
}
|
|
1511
|
+
if (!col.dataIndex) return true;
|
|
1512
|
+
return checkedColumns.value.includes(col.dataIndex);
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
columns = columns.filter((col) => col.show !== false);
|
|
1516
|
+
columns = columns.map((col) => {
|
|
1517
|
+
if (!col.slotName && (col.customRender || col.format)) {
|
|
1518
|
+
return { ...col, slotName: col.dataIndex };
|
|
1519
|
+
}
|
|
1520
|
+
return col;
|
|
1521
|
+
});
|
|
1522
|
+
return columns;
|
|
1523
|
+
});
|
|
1524
|
+
const settingColumns = computed(() => {
|
|
1525
|
+
const mergedProps = getMergedProps.value;
|
|
1526
|
+
return mergedProps.columns.filter((col) => {
|
|
1527
|
+
if (typeof col.ifShow === "function") {
|
|
1528
|
+
return col.ifShow(col);
|
|
1529
|
+
}
|
|
1530
|
+
return col.ifShow !== false && col.dataIndex;
|
|
1531
|
+
});
|
|
1532
|
+
});
|
|
1533
|
+
const getBindValues = computed(() => {
|
|
1534
|
+
const mergedProps = getMergedProps.value;
|
|
1535
|
+
const { columns, data, loading, pagination, search, toolbar, api, beforeFetch, afterFetch, onFetchError, immediate, showIndexColumn, indexColumnProps, showActionColumn, actionColumn, rowKey, expandable, scroll, draggable, bordered, stripe, showHeader, size, rowSelection, ...rest } = mergedProps;
|
|
1536
|
+
return rest;
|
|
1537
|
+
});
|
|
1538
|
+
const getIndexNumber = (rowIndex) => {
|
|
1539
|
+
const pagination = getPaginationConfig.value;
|
|
1540
|
+
if (pagination === false) {
|
|
1541
|
+
return rowIndex + 1;
|
|
1542
|
+
}
|
|
1543
|
+
return (pagination.current - 1) * pagination.pageSize + rowIndex + 1;
|
|
1544
|
+
};
|
|
1545
|
+
const renderCustomCell = (col, slotProps) => {
|
|
1546
|
+
if (!col.customRender) return null;
|
|
1547
|
+
const result = col.customRender(slotProps);
|
|
1548
|
+
if (result === null || result === void 0) {
|
|
1549
|
+
return null;
|
|
1550
|
+
}
|
|
1551
|
+
if (typeof result === "object" && result !== null && "type" in result) {
|
|
1552
|
+
return result;
|
|
1553
|
+
}
|
|
1554
|
+
return h("span", String(result));
|
|
1555
|
+
};
|
|
1556
|
+
const getActionButtons = (record) => {
|
|
1557
|
+
var _a;
|
|
1558
|
+
const mergedProps = getMergedProps.value;
|
|
1559
|
+
if (!((_a = mergedProps.actionColumn) == null ? void 0 : _a.actions)) {
|
|
1560
|
+
return [];
|
|
1561
|
+
}
|
|
1562
|
+
const actions = mergedProps.actionColumn.actions(record);
|
|
1563
|
+
return actions.filter((action) => {
|
|
1564
|
+
if (typeof action.show === "function") {
|
|
1565
|
+
return action.show(record);
|
|
1566
|
+
}
|
|
1567
|
+
return action.show !== false;
|
|
1568
|
+
});
|
|
1569
|
+
};
|
|
1570
|
+
const getActionDisabled = (action, record) => {
|
|
1571
|
+
if (typeof action.disabled === "function") {
|
|
1572
|
+
return action.disabled(record);
|
|
1573
|
+
}
|
|
1574
|
+
return action.disabled || false;
|
|
1575
|
+
};
|
|
1576
|
+
const handleActionClick = (action, record) => {
|
|
1577
|
+
if (action.onClick) {
|
|
1578
|
+
action.onClick(record);
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
const handleTableChange = (_pagination, sorter, filters) => {
|
|
1582
|
+
emit("change", paginationRef.value, sorter, filters);
|
|
1583
|
+
};
|
|
1584
|
+
const handlePageChange = (page) => {
|
|
1585
|
+
if (paginationRef.value) {
|
|
1586
|
+
paginationRef.value.current = page;
|
|
1587
|
+
}
|
|
1588
|
+
if (getMergedProps.value.api) {
|
|
1589
|
+
fetchData();
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
const handlePageSizeChange = (pageSize) => {
|
|
1593
|
+
if (paginationRef.value) {
|
|
1594
|
+
paginationRef.value.pageSize = pageSize;
|
|
1595
|
+
paginationRef.value.current = 1;
|
|
1596
|
+
}
|
|
1597
|
+
if (getMergedProps.value.api) {
|
|
1598
|
+
fetchData();
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
const flattenObject = (obj, prefix = "") => {
|
|
1602
|
+
const result = {};
|
|
1603
|
+
for (const key in obj) {
|
|
1604
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1605
|
+
const value = obj[key];
|
|
1606
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
1607
|
+
if (value && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date)) {
|
|
1608
|
+
Object.assign(result, flattenObject(value, newKey));
|
|
1609
|
+
} else {
|
|
1610
|
+
result[newKey] = value;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
return result;
|
|
1615
|
+
};
|
|
1616
|
+
const filterEmptyValues = (obj) => {
|
|
1617
|
+
const result = {};
|
|
1618
|
+
for (const key in obj) {
|
|
1619
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1620
|
+
const value = obj[key];
|
|
1621
|
+
if (value !== null && value !== void 0 && value !== "") {
|
|
1622
|
+
result[key] = value;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return result;
|
|
1627
|
+
};
|
|
1628
|
+
const handleSearch = async (values) => {
|
|
1629
|
+
const flatValues = flattenObject(values);
|
|
1630
|
+
const filteredValues = filterEmptyValues(flatValues);
|
|
1631
|
+
searchParams.value = filteredValues;
|
|
1632
|
+
if (paginationRef.value) {
|
|
1633
|
+
paginationRef.value.current = 1;
|
|
1634
|
+
}
|
|
1635
|
+
emit("search", filteredValues);
|
|
1636
|
+
if (getSearchConfig.value.onSearch) {
|
|
1637
|
+
getSearchConfig.value.onSearch(filteredValues);
|
|
1638
|
+
}
|
|
1639
|
+
if (getMergedProps.value.api) {
|
|
1640
|
+
await debouncedFetchData();
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
const handleReset = async () => {
|
|
1644
|
+
searchParams.value = {};
|
|
1645
|
+
if (paginationRef.value) {
|
|
1646
|
+
paginationRef.value.current = 1;
|
|
1647
|
+
}
|
|
1648
|
+
emit("reset");
|
|
1649
|
+
if (getSearchConfig.value.onReset) {
|
|
1650
|
+
getSearchConfig.value.onReset();
|
|
1651
|
+
}
|
|
1652
|
+
if (getMergedProps.value.api) {
|
|
1653
|
+
await fetchData();
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
const handleDensityChange = (value) => {
|
|
1657
|
+
tableSizeRef.value = value;
|
|
1658
|
+
};
|
|
1659
|
+
const handleColumnChange = (values) => {
|
|
1660
|
+
checkedColumns.value = values;
|
|
1661
|
+
};
|
|
1662
|
+
const handleFullscreen = async () => {
|
|
1663
|
+
const wrapper = document.querySelector(".basic-table-wrapper");
|
|
1664
|
+
if (!wrapper) return;
|
|
1665
|
+
try {
|
|
1666
|
+
if (!isFullscreen.value) {
|
|
1667
|
+
if (wrapper.requestFullscreen) {
|
|
1668
|
+
await wrapper.requestFullscreen();
|
|
1669
|
+
}
|
|
1670
|
+
} else {
|
|
1671
|
+
if (document.exitFullscreen && document.fullscreenElement) {
|
|
1672
|
+
await document.exitFullscreen();
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
} catch (error) {
|
|
1676
|
+
console.error("全屏操作失败:", error);
|
|
1677
|
+
Message.error("全屏操作失败");
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
const handleSelect = (rowKeys, rowKey, record) => {
|
|
1681
|
+
selectedRowKeys.value = rowKeys;
|
|
1682
|
+
selectedRows.value = dataSource.value.filter((item) => rowKeys.includes(getRowKey(item)));
|
|
1683
|
+
emit("select", rowKeys, rowKey, record);
|
|
1684
|
+
};
|
|
1685
|
+
const handleSelectAll = (checked) => {
|
|
1686
|
+
if (checked) {
|
|
1687
|
+
selectedRowKeys.value = dataSource.value.map((item) => getRowKey(item));
|
|
1688
|
+
selectedRows.value = [...dataSource.value];
|
|
1689
|
+
} else {
|
|
1690
|
+
selectedRowKeys.value = [];
|
|
1691
|
+
selectedRows.value = [];
|
|
1692
|
+
}
|
|
1693
|
+
emit("selectAll", checked);
|
|
1694
|
+
};
|
|
1695
|
+
const handleExpand = (record, expanded) => {
|
|
1696
|
+
emit("expand", record, expanded);
|
|
1697
|
+
};
|
|
1698
|
+
const handleRowClick = (record, event) => {
|
|
1699
|
+
emit("row-click", record, event);
|
|
1700
|
+
};
|
|
1701
|
+
const handleRowDblclick = (record, event) => {
|
|
1702
|
+
emit("row-dblclick", record, event);
|
|
1703
|
+
};
|
|
1704
|
+
const handleCellClick = (record, column, event) => {
|
|
1705
|
+
emit("cell-click", record, column, event);
|
|
1706
|
+
};
|
|
1707
|
+
const fetchData = async () => {
|
|
1708
|
+
const mergedProps = getMergedProps.value;
|
|
1709
|
+
if (!mergedProps.api) return;
|
|
1710
|
+
try {
|
|
1711
|
+
loadingRef.value = true;
|
|
1712
|
+
let params = {
|
|
1713
|
+
...searchParams.value
|
|
1714
|
+
};
|
|
1715
|
+
if (paginationRef.value) {
|
|
1716
|
+
params.page = paginationRef.value.current;
|
|
1717
|
+
params.pageSize = paginationRef.value.pageSize;
|
|
1718
|
+
}
|
|
1719
|
+
if (mergedProps.beforeFetch) {
|
|
1720
|
+
params = mergedProps.beforeFetch(params);
|
|
1721
|
+
}
|
|
1722
|
+
const result = await mergedProps.api(params);
|
|
1723
|
+
if (!result || typeof result !== "object") {
|
|
1724
|
+
throw {
|
|
1725
|
+
code: ERROR_CODES.INVALID_RESPONSE,
|
|
1726
|
+
message: "API 响应格式无效:返回值不是对象",
|
|
1727
|
+
data: result
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
if (!("data" in result)) {
|
|
1731
|
+
throw {
|
|
1732
|
+
code: ERROR_CODES.INVALID_RESPONSE,
|
|
1733
|
+
message: "API 响应格式无效:缺少 data 字段",
|
|
1734
|
+
data: result
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
if (!Array.isArray(result.data)) {
|
|
1738
|
+
console.warn("API 响应格式警告:data 字段不是数组,已转换为空数组");
|
|
1739
|
+
}
|
|
1740
|
+
if (!("total" in result) || typeof result.total !== "number") {
|
|
1741
|
+
console.warn("API 响应格式警告:total 字段缺失或类型错误,已设置为 0");
|
|
1742
|
+
}
|
|
1743
|
+
let data = Array.isArray(result.data) ? result.data : [];
|
|
1744
|
+
let total = typeof result.total === "number" ? result.total : 0;
|
|
1745
|
+
if (total < data.length) {
|
|
1746
|
+
console.warn(`数据一致性警告:total(${total}) 小于 data.length(${data.length})`);
|
|
1747
|
+
}
|
|
1748
|
+
if (mergedProps.afterFetch) {
|
|
1749
|
+
const processed = mergedProps.afterFetch(result);
|
|
1750
|
+
data = Array.isArray(processed.data) ? processed.data : data;
|
|
1751
|
+
total = typeof processed.total === "number" ? processed.total : total;
|
|
1752
|
+
}
|
|
1753
|
+
dataSource.value = data;
|
|
1754
|
+
if (paginationRef.value) {
|
|
1755
|
+
paginationRef.value.total = total;
|
|
1756
|
+
}
|
|
1757
|
+
emit("fetch-success", data);
|
|
1758
|
+
} catch (error) {
|
|
1759
|
+
console.error("表格数据加载失败:", error);
|
|
1760
|
+
let errorMessage = "数据加载失败";
|
|
1761
|
+
let errorCode = ERROR_CODES.UNKNOWN_ERROR;
|
|
1762
|
+
if (error instanceof Error) {
|
|
1763
|
+
errorMessage = error.message;
|
|
1764
|
+
if (error.message.includes("network") || error.message.includes("fetch")) {
|
|
1765
|
+
errorCode = ERROR_CODES.NETWORK_ERROR;
|
|
1766
|
+
} else if (error.message.includes("timeout")) {
|
|
1767
|
+
errorCode = ERROR_CODES.TIMEOUT;
|
|
1768
|
+
}
|
|
1769
|
+
} else if (typeof error === "object" && error !== null) {
|
|
1770
|
+
const err = error;
|
|
1771
|
+
errorMessage = err.message || errorMessage;
|
|
1772
|
+
errorCode = err.code || errorCode;
|
|
1773
|
+
}
|
|
1774
|
+
if (errorCode === ERROR_CODES.NETWORK_ERROR) {
|
|
1775
|
+
Message.error("网络连接失败,请检查网络设置");
|
|
1776
|
+
} else if (errorCode === ERROR_CODES.TIMEOUT) {
|
|
1777
|
+
Message.error("请求超时,请稍后重试");
|
|
1778
|
+
} else if (errorCode === ERROR_CODES.INVALID_RESPONSE) {
|
|
1779
|
+
Message.error(`数据格式错误: ${errorMessage}`);
|
|
1780
|
+
} else {
|
|
1781
|
+
Message.error(`数据加载失败: ${errorMessage}`);
|
|
1782
|
+
}
|
|
1783
|
+
dataSource.value = [];
|
|
1784
|
+
if (paginationRef.value) {
|
|
1785
|
+
paginationRef.value.total = 0;
|
|
1786
|
+
}
|
|
1787
|
+
const fetchError = {
|
|
1788
|
+
code: errorCode,
|
|
1789
|
+
message: errorMessage,
|
|
1790
|
+
originalError: error
|
|
1791
|
+
};
|
|
1792
|
+
emit("fetch-error", fetchError);
|
|
1793
|
+
if (mergedProps.onFetchError) {
|
|
1794
|
+
mergedProps.onFetchError(fetchError);
|
|
1795
|
+
}
|
|
1796
|
+
} finally {
|
|
1797
|
+
loadingRef.value = false;
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
const handleRefresh = debounce(async () => {
|
|
1801
|
+
await fetchData();
|
|
1802
|
+
}, DEBOUNCE_DELAY.REFRESH);
|
|
1803
|
+
const debouncedFetchData = debounce(async () => {
|
|
1804
|
+
await fetchData();
|
|
1805
|
+
}, DEBOUNCE_DELAY.SEARCH);
|
|
1806
|
+
const initColumnSetting = () => {
|
|
1807
|
+
if (getStorageKey() && storedColumns.value.length > 0) {
|
|
1808
|
+
checkedColumns.value = storedColumns.value;
|
|
1809
|
+
} else {
|
|
1810
|
+
checkedColumns.value = settingColumns.value.filter((col) => !col.defaultHidden).map((col) => col.dataIndex);
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
const getDataSource = () => dataSource.value;
|
|
1814
|
+
const setDataSource = async (data) => {
|
|
1815
|
+
dataSource.value = data;
|
|
1816
|
+
if (paginationRef.value && !getMergedProps.value.api) {
|
|
1817
|
+
paginationRef.value.total = data.length;
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
const reload = async (opt2) => {
|
|
1821
|
+
if (opt2 == null ? void 0 : opt2.page) {
|
|
1822
|
+
paginationRef.value.current = opt2.page;
|
|
1823
|
+
}
|
|
1824
|
+
await fetchData();
|
|
1825
|
+
};
|
|
1826
|
+
const refresh = async () => {
|
|
1827
|
+
await fetchData();
|
|
1828
|
+
};
|
|
1829
|
+
const getSelectRows = () => selectedRows.value;
|
|
1830
|
+
const getSelectRowKeys = () => selectedRowKeys.value;
|
|
1831
|
+
const clearSelectedRowKeys = () => {
|
|
1832
|
+
selectedRowKeys.value = [];
|
|
1833
|
+
selectedRows.value = [];
|
|
1834
|
+
};
|
|
1835
|
+
const setSelectedRowKeys = (keys) => {
|
|
1836
|
+
selectedRowKeys.value = keys;
|
|
1837
|
+
selectedRows.value = dataSource.value.filter((item) => keys.includes(getRowKey(item)));
|
|
1838
|
+
};
|
|
1839
|
+
const deleteSelectRowByKey = (key) => {
|
|
1840
|
+
dataSource.value = dataSource.value.filter((item) => getRowKey(item) !== key);
|
|
1841
|
+
selectedRowKeys.value = selectedRowKeys.value.filter((k) => k !== key);
|
|
1842
|
+
selectedRows.value = selectedRows.value.filter((item) => getRowKey(item) !== key);
|
|
1843
|
+
};
|
|
1844
|
+
const getPaginationInfo = () => getPaginationConfig.value;
|
|
1845
|
+
const setPagination = async (info) => {
|
|
1846
|
+
paginationRef.value = { ...paginationRef.value, ...info };
|
|
1847
|
+
};
|
|
1848
|
+
const getSize = () => tableSizeRef.value;
|
|
1849
|
+
const setSize = (size) => {
|
|
1850
|
+
tableSizeRef.value = size;
|
|
1851
|
+
};
|
|
1852
|
+
const updateColumns = async (columns) => {
|
|
1853
|
+
innerPropsRef.value.columns = columns;
|
|
1854
|
+
};
|
|
1855
|
+
const getColumns = () => getMergedProps.value.columns;
|
|
1856
|
+
const setProps = async (newProps) => {
|
|
1857
|
+
innerPropsRef.value = { ...innerPropsRef.value, ...newProps };
|
|
1858
|
+
if (newProps.size) {
|
|
1859
|
+
tableSizeRef.value = newProps.size;
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
const setLoading = (loading) => {
|
|
1863
|
+
loadingRef.value = loading;
|
|
1864
|
+
};
|
|
1865
|
+
const getSearchFormValues = () => {
|
|
1866
|
+
var _a, _b;
|
|
1867
|
+
return ((_b = (_a = searchFormRef.value) == null ? void 0 : _a.getFieldsValue) == null ? void 0 : _b.call(_a)) || {};
|
|
1868
|
+
};
|
|
1869
|
+
const setSearchFormValues = async (values) => {
|
|
1870
|
+
var _a, _b;
|
|
1871
|
+
await ((_b = (_a = searchFormRef.value) == null ? void 0 : _a.setFieldsValue) == null ? void 0 : _b.call(_a, values));
|
|
1872
|
+
};
|
|
1873
|
+
const expandAll = () => {
|
|
1874
|
+
};
|
|
1875
|
+
const collapseAll = () => {
|
|
1876
|
+
};
|
|
1877
|
+
__expose({
|
|
1878
|
+
getDataSource,
|
|
1879
|
+
setDataSource,
|
|
1880
|
+
reload,
|
|
1881
|
+
refresh,
|
|
1882
|
+
getSelectRows,
|
|
1883
|
+
getSelectRowKeys,
|
|
1884
|
+
clearSelectedRowKeys,
|
|
1885
|
+
setSelectedRowKeys,
|
|
1886
|
+
deleteSelectRowByKey,
|
|
1887
|
+
getPaginationInfo,
|
|
1888
|
+
setPagination,
|
|
1889
|
+
getSize,
|
|
1890
|
+
setSize,
|
|
1891
|
+
updateColumns,
|
|
1892
|
+
getColumns,
|
|
1893
|
+
setProps,
|
|
1894
|
+
setLoading,
|
|
1895
|
+
getSearchFormValues,
|
|
1896
|
+
setSearchFormValues,
|
|
1897
|
+
expandAll,
|
|
1898
|
+
collapseAll,
|
|
1899
|
+
tableRef,
|
|
1900
|
+
searchFormRef
|
|
1901
|
+
});
|
|
1902
|
+
onMounted(async () => {
|
|
1903
|
+
await nextTick();
|
|
1904
|
+
initPagination();
|
|
1905
|
+
initColumnSetting();
|
|
1906
|
+
document.addEventListener("fullscreenchange", handleFullscreenChange);
|
|
1907
|
+
await nextTick();
|
|
1908
|
+
const tableInstance = {
|
|
1909
|
+
getDataSource,
|
|
1910
|
+
setDataSource,
|
|
1911
|
+
reload,
|
|
1912
|
+
refresh,
|
|
1913
|
+
getSelectRows,
|
|
1914
|
+
getSelectRowKeys,
|
|
1915
|
+
clearSelectedRowKeys,
|
|
1916
|
+
setSelectedRowKeys,
|
|
1917
|
+
deleteSelectRowByKey,
|
|
1918
|
+
getPaginationInfo,
|
|
1919
|
+
setPagination,
|
|
1920
|
+
getSize,
|
|
1921
|
+
setSize,
|
|
1922
|
+
updateColumns,
|
|
1923
|
+
getColumns,
|
|
1924
|
+
setProps,
|
|
1925
|
+
setLoading,
|
|
1926
|
+
getSearchFormValues,
|
|
1927
|
+
setSearchFormValues,
|
|
1928
|
+
expandAll,
|
|
1929
|
+
collapseAll,
|
|
1930
|
+
tableRef,
|
|
1931
|
+
searchFormRef
|
|
1932
|
+
};
|
|
1933
|
+
const formInstance = {
|
|
1934
|
+
getFieldsValue: () => {
|
|
1935
|
+
var _a, _b;
|
|
1936
|
+
return ((_b = (_a = searchFormRef.value) == null ? void 0 : _a.getFieldsValue) == null ? void 0 : _b.call(_a)) || {};
|
|
1937
|
+
},
|
|
1938
|
+
setFieldsValue: (values) => {
|
|
1939
|
+
var _a, _b;
|
|
1940
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.setFieldsValue) == null ? void 0 : _b.call(_a, values);
|
|
1941
|
+
},
|
|
1942
|
+
resetFields: () => {
|
|
1943
|
+
var _a, _b;
|
|
1944
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.resetFields) == null ? void 0 : _b.call(_a);
|
|
1945
|
+
},
|
|
1946
|
+
validate: () => {
|
|
1947
|
+
var _a, _b;
|
|
1948
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.validate) == null ? void 0 : _b.call(_a);
|
|
1949
|
+
},
|
|
1950
|
+
validateFields: () => {
|
|
1951
|
+
var _a, _b;
|
|
1952
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.validate) == null ? void 0 : _b.call(_a);
|
|
1953
|
+
},
|
|
1954
|
+
// BasicForm 没有单独的 validateFields,使用 validate
|
|
1955
|
+
clearValidate: (field) => {
|
|
1956
|
+
var _a, _b;
|
|
1957
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.clearValidate) == null ? void 0 : _b.call(_a, field);
|
|
1958
|
+
},
|
|
1959
|
+
submit: () => {
|
|
1960
|
+
var _a, _b;
|
|
1961
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.handleSubmit) == null ? void 0 : _b.call(_a);
|
|
1962
|
+
},
|
|
1963
|
+
updateSchema: (schema) => {
|
|
1964
|
+
var _a, _b;
|
|
1965
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.updateSchema) == null ? void 0 : _b.call(_a, schema);
|
|
1966
|
+
},
|
|
1967
|
+
resetSchema: (schemas) => {
|
|
1968
|
+
var _a, _b;
|
|
1969
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.resetSchema) == null ? void 0 : _b.call(_a, schemas);
|
|
1970
|
+
},
|
|
1971
|
+
removeSchemaByField: (field) => {
|
|
1972
|
+
var _a, _b;
|
|
1973
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.removeSchema) == null ? void 0 : _b.call(_a, field);
|
|
1974
|
+
},
|
|
1975
|
+
// 实际方法名是 removeSchema
|
|
1976
|
+
appendSchemaByField: () => {
|
|
1977
|
+
console.warn("appendSchemaByField 方法暂不支持,请使用 updateSchema 或 setProps");
|
|
1978
|
+
},
|
|
1979
|
+
getSchema: (field) => {
|
|
1980
|
+
var _a, _b;
|
|
1981
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.getSchema) == null ? void 0 : _b.call(_a, field);
|
|
1982
|
+
},
|
|
1983
|
+
setProps: (formProps) => {
|
|
1984
|
+
var _a, _b;
|
|
1985
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.setProps) == null ? void 0 : _b.call(_a, formProps);
|
|
1986
|
+
},
|
|
1987
|
+
scrollToField: (name, options) => {
|
|
1988
|
+
var _a, _b;
|
|
1989
|
+
return (_b = (_a = searchFormRef.value) == null ? void 0 : _a.scrollToField) == null ? void 0 : _b.call(_a, name, options);
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
emit("register", tableInstance, formInstance);
|
|
1993
|
+
const mergedProps = getMergedProps.value;
|
|
1994
|
+
if (mergedProps.immediate && mergedProps.api) {
|
|
1995
|
+
await fetchData();
|
|
1996
|
+
}
|
|
1997
|
+
});
|
|
1998
|
+
onBeforeUnmount(() => {
|
|
1999
|
+
document.removeEventListener("fullscreenchange", handleFullscreenChange);
|
|
2000
|
+
if (document.fullscreenElement) {
|
|
2001
|
+
document.exitFullscreen().catch((error) => {
|
|
2002
|
+
console.error("退出全屏失败:", error);
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
handleRefresh.cancel();
|
|
2006
|
+
debouncedFetchData.cancel();
|
|
2007
|
+
dataSource.value = [];
|
|
2008
|
+
selectedRowKeys.value = [];
|
|
2009
|
+
selectedRows.value = [];
|
|
2010
|
+
searchParams.value = {};
|
|
2011
|
+
checkedColumns.value = [];
|
|
2012
|
+
innerPropsRef.value = {};
|
|
2013
|
+
tableRef.value = null;
|
|
2014
|
+
searchFormRef.value = null;
|
|
2015
|
+
});
|
|
2016
|
+
return (_ctx, _cache) => {
|
|
2017
|
+
const _component_a_divider = resolveComponent("a-divider");
|
|
2018
|
+
const _component_a_button = resolveComponent("a-button");
|
|
2019
|
+
const _component_a_tooltip = resolveComponent("a-tooltip");
|
|
2020
|
+
const _component_a_doption = resolveComponent("a-doption");
|
|
2021
|
+
const _component_a_dropdown = resolveComponent("a-dropdown");
|
|
2022
|
+
const _component_a_checkbox = resolveComponent("a-checkbox");
|
|
2023
|
+
const _component_a_checkbox_group = resolveComponent("a-checkbox-group");
|
|
2024
|
+
const _component_a_popover = resolveComponent("a-popover");
|
|
2025
|
+
const _component_a_space = resolveComponent("a-space");
|
|
2026
|
+
const _component_a_link = resolveComponent("a-link");
|
|
2027
|
+
const _component_a_popconfirm = resolveComponent("a-popconfirm");
|
|
2028
|
+
const _component_a_table = resolveComponent("a-table");
|
|
2029
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
2030
|
+
getSearchConfig.value.show ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
|
|
2031
|
+
createVNode(unref(_sfc_main$9), mergeProps({
|
|
2032
|
+
ref_key: "searchFormRef",
|
|
2033
|
+
ref: searchFormRef
|
|
2034
|
+
}, getSearchFormProps.value, {
|
|
2035
|
+
onSubmit: handleSearch,
|
|
2036
|
+
onReset: handleReset
|
|
2037
|
+
}), null, 16),
|
|
2038
|
+
createVNode(_component_a_divider, { class: "!mt-0" })
|
|
2039
|
+
])) : createCommentVNode("", true),
|
|
2040
|
+
getToolbarConfig.value.show ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
|
|
2041
|
+
createElementVNode("div", _hoisted_4$1, [
|
|
2042
|
+
renderSlot(_ctx.$slots, "tableTitle", {}, () => [
|
|
2043
|
+
getToolbarConfig.value.title ? (openBlock(), createElementBlock("div", _hoisted_5$1, toDisplayString(getToolbarConfig.value.title), 1)) : createCommentVNode("", true)
|
|
2044
|
+
], true)
|
|
2045
|
+
]),
|
|
2046
|
+
createElementVNode("div", _hoisted_6, [
|
|
2047
|
+
createVNode(_component_a_space, null, {
|
|
2048
|
+
default: withCtx(() => [
|
|
2049
|
+
getToolbarConfig.value.actions && getToolbarConfig.value.actions.length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(getToolbarConfig.value.actions, (action, index) => {
|
|
2050
|
+
return withDirectives((openBlock(), createBlock(_component_a_button, mergeProps({
|
|
2051
|
+
key: index,
|
|
2052
|
+
onClick: action.onClick
|
|
2053
|
+
}, { ref_for: true }, action), createSlots({
|
|
2054
|
+
default: withCtx(() => [
|
|
2055
|
+
createTextVNode(" " + toDisplayString(action.label), 1)
|
|
2056
|
+
]),
|
|
2057
|
+
_: 2
|
|
2058
|
+
}, [
|
|
2059
|
+
action.icon ? {
|
|
2060
|
+
name: "icon",
|
|
2061
|
+
fn: withCtx(() => [
|
|
2062
|
+
(openBlock(), createBlock(resolveDynamicComponent(action.icon)))
|
|
2063
|
+
]),
|
|
2064
|
+
key: "0"
|
|
2065
|
+
} : void 0
|
|
2066
|
+
]), 1040, ["onClick"])), [
|
|
2067
|
+
[vShow, action.show !== false]
|
|
2068
|
+
]);
|
|
2069
|
+
}), 128)) : createCommentVNode("", true),
|
|
2070
|
+
getToolbarConfig.value.showRefresh ? (openBlock(), createBlock(_component_a_tooltip, {
|
|
2071
|
+
key: 1,
|
|
2072
|
+
content: "刷新"
|
|
2073
|
+
}, {
|
|
2074
|
+
default: withCtx(() => [
|
|
2075
|
+
createVNode(_component_a_button, {
|
|
2076
|
+
onClick: unref(handleRefresh),
|
|
2077
|
+
"aria-label": "刷新表格"
|
|
2078
|
+
}, {
|
|
2079
|
+
icon: withCtx(() => [
|
|
2080
|
+
createVNode(unref(IconRefresh))
|
|
2081
|
+
]),
|
|
2082
|
+
_: 1
|
|
2083
|
+
}, 8, ["onClick"])
|
|
2084
|
+
]),
|
|
2085
|
+
_: 1
|
|
2086
|
+
})) : createCommentVNode("", true),
|
|
2087
|
+
getToolbarConfig.value.showFullscreen ? (openBlock(), createBlock(_component_a_tooltip, {
|
|
2088
|
+
key: 2,
|
|
2089
|
+
content: isFullscreen.value ? "退出全屏" : "全屏"
|
|
2090
|
+
}, {
|
|
2091
|
+
default: withCtx(() => [
|
|
2092
|
+
createVNode(_component_a_button, {
|
|
2093
|
+
onClick: handleFullscreen,
|
|
2094
|
+
"aria-label": isFullscreen.value ? "退出全屏" : "全屏显示"
|
|
2095
|
+
}, {
|
|
2096
|
+
icon: withCtx(() => [
|
|
2097
|
+
isFullscreen.value ? (openBlock(), createBlock(unref(IconFullscreenExit), { key: 0 })) : (openBlock(), createBlock(unref(IconFullscreen), { key: 1 }))
|
|
2098
|
+
]),
|
|
2099
|
+
_: 1
|
|
2100
|
+
}, 8, ["aria-label"])
|
|
2101
|
+
]),
|
|
2102
|
+
_: 1
|
|
2103
|
+
}, 8, ["content"])) : createCommentVNode("", true),
|
|
2104
|
+
getToolbarConfig.value.showDensity ? (openBlock(), createBlock(_component_a_dropdown, {
|
|
2105
|
+
key: 3,
|
|
2106
|
+
onSelect: handleDensityChange
|
|
2107
|
+
}, {
|
|
2108
|
+
content: withCtx(() => [
|
|
2109
|
+
createVNode(_component_a_doption, { value: "mini" }, {
|
|
2110
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [
|
|
2111
|
+
createTextVNode("紧凑", -1)
|
|
2112
|
+
])]),
|
|
2113
|
+
_: 1
|
|
2114
|
+
}),
|
|
2115
|
+
createVNode(_component_a_doption, { value: "small" }, {
|
|
2116
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [
|
|
2117
|
+
createTextVNode("偏小", -1)
|
|
2118
|
+
])]),
|
|
2119
|
+
_: 1
|
|
2120
|
+
}),
|
|
2121
|
+
createVNode(_component_a_doption, { value: "medium" }, {
|
|
2122
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [
|
|
2123
|
+
createTextVNode("默认", -1)
|
|
2124
|
+
])]),
|
|
2125
|
+
_: 1
|
|
2126
|
+
}),
|
|
2127
|
+
createVNode(_component_a_doption, { value: "large" }, {
|
|
2128
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [
|
|
2129
|
+
createTextVNode("宽松", -1)
|
|
2130
|
+
])]),
|
|
2131
|
+
_: 1
|
|
2132
|
+
})
|
|
2133
|
+
]),
|
|
2134
|
+
default: withCtx(() => [
|
|
2135
|
+
createVNode(_component_a_tooltip, { content: "密度" }, {
|
|
2136
|
+
default: withCtx(() => [
|
|
2137
|
+
createVNode(_component_a_button, { "aria-label": "设置表格密度" }, {
|
|
2138
|
+
icon: withCtx(() => [
|
|
2139
|
+
createVNode(unref(IconLineHeight))
|
|
2140
|
+
]),
|
|
2141
|
+
_: 1
|
|
2142
|
+
})
|
|
2143
|
+
]),
|
|
2144
|
+
_: 1
|
|
2145
|
+
})
|
|
2146
|
+
]),
|
|
2147
|
+
_: 1
|
|
2148
|
+
})) : createCommentVNode("", true),
|
|
2149
|
+
getToolbarConfig.value.showColumnSetting ? (openBlock(), createBlock(_component_a_popover, {
|
|
2150
|
+
key: 4,
|
|
2151
|
+
trigger: "click",
|
|
2152
|
+
position: "br"
|
|
2153
|
+
}, {
|
|
2154
|
+
content: withCtx(() => [
|
|
2155
|
+
createElementVNode("div", _hoisted_7, [
|
|
2156
|
+
createVNode(_component_a_checkbox_group, {
|
|
2157
|
+
modelValue: checkedColumns.value,
|
|
2158
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => checkedColumns.value = $event),
|
|
2159
|
+
onChange: handleColumnChange
|
|
2160
|
+
}, {
|
|
2161
|
+
default: withCtx(() => [
|
|
2162
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(settingColumns.value, (col) => {
|
|
2163
|
+
return openBlock(), createElementBlock("div", {
|
|
2164
|
+
key: col.dataIndex,
|
|
2165
|
+
class: "column-setting-item"
|
|
2166
|
+
}, [
|
|
2167
|
+
createVNode(_component_a_checkbox, {
|
|
2168
|
+
value: col.dataIndex
|
|
2169
|
+
}, {
|
|
2170
|
+
default: withCtx(() => [
|
|
2171
|
+
createTextVNode(toDisplayString(col.title), 1)
|
|
2172
|
+
]),
|
|
2173
|
+
_: 2
|
|
2174
|
+
}, 1032, ["value"])
|
|
2175
|
+
]);
|
|
2176
|
+
}), 128))
|
|
2177
|
+
]),
|
|
2178
|
+
_: 1
|
|
2179
|
+
}, 8, ["modelValue"])
|
|
2180
|
+
])
|
|
2181
|
+
]),
|
|
2182
|
+
default: withCtx(() => [
|
|
2183
|
+
createVNode(_component_a_tooltip, { content: "列设置" }, {
|
|
2184
|
+
default: withCtx(() => [
|
|
2185
|
+
createVNode(_component_a_button, { "aria-label": "设置显示列" }, {
|
|
2186
|
+
icon: withCtx(() => [
|
|
2187
|
+
createVNode(unref(IconSettings))
|
|
2188
|
+
]),
|
|
2189
|
+
_: 1
|
|
2190
|
+
})
|
|
2191
|
+
]),
|
|
2192
|
+
_: 1
|
|
2193
|
+
})
|
|
2194
|
+
]),
|
|
2195
|
+
_: 1
|
|
2196
|
+
})) : createCommentVNode("", true)
|
|
2197
|
+
]),
|
|
2198
|
+
_: 1
|
|
2199
|
+
})
|
|
2200
|
+
])
|
|
2201
|
+
])) : createCommentVNode("", true),
|
|
2202
|
+
createVNode(_component_a_table, mergeProps({
|
|
2203
|
+
ref_key: "tableRef",
|
|
2204
|
+
ref: tableRef
|
|
2205
|
+
}, getBindValues.value, {
|
|
2206
|
+
columns: getViewColumns.value,
|
|
2207
|
+
data: dataSource.value,
|
|
2208
|
+
loading: loadingRef.value,
|
|
2209
|
+
pagination: getPaginationConfig.value,
|
|
2210
|
+
"row-selection": getRowSelectionConfig.value,
|
|
2211
|
+
expandable: getMergedProps.value.expandable,
|
|
2212
|
+
scroll: getScrollConfig.value,
|
|
2213
|
+
draggable: getMergedProps.value.draggable,
|
|
2214
|
+
bordered: getMergedProps.value.bordered,
|
|
2215
|
+
stripe: getMergedProps.value.stripe,
|
|
2216
|
+
"show-header": getMergedProps.value.showHeader,
|
|
2217
|
+
size: tableSizeRef.value,
|
|
2218
|
+
"row-key": getRowKeyProp.value,
|
|
2219
|
+
onChange: handleTableChange,
|
|
2220
|
+
onPageChange: handlePageChange,
|
|
2221
|
+
onPageSizeChange: handlePageSizeChange,
|
|
2222
|
+
onSelect: handleSelect,
|
|
2223
|
+
onSelectAll: handleSelectAll,
|
|
2224
|
+
onExpand: handleExpand,
|
|
2225
|
+
onRowClick: handleRowClick,
|
|
2226
|
+
onRowDblclick: handleRowDblclick,
|
|
2227
|
+
onCellClick: handleCellClick
|
|
2228
|
+
}), createSlots({ _: 2 }, [
|
|
2229
|
+
renderList(getViewColumns.value.filter((c) => c.slotName), (col) => {
|
|
2230
|
+
return {
|
|
2231
|
+
name: col.slotName,
|
|
2232
|
+
fn: withCtx((slotProps) => [
|
|
2233
|
+
col.slotName === "__index__" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2234
|
+
createTextVNode(toDisplayString(getIndexNumber(slotProps.rowIndex)), 1)
|
|
2235
|
+
], 64)) : col.slotName === "action" ? renderSlot(_ctx.$slots, "action", {
|
|
2236
|
+
key: 1,
|
|
2237
|
+
record: slotProps.record
|
|
2238
|
+
}, () => [
|
|
2239
|
+
createVNode(_component_a_space, null, {
|
|
2240
|
+
default: withCtx(() => [
|
|
2241
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(getActionButtons(slotProps.record), (action) => {
|
|
2242
|
+
return openBlock(), createElementBlock(Fragment, {
|
|
2243
|
+
key: action.label
|
|
2244
|
+
}, [
|
|
2245
|
+
action.popConfirm ? (openBlock(), createBlock(_component_a_popconfirm, {
|
|
2246
|
+
key: 0,
|
|
2247
|
+
content: action.popConfirm.title,
|
|
2248
|
+
"ok-text": action.popConfirm.okText,
|
|
2249
|
+
"cancel-text": action.popConfirm.cancelText,
|
|
2250
|
+
onOk: ($event) => {
|
|
2251
|
+
var _a, _b;
|
|
2252
|
+
return (_b = (_a = action.popConfirm).onConfirm) == null ? void 0 : _b.call(_a, slotProps.record);
|
|
2253
|
+
},
|
|
2254
|
+
onCancel: action.popConfirm.onCancel
|
|
2255
|
+
}, {
|
|
2256
|
+
default: withCtx(() => [
|
|
2257
|
+
createVNode(_component_a_link, {
|
|
2258
|
+
status: action.color,
|
|
2259
|
+
disabled: getActionDisabled(action, slotProps.record),
|
|
2260
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
2261
|
+
}, ["stop"]))
|
|
2262
|
+
}, createSlots({
|
|
2263
|
+
default: withCtx(() => [
|
|
2264
|
+
createTextVNode(" " + toDisplayString(action.label), 1)
|
|
2265
|
+
]),
|
|
2266
|
+
_: 2
|
|
2267
|
+
}, [
|
|
2268
|
+
action.icon ? {
|
|
2269
|
+
name: "icon",
|
|
2270
|
+
fn: withCtx(() => [
|
|
2271
|
+
(openBlock(), createBlock(resolveDynamicComponent(action.icon)))
|
|
2272
|
+
]),
|
|
2273
|
+
key: "0"
|
|
2274
|
+
} : void 0
|
|
2275
|
+
]), 1032, ["status", "disabled"])
|
|
2276
|
+
]),
|
|
2277
|
+
_: 2
|
|
2278
|
+
}, 1032, ["content", "ok-text", "cancel-text", "onOk", "onCancel"])) : (openBlock(), createBlock(_component_a_link, {
|
|
2279
|
+
key: 1,
|
|
2280
|
+
status: action.color,
|
|
2281
|
+
disabled: getActionDisabled(action, slotProps.record),
|
|
2282
|
+
onClick: ($event) => handleActionClick(action, slotProps.record)
|
|
2283
|
+
}, createSlots({
|
|
2284
|
+
default: withCtx(() => [
|
|
2285
|
+
createTextVNode(" " + toDisplayString(action.label), 1)
|
|
2286
|
+
]),
|
|
2287
|
+
_: 2
|
|
2288
|
+
}, [
|
|
2289
|
+
action.icon ? {
|
|
2290
|
+
name: "icon",
|
|
2291
|
+
fn: withCtx(() => [
|
|
2292
|
+
(openBlock(), createBlock(resolveDynamicComponent(action.icon)))
|
|
2293
|
+
]),
|
|
2294
|
+
key: "0"
|
|
2295
|
+
} : void 0
|
|
2296
|
+
]), 1032, ["status", "disabled", "onClick"]))
|
|
2297
|
+
], 64);
|
|
2298
|
+
}), 128))
|
|
2299
|
+
]),
|
|
2300
|
+
_: 2
|
|
2301
|
+
}, 1024)
|
|
2302
|
+
], true) : _ctx.$slots[col.dataIndex] ? renderSlot(_ctx.$slots, col.dataIndex, normalizeProps(mergeProps({ key: 2 }, slotProps)), void 0, true) : col.customRender ? (openBlock(), createBlock(resolveDynamicComponent(renderCustomCell(col, slotProps)), { key: 3 })) : col.format ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
|
|
2303
|
+
createTextVNode(toDisplayString(col.format(slotProps.record[col.dataIndex], slotProps.record, slotProps.rowIndex)), 1)
|
|
2304
|
+
], 64)) : createCommentVNode("", true)
|
|
2305
|
+
])
|
|
2306
|
+
};
|
|
2307
|
+
})
|
|
2308
|
+
]), 1040, ["columns", "data", "loading", "pagination", "row-selection", "expandable", "scroll", "draggable", "bordered", "stripe", "show-header", "size", "row-key"])
|
|
2309
|
+
]);
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
});
|
|
2313
|
+
const _export_sfc = (sfc, props) => {
|
|
2314
|
+
const target = sfc.__vccOpts || sfc;
|
|
2315
|
+
for (const [key, val] of props) {
|
|
2316
|
+
target[key] = val;
|
|
2317
|
+
}
|
|
2318
|
+
return target;
|
|
2319
|
+
};
|
|
2320
|
+
const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a77f6f35"]]);
|
|
2321
|
+
function useTable(options = {}) {
|
|
2322
|
+
const tableRef = ref(null);
|
|
2323
|
+
const formRef = ref(null);
|
|
2324
|
+
const loadedRef = ref(false);
|
|
2325
|
+
const dataSourceRef = ref([]);
|
|
2326
|
+
const propsRef = ref({});
|
|
2327
|
+
const register = async (tableInstance, formInstance) => {
|
|
2328
|
+
await nextTick();
|
|
2329
|
+
tableRef.value = tableInstance;
|
|
2330
|
+
formRef.value = formInstance;
|
|
2331
|
+
loadedRef.value = true;
|
|
2332
|
+
if (options && Object.keys(options).length > 0) {
|
|
2333
|
+
await setProps(options);
|
|
2334
|
+
}
|
|
2335
|
+
if (options.immediate) {
|
|
2336
|
+
if (options.api) {
|
|
2337
|
+
await reload();
|
|
2338
|
+
} else if (options.data && options.data.length > 0) {
|
|
2339
|
+
await setDataSource(options.data);
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
};
|
|
2343
|
+
const getTable = () => {
|
|
2344
|
+
const table = unref(tableRef);
|
|
2345
|
+
if (!table) {
|
|
2346
|
+
console.error("表格实例尚未注册,请确保组件已挂载并正确使用 @register");
|
|
2347
|
+
}
|
|
2348
|
+
return table;
|
|
2349
|
+
};
|
|
2350
|
+
const getDataSource = () => {
|
|
2351
|
+
const table = getTable();
|
|
2352
|
+
if (!table) return [];
|
|
2353
|
+
if (table.getDataSource) {
|
|
2354
|
+
return table.getDataSource();
|
|
2355
|
+
}
|
|
2356
|
+
return unref(dataSourceRef) || [];
|
|
2357
|
+
};
|
|
2358
|
+
const setDataSource = async (data) => {
|
|
2359
|
+
const table = getTable();
|
|
2360
|
+
if (!table) return;
|
|
2361
|
+
dataSourceRef.value = data;
|
|
2362
|
+
if (table.setDataSource) {
|
|
2363
|
+
await table.setDataSource(data);
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
const reload = async (opt2) => {
|
|
2367
|
+
const table = getTable();
|
|
2368
|
+
if (!table) return;
|
|
2369
|
+
if (table.reload) {
|
|
2370
|
+
await table.reload(opt2);
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
const refresh = async () => {
|
|
2374
|
+
const table = getTable();
|
|
2375
|
+
if (!table) return;
|
|
2376
|
+
if (table.refresh) {
|
|
2377
|
+
await table.refresh();
|
|
2378
|
+
} else {
|
|
2379
|
+
await reload();
|
|
2380
|
+
}
|
|
2381
|
+
};
|
|
2382
|
+
const getSelectRows = () => {
|
|
2383
|
+
const table = getTable();
|
|
2384
|
+
if (!table) return [];
|
|
2385
|
+
if (table.getSelectRows) {
|
|
2386
|
+
return table.getSelectRows();
|
|
2387
|
+
}
|
|
2388
|
+
return [];
|
|
2389
|
+
};
|
|
2390
|
+
const getSelectRowKeys = () => {
|
|
2391
|
+
const table = getTable();
|
|
2392
|
+
if (!table) return [];
|
|
2393
|
+
if (table.getSelectRowKeys) {
|
|
2394
|
+
return table.getSelectRowKeys();
|
|
2395
|
+
}
|
|
2396
|
+
return [];
|
|
2397
|
+
};
|
|
2398
|
+
const clearSelectedRowKeys = () => {
|
|
2399
|
+
const table = getTable();
|
|
2400
|
+
if (!table) return;
|
|
2401
|
+
if (table.clearSelectedRowKeys) {
|
|
2402
|
+
table.clearSelectedRowKeys();
|
|
2403
|
+
}
|
|
2404
|
+
};
|
|
2405
|
+
const setSelectedRowKeys = (keys) => {
|
|
2406
|
+
const table = getTable();
|
|
2407
|
+
if (!table) return;
|
|
2408
|
+
if (table.setSelectedRowKeys) {
|
|
2409
|
+
table.setSelectedRowKeys(keys);
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
const deleteSelectRowByKey = (key) => {
|
|
2413
|
+
const table = getTable();
|
|
2414
|
+
if (!table) return;
|
|
2415
|
+
if (table.deleteSelectRowByKey) {
|
|
2416
|
+
table.deleteSelectRowByKey(key);
|
|
2417
|
+
}
|
|
2418
|
+
};
|
|
2419
|
+
const getPaginationInfo = () => {
|
|
2420
|
+
const table = getTable();
|
|
2421
|
+
if (!table) return false;
|
|
2422
|
+
if (table.getPaginationInfo) {
|
|
2423
|
+
return table.getPaginationInfo();
|
|
2424
|
+
}
|
|
2425
|
+
return false;
|
|
2426
|
+
};
|
|
2427
|
+
const setPagination = async (info) => {
|
|
2428
|
+
const table = getTable();
|
|
2429
|
+
if (!table) return;
|
|
2430
|
+
if (table.setPagination) {
|
|
2431
|
+
await table.setPagination(info);
|
|
2432
|
+
}
|
|
2433
|
+
};
|
|
2434
|
+
const getSize = () => {
|
|
2435
|
+
const table = getTable();
|
|
2436
|
+
if (!table) return "medium";
|
|
2437
|
+
if (table.getSize) {
|
|
2438
|
+
return table.getSize();
|
|
2439
|
+
}
|
|
2440
|
+
return "medium";
|
|
2441
|
+
};
|
|
2442
|
+
const setSize = (size) => {
|
|
2443
|
+
const table = getTable();
|
|
2444
|
+
if (!table) return;
|
|
2445
|
+
if (table.setSize) {
|
|
2446
|
+
table.setSize(size);
|
|
2447
|
+
}
|
|
2448
|
+
};
|
|
2449
|
+
const updateColumns = async (columns) => {
|
|
2450
|
+
const table = getTable();
|
|
2451
|
+
if (!table) return;
|
|
2452
|
+
if (table.updateColumns) {
|
|
2453
|
+
await table.updateColumns(columns);
|
|
2454
|
+
}
|
|
2455
|
+
};
|
|
2456
|
+
const getColumns = () => {
|
|
2457
|
+
const table = getTable();
|
|
2458
|
+
if (!table) return [];
|
|
2459
|
+
if (table.getColumns) {
|
|
2460
|
+
return table.getColumns();
|
|
2461
|
+
}
|
|
2462
|
+
return [];
|
|
2463
|
+
};
|
|
2464
|
+
const setProps = async (props) => {
|
|
2465
|
+
propsRef.value = { ...propsRef.value, ...props };
|
|
2466
|
+
const table = getTable();
|
|
2467
|
+
if (!table) {
|
|
2468
|
+
return;
|
|
2469
|
+
}
|
|
2470
|
+
if (table.setProps) {
|
|
2471
|
+
await table.setProps(props);
|
|
2472
|
+
}
|
|
2473
|
+
};
|
|
2474
|
+
const setLoading = (loading) => {
|
|
2475
|
+
const table = getTable();
|
|
2476
|
+
if (!table) return;
|
|
2477
|
+
if (table.setLoading) {
|
|
2478
|
+
table.setLoading(loading);
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
const getSearchFormValues = () => {
|
|
2482
|
+
const table = getTable();
|
|
2483
|
+
if (!table) return {};
|
|
2484
|
+
if (table.getSearchFormValues) {
|
|
2485
|
+
return table.getSearchFormValues();
|
|
2486
|
+
}
|
|
2487
|
+
return {};
|
|
2488
|
+
};
|
|
2489
|
+
const setSearchFormValues = async (values) => {
|
|
2490
|
+
const table = getTable();
|
|
2491
|
+
if (!table) return;
|
|
2492
|
+
if (table.setSearchFormValues) {
|
|
2493
|
+
await table.setSearchFormValues(values);
|
|
2494
|
+
}
|
|
2495
|
+
};
|
|
2496
|
+
const expandAll = () => {
|
|
2497
|
+
const table = getTable();
|
|
2498
|
+
if (!table) return;
|
|
2499
|
+
if (table.expandAll) {
|
|
2500
|
+
table.expandAll();
|
|
2501
|
+
}
|
|
2502
|
+
};
|
|
2503
|
+
const collapseAll = () => {
|
|
2504
|
+
const table = getTable();
|
|
2505
|
+
if (!table) return;
|
|
2506
|
+
if (table.collapseAll) {
|
|
2507
|
+
table.collapseAll();
|
|
2508
|
+
}
|
|
2509
|
+
};
|
|
2510
|
+
const getForm = () => {
|
|
2511
|
+
const form = unref(formRef);
|
|
2512
|
+
if (!form) {
|
|
2513
|
+
console.warn("[useTable] 查询表单实例尚未注册,请确保表格配置了查询表单 (search.show = true)");
|
|
2514
|
+
return void 0;
|
|
2515
|
+
}
|
|
2516
|
+
const testMethod = form.getFieldsValue;
|
|
2517
|
+
if (!testMethod || typeof testMethod !== "function") {
|
|
2518
|
+
console.warn("[useTable] 查询表单实例方法不可用");
|
|
2519
|
+
return void 0;
|
|
2520
|
+
}
|
|
2521
|
+
return form;
|
|
2522
|
+
};
|
|
2523
|
+
const tableMethods = {
|
|
2524
|
+
getDataSource,
|
|
2525
|
+
setDataSource,
|
|
2526
|
+
reload,
|
|
2527
|
+
refresh,
|
|
2528
|
+
getSelectRows,
|
|
2529
|
+
getSelectRowKeys,
|
|
2530
|
+
clearSelectedRowKeys,
|
|
2531
|
+
setSelectedRowKeys,
|
|
2532
|
+
deleteSelectRowByKey,
|
|
2533
|
+
getPaginationInfo,
|
|
2534
|
+
setPagination,
|
|
2535
|
+
getSize,
|
|
2536
|
+
setSize,
|
|
2537
|
+
updateColumns,
|
|
2538
|
+
getColumns,
|
|
2539
|
+
setProps,
|
|
2540
|
+
setLoading,
|
|
2541
|
+
getSearchFormValues,
|
|
2542
|
+
setSearchFormValues,
|
|
2543
|
+
expandAll,
|
|
2544
|
+
collapseAll,
|
|
2545
|
+
getForm,
|
|
2546
|
+
tableRef,
|
|
2547
|
+
getTable
|
|
2548
|
+
};
|
|
2549
|
+
return [register, tableMethods];
|
|
2550
|
+
}
|
|
2551
|
+
function createTableColumns(columns) {
|
|
2552
|
+
return columns.map((column, index) => ({
|
|
2553
|
+
key: column.key || column.dataIndex || `column_${index}`,
|
|
2554
|
+
...column
|
|
2555
|
+
}));
|
|
2556
|
+
}
|
|
2557
|
+
function mergeTableColumns(...columns) {
|
|
2558
|
+
return columns.flat();
|
|
2559
|
+
}
|
|
2560
|
+
const _hoisted_1$1 = { style: { "position": "relative", "width": "100%" } };
|
|
2561
|
+
const _hoisted_2$1 = { key: 1 };
|
|
2562
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
2563
|
+
...{
|
|
2564
|
+
name: "BasicModal",
|
|
2565
|
+
inheritAttrs: false
|
|
2566
|
+
},
|
|
2567
|
+
__name: "BasicModal",
|
|
2568
|
+
props: {
|
|
2569
|
+
visible: { type: Boolean, default: false },
|
|
2570
|
+
defaultVisible: { type: Boolean, default: false },
|
|
2571
|
+
title: {},
|
|
2572
|
+
alignCenter: { type: Boolean },
|
|
2573
|
+
unmountOnClose: { type: Boolean },
|
|
2574
|
+
maskClosable: { type: Boolean, default: true },
|
|
2575
|
+
hideTitle: { type: Boolean },
|
|
2576
|
+
hideCancel: { type: Boolean },
|
|
2577
|
+
simple: { type: Boolean },
|
|
2578
|
+
closable: { type: Boolean, default: true },
|
|
2579
|
+
okText: { default: "确定" },
|
|
2580
|
+
cancelText: { default: "取消" },
|
|
2581
|
+
okLoading: { type: Boolean },
|
|
2582
|
+
okButtonProps: {},
|
|
2583
|
+
cancelButtonProps: {},
|
|
2584
|
+
fullscreen: { type: Boolean },
|
|
2585
|
+
width: { default: 520 },
|
|
2586
|
+
top: {},
|
|
2587
|
+
renderToBody: { type: Boolean },
|
|
2588
|
+
popupContainer: {},
|
|
2589
|
+
maskStyle: {},
|
|
2590
|
+
modalStyle: {},
|
|
2591
|
+
modalClass: {},
|
|
2592
|
+
popupAnimationName: {},
|
|
2593
|
+
mask: { type: Boolean, default: true },
|
|
2594
|
+
onBeforeOk: {},
|
|
2595
|
+
onBeforeCancel: {},
|
|
2596
|
+
escToClose: { type: Boolean },
|
|
2597
|
+
draggable: { type: Boolean, default: false },
|
|
2598
|
+
footer: { type: Boolean, default: true },
|
|
2599
|
+
titleAlign: { default: "center" },
|
|
2600
|
+
height: {},
|
|
2601
|
+
minHeight: {},
|
|
2602
|
+
useWrapper: { type: Boolean, default: true },
|
|
2603
|
+
wrapperFooterOffset: { default: 0 },
|
|
2604
|
+
canFullscreen: { type: Boolean, default: false },
|
|
2605
|
+
defaultFullscreen: { type: Boolean, default: false },
|
|
2606
|
+
loading: { type: Boolean, default: false },
|
|
2607
|
+
loadingTip: {},
|
|
2608
|
+
showCancelBtn: { type: Boolean, default: true },
|
|
2609
|
+
showOkBtn: { type: Boolean, default: true },
|
|
2610
|
+
helpMessage: {},
|
|
2611
|
+
centered: { type: Boolean, default: false },
|
|
2612
|
+
closeFunc: {},
|
|
2613
|
+
showFooter: { type: Boolean, default: true }
|
|
2614
|
+
},
|
|
2615
|
+
emits: ["register", "update:visible", "ok", "cancel", "visible-change"],
|
|
2616
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2617
|
+
const props = __props;
|
|
2618
|
+
const emit = __emit;
|
|
2619
|
+
const visibleRef = ref(false);
|
|
2620
|
+
const fullscreenRef = ref(false);
|
|
2621
|
+
const confirmLoading = ref(false);
|
|
2622
|
+
const modalLoading = ref(false);
|
|
2623
|
+
const propsRef = ref({});
|
|
2624
|
+
const getProps = computed(() => {
|
|
2625
|
+
return { ...props, ...unref(propsRef) };
|
|
2626
|
+
});
|
|
2627
|
+
const getBindValue = computed(() => {
|
|
2628
|
+
const propsData = unref(getProps);
|
|
2629
|
+
return {
|
|
2630
|
+
width: fullscreenRef.value ? "100%" : propsData.width,
|
|
2631
|
+
fullscreen: fullscreenRef.value,
|
|
2632
|
+
maskClosable: propsData.maskClosable,
|
|
2633
|
+
closable: propsData.closable,
|
|
2634
|
+
unmountOnClose: propsData.unmountOnClose,
|
|
2635
|
+
alignCenter: propsData.alignCenter || propsData.centered,
|
|
2636
|
+
simple: propsData.simple,
|
|
2637
|
+
hideTitle: propsData.hideTitle,
|
|
2638
|
+
renderToBody: propsData.renderToBody,
|
|
2639
|
+
popupContainer: propsData.popupContainer,
|
|
2640
|
+
maskStyle: propsData.maskStyle,
|
|
2641
|
+
modalStyle: getModalStyle.value,
|
|
2642
|
+
modalClass: propsData.modalClass,
|
|
2643
|
+
escToClose: propsData.escToClose,
|
|
2644
|
+
draggable: propsData.draggable,
|
|
2645
|
+
mask: propsData.mask,
|
|
2646
|
+
top: propsData.top,
|
|
2647
|
+
footer: propsData.footer === false ? false : void 0,
|
|
2648
|
+
titleAlign: propsData.titleAlign
|
|
2649
|
+
};
|
|
2650
|
+
});
|
|
2651
|
+
const getModalStyle = computed(() => {
|
|
2652
|
+
const propsData = unref(getProps);
|
|
2653
|
+
const style = { ...propsData.modalStyle };
|
|
2654
|
+
if (propsData.height) {
|
|
2655
|
+
style.height = typeof propsData.height === "number" ? `${propsData.height}px` : propsData.height;
|
|
2656
|
+
}
|
|
2657
|
+
if (propsData.minHeight) {
|
|
2658
|
+
style.minHeight = typeof propsData.minHeight === "number" ? `${propsData.minHeight}px` : propsData.minHeight;
|
|
2659
|
+
}
|
|
2660
|
+
if (fullscreenRef.value) {
|
|
2661
|
+
style.height = "100vh";
|
|
2662
|
+
style.width = "100vw";
|
|
2663
|
+
}
|
|
2664
|
+
return style;
|
|
2665
|
+
});
|
|
2666
|
+
const wrapperStyle = computed(() => {
|
|
2667
|
+
const propsData = unref(getProps);
|
|
2668
|
+
const style = {};
|
|
2669
|
+
if (propsData.height) {
|
|
2670
|
+
const height = typeof propsData.height === "number" ? propsData.height : parseInt(propsData.height);
|
|
2671
|
+
style.maxHeight = `${height - propsData.wrapperFooterOffset}px`;
|
|
2672
|
+
style.overflowY = "auto";
|
|
2673
|
+
}
|
|
2674
|
+
return style;
|
|
2675
|
+
});
|
|
2676
|
+
const spinStyle = computed(() => {
|
|
2677
|
+
const propsData = unref(getProps);
|
|
2678
|
+
const style = {
|
|
2679
|
+
minHeight: propsData.minHeight ? typeof propsData.minHeight === "number" ? `${propsData.minHeight}px` : propsData.minHeight : "200px",
|
|
2680
|
+
pointerEvents: "none"
|
|
2681
|
+
// 禁用所有交互
|
|
2682
|
+
};
|
|
2683
|
+
return style;
|
|
2684
|
+
});
|
|
2685
|
+
const getCancelButtonProps = computed(() => {
|
|
2686
|
+
const propsData = unref(getProps);
|
|
2687
|
+
return {
|
|
2688
|
+
...propsData.cancelButtonProps
|
|
2689
|
+
};
|
|
2690
|
+
});
|
|
2691
|
+
const getOkButtonProps = computed(() => {
|
|
2692
|
+
const propsData = unref(getProps);
|
|
2693
|
+
return {
|
|
2694
|
+
...propsData.okButtonProps,
|
|
2695
|
+
loading: confirmLoading.value || propsData.okLoading
|
|
2696
|
+
};
|
|
2697
|
+
});
|
|
2698
|
+
const handleVisibleChange = (visible) => {
|
|
2699
|
+
visibleRef.value = visible;
|
|
2700
|
+
emit("update:visible", visible);
|
|
2701
|
+
emit("visible-change", visible);
|
|
2702
|
+
};
|
|
2703
|
+
const handleOkInternal = async () => {
|
|
2704
|
+
const propsData = unref(getProps);
|
|
2705
|
+
if (confirmLoading.value || propsData.loading) {
|
|
2706
|
+
return;
|
|
2707
|
+
}
|
|
2708
|
+
if (propsData.onBeforeOk) {
|
|
2709
|
+
confirmLoading.value = true;
|
|
2710
|
+
try {
|
|
2711
|
+
await new Promise((resolve, reject) => {
|
|
2712
|
+
propsData.onBeforeOk((closed) => {
|
|
2713
|
+
if (closed) {
|
|
2714
|
+
resolve(true);
|
|
2715
|
+
} else {
|
|
2716
|
+
reject(false);
|
|
2717
|
+
}
|
|
2718
|
+
});
|
|
2719
|
+
});
|
|
2720
|
+
emit("ok");
|
|
2721
|
+
handleVisibleChange(false);
|
|
2722
|
+
} catch (e) {
|
|
2723
|
+
} finally {
|
|
2724
|
+
confirmLoading.value = false;
|
|
2725
|
+
}
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
if (propsData.closeFunc) {
|
|
2729
|
+
confirmLoading.value = true;
|
|
2730
|
+
try {
|
|
2731
|
+
const canClose = await propsData.closeFunc();
|
|
2732
|
+
if (canClose) {
|
|
2733
|
+
emit("ok");
|
|
2734
|
+
handleVisibleChange(false);
|
|
2735
|
+
}
|
|
2736
|
+
} finally {
|
|
2737
|
+
confirmLoading.value = false;
|
|
2738
|
+
}
|
|
2739
|
+
return;
|
|
2740
|
+
}
|
|
2741
|
+
emit("ok");
|
|
2742
|
+
handleVisibleChange(false);
|
|
2743
|
+
};
|
|
2744
|
+
const handleOk = handleOkInternal;
|
|
2745
|
+
const handleCancel = async () => {
|
|
2746
|
+
const propsData = unref(getProps);
|
|
2747
|
+
if (propsData.onBeforeCancel) {
|
|
2748
|
+
try {
|
|
2749
|
+
await new Promise((resolve, reject) => {
|
|
2750
|
+
propsData.onBeforeCancel((closed) => {
|
|
2751
|
+
if (closed) {
|
|
2752
|
+
resolve(true);
|
|
2753
|
+
} else {
|
|
2754
|
+
reject(false);
|
|
2755
|
+
}
|
|
2756
|
+
});
|
|
2757
|
+
});
|
|
2758
|
+
emit("cancel");
|
|
2759
|
+
handleVisibleChange(false);
|
|
2760
|
+
} catch (e) {
|
|
2761
|
+
}
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2764
|
+
emit("cancel");
|
|
2765
|
+
handleVisibleChange(false);
|
|
2766
|
+
};
|
|
2767
|
+
const handleFullscreen = () => {
|
|
2768
|
+
fullscreenRef.value = !fullscreenRef.value;
|
|
2769
|
+
};
|
|
2770
|
+
const setModalProps = (modalProps) => {
|
|
2771
|
+
propsRef.value = { ...unref(propsRef), ...modalProps };
|
|
2772
|
+
};
|
|
2773
|
+
const openModal = () => {
|
|
2774
|
+
handleVisibleChange(true);
|
|
2775
|
+
};
|
|
2776
|
+
const closeModal = () => {
|
|
2777
|
+
handleVisibleChange(false);
|
|
2778
|
+
};
|
|
2779
|
+
const changeOkLoading = (loading) => {
|
|
2780
|
+
confirmLoading.value = loading;
|
|
2781
|
+
};
|
|
2782
|
+
const changeLoading = (loading) => {
|
|
2783
|
+
modalLoading.value = loading;
|
|
2784
|
+
setModalProps({ loading });
|
|
2785
|
+
};
|
|
2786
|
+
const getModalProps = () => {
|
|
2787
|
+
return { ...unref(getProps), visible: visibleRef.value };
|
|
2788
|
+
};
|
|
2789
|
+
const modalMethods = {
|
|
2790
|
+
setModalProps,
|
|
2791
|
+
openModal,
|
|
2792
|
+
closeModal,
|
|
2793
|
+
changeOkLoading,
|
|
2794
|
+
changeLoading,
|
|
2795
|
+
getModalProps
|
|
2796
|
+
};
|
|
2797
|
+
__expose(modalMethods);
|
|
2798
|
+
watch(
|
|
2799
|
+
() => props.visible,
|
|
2800
|
+
(val) => {
|
|
2801
|
+
visibleRef.value = val;
|
|
2802
|
+
},
|
|
2803
|
+
{ immediate: true }
|
|
2804
|
+
);
|
|
2805
|
+
watch(
|
|
2806
|
+
() => props.defaultFullscreen,
|
|
2807
|
+
(val) => {
|
|
2808
|
+
fullscreenRef.value = val || false;
|
|
2809
|
+
},
|
|
2810
|
+
{ immediate: true }
|
|
2811
|
+
);
|
|
2812
|
+
onMounted(() => {
|
|
2813
|
+
nextTick(() => {
|
|
2814
|
+
emit("register", modalMethods);
|
|
2815
|
+
});
|
|
2816
|
+
});
|
|
2817
|
+
return (_ctx, _cache) => {
|
|
2818
|
+
const _component_a_tooltip = resolveComponent("a-tooltip");
|
|
2819
|
+
const _component_a_spin = resolveComponent("a-spin");
|
|
2820
|
+
const _component_a_button = resolveComponent("a-button");
|
|
2821
|
+
const _component_a_space = resolveComponent("a-space");
|
|
2822
|
+
const _component_a_modal = resolveComponent("a-modal");
|
|
2823
|
+
return openBlock(), createBlock(_component_a_modal, mergeProps(getBindValue.value, {
|
|
2824
|
+
visible: visibleRef.value,
|
|
2825
|
+
"onUpdate:visible": handleVisibleChange,
|
|
2826
|
+
onOk: unref(handleOk),
|
|
2827
|
+
onCancel: handleCancel
|
|
2828
|
+
}), createSlots({
|
|
2829
|
+
default: withCtx(() => [
|
|
2830
|
+
getProps.value.loading ? (openBlock(), createBlock(_component_a_spin, {
|
|
2831
|
+
key: 0,
|
|
2832
|
+
tip: getProps.value.loadingTip,
|
|
2833
|
+
loading: true,
|
|
2834
|
+
style: normalizeStyle(spinStyle.value),
|
|
2835
|
+
class: "w-full"
|
|
2836
|
+
}, {
|
|
2837
|
+
default: withCtx(() => [
|
|
2838
|
+
getProps.value.useWrapper ? (openBlock(), createElementBlock("div", {
|
|
2839
|
+
key: 0,
|
|
2840
|
+
style: normalizeStyle(wrapperStyle.value),
|
|
2841
|
+
class: "modal-wrapper"
|
|
2842
|
+
}, [
|
|
2843
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
2844
|
+
], 4)) : renderSlot(_ctx.$slots, "default", { key: 1 }, void 0, true)
|
|
2845
|
+
]),
|
|
2846
|
+
_: 3
|
|
2847
|
+
}, 8, ["tip", "style"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
2848
|
+
getProps.value.useWrapper ? (openBlock(), createElementBlock("div", {
|
|
2849
|
+
key: 0,
|
|
2850
|
+
style: normalizeStyle(wrapperStyle.value),
|
|
2851
|
+
class: "modal-wrapper"
|
|
2852
|
+
}, [
|
|
2853
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
2854
|
+
], 4)) : renderSlot(_ctx.$slots, "default", { key: 1 }, void 0, true)
|
|
2855
|
+
], 64))
|
|
2856
|
+
]),
|
|
2857
|
+
_: 2
|
|
2858
|
+
}, [
|
|
2859
|
+
_ctx.$slots.title ? {
|
|
2860
|
+
name: "title",
|
|
2861
|
+
fn: withCtx(() => [
|
|
2862
|
+
renderSlot(_ctx.$slots, "title", {}, void 0, true)
|
|
2863
|
+
]),
|
|
2864
|
+
key: "0"
|
|
2865
|
+
} : getProps.value.title ? {
|
|
2866
|
+
name: "title",
|
|
2867
|
+
fn: withCtx(() => [
|
|
2868
|
+
createElementVNode("div", _hoisted_1$1, [
|
|
2869
|
+
createElementVNode("span", {
|
|
2870
|
+
style: normalizeStyle({ display: "block", textAlign: getProps.value.titleAlign }),
|
|
2871
|
+
class: normalizeClass(["block"])
|
|
2872
|
+
}, toDisplayString(getProps.value.title), 5),
|
|
2873
|
+
createElementVNode("div", {
|
|
2874
|
+
class: normalizeClass(["modal-title-actions", getProps.value.closable ? "has-close" : ""])
|
|
2875
|
+
}, [
|
|
2876
|
+
getProps.value.helpMessage ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2877
|
+
Array.isArray(getProps.value.helpMessage) ? (openBlock(), createBlock(_component_a_tooltip, {
|
|
2878
|
+
key: 0,
|
|
2879
|
+
position: "top"
|
|
2880
|
+
}, {
|
|
2881
|
+
content: withCtx(() => [
|
|
2882
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(getProps.value.helpMessage, (msg, index) => {
|
|
2883
|
+
return openBlock(), createElementBlock("div", { key: index }, toDisplayString(msg), 1);
|
|
2884
|
+
}), 128))
|
|
2885
|
+
]),
|
|
2886
|
+
default: withCtx(() => [
|
|
2887
|
+
createVNode(unref(IconQuestionCircle), { class: "cursor-help text-gray-400" })
|
|
2888
|
+
]),
|
|
2889
|
+
_: 1
|
|
2890
|
+
})) : (openBlock(), createBlock(_component_a_tooltip, {
|
|
2891
|
+
key: 1,
|
|
2892
|
+
position: "top"
|
|
2893
|
+
}, {
|
|
2894
|
+
content: withCtx(() => [
|
|
2895
|
+
createTextVNode(toDisplayString(getProps.value.helpMessage), 1)
|
|
2896
|
+
]),
|
|
2897
|
+
default: withCtx(() => [
|
|
2898
|
+
createVNode(unref(IconQuestionCircle), { class: "cursor-help text-gray-400" })
|
|
2899
|
+
]),
|
|
2900
|
+
_: 1
|
|
2901
|
+
}))
|
|
2902
|
+
], 64)) : createCommentVNode("", true),
|
|
2903
|
+
getProps.value.canFullscreen ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
|
|
2904
|
+
!fullscreenRef.value ? (openBlock(), createBlock(unref(IconFullscreen), {
|
|
2905
|
+
key: 0,
|
|
2906
|
+
class: "cursor-pointer",
|
|
2907
|
+
onClick: handleFullscreen
|
|
2908
|
+
})) : (openBlock(), createBlock(unref(IconFullscreenExit), {
|
|
2909
|
+
key: 1,
|
|
2910
|
+
class: "cursor-pointer",
|
|
2911
|
+
onClick: handleFullscreen
|
|
2912
|
+
}))
|
|
2913
|
+
])) : createCommentVNode("", true)
|
|
2914
|
+
], 2)
|
|
2915
|
+
])
|
|
2916
|
+
]),
|
|
2917
|
+
key: "1"
|
|
2918
|
+
} : void 0,
|
|
2919
|
+
_ctx.$slots.footer ? {
|
|
2920
|
+
name: "footer",
|
|
2921
|
+
fn: withCtx(() => [
|
|
2922
|
+
renderSlot(_ctx.$slots, "footer", {}, void 0, true)
|
|
2923
|
+
]),
|
|
2924
|
+
key: "2"
|
|
2925
|
+
} : getProps.value.showFooter !== false ? {
|
|
2926
|
+
name: "footer",
|
|
2927
|
+
fn: withCtx(() => [
|
|
2928
|
+
createElementVNode("div", {
|
|
2929
|
+
style: normalizeStyle({
|
|
2930
|
+
pointerEvents: getProps.value.loading ? "none" : "auto",
|
|
2931
|
+
opacity: getProps.value.loading ? 0.6 : 1
|
|
2932
|
+
})
|
|
2933
|
+
}, [
|
|
2934
|
+
createVNode(_component_a_space, null, {
|
|
2935
|
+
default: withCtx(() => [
|
|
2936
|
+
renderSlot(_ctx.$slots, "insertFooter", {}, void 0, true),
|
|
2937
|
+
getProps.value.showCancelBtn ? (openBlock(), createBlock(_component_a_button, mergeProps({ key: 0 }, getCancelButtonProps.value, { onClick: handleCancel }), {
|
|
2938
|
+
default: withCtx(() => [
|
|
2939
|
+
createTextVNode(toDisplayString(getProps.value.cancelText || "取消"), 1)
|
|
2940
|
+
]),
|
|
2941
|
+
_: 1
|
|
2942
|
+
}, 16)) : createCommentVNode("", true),
|
|
2943
|
+
renderSlot(_ctx.$slots, "centerFooter", {}, void 0, true),
|
|
2944
|
+
getProps.value.showOkBtn ? (openBlock(), createBlock(_component_a_button, mergeProps({ key: 1 }, getOkButtonProps.value, {
|
|
2945
|
+
type: "primary",
|
|
2946
|
+
onClick: unref(handleOk)
|
|
2947
|
+
}), {
|
|
2948
|
+
default: withCtx(() => [
|
|
2949
|
+
createTextVNode(toDisplayString(getProps.value.okText || "确定"), 1)
|
|
2950
|
+
]),
|
|
2951
|
+
_: 1
|
|
2952
|
+
}, 16, ["onClick"])) : createCommentVNode("", true),
|
|
2953
|
+
renderSlot(_ctx.$slots, "appendFooter", {}, void 0, true)
|
|
2954
|
+
]),
|
|
2955
|
+
_: 3
|
|
2956
|
+
})
|
|
2957
|
+
], 4)
|
|
2958
|
+
]),
|
|
2959
|
+
key: "3"
|
|
2960
|
+
} : {
|
|
2961
|
+
name: "footer",
|
|
2962
|
+
fn: withCtx(() => []),
|
|
2963
|
+
key: "4"
|
|
2964
|
+
}
|
|
2965
|
+
]), 1040, ["visible", "onOk"]);
|
|
2966
|
+
};
|
|
2967
|
+
}
|
|
2968
|
+
});
|
|
2969
|
+
const BasicModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-e288f849"]]);
|
|
2970
|
+
function useModal(props) {
|
|
2971
|
+
const modalRef = ref(null);
|
|
2972
|
+
const loadedRef = ref(false);
|
|
2973
|
+
const register = (modalInstance) => {
|
|
2974
|
+
modalRef.value = modalInstance;
|
|
2975
|
+
loadedRef.value = true;
|
|
2976
|
+
if (props && Object.keys(props).length > 0) {
|
|
2977
|
+
setModalProps(props);
|
|
2978
|
+
}
|
|
2979
|
+
};
|
|
2980
|
+
const getModal = () => {
|
|
2981
|
+
const modal = unref(modalRef);
|
|
2982
|
+
if (!modal) {
|
|
2983
|
+
console.error("Modal 实例尚未注册,请确保组件已挂载并正确使用 @register");
|
|
2984
|
+
return null;
|
|
2985
|
+
}
|
|
2986
|
+
return modal;
|
|
2987
|
+
};
|
|
2988
|
+
const openModal = (visible = true, data) => {
|
|
2989
|
+
const modal = getModal();
|
|
2990
|
+
if (!modal) return;
|
|
2991
|
+
if (data !== void 0) {
|
|
2992
|
+
modal.setModalProps({ _data: data });
|
|
2993
|
+
}
|
|
2994
|
+
if (visible) {
|
|
2995
|
+
modal.openModal();
|
|
2996
|
+
} else {
|
|
2997
|
+
modal.closeModal();
|
|
2998
|
+
}
|
|
2999
|
+
};
|
|
3000
|
+
const closeModal = () => {
|
|
3001
|
+
const modal = getModal();
|
|
3002
|
+
if (!modal) return;
|
|
3003
|
+
modal.closeModal();
|
|
3004
|
+
};
|
|
3005
|
+
const setModalProps = (modalProps) => {
|
|
3006
|
+
const modal = getModal();
|
|
3007
|
+
if (!modal) return;
|
|
3008
|
+
modal.setModalProps(modalProps);
|
|
3009
|
+
};
|
|
3010
|
+
const getVisible = () => {
|
|
3011
|
+
const modal = getModal();
|
|
3012
|
+
if (!modal) return false;
|
|
3013
|
+
return modal.getModalProps().visible || false;
|
|
3014
|
+
};
|
|
3015
|
+
return [
|
|
3016
|
+
register,
|
|
3017
|
+
{
|
|
3018
|
+
openModal,
|
|
3019
|
+
closeModal,
|
|
3020
|
+
setModalProps,
|
|
3021
|
+
getVisible
|
|
3022
|
+
}
|
|
3023
|
+
];
|
|
3024
|
+
}
|
|
3025
|
+
function useModalInner(callbackFn) {
|
|
3026
|
+
const modalRef = ref(null);
|
|
3027
|
+
const loadedRef = ref(false);
|
|
3028
|
+
const instance = getCurrentInstance();
|
|
3029
|
+
if (!instance) {
|
|
3030
|
+
throw new Error("useModalInner 必须在 setup 函数中调用");
|
|
3031
|
+
}
|
|
3032
|
+
const register = (modalInstance) => {
|
|
3033
|
+
var _a, _b;
|
|
3034
|
+
if (unref(loadedRef) && modalInstance === unref(modalRef)) return;
|
|
3035
|
+
modalRef.value = modalInstance;
|
|
3036
|
+
loadedRef.value = true;
|
|
3037
|
+
(_a = instance.proxy) == null ? void 0 : _a.$watch(
|
|
3038
|
+
() => getModalProps().visible,
|
|
3039
|
+
(visible) => {
|
|
3040
|
+
if (visible && callbackFn) {
|
|
3041
|
+
const props = getModalProps();
|
|
3042
|
+
callbackFn(props._data);
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
);
|
|
3046
|
+
(_b = instance.emit) == null ? void 0 : _b.call(instance, "register", modalInstance);
|
|
3047
|
+
};
|
|
3048
|
+
const getModal = () => {
|
|
3049
|
+
const modal = unref(modalRef);
|
|
3050
|
+
if (!modal) {
|
|
3051
|
+
console.error("Modal 实例尚未注册,请确保组件已挂载并正确使用 @register");
|
|
3052
|
+
return null;
|
|
3053
|
+
}
|
|
3054
|
+
return modal;
|
|
3055
|
+
};
|
|
3056
|
+
const closeModal = () => {
|
|
3057
|
+
const modal = getModal();
|
|
3058
|
+
if (!modal) return;
|
|
3059
|
+
modal.closeModal();
|
|
3060
|
+
};
|
|
3061
|
+
const changeOkLoading = (loading) => {
|
|
3062
|
+
const modal = getModal();
|
|
3063
|
+
if (!modal) return;
|
|
3064
|
+
modal.changeOkLoading(loading);
|
|
3065
|
+
};
|
|
3066
|
+
const changeLoading = (loading) => {
|
|
3067
|
+
const modal = getModal();
|
|
3068
|
+
if (!modal) return;
|
|
3069
|
+
modal.changeLoading(loading);
|
|
3070
|
+
};
|
|
3071
|
+
const setModalProps = (props) => {
|
|
3072
|
+
const modal = getModal();
|
|
3073
|
+
if (!modal) return;
|
|
3074
|
+
modal.setModalProps(props);
|
|
3075
|
+
};
|
|
3076
|
+
const getModalProps = () => {
|
|
3077
|
+
const modal = getModal();
|
|
3078
|
+
if (!modal) return {};
|
|
3079
|
+
return modal.getModalProps();
|
|
3080
|
+
};
|
|
3081
|
+
onUnmounted(() => {
|
|
3082
|
+
modalRef.value = null;
|
|
3083
|
+
loadedRef.value = false;
|
|
3084
|
+
});
|
|
3085
|
+
return [
|
|
3086
|
+
register,
|
|
3087
|
+
{
|
|
3088
|
+
closeModal,
|
|
3089
|
+
changeOkLoading,
|
|
3090
|
+
changeLoading,
|
|
3091
|
+
setModalProps,
|
|
3092
|
+
getModalProps
|
|
3093
|
+
}
|
|
3094
|
+
];
|
|
3095
|
+
}
|
|
3096
|
+
const _hoisted_1 = { class: "basic-description" };
|
|
3097
|
+
const _hoisted_2 = {
|
|
3098
|
+
key: 0,
|
|
3099
|
+
class: "description-header"
|
|
3100
|
+
};
|
|
3101
|
+
const _hoisted_3 = { class: "description-title" };
|
|
3102
|
+
const _hoisted_4 = {
|
|
3103
|
+
key: 0,
|
|
3104
|
+
class: "description-extra"
|
|
3105
|
+
};
|
|
3106
|
+
const _hoisted_5 = { key: 1 };
|
|
3107
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3108
|
+
...{
|
|
3109
|
+
name: "BasicDescription",
|
|
3110
|
+
inheritAttrs: false
|
|
3111
|
+
},
|
|
3112
|
+
__name: "BasicDescription",
|
|
3113
|
+
props: {
|
|
3114
|
+
title: {},
|
|
3115
|
+
column: { default: 3 },
|
|
3116
|
+
schema: {},
|
|
3117
|
+
data: {},
|
|
3118
|
+
helpMessageOptions: {},
|
|
3119
|
+
labelAlign: { default: "left" },
|
|
3120
|
+
size: { default: "medium" },
|
|
3121
|
+
bordered: { type: Boolean, default: true },
|
|
3122
|
+
layout: { default: "horizontal" },
|
|
3123
|
+
colon: { type: Boolean, default: true },
|
|
3124
|
+
align: { default: "left" },
|
|
3125
|
+
style: {},
|
|
3126
|
+
class: {},
|
|
3127
|
+
extra: {}
|
|
3128
|
+
},
|
|
3129
|
+
emits: ["register"],
|
|
3130
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
3131
|
+
const props = __props;
|
|
3132
|
+
const emit = __emit;
|
|
3133
|
+
const propsRef = ref({});
|
|
3134
|
+
const RenderContent = defineComponent({
|
|
3135
|
+
props: {
|
|
3136
|
+
render: {
|
|
3137
|
+
type: Function,
|
|
3138
|
+
required: true
|
|
3139
|
+
},
|
|
3140
|
+
value: {
|
|
3141
|
+
type: [String, Number, Object, Array, Boolean],
|
|
3142
|
+
default: void 0
|
|
3143
|
+
},
|
|
3144
|
+
data: {
|
|
3145
|
+
type: Object,
|
|
3146
|
+
default: () => ({})
|
|
3147
|
+
}
|
|
3148
|
+
},
|
|
3149
|
+
setup(props2) {
|
|
3150
|
+
return () => {
|
|
3151
|
+
const result = props2.render(props2.value, props2.data);
|
|
3152
|
+
if (typeof result === "string" || typeof result === "number") {
|
|
3153
|
+
return h("span", result);
|
|
3154
|
+
}
|
|
3155
|
+
return result;
|
|
3156
|
+
};
|
|
3157
|
+
}
|
|
3158
|
+
});
|
|
3159
|
+
const getProps = computed(() => {
|
|
3160
|
+
return { ...props, ...unref(propsRef) };
|
|
3161
|
+
});
|
|
3162
|
+
const getBindValue = computed(() => {
|
|
3163
|
+
const propsData = unref(getProps);
|
|
3164
|
+
return {
|
|
3165
|
+
column: propsData.column,
|
|
3166
|
+
size: propsData.size,
|
|
3167
|
+
bordered: propsData.bordered,
|
|
3168
|
+
layout: propsData.layout,
|
|
3169
|
+
labelAlign: propsData.labelAlign,
|
|
3170
|
+
align: propsData.align,
|
|
3171
|
+
colon: propsData.colon,
|
|
3172
|
+
style: propsData.style,
|
|
3173
|
+
class: propsData.class
|
|
3174
|
+
};
|
|
3175
|
+
});
|
|
3176
|
+
const getSchema = computed(() => {
|
|
3177
|
+
const propsData = unref(getProps);
|
|
3178
|
+
const schema = propsData.schema || [];
|
|
3179
|
+
const data = propsData.data || {};
|
|
3180
|
+
return schema.filter((item) => {
|
|
3181
|
+
if (item.show && typeof item.show === "function") {
|
|
3182
|
+
return item.show(data);
|
|
3183
|
+
}
|
|
3184
|
+
return true;
|
|
3185
|
+
});
|
|
3186
|
+
});
|
|
3187
|
+
const getFieldValue = (field) => {
|
|
3188
|
+
const propsData = unref(getProps);
|
|
3189
|
+
const data = propsData.data || {};
|
|
3190
|
+
if (field.includes(".")) {
|
|
3191
|
+
return field.split(".").reduce((obj, key) => {
|
|
3192
|
+
return obj == null ? void 0 : obj[key];
|
|
3193
|
+
}, data);
|
|
3194
|
+
}
|
|
3195
|
+
return data[field];
|
|
3196
|
+
};
|
|
3197
|
+
const getLabelStyle = (item) => {
|
|
3198
|
+
const style = { ...item.labelStyle };
|
|
3199
|
+
if (item.labelMinWidth) {
|
|
3200
|
+
style.minWidth = `${item.labelMinWidth}px`;
|
|
3201
|
+
}
|
|
3202
|
+
return style;
|
|
3203
|
+
};
|
|
3204
|
+
const getContentStyle = (item) => {
|
|
3205
|
+
const style = { ...item.contentStyle };
|
|
3206
|
+
if (item.contentMinWidth) {
|
|
3207
|
+
style.minWidth = `${item.contentMinWidth}px`;
|
|
3208
|
+
}
|
|
3209
|
+
return style;
|
|
3210
|
+
};
|
|
3211
|
+
const setDescriptionProps = (descriptionProps) => {
|
|
3212
|
+
propsRef.value = { ...unref(propsRef), ...descriptionProps };
|
|
3213
|
+
};
|
|
3214
|
+
const getDescriptionProps = () => {
|
|
3215
|
+
return unref(getProps);
|
|
3216
|
+
};
|
|
3217
|
+
const descriptionMethods = {
|
|
3218
|
+
setDescriptionProps,
|
|
3219
|
+
getDescriptionProps
|
|
3220
|
+
};
|
|
3221
|
+
__expose(descriptionMethods);
|
|
3222
|
+
onMounted(() => {
|
|
3223
|
+
nextTick(() => {
|
|
3224
|
+
emit("register", descriptionMethods);
|
|
3225
|
+
});
|
|
3226
|
+
});
|
|
3227
|
+
return (_ctx, _cache) => {
|
|
3228
|
+
var _a;
|
|
3229
|
+
const _component_a_tooltip = resolveComponent("a-tooltip");
|
|
3230
|
+
const _component_a_descriptions_item = resolveComponent("a-descriptions-item");
|
|
3231
|
+
const _component_a_descriptions = resolveComponent("a-descriptions");
|
|
3232
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
3233
|
+
getProps.value.title || _ctx.$slots.title || _ctx.$slots.extra ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
3234
|
+
createElementVNode("div", _hoisted_3, [
|
|
3235
|
+
_ctx.$slots.title ? renderSlot(_ctx.$slots, "title", { key: 0 }, void 0, true) : getProps.value.title ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
3236
|
+
createElementVNode("span", null, toDisplayString(getProps.value.title), 1),
|
|
3237
|
+
((_a = getProps.value.helpMessageOptions) == null ? void 0 : _a.helpMessage) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
3238
|
+
Array.isArray(getProps.value.helpMessageOptions.helpMessage) ? (openBlock(), createBlock(_component_a_tooltip, {
|
|
3239
|
+
key: 0,
|
|
3240
|
+
position: "top"
|
|
3241
|
+
}, {
|
|
3242
|
+
content: withCtx(() => [
|
|
3243
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(getProps.value.helpMessageOptions.helpMessage, (msg, index) => {
|
|
3244
|
+
return openBlock(), createElementBlock("div", { key: index }, toDisplayString(msg), 1);
|
|
3245
|
+
}), 128))
|
|
3246
|
+
]),
|
|
3247
|
+
default: withCtx(() => [
|
|
3248
|
+
createVNode(unref(IconQuestionCircle), { class: "ml-2 cursor-help text-gray-400" })
|
|
3249
|
+
]),
|
|
3250
|
+
_: 1
|
|
3251
|
+
})) : (openBlock(), createBlock(_component_a_tooltip, {
|
|
3252
|
+
key: 1,
|
|
3253
|
+
position: "top"
|
|
3254
|
+
}, {
|
|
3255
|
+
content: withCtx(() => [
|
|
3256
|
+
createTextVNode(toDisplayString(getProps.value.helpMessageOptions.helpMessage), 1)
|
|
3257
|
+
]),
|
|
3258
|
+
default: withCtx(() => [
|
|
3259
|
+
createVNode(unref(IconQuestionCircle), { class: "ml-2 cursor-help text-gray-400" })
|
|
3260
|
+
]),
|
|
3261
|
+
_: 1
|
|
3262
|
+
}))
|
|
3263
|
+
], 64)) : createCommentVNode("", true)
|
|
3264
|
+
], 64)) : createCommentVNode("", true)
|
|
3265
|
+
]),
|
|
3266
|
+
getProps.value.extra || _ctx.$slots.extra ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
3267
|
+
_ctx.$slots.extra ? renderSlot(_ctx.$slots, "extra", { key: 0 }, void 0, true) : (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(getProps.value.extra), 1))
|
|
3268
|
+
])) : createCommentVNode("", true)
|
|
3269
|
+
])) : createCommentVNode("", true),
|
|
3270
|
+
createVNode(_component_a_descriptions, normalizeProps(guardReactiveProps(getBindValue.value)), {
|
|
3271
|
+
default: withCtx(() => [
|
|
3272
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(getSchema.value, (item) => {
|
|
3273
|
+
return openBlock(), createBlock(_component_a_descriptions_item, {
|
|
3274
|
+
key: item.field,
|
|
3275
|
+
label: item.label,
|
|
3276
|
+
span: item.span
|
|
3277
|
+
}, {
|
|
3278
|
+
label: withCtx(() => [
|
|
3279
|
+
createElementVNode("div", {
|
|
3280
|
+
style: normalizeStyle(getLabelStyle(item))
|
|
3281
|
+
}, toDisplayString(item.label), 5)
|
|
3282
|
+
]),
|
|
3283
|
+
default: withCtx(() => [
|
|
3284
|
+
createElementVNode("div", {
|
|
3285
|
+
style: normalizeStyle(getContentStyle(item))
|
|
3286
|
+
}, [
|
|
3287
|
+
item.render ? (openBlock(), createBlock(unref(RenderContent), {
|
|
3288
|
+
key: 0,
|
|
3289
|
+
render: item.render,
|
|
3290
|
+
value: getFieldValue(item.field),
|
|
3291
|
+
data: getProps.value.data || {}
|
|
3292
|
+
}, null, 8, ["render", "value", "data"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
3293
|
+
createTextVNode(toDisplayString(getFieldValue(item.field)), 1)
|
|
3294
|
+
], 64))
|
|
3295
|
+
], 4)
|
|
3296
|
+
]),
|
|
3297
|
+
_: 2
|
|
3298
|
+
}, 1032, ["label", "span"]);
|
|
3299
|
+
}), 128))
|
|
3300
|
+
]),
|
|
3301
|
+
_: 1
|
|
3302
|
+
}, 16)
|
|
3303
|
+
]);
|
|
3304
|
+
};
|
|
3305
|
+
}
|
|
3306
|
+
});
|
|
3307
|
+
const BasicDescription = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7c27763b"]]);
|
|
3308
|
+
function useDescription(props) {
|
|
3309
|
+
const descriptionRef = ref(null);
|
|
3310
|
+
const loadedRef = ref(false);
|
|
3311
|
+
const register = (descriptionInstance) => {
|
|
3312
|
+
descriptionRef.value = descriptionInstance;
|
|
3313
|
+
loadedRef.value = true;
|
|
3314
|
+
if (props && Object.keys(props).length > 0) {
|
|
3315
|
+
setDescriptionProps(props);
|
|
3316
|
+
}
|
|
3317
|
+
};
|
|
3318
|
+
const getDescription = () => {
|
|
3319
|
+
const description = unref(descriptionRef);
|
|
3320
|
+
if (!description) {
|
|
3321
|
+
throw new Error("Description 实例尚未注册,请确保组件已挂载并正确使用 @register");
|
|
3322
|
+
}
|
|
3323
|
+
return description;
|
|
3324
|
+
};
|
|
3325
|
+
const setDescriptionProps = (descriptionProps) => {
|
|
3326
|
+
try {
|
|
3327
|
+
const description = getDescription();
|
|
3328
|
+
description.setDescriptionProps(descriptionProps);
|
|
3329
|
+
} catch (error) {
|
|
3330
|
+
console.error("设置 Description Props 失败:", error);
|
|
3331
|
+
}
|
|
3332
|
+
};
|
|
3333
|
+
const getDescriptionProps = () => {
|
|
3334
|
+
try {
|
|
3335
|
+
const description = getDescription();
|
|
3336
|
+
return description.getDescriptionProps();
|
|
3337
|
+
} catch (error) {
|
|
3338
|
+
console.error("获取 Description Props 失败:", error);
|
|
3339
|
+
return {};
|
|
3340
|
+
}
|
|
3341
|
+
};
|
|
3342
|
+
return [
|
|
3343
|
+
register,
|
|
3344
|
+
{
|
|
3345
|
+
setDescriptionProps,
|
|
3346
|
+
getDescriptionProps
|
|
3347
|
+
}
|
|
3348
|
+
];
|
|
3349
|
+
}
|
|
3350
|
+
function formatDate(date, format = "YYYY-MM-DD HH:mm:ss") {
|
|
3351
|
+
const d = typeof date === "number" ? new Date(date) : date;
|
|
3352
|
+
const year = d.getFullYear();
|
|
3353
|
+
const month = String(d.getMonth() + 1).padStart(2, "0");
|
|
3354
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
3355
|
+
const hours = String(d.getHours()).padStart(2, "0");
|
|
3356
|
+
const minutes = String(d.getMinutes()).padStart(2, "0");
|
|
3357
|
+
const seconds = String(d.getSeconds()).padStart(2, "0");
|
|
3358
|
+
return format.replace("YYYY", String(year)).replace("MM", month).replace("DD", day).replace("HH", hours).replace("mm", minutes).replace("ss", seconds);
|
|
3359
|
+
}
|
|
3360
|
+
function formatNumber(num) {
|
|
3361
|
+
return num.toLocaleString("zh-CN");
|
|
3362
|
+
}
|
|
3363
|
+
function formatFileSize(bytes) {
|
|
3364
|
+
if (bytes === 0) return "0 B";
|
|
3365
|
+
const k = 1024;
|
|
3366
|
+
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
3367
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
3368
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
3369
|
+
}
|
|
3370
|
+
function isValidEmail(email) {
|
|
3371
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
3372
|
+
return emailRegex.test(email);
|
|
3373
|
+
}
|
|
3374
|
+
function isValidPhone(phone) {
|
|
3375
|
+
const phoneRegex = /^1[3-9]\d{9}$/;
|
|
3376
|
+
return phoneRegex.test(phone);
|
|
3377
|
+
}
|
|
3378
|
+
function isValidUrl(url) {
|
|
3379
|
+
try {
|
|
3380
|
+
new URL(url);
|
|
3381
|
+
return true;
|
|
3382
|
+
} catch {
|
|
3383
|
+
return false;
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
function isValidIdCard(idCard) {
|
|
3387
|
+
const idCardRegex = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/;
|
|
3388
|
+
return idCardRegex.test(idCard);
|
|
3389
|
+
}
|
|
3390
|
+
function useDebounce(value, delay = 300) {
|
|
3391
|
+
const debouncedValue = ref(value.value);
|
|
3392
|
+
let timer = null;
|
|
3393
|
+
const updateValue = (newValue) => {
|
|
3394
|
+
if (timer) {
|
|
3395
|
+
clearTimeout(timer);
|
|
3396
|
+
}
|
|
3397
|
+
timer = setTimeout(() => {
|
|
3398
|
+
debouncedValue.value = newValue;
|
|
3399
|
+
}, delay);
|
|
3400
|
+
};
|
|
3401
|
+
watch(
|
|
3402
|
+
value,
|
|
3403
|
+
(newValue) => {
|
|
3404
|
+
updateValue(newValue);
|
|
3405
|
+
},
|
|
3406
|
+
{ immediate: true }
|
|
3407
|
+
);
|
|
3408
|
+
onBeforeUnmount(() => {
|
|
3409
|
+
if (timer) {
|
|
3410
|
+
clearTimeout(timer);
|
|
3411
|
+
}
|
|
3412
|
+
});
|
|
3413
|
+
return debouncedValue;
|
|
3414
|
+
}
|
|
702
3415
|
function useToggle(initialValue = false) {
|
|
703
3416
|
const value = ref(initialValue);
|
|
704
3417
|
const toggle = () => {
|
|
@@ -713,9 +3426,14 @@ function useToggle(initialValue = false) {
|
|
|
713
3426
|
return [value, toggle, setTrue, setFalse];
|
|
714
3427
|
}
|
|
715
3428
|
export {
|
|
716
|
-
|
|
3429
|
+
BasicDescription,
|
|
3430
|
+
_sfc_main$9 as BasicForm,
|
|
3431
|
+
BasicModal,
|
|
3432
|
+
BasicTable,
|
|
717
3433
|
componentMap,
|
|
718
3434
|
createFormSchema,
|
|
3435
|
+
createTableColumns,
|
|
3436
|
+
debounce,
|
|
719
3437
|
formatDate,
|
|
720
3438
|
formatFileSize,
|
|
721
3439
|
formatNumber,
|
|
@@ -725,10 +3443,16 @@ export {
|
|
|
725
3443
|
isValidPhone,
|
|
726
3444
|
isValidUrl,
|
|
727
3445
|
mergeFormSchemas,
|
|
3446
|
+
mergeTableColumns,
|
|
728
3447
|
registerComponent,
|
|
3448
|
+
throttle,
|
|
729
3449
|
useDebounce,
|
|
3450
|
+
useDescription,
|
|
730
3451
|
useForm,
|
|
731
3452
|
useLocalStorage,
|
|
3453
|
+
useModal,
|
|
3454
|
+
useModalInner,
|
|
3455
|
+
useTable,
|
|
732
3456
|
useToggle
|
|
733
3457
|
};
|
|
734
3458
|
//# sourceMappingURL=index.esm.js.map
|