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