knt-shared 1.2.5 → 1.3.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 (44) hide show
  1. package/dist/components/Description/types.d.ts +2 -2
  2. package/dist/components/Description/types.d.ts.map +1 -1
  3. package/dist/components/Form/BasicForm.vue.d.ts +173 -0
  4. package/dist/components/Form/BasicForm.vue.d.ts.map +1 -0
  5. package/dist/components/Form/componentMap.d.ts +3 -8
  6. package/dist/components/Form/componentMap.d.ts.map +1 -1
  7. package/dist/components/Form/index.d.ts +5 -7
  8. package/dist/components/Form/index.d.ts.map +1 -1
  9. package/dist/components/Form/types.d.ts +11 -4
  10. package/dist/components/Form/types.d.ts.map +1 -1
  11. package/dist/components/Table/BasicTable.vue.d.ts +20 -0
  12. package/dist/components/Table/BasicTable.vue.d.ts.map +1 -1
  13. package/dist/components/Table/components/EditCell.vue.d.ts +45 -0
  14. package/dist/components/Table/components/EditCell.vue.d.ts.map +1 -0
  15. package/dist/components/Table/components/componentMap.d.ts +1299 -0
  16. package/dist/components/Table/components/componentMap.d.ts.map +1 -0
  17. package/dist/components/Table/hooks/useEditValidation.d.ts +18 -0
  18. package/dist/components/Table/hooks/useEditValidation.d.ts.map +1 -0
  19. package/dist/components/Table/hooks/useTableEdit.d.ts +27 -0
  20. package/dist/components/Table/hooks/useTableEdit.d.ts.map +1 -0
  21. package/dist/components/Table/index.d.ts +2 -2
  22. package/dist/components/Table/index.d.ts.map +1 -1
  23. package/dist/components/Table/types.d.ts +120 -6
  24. package/dist/components/Table/types.d.ts.map +1 -1
  25. package/dist/components/Table/useTable.d.ts.map +1 -1
  26. package/dist/components/TextEllipsis/BasicTextEllipsis.vue.d.ts +43 -0
  27. package/dist/components/TextEllipsis/BasicTextEllipsis.vue.d.ts.map +1 -0
  28. package/dist/components/TextEllipsis/index.d.ts +6 -0
  29. package/dist/components/TextEllipsis/index.d.ts.map +1 -0
  30. package/dist/components/TextEllipsis/types.d.ts +18 -0
  31. package/dist/components/TextEllipsis/types.d.ts.map +1 -0
  32. package/dist/components/Upload/BasicUpload.vue.d.ts +1 -1
  33. package/dist/components/Upload/types.d.ts +3 -3
  34. package/dist/components/Upload/types.d.ts.map +1 -1
  35. package/dist/components/index.d.ts +1 -0
  36. package/dist/components/index.d.ts.map +1 -1
  37. package/dist/index.cjs.js +1072 -279
  38. package/dist/index.cjs.js.map +1 -1
  39. package/dist/index.esm.js +1072 -279
  40. package/dist/index.esm.js.map +1 -1
  41. package/dist/style.css +52 -31
  42. package/dist/types/global.d.ts +2 -2
  43. package/dist/types/global.d.ts.map +1 -1
  44. package/package.json +2 -2
package/dist/index.esm.js CHANGED
@@ -22,7 +22,7 @@ var _export_sfc$1 = (sfc, props) => {
22
22
  }
23
23
  return sfc;
24
24
  };
25
- const _sfc_main$c = defineComponent({
25
+ const _sfc_main$e = defineComponent({
26
26
  name: "IconPlus",
27
27
  props: {
28
28
  size: {
@@ -75,7 +75,7 @@ const _sfc_main$c = defineComponent({
75
75
  };
76
76
  }
77
77
  });
78
- const _hoisted_1$b = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
78
+ const _hoisted_1$d = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
79
79
  function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
80
80
  return openBlock(), createElementBlock("svg", {
81
81
  viewBox: "0 0 48 48",
@@ -90,9 +90,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
90
90
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
91
91
  }, _cache[1] || (_cache[1] = [
92
92
  createElementVNode("path", { d: "M5 24h38M24 5v38" }, null, -1)
93
- ]), 14, _hoisted_1$b);
93
+ ]), 14, _hoisted_1$d);
94
94
  }
95
- var _IconPlus = /* @__PURE__ */ _export_sfc$1(_sfc_main$c, [["render", _sfc_render$7]]);
95
+ var _IconPlus = /* @__PURE__ */ _export_sfc$1(_sfc_main$e, [["render", _sfc_render$7]]);
96
96
  const IconPlus = Object.assign(_IconPlus, {
97
97
  install: (app, options) => {
98
98
  var _a;
@@ -100,7 +100,7 @@ const IconPlus = Object.assign(_IconPlus, {
100
100
  app.component(iconPrefix + _IconPlus.name, _IconPlus);
101
101
  }
102
102
  });
103
- const _sfc_main$b = defineComponent({
103
+ const _sfc_main$d = defineComponent({
104
104
  name: "IconQuestionCircle",
105
105
  props: {
106
106
  size: {
@@ -153,7 +153,7 @@ const _sfc_main$b = defineComponent({
153
153
  };
154
154
  }
155
155
  });
156
- const _hoisted_1$a = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
156
+ const _hoisted_1$c = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
157
157
  function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
158
158
  return openBlock(), createElementBlock("svg", {
159
159
  viewBox: "0 0 48 48",
@@ -169,9 +169,9 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
169
169
  }, _cache[1] || (_cache[1] = [
170
170
  createElementVNode("path", { d: "M42 24c0 9.941-8.059 18-18 18S6 33.941 6 24 14.059 6 24 6s18 8.059 18 18Z" }, null, -1),
171
171
  createElementVNode("path", { d: "M24.006 31v4.008m0-6.008L24 28c0-3 3-4 4.78-6.402C30.558 19.195 28.288 15 23.987 15c-4.014 0-5.382 2.548-5.388 4.514v.465" }, null, -1)
172
- ]), 14, _hoisted_1$a);
172
+ ]), 14, _hoisted_1$c);
173
173
  }
174
- var _IconQuestionCircle = /* @__PURE__ */ _export_sfc$1(_sfc_main$b, [["render", _sfc_render$6]]);
174
+ var _IconQuestionCircle = /* @__PURE__ */ _export_sfc$1(_sfc_main$d, [["render", _sfc_render$6]]);
175
175
  const IconQuestionCircle = Object.assign(_IconQuestionCircle, {
176
176
  install: (app, options) => {
177
177
  var _a;
@@ -179,7 +179,7 @@ const IconQuestionCircle = Object.assign(_IconQuestionCircle, {
179
179
  app.component(iconPrefix + _IconQuestionCircle.name, _IconQuestionCircle);
180
180
  }
181
181
  });
182
- const _sfc_main$a = defineComponent({
182
+ const _sfc_main$c = defineComponent({
183
183
  name: "IconRefresh",
184
184
  props: {
185
185
  size: {
@@ -232,7 +232,7 @@ const _sfc_main$a = defineComponent({
232
232
  };
233
233
  }
234
234
  });
235
- const _hoisted_1$9 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
235
+ const _hoisted_1$b = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
236
236
  function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
237
237
  return openBlock(), createElementBlock("svg", {
238
238
  viewBox: "0 0 48 48",
@@ -247,9 +247,9 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
247
247
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
248
248
  }, _cache[1] || (_cache[1] = [
249
249
  createElementVNode("path", { d: "M38.837 18C36.463 12.136 30.715 8 24 8 15.163 8 8 15.163 8 24s7.163 16 16 16c7.455 0 13.72-5.1 15.496-12M40 8v10H30" }, null, -1)
250
- ]), 14, _hoisted_1$9);
250
+ ]), 14, _hoisted_1$b);
251
251
  }
252
- var _IconRefresh = /* @__PURE__ */ _export_sfc$1(_sfc_main$a, [["render", _sfc_render$5]]);
252
+ var _IconRefresh = /* @__PURE__ */ _export_sfc$1(_sfc_main$c, [["render", _sfc_render$5]]);
253
253
  const IconRefresh = Object.assign(_IconRefresh, {
254
254
  install: (app, options) => {
255
255
  var _a;
@@ -257,7 +257,7 @@ const IconRefresh = Object.assign(_IconRefresh, {
257
257
  app.component(iconPrefix + _IconRefresh.name, _IconRefresh);
258
258
  }
259
259
  });
260
- const _sfc_main$9 = defineComponent({
260
+ const _sfc_main$b = defineComponent({
261
261
  name: "IconSettings",
262
262
  props: {
263
263
  size: {
@@ -310,7 +310,7 @@ const _sfc_main$9 = defineComponent({
310
310
  };
311
311
  }
312
312
  });
313
- const _hoisted_1$8 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
313
+ const _hoisted_1$a = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
314
314
  function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
315
315
  return openBlock(), createElementBlock("svg", {
316
316
  viewBox: "0 0 48 48",
@@ -326,9 +326,9 @@ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
326
326
  }, _cache[1] || (_cache[1] = [
327
327
  createElementVNode("path", { d: "M18.797 6.732A1 1 0 0 1 19.76 6h8.48a1 1 0 0 1 .964.732l1.285 4.628a1 1 0 0 0 1.213.7l4.651-1.2a1 1 0 0 1 1.116.468l4.24 7.344a1 1 0 0 1-.153 1.2L38.193 23.3a1 1 0 0 0 0 1.402l3.364 3.427a1 1 0 0 1 .153 1.2l-4.24 7.344a1 1 0 0 1-1.116.468l-4.65-1.2a1 1 0 0 0-1.214.7l-1.285 4.628a1 1 0 0 1-.964.732h-8.48a1 1 0 0 1-.963-.732L17.51 36.64a1 1 0 0 0-1.213-.7l-4.65 1.2a1 1 0 0 1-1.116-.468l-4.24-7.344a1 1 0 0 1 .153-1.2L9.809 24.7a1 1 0 0 0 0-1.402l-3.364-3.427a1 1 0 0 1-.153-1.2l4.24-7.344a1 1 0 0 1 1.116-.468l4.65 1.2a1 1 0 0 0 1.213-.7l1.286-4.628Z" }, null, -1),
328
328
  createElementVNode("path", { d: "M30 24a6 6 0 1 1-12 0 6 6 0 0 1 12 0Z" }, null, -1)
329
- ]), 14, _hoisted_1$8);
329
+ ]), 14, _hoisted_1$a);
330
330
  }
331
- var _IconSettings = /* @__PURE__ */ _export_sfc$1(_sfc_main$9, [["render", _sfc_render$4]]);
331
+ var _IconSettings = /* @__PURE__ */ _export_sfc$1(_sfc_main$b, [["render", _sfc_render$4]]);
332
332
  const IconSettings = Object.assign(_IconSettings, {
333
333
  install: (app, options) => {
334
334
  var _a;
@@ -336,7 +336,7 @@ const IconSettings = Object.assign(_IconSettings, {
336
336
  app.component(iconPrefix + _IconSettings.name, _IconSettings);
337
337
  }
338
338
  });
339
- const _sfc_main$8 = defineComponent({
339
+ const _sfc_main$a = defineComponent({
340
340
  name: "IconUpload",
341
341
  props: {
342
342
  size: {
@@ -389,7 +389,7 @@ const _sfc_main$8 = defineComponent({
389
389
  };
390
390
  }
391
391
  });
392
- const _hoisted_1$7 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
392
+ const _hoisted_1$9 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
393
393
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
394
394
  return openBlock(), createElementBlock("svg", {
395
395
  viewBox: "0 0 48 48",
@@ -404,9 +404,9 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
404
404
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
405
405
  }, _cache[1] || (_cache[1] = [
406
406
  createElementVNode("path", { d: "M14.93 17.071 24.001 8l9.071 9.071m-9.07 16.071v-25M40 35v6H8v-6" }, null, -1)
407
- ]), 14, _hoisted_1$7);
407
+ ]), 14, _hoisted_1$9);
408
408
  }
409
- var _IconUpload = /* @__PURE__ */ _export_sfc$1(_sfc_main$8, [["render", _sfc_render$3]]);
409
+ var _IconUpload = /* @__PURE__ */ _export_sfc$1(_sfc_main$a, [["render", _sfc_render$3]]);
410
410
  const IconUpload = Object.assign(_IconUpload, {
411
411
  install: (app, options) => {
412
412
  var _a;
@@ -414,7 +414,7 @@ const IconUpload = Object.assign(_IconUpload, {
414
414
  app.component(iconPrefix + _IconUpload.name, _IconUpload);
415
415
  }
416
416
  });
417
- const _sfc_main$7 = defineComponent({
417
+ const _sfc_main$9 = defineComponent({
418
418
  name: "IconLineHeight",
419
419
  props: {
420
420
  size: {
@@ -467,7 +467,7 @@ const _sfc_main$7 = defineComponent({
467
467
  };
468
468
  }
469
469
  });
470
- const _hoisted_1$6 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
470
+ const _hoisted_1$8 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
471
471
  function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
472
472
  return openBlock(), createElementBlock("svg", {
473
473
  viewBox: "0 0 48 48",
@@ -488,9 +488,9 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
488
488
  stroke: "none"
489
489
  }, null, -1),
490
490
  createElementVNode("path", { d: "M39 13h2l-2-3.5-2 3.5h2Zm0 0v22m0 0h2l-2 3.5-2-3.5h2Z" }, null, -1)
491
- ]), 14, _hoisted_1$6);
491
+ ]), 14, _hoisted_1$8);
492
492
  }
493
- var _IconLineHeight = /* @__PURE__ */ _export_sfc$1(_sfc_main$7, [["render", _sfc_render$2]]);
493
+ var _IconLineHeight = /* @__PURE__ */ _export_sfc$1(_sfc_main$9, [["render", _sfc_render$2]]);
494
494
  const IconLineHeight = Object.assign(_IconLineHeight, {
495
495
  install: (app, options) => {
496
496
  var _a;
@@ -498,7 +498,7 @@ const IconLineHeight = Object.assign(_IconLineHeight, {
498
498
  app.component(iconPrefix + _IconLineHeight.name, _IconLineHeight);
499
499
  }
500
500
  });
501
- const _sfc_main$6 = defineComponent({
501
+ const _sfc_main$8 = defineComponent({
502
502
  name: "IconFullscreenExit",
503
503
  props: {
504
504
  size: {
@@ -551,7 +551,7 @@ const _sfc_main$6 = defineComponent({
551
551
  };
552
552
  }
553
553
  });
554
- const _hoisted_1$5 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
554
+ const _hoisted_1$7 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
555
555
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
556
556
  return openBlock(), createElementBlock("svg", {
557
557
  viewBox: "0 0 48 48",
@@ -566,9 +566,9 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
566
566
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
567
567
  }, _cache[1] || (_cache[1] = [
568
568
  createElementVNode("path", { d: "M35 6v8a1 1 0 0 0 1 1h8M13 6v8a1 1 0 0 1-1 1H4m31 27v-8a1 1 0 0 1 1-1h8m-31 9v-8a1 1 0 0 0-1-1H4" }, null, -1)
569
- ]), 14, _hoisted_1$5);
569
+ ]), 14, _hoisted_1$7);
570
570
  }
571
- var _IconFullscreenExit = /* @__PURE__ */ _export_sfc$1(_sfc_main$6, [["render", _sfc_render$1]]);
571
+ var _IconFullscreenExit = /* @__PURE__ */ _export_sfc$1(_sfc_main$8, [["render", _sfc_render$1]]);
572
572
  const IconFullscreenExit = Object.assign(_IconFullscreenExit, {
573
573
  install: (app, options) => {
574
574
  var _a;
@@ -576,7 +576,7 @@ const IconFullscreenExit = Object.assign(_IconFullscreenExit, {
576
576
  app.component(iconPrefix + _IconFullscreenExit.name, _IconFullscreenExit);
577
577
  }
578
578
  });
579
- const _sfc_main$5 = defineComponent({
579
+ const _sfc_main$7 = defineComponent({
580
580
  name: "IconFullscreen",
581
581
  props: {
582
582
  size: {
@@ -629,7 +629,7 @@ const _sfc_main$5 = defineComponent({
629
629
  };
630
630
  }
631
631
  });
632
- const _hoisted_1$4 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
632
+ const _hoisted_1$6 = ["stroke-width", "stroke-linecap", "stroke-linejoin"];
633
633
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
634
634
  return openBlock(), createElementBlock("svg", {
635
635
  viewBox: "0 0 48 48",
@@ -644,9 +644,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
644
644
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args))
645
645
  }, _cache[1] || (_cache[1] = [
646
646
  createElementVNode("path", { d: "M42 17V9a1 1 0 0 0-1-1h-8M6 17V9a1 1 0 0 1 1-1h8m27 23v8a1 1 0 0 1-1 1h-8M6 31v8a1 1 0 0 0 1 1h8" }, null, -1)
647
- ]), 14, _hoisted_1$4);
647
+ ]), 14, _hoisted_1$6);
648
648
  }
649
- var _IconFullscreen = /* @__PURE__ */ _export_sfc$1(_sfc_main$5, [["render", _sfc_render]]);
649
+ var _IconFullscreen = /* @__PURE__ */ _export_sfc$1(_sfc_main$7, [["render", _sfc_render]]);
650
650
  const IconFullscreen = Object.assign(_IconFullscreen, {
651
651
  install: (app, options) => {
652
652
  var _a;
@@ -654,13 +654,13 @@ const IconFullscreen = Object.assign(_IconFullscreen, {
654
654
  app.component(iconPrefix + _IconFullscreen.name, _IconFullscreen);
655
655
  }
656
656
  });
657
- const _hoisted_1$3 = { class: "basic-upload" };
658
- const _hoisted_2$3 = {
657
+ const _hoisted_1$5 = { class: "basic-upload" };
658
+ const _hoisted_2$4 = {
659
659
  key: 0,
660
660
  class: "upload-text"
661
661
  };
662
662
  const _hoisted_3$2 = { class: "upload-tip" };
663
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
663
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
664
664
  ...{
665
665
  name: "BasicUpload",
666
666
  inheritAttrs: false
@@ -709,7 +709,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
709
709
  emits: ["register", "update:modelValue", "change", "success", "handleSuccess", "error", "handlError", "progress", "remove", "preview", "exceed"],
710
710
  setup(__props, { expose: __expose, emit: __emit }) {
711
711
  useCssVars((_ctx) => ({
712
- "v43e7547c": cardSizeValue.value
712
+ "f530bac6": cardSizeValue.value
713
713
  }));
714
714
  const props = __props;
715
715
  const emit = __emit;
@@ -941,7 +941,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
941
941
  fileListRef.value = fileList;
942
942
  emit("change", fileList);
943
943
  const isRemove = newLength < oldLength;
944
- const fileKey = currentFile.uid;
944
+ const fileKey = currentFile.uid || `file-${Date.now()}-${Math.random()}`;
945
945
  const lastStatus = processedFiles.value.get(fileKey);
946
946
  if (currentFile.status === "done" && lastStatus !== "done" && !isRemove) {
947
947
  processedFiles.value.set(fileKey, "done");
@@ -1104,7 +1104,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1104
1104
  return (_ctx, _cache) => {
1105
1105
  const _component_a_button = resolveComponent("a-button");
1106
1106
  const _component_a_upload = resolveComponent("a-upload");
1107
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
1107
+ return openBlock(), createElementBlock("div", _hoisted_1$5, [
1108
1108
  createVNode(_component_a_upload, mergeProps({
1109
1109
  ref_key: "uploadRef",
1110
1110
  ref: uploadRef
@@ -1129,7 +1129,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1129
1129
  })
1130
1130
  }, [
1131
1131
  createVNode(unref(IconPlus), { size: 16 }),
1132
- getProps.value.uploadButtonText ? (openBlock(), createElementBlock("div", _hoisted_2$3, toDisplayString(getProps.value.uploadButtonText), 1)) : createCommentVNode("", true)
1132
+ getProps.value.uploadButtonText ? (openBlock(), createElementBlock("div", _hoisted_2$4, toDisplayString(getProps.value.uploadButtonText), 1)) : createCommentVNode("", true)
1133
1133
  ], 4)) : (openBlock(), createBlock(_component_a_button, {
1134
1134
  key: 1,
1135
1135
  type: getProps.value.uploadButtonType || "primary"
@@ -1181,7 +1181,103 @@ const _export_sfc = (sfc, props) => {
1181
1181
  }
1182
1182
  return target;
1183
1183
  };
1184
- const BasicUpload = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-00569ecd"]]);
1184
+ const BasicUpload = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-03d56780"]]);
1185
+ function useUpload(props) {
1186
+ const uploadRef = ref(null);
1187
+ const fileListRef = ref((props == null ? void 0 : props.defaultFileList) || []);
1188
+ const register = (uploadInstance) => {
1189
+ uploadRef.value = uploadInstance;
1190
+ if ((props == null ? void 0 : props.defaultFileList) && props.defaultFileList.length > 0) {
1191
+ uploadInstance.setFileList(props.defaultFileList);
1192
+ }
1193
+ if (props && Object.keys(props).length > 0) {
1194
+ const { defaultFileList, ...restProps } = props;
1195
+ if (Object.keys(restProps).length > 0) {
1196
+ setProps(restProps);
1197
+ }
1198
+ }
1199
+ };
1200
+ const getUpload = () => {
1201
+ const upload2 = unref(uploadRef);
1202
+ if (!upload2) {
1203
+ throw new Error('Upload 实例未注册,请确保在组件上使用 @register="register"');
1204
+ }
1205
+ return upload2;
1206
+ };
1207
+ const submit = () => {
1208
+ getUpload().submit();
1209
+ };
1210
+ const abort = (fileItem) => {
1211
+ getUpload().abort(fileItem);
1212
+ };
1213
+ const clearFiles = () => {
1214
+ getUpload().clearFiles();
1215
+ fileListRef.value = [];
1216
+ };
1217
+ const getFileList = () => {
1218
+ return getUpload().getFileList();
1219
+ };
1220
+ const upload = (fileItem) => {
1221
+ getUpload().upload(fileItem);
1222
+ };
1223
+ const setFileList = (files) => {
1224
+ fileListRef.value = files;
1225
+ const upload2 = getUpload();
1226
+ if (upload2.setFileList) {
1227
+ upload2.setFileList(files);
1228
+ }
1229
+ };
1230
+ const addFile = (file) => {
1231
+ fileListRef.value.push(file);
1232
+ const upload2 = getUpload();
1233
+ if (upload2.addFile) {
1234
+ upload2.addFile(file);
1235
+ }
1236
+ };
1237
+ const removeFile = (fileItem) => {
1238
+ const index = fileListRef.value.findIndex(
1239
+ (item) => item.uid === fileItem.uid
1240
+ );
1241
+ if (index !== -1) {
1242
+ fileListRef.value.splice(index, 1);
1243
+ }
1244
+ const upload2 = getUpload();
1245
+ if (upload2.removeFile) {
1246
+ upload2.removeFile(fileItem);
1247
+ }
1248
+ };
1249
+ const updateFile = (fileItem) => {
1250
+ const index = fileListRef.value.findIndex(
1251
+ (item) => item.uid === fileItem.uid
1252
+ );
1253
+ if (index !== -1) {
1254
+ fileListRef.value[index] = { ...fileListRef.value[index], ...fileItem };
1255
+ }
1256
+ const upload2 = getUpload();
1257
+ if (upload2.updateFile) {
1258
+ upload2.updateFile(fileItem);
1259
+ }
1260
+ };
1261
+ const setProps = (uploadProps) => {
1262
+ getUpload().setProps(uploadProps);
1263
+ };
1264
+ const methods = {
1265
+ get fileList() {
1266
+ return fileListRef.value;
1267
+ },
1268
+ submit,
1269
+ abort,
1270
+ upload,
1271
+ clearFiles,
1272
+ getFileList,
1273
+ setFileList,
1274
+ addFile,
1275
+ removeFile,
1276
+ updateFile,
1277
+ setProps
1278
+ };
1279
+ return [register, methods];
1280
+ }
1185
1281
  const componentMap = {
1186
1282
  Input,
1187
1283
  InputNumber,
@@ -1255,7 +1351,7 @@ function getRules(component, label) {
1255
1351
  }
1256
1352
  return [{ required: true, message: `请选择${label}` }];
1257
1353
  }
1258
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1354
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1259
1355
  ...{
1260
1356
  name: "BasicForm",
1261
1357
  inheritAttrs: false
@@ -1388,6 +1484,29 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1388
1484
  const componentType = typeof schema.component === "string" ? schema.component : "";
1389
1485
  return getPlaceholder(componentType, schema.label);
1390
1486
  };
1487
+ const shouldRenderCustomLabel = (schema) => {
1488
+ return !!(schema.labelEllipsis || schema.labelTooltip);
1489
+ };
1490
+ const getLabelStyle = (schema) => {
1491
+ if (!schema.labelEllipsis) {
1492
+ return {};
1493
+ }
1494
+ const maxWidth = schema.labelMaxWidth || "150px";
1495
+ return {
1496
+ display: "inline-block",
1497
+ maxWidth: typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth,
1498
+ overflow: "hidden",
1499
+ textOverflow: "ellipsis",
1500
+ whiteSpace: "nowrap",
1501
+ verticalAlign: "middle"
1502
+ };
1503
+ };
1504
+ const getLabelTooltipContent = (schema) => {
1505
+ if (typeof schema.labelTooltip === "string") {
1506
+ return schema.labelTooltip;
1507
+ }
1508
+ return schema.label;
1509
+ };
1391
1510
  const handleSubmit = async (data) => {
1392
1511
  try {
1393
1512
  submitLoading.value = true;
@@ -1551,6 +1670,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1551
1670
  dynamicProps.value = {};
1552
1671
  });
1553
1672
  return (_ctx, _cache) => {
1673
+ const _component_a_tooltip = resolveComponent("a-tooltip");
1554
1674
  const _component_a_form_item = resolveComponent("a-form-item");
1555
1675
  const _component_a_col = resolveComponent("a-col");
1556
1676
  const _component_a_button = resolveComponent("a-button");
@@ -1578,7 +1698,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1578
1698
  schema.render ? (openBlock(), createBlock(resolveDynamicComponent(schema.render(schema, formModel)), { key: 0 })) : (openBlock(), createBlock(_component_a_form_item, mergeProps({
1579
1699
  key: 1,
1580
1700
  ref_for: true
1581
- }, getFormItemBindValue(schema)), {
1701
+ }, getFormItemBindValue(schema)), createSlots({
1582
1702
  default: withCtx(() => [
1583
1703
  schema.slotName ? renderSlot(_ctx.$slots, schema.slotName, {
1584
1704
  key: 0,
@@ -1592,7 +1712,28 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1592
1712
  }, { ref_for: true }, schema.componentProps), null, 16, ["modelValue", "onUpdate:modelValue", "placeholder"]))
1593
1713
  ]),
1594
1714
  _: 2
1595
- }, 1040))
1715
+ }, [
1716
+ shouldRenderCustomLabel(schema) ? {
1717
+ name: "label",
1718
+ fn: withCtx(() => [
1719
+ schema.labelTooltip ? (openBlock(), createBlock(_component_a_tooltip, {
1720
+ key: 0,
1721
+ content: getLabelTooltipContent(schema)
1722
+ }, {
1723
+ default: withCtx(() => [
1724
+ createElementVNode("span", {
1725
+ style: normalizeStyle(getLabelStyle(schema))
1726
+ }, toDisplayString(schema.label), 5)
1727
+ ]),
1728
+ _: 2
1729
+ }, 1032, ["content"])) : (openBlock(), createElementBlock("span", {
1730
+ key: 1,
1731
+ style: normalizeStyle(getLabelStyle(schema))
1732
+ }, toDisplayString(schema.label), 5))
1733
+ ]),
1734
+ key: "0"
1735
+ } : void 0
1736
+ ]), 1040))
1596
1737
  ]),
1597
1738
  _: 2
1598
1739
  }, 1040, ["data-field"]);
@@ -1909,69 +2050,635 @@ function debounce(func, wait = 300, immediate = false) {
1909
2050
  if (callNow) {
1910
2051
  func.apply(context, args);
1911
2052
  }
1912
- };
1913
- debounced.cancel = () => {
1914
- if (timeout) {
1915
- clearTimeout(timeout);
1916
- timeout = null;
2053
+ };
2054
+ debounced.cancel = () => {
2055
+ if (timeout) {
2056
+ clearTimeout(timeout);
2057
+ timeout = null;
2058
+ }
2059
+ };
2060
+ return debounced;
2061
+ }
2062
+ function throttle(func, wait = 300) {
2063
+ let timeout = null;
2064
+ let previous = 0;
2065
+ return function(...args) {
2066
+ const context = this;
2067
+ const now = Date.now();
2068
+ const remaining = wait - (now - previous);
2069
+ if (remaining <= 0 || remaining > wait) {
2070
+ if (timeout) {
2071
+ clearTimeout(timeout);
2072
+ timeout = null;
2073
+ }
2074
+ previous = now;
2075
+ func.apply(context, args);
2076
+ } else if (!timeout) {
2077
+ timeout = setTimeout(() => {
2078
+ previous = Date.now();
2079
+ timeout = null;
2080
+ func.apply(context, args);
2081
+ }, remaining);
2082
+ }
2083
+ };
2084
+ }
2085
+ const _hoisted_1$4 = { class: "basic-text-ellipsis" };
2086
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
2087
+ __name: "BasicTextEllipsis",
2088
+ props: {
2089
+ text: { default: "" },
2090
+ lines: { default: 1 },
2091
+ tooltip: { type: Boolean, default: true },
2092
+ tooltipTrigger: { default: "hover" },
2093
+ tooltipProps: { default: () => ({}) },
2094
+ alwaysShowTooltip: { type: Boolean, default: false }
2095
+ },
2096
+ setup(__props) {
2097
+ const props = __props;
2098
+ const textRef = ref();
2099
+ const isTruncated = ref(false);
2100
+ let resizeObserver = null;
2101
+ const ellipsisStyle = computed(() => {
2102
+ if (props.lines === 1) {
2103
+ return {
2104
+ overflow: "hidden",
2105
+ textOverflow: "ellipsis",
2106
+ whiteSpace: "nowrap"
2107
+ };
2108
+ }
2109
+ return {
2110
+ display: "-webkit-box",
2111
+ "-webkit-box-orient": "vertical",
2112
+ "-webkit-line-clamp": props.lines,
2113
+ overflow: "hidden",
2114
+ textOverflow: "ellipsis",
2115
+ wordBreak: "break-word"
2116
+ };
2117
+ });
2118
+ const showTooltip = computed(() => {
2119
+ if (!props.tooltip) {
2120
+ return false;
2121
+ }
2122
+ if (props.alwaysShowTooltip) {
2123
+ return true;
2124
+ }
2125
+ return isTruncated.value;
2126
+ });
2127
+ const checkTruncation = () => {
2128
+ if (!textRef.value) {
2129
+ return;
2130
+ }
2131
+ const element = textRef.value;
2132
+ if (props.lines === 1) {
2133
+ isTruncated.value = element.scrollWidth > element.clientWidth;
2134
+ } else {
2135
+ isTruncated.value = element.scrollHeight > element.clientHeight;
2136
+ }
2137
+ };
2138
+ const debouncedCheck = debounce(checkTruncation, 100);
2139
+ const initResizeObserver = () => {
2140
+ if (!textRef.value) {
2141
+ return;
2142
+ }
2143
+ resizeObserver = new ResizeObserver(() => {
2144
+ debouncedCheck();
2145
+ });
2146
+ resizeObserver.observe(textRef.value);
2147
+ };
2148
+ const cleanupResizeObserver = () => {
2149
+ if (resizeObserver) {
2150
+ resizeObserver.disconnect();
2151
+ resizeObserver = null;
2152
+ }
2153
+ debouncedCheck.cancel();
2154
+ };
2155
+ onMounted(() => {
2156
+ nextTick(() => {
2157
+ checkTruncation();
2158
+ initResizeObserver();
2159
+ });
2160
+ });
2161
+ onBeforeUnmount(() => {
2162
+ cleanupResizeObserver();
2163
+ });
2164
+ watch(
2165
+ () => [props.text, props.lines],
2166
+ () => {
2167
+ nextTick(() => {
2168
+ checkTruncation();
2169
+ });
2170
+ }
2171
+ );
2172
+ return (_ctx, _cache) => {
2173
+ const _component_a_tooltip = resolveComponent("a-tooltip");
2174
+ return openBlock(), createElementBlock("div", _hoisted_1$4, [
2175
+ showTooltip.value ? (openBlock(), createBlock(_component_a_tooltip, mergeProps({
2176
+ key: 0,
2177
+ content: __props.text,
2178
+ trigger: __props.tooltipTrigger
2179
+ }, __props.tooltipProps), {
2180
+ default: withCtx(() => [
2181
+ createElementVNode("div", {
2182
+ ref_key: "textRef",
2183
+ ref: textRef,
2184
+ class: "text-ellipsis-content",
2185
+ style: normalizeStyle(ellipsisStyle.value)
2186
+ }, toDisplayString(__props.text), 5)
2187
+ ]),
2188
+ _: 1
2189
+ }, 16, ["content", "trigger"])) : (openBlock(), createElementBlock("div", {
2190
+ key: 1,
2191
+ ref_key: "textRef",
2192
+ ref: textRef,
2193
+ class: "text-ellipsis-content",
2194
+ style: normalizeStyle(ellipsisStyle.value)
2195
+ }, toDisplayString(__props.text), 5))
2196
+ ]);
2197
+ };
2198
+ }
2199
+ });
2200
+ const BasicTextEllipsis = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-05b93f77"]]);
2201
+ function useLocalStorage(key, initialValue) {
2202
+ let initialStoredValue;
2203
+ try {
2204
+ const item = window.localStorage.getItem(key);
2205
+ initialStoredValue = item ? JSON.parse(item) : initialValue;
2206
+ } catch (error) {
2207
+ console.error(`Error reading localStorage key "${key}":`, error);
2208
+ initialStoredValue = initialValue;
2209
+ }
2210
+ const storedValue = ref(initialStoredValue);
2211
+ const setValue = (value) => {
2212
+ try {
2213
+ const valueToStore = value instanceof Function ? value(storedValue.value) : value;
2214
+ storedValue.value = valueToStore;
2215
+ window.localStorage.setItem(key, JSON.stringify(valueToStore));
2216
+ } catch (error) {
2217
+ console.error(`Error setting localStorage key "${key}":`, error);
2218
+ }
2219
+ };
2220
+ watch(
2221
+ storedValue,
2222
+ (newValue) => {
2223
+ try {
2224
+ window.localStorage.setItem(key, JSON.stringify(newValue));
2225
+ } catch (error) {
2226
+ console.error(`Error syncing localStorage key "${key}":`, error);
2227
+ }
2228
+ },
2229
+ { deep: true }
2230
+ );
2231
+ return [storedValue, setValue];
2232
+ }
2233
+ const editComponentMap = {
2234
+ ...componentMap
2235
+ // 可以添加 Table 专用的编辑组件
2236
+ };
2237
+ function getEditComponent(name) {
2238
+ if (typeof name === "string") {
2239
+ return editComponentMap[name];
2240
+ }
2241
+ return name;
2242
+ }
2243
+ const _hoisted_1$3 = { class: "edit-cell" };
2244
+ const _hoisted_2$3 = {
2245
+ key: 0,
2246
+ class: "edit-cell-error"
2247
+ };
2248
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2249
+ ...{
2250
+ name: "EditCell"
2251
+ },
2252
+ __name: "EditCell",
2253
+ props: {
2254
+ column: {},
2255
+ record: {},
2256
+ value: {},
2257
+ size: { default: "small" },
2258
+ error: {}
2259
+ },
2260
+ emits: ["change"],
2261
+ setup(__props, { emit: __emit }) {
2262
+ const props = __props;
2263
+ const emit = __emit;
2264
+ const editComponent = computed(() => {
2265
+ if (!props.column.editComponent) {
2266
+ return getEditComponent("Input");
2267
+ }
2268
+ return getEditComponent(props.column.editComponent);
2269
+ });
2270
+ const componentProps = computed(() => {
2271
+ let baseProps = {
2272
+ placeholder: `请输入${props.column.title || ""}`
2273
+ };
2274
+ if (props.column.editComponentProps) {
2275
+ if (typeof props.column.editComponentProps === "function") {
2276
+ const dynamicProps = props.column.editComponentProps(props.record);
2277
+ baseProps = { ...baseProps, ...dynamicProps };
2278
+ } else {
2279
+ baseProps = { ...baseProps, ...props.column.editComponentProps };
2280
+ }
2281
+ }
2282
+ return baseProps;
2283
+ });
2284
+ const handleChange = (value) => {
2285
+ emit("change", value);
2286
+ };
2287
+ return (_ctx, _cache) => {
2288
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
2289
+ (openBlock(), createBlock(resolveDynamicComponent(editComponent.value), mergeProps(componentProps.value, {
2290
+ "model-value": __props.value,
2291
+ "onUpdate:modelValue": handleChange,
2292
+ size: __props.size,
2293
+ status: __props.error ? "error" : void 0,
2294
+ class: "edit-cell-input"
2295
+ }), null, 16, ["model-value", "size", "status"])),
2296
+ __props.error ? (openBlock(), createElementBlock("div", _hoisted_2$3, toDisplayString(__props.error), 1)) : createCommentVNode("", true)
2297
+ ]);
2298
+ };
2299
+ }
2300
+ });
2301
+ const EditCell = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-3dab69d1"]]);
2302
+ function useEditValidation() {
2303
+ const validateField = async (value, column, record) => {
2304
+ if (!column.editRule) {
2305
+ return { valid: true };
2306
+ }
2307
+ const rules = Array.isArray(column.editRule) ? column.editRule : [column.editRule];
2308
+ for (const rule of rules) {
2309
+ const result = await validateSingleRule(value, rule, column, record);
2310
+ if (!result.valid) {
2311
+ return result;
2312
+ }
2313
+ }
2314
+ return { valid: true };
2315
+ };
2316
+ const validateSingleRule = async (value, rule, column, record) => {
2317
+ const label = column.title || column.dataIndex || "字段";
2318
+ if (rule.required) {
2319
+ if (value === null || value === void 0 || value === "") {
2320
+ return {
2321
+ valid: false,
2322
+ message: rule.message || `请输入${label}`
2323
+ };
2324
+ }
2325
+ }
2326
+ if (value === null || value === void 0 || value === "") {
2327
+ return { valid: true };
2328
+ }
2329
+ if (rule.pattern) {
2330
+ if (!rule.pattern.test(String(value))) {
2331
+ return {
2332
+ valid: false,
2333
+ message: rule.message || `${label}格式不正确`
2334
+ };
2335
+ }
2336
+ }
2337
+ if (typeof value === "number") {
2338
+ if (rule.min !== void 0 && value < rule.min) {
2339
+ return {
2340
+ valid: false,
2341
+ message: rule.message || `${label}不能小于${rule.min}`
2342
+ };
2343
+ }
2344
+ if (rule.max !== void 0 && value > rule.max) {
2345
+ return {
2346
+ valid: false,
2347
+ message: rule.message || `${label}不能大于${rule.max}`
2348
+ };
2349
+ }
2350
+ }
2351
+ if (typeof value === "string") {
2352
+ if (rule.minLength !== void 0 && value.length < rule.minLength) {
2353
+ return {
2354
+ valid: false,
2355
+ message: rule.message || `${label}长度不能小于${rule.minLength}个字符`
2356
+ };
2357
+ }
2358
+ if (rule.maxLength !== void 0 && value.length > rule.maxLength) {
2359
+ return {
2360
+ valid: false,
2361
+ message: rule.message || `${label}长度不能大于${rule.maxLength}个字符`
2362
+ };
2363
+ }
2364
+ }
2365
+ if (rule.validator) {
2366
+ try {
2367
+ const result = await rule.validator(value, record);
2368
+ if (result === false) {
2369
+ return {
2370
+ valid: false,
2371
+ message: rule.message || `${label}验证失败`
2372
+ };
2373
+ }
2374
+ if (typeof result === "string") {
2375
+ return {
2376
+ valid: false,
2377
+ message: result
2378
+ };
2379
+ }
2380
+ return { valid: true };
2381
+ } catch (error) {
2382
+ console.error("[useEditValidation] validator error:", error);
2383
+ return {
2384
+ valid: false,
2385
+ message: rule.message || `${label}验证失败`
2386
+ };
2387
+ }
2388
+ }
2389
+ return { valid: true };
2390
+ };
2391
+ const validateRow = async (editValues, columns, record) => {
2392
+ const errors = {};
2393
+ for (const column of columns) {
2394
+ if (!column.dataIndex || !column.editRule) {
2395
+ continue;
2396
+ }
2397
+ const value = editValues[column.dataIndex];
2398
+ const result = await validateField(value, column, record);
2399
+ if (!result.valid && result.message) {
2400
+ errors[column.dataIndex] = result.message;
2401
+ }
2402
+ }
2403
+ return {
2404
+ valid: Object.keys(errors).length === 0,
2405
+ errors
2406
+ };
2407
+ };
2408
+ return {
2409
+ validateField,
2410
+ validateRow
2411
+ };
2412
+ }
2413
+ function useTableEdit(props, dataSource, getRowKey) {
2414
+ const editingStateMap = reactive({});
2415
+ const editValueMap = reactive({});
2416
+ const originalDataMap = reactive({});
2417
+ const validationErrorMap = reactive({});
2418
+ const { validateRow } = useEditValidation();
2419
+ const editConfig = computed(() => {
2420
+ return {
2421
+ mode: "row",
2422
+ enabled: true,
2423
+ allowAdd: true,
2424
+ allowDelete: true,
2425
+ ...props.value.editConfig
2426
+ };
2427
+ });
2428
+ const getEditableColumns = (columns) => {
2429
+ return columns.filter((col) => col.edit || col.editable);
2430
+ };
2431
+ const isEditing = (record, column) => {
2432
+ const recordKey = String(getRowKey(record));
2433
+ if (!editingStateMap[recordKey]) {
2434
+ return false;
2435
+ }
2436
+ if (column && column.dataIndex) {
2437
+ return !!editingStateMap[recordKey][column.dataIndex];
2438
+ }
2439
+ return Object.values(editingStateMap[recordKey]).some(Boolean);
2440
+ };
2441
+ const getEditValue = (record, column) => {
2442
+ const recordKey = String(getRowKey(record));
2443
+ const columnKey = column.dataIndex;
2444
+ if (editValueMap[recordKey] && columnKey in editValueMap[recordKey]) {
2445
+ return editValueMap[recordKey][columnKey];
2446
+ }
2447
+ if (column.editValueGetter) {
2448
+ return column.editValueGetter(record);
2449
+ }
2450
+ return record[columnKey];
2451
+ };
2452
+ const setEditValue = (record, column, value) => {
2453
+ const recordKey = String(getRowKey(record));
2454
+ const columnKey = column.dataIndex;
2455
+ if (!editValueMap[recordKey]) {
2456
+ editValueMap[recordKey] = {};
2457
+ }
2458
+ editValueMap[recordKey][columnKey] = value;
2459
+ if (validationErrorMap[recordKey] && validationErrorMap[recordKey][columnKey]) {
2460
+ delete validationErrorMap[recordKey][columnKey];
2461
+ }
2462
+ };
2463
+ const getValidationError = (record, column) => {
2464
+ const recordKey = String(getRowKey(record));
2465
+ const columnKey = column.dataIndex;
2466
+ if (validationErrorMap[recordKey]) {
2467
+ return validationErrorMap[recordKey][columnKey];
2468
+ }
2469
+ return void 0;
2470
+ };
2471
+ const startEdit = (record, column) => {
2472
+ const recordKey = String(getRowKey(record));
2473
+ const mode = editConfig.value.mode || "row";
2474
+ if (!originalDataMap[recordKey]) {
2475
+ originalDataMap[recordKey] = { ...record };
2476
+ }
2477
+ if (!editingStateMap[recordKey]) {
2478
+ editingStateMap[recordKey] = {};
2479
+ }
2480
+ if (!editValueMap[recordKey]) {
2481
+ editValueMap[recordKey] = {};
2482
+ }
2483
+ if (mode === "row") {
2484
+ const editableColumns = getEditableColumns(props.value.columns || []);
2485
+ editableColumns.forEach((col) => {
2486
+ if (col.dataIndex) {
2487
+ editingStateMap[recordKey][col.dataIndex] = true;
2488
+ if (!(col.dataIndex in editValueMap[recordKey])) {
2489
+ editValueMap[recordKey][col.dataIndex] = getEditValue(record, col);
2490
+ }
2491
+ }
2492
+ });
2493
+ } else if (mode === "cell" && column && column.dataIndex) {
2494
+ editingStateMap[recordKey][column.dataIndex] = true;
2495
+ if (!(column.dataIndex in editValueMap[recordKey])) {
2496
+ editValueMap[recordKey][column.dataIndex] = getEditValue(record, column);
2497
+ }
2498
+ }
2499
+ };
2500
+ const getChangedValues = (record) => {
2501
+ const recordKey = String(getRowKey(record));
2502
+ const changedValues = {};
2503
+ if (!editValueMap[recordKey]) {
2504
+ return changedValues;
2505
+ }
2506
+ Object.keys(editValueMap[recordKey]).forEach((columnKey) => {
2507
+ var _a;
2508
+ const editValue = editValueMap[recordKey][columnKey];
2509
+ const originalValue = (_a = originalDataMap[recordKey]) == null ? void 0 : _a[columnKey];
2510
+ if (editValue !== originalValue) {
2511
+ changedValues[columnKey] = editValue;
2512
+ }
2513
+ });
2514
+ return changedValues;
2515
+ };
2516
+ const saveEdit = async (record) => {
2517
+ const recordKey = String(getRowKey(record));
2518
+ if (!isEditing(record)) {
2519
+ return true;
2520
+ }
2521
+ const editableColumns = getEditableColumns(props.value.columns || []);
2522
+ let columnsToValidate;
2523
+ if (editConfig.value.mode === "cell") {
2524
+ const editingColumns = editingStateMap[recordKey] || {};
2525
+ columnsToValidate = editableColumns.filter(
2526
+ (col) => col.dataIndex && editingColumns[col.dataIndex]
2527
+ );
2528
+ } else {
2529
+ columnsToValidate = editableColumns;
2530
+ }
2531
+ const validationResult = await validateRow(
2532
+ editValueMap[recordKey] || {},
2533
+ columnsToValidate,
2534
+ record
2535
+ );
2536
+ if (!validationResult.valid) {
2537
+ validationErrorMap[recordKey] = validationResult.errors;
2538
+ const firstError = Object.values(validationResult.errors)[0];
2539
+ if (firstError) {
2540
+ Message.error(firstError);
2541
+ }
2542
+ return false;
2543
+ }
2544
+ const changedValues = getChangedValues(record);
2545
+ if (editConfig.value.beforeSave) {
2546
+ try {
2547
+ const result = await editConfig.value.beforeSave(record, changedValues);
2548
+ if (result === false) {
2549
+ return false;
2550
+ }
2551
+ } catch (error) {
2552
+ console.error("[useTableEdit] beforeSave error:", error);
2553
+ Message.error("保存前验证失败");
2554
+ return false;
2555
+ }
2556
+ }
2557
+ if (editValueMap[recordKey]) {
2558
+ Object.keys(editValueMap[recordKey]).forEach((columnKey) => {
2559
+ const column = editableColumns.find((col) => col.dataIndex === columnKey);
2560
+ let value = editValueMap[recordKey][columnKey];
2561
+ if (column == null ? void 0 : column.editValueSetter) {
2562
+ value = column.editValueSetter(value, record);
2563
+ }
2564
+ record[columnKey] = value;
2565
+ });
2566
+ }
2567
+ if (editConfig.value.onSave) {
2568
+ try {
2569
+ await editConfig.value.onSave(record, changedValues);
2570
+ } catch (error) {
2571
+ console.error("[useTableEdit] onSave error:", error);
2572
+ }
2573
+ }
2574
+ delete editingStateMap[recordKey];
2575
+ delete editValueMap[recordKey];
2576
+ delete originalDataMap[recordKey];
2577
+ delete validationErrorMap[recordKey];
2578
+ Message.success("保存成功");
2579
+ return true;
2580
+ };
2581
+ const cancelEdit = (record) => {
2582
+ const recordKey = String(getRowKey(record));
2583
+ if (!isEditing(record)) {
2584
+ return;
2585
+ }
2586
+ if (originalDataMap[recordKey]) {
2587
+ Object.keys(originalDataMap[recordKey]).forEach((key) => {
2588
+ record[key] = originalDataMap[recordKey][key];
2589
+ });
2590
+ }
2591
+ if (editConfig.value.onCancel) {
2592
+ editConfig.value.onCancel(record);
1917
2593
  }
2594
+ delete editingStateMap[recordKey];
2595
+ delete editValueMap[recordKey];
2596
+ delete originalDataMap[recordKey];
2597
+ delete validationErrorMap[recordKey];
1918
2598
  };
1919
- return debounced;
1920
- }
1921
- function throttle(func, wait = 300) {
1922
- let timeout = null;
1923
- let previous = 0;
1924
- return function(...args) {
1925
- const context = this;
1926
- const now = Date.now();
1927
- const remaining = wait - (now - previous);
1928
- if (remaining <= 0 || remaining > wait) {
1929
- if (timeout) {
1930
- clearTimeout(timeout);
1931
- timeout = null;
2599
+ const deleteRow = async (record) => {
2600
+ const recordKey = String(getRowKey(record));
2601
+ if (editConfig.value.onDelete) {
2602
+ try {
2603
+ await editConfig.value.onDelete(record);
2604
+ } catch (error) {
2605
+ console.error("[useTableEdit] onDelete error:", error);
2606
+ Message.error("删除失败");
2607
+ return;
1932
2608
  }
1933
- previous = now;
1934
- func.apply(context, args);
1935
- } else if (!timeout) {
1936
- timeout = setTimeout(() => {
1937
- previous = Date.now();
1938
- timeout = null;
1939
- func.apply(context, args);
1940
- }, remaining);
1941
2609
  }
1942
- };
1943
- }
1944
- function useLocalStorage(key, initialValue) {
1945
- let initialStoredValue;
1946
- try {
1947
- const item = window.localStorage.getItem(key);
1948
- initialStoredValue = item ? JSON.parse(item) : initialValue;
1949
- } catch (error) {
1950
- console.error(`Error reading localStorage key "${key}":`, error);
1951
- initialStoredValue = initialValue;
1952
- }
1953
- const storedValue = ref(initialStoredValue);
1954
- const setValue = (value) => {
1955
- try {
1956
- const valueToStore = value instanceof Function ? value(storedValue.value) : value;
1957
- storedValue.value = valueToStore;
1958
- window.localStorage.setItem(key, JSON.stringify(valueToStore));
1959
- } catch (error) {
1960
- console.error(`Error setting localStorage key "${key}":`, error);
2610
+ const index = dataSource.value.findIndex((item) => getRowKey(item) === recordKey);
2611
+ if (index > -1) {
2612
+ dataSource.value.splice(index, 1);
1961
2613
  }
2614
+ delete editingStateMap[recordKey];
2615
+ delete editValueMap[recordKey];
2616
+ delete originalDataMap[recordKey];
2617
+ delete validationErrorMap[recordKey];
2618
+ Message.success("删除成功");
1962
2619
  };
1963
- watch(
1964
- storedValue,
1965
- (newValue) => {
2620
+ const addRow = async () => {
2621
+ let newRecord = {};
2622
+ if (editConfig.value.onAdd) {
1966
2623
  try {
1967
- window.localStorage.setItem(key, JSON.stringify(newValue));
2624
+ newRecord = await editConfig.value.onAdd();
1968
2625
  } catch (error) {
1969
- console.error(`Error syncing localStorage key "${key}":`, error);
2626
+ console.error("[useTableEdit] onAdd error:", error);
2627
+ Message.error("添加失败");
2628
+ return;
1970
2629
  }
1971
- },
1972
- { deep: true }
1973
- );
1974
- return [storedValue, setValue];
2630
+ }
2631
+ const rowKey = props.value.rowKey || "id";
2632
+ if (typeof rowKey === "string" && !newRecord[rowKey]) {
2633
+ newRecord[rowKey] = `temp_${Date.now()}_${Math.random()}`;
2634
+ }
2635
+ dataSource.value.unshift(newRecord);
2636
+ startEdit(newRecord);
2637
+ };
2638
+ const getEditingRows = () => {
2639
+ const editingKeys = Object.keys(editingStateMap);
2640
+ return dataSource.value.filter((record) => {
2641
+ const recordKey = String(getRowKey(record));
2642
+ return editingKeys.includes(recordKey);
2643
+ });
2644
+ };
2645
+ const saveAllEdits = async () => {
2646
+ const editingRows = getEditingRows();
2647
+ if (editingRows.length === 0) {
2648
+ return true;
2649
+ }
2650
+ for (const record of editingRows) {
2651
+ const success = await saveEdit(record);
2652
+ if (!success) {
2653
+ return false;
2654
+ }
2655
+ }
2656
+ return true;
2657
+ };
2658
+ const cancelAllEdits = () => {
2659
+ const editingRows = getEditingRows();
2660
+ editingRows.forEach((record) => {
2661
+ cancelEdit(record);
2662
+ });
2663
+ };
2664
+ return {
2665
+ editingStateMap,
2666
+ editValueMap,
2667
+ validationErrorMap,
2668
+ isEditing,
2669
+ getEditValue,
2670
+ setEditValue,
2671
+ getValidationError,
2672
+ startEdit,
2673
+ saveEdit,
2674
+ cancelEdit,
2675
+ deleteRow,
2676
+ addRow,
2677
+ getEditingRows,
2678
+ saveAllEdits,
2679
+ cancelAllEdits,
2680
+ getChangedValues
2681
+ };
1975
2682
  }
1976
2683
  const _hoisted_1$2 = { class: "basic-table-wrapper" };
1977
2684
  const _hoisted_2$2 = {
@@ -2035,9 +2742,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2035
2742
  autoHeight: { type: Boolean, default: false },
2036
2743
  maxHeight: {},
2037
2744
  tableClass: {},
2038
- tableStyle: {}
2745
+ tableStyle: {},
2746
+ editConfig: {}
2039
2747
  },
2040
- emits: ["register", "change", "select", "selectAll", "expand", "row-click", "row-dblclick", "cell-click", "search", "reset", "fetch-success", "fetch-error"],
2748
+ emits: ["register", "change", "select", "selectAll", "expand", "row-click", "row-dblclick", "cell-click", "search", "reset", "fetch-success", "fetch-error", "edit-save", "edit-cancel", "edit-delete", "edit-add"],
2041
2749
  setup(__props, { expose: __expose, emit: __emit }) {
2042
2750
  const DEBOUNCE_DELAY = {
2043
2751
  REFRESH: 300,
@@ -2246,6 +2954,31 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2246
2954
  }
2247
2955
  return record[mergedProps.rowKey];
2248
2956
  };
2957
+ const {
2958
+ isEditing,
2959
+ getEditValue,
2960
+ setEditValue,
2961
+ getValidationError,
2962
+ startEdit,
2963
+ saveEdit,
2964
+ cancelEdit,
2965
+ deleteRow,
2966
+ addRow,
2967
+ getEditingRows,
2968
+ saveAllEdits,
2969
+ cancelAllEdits,
2970
+ getChangedValues
2971
+ } = useTableEdit(getMergedProps, dataSource, getRowKey);
2972
+ const originalColumnsMap = computed(() => {
2973
+ const mergedProps = getMergedProps.value;
2974
+ const map = /* @__PURE__ */ new Map();
2975
+ mergedProps.columns.forEach((col) => {
2976
+ if (col.dataIndex) {
2977
+ map.set(col.dataIndex, col);
2978
+ }
2979
+ });
2980
+ return map;
2981
+ });
2249
2982
  const getViewColumns = computed(() => {
2250
2983
  const mergedProps = getMergedProps.value;
2251
2984
  let columns = [...mergedProps.columns];
@@ -2283,6 +3016,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2283
3016
  }
2284
3017
  columns = columns.filter((col) => col.show !== false);
2285
3018
  columns = columns.map((col) => {
3019
+ if ((col.edit || col.editable) && !col.slotName) {
3020
+ return { ...col, slotName: col.dataIndex };
3021
+ }
3022
+ if (!col.slotName && col.ellipsis && typeof col.ellipsis === "object") {
3023
+ const { ellipsis, ...restCol } = col;
3024
+ return { ...restCol, slotName: col.dataIndex };
3025
+ }
2286
3026
  if (!col.slotName && (col.customRender || col.format)) {
2287
3027
  return { ...col, slotName: col.dataIndex };
2288
3028
  }
@@ -2722,7 +3462,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2722
3462
  expandAll,
2723
3463
  collapseAll,
2724
3464
  tableRef,
2725
- searchFormRef
3465
+ searchFormRef,
3466
+ // 编辑相关方法
3467
+ startEdit,
3468
+ saveEdit,
3469
+ cancelEdit,
3470
+ deleteRow,
3471
+ addRow,
3472
+ getEditingRows,
3473
+ saveAllEdits,
3474
+ cancelAllEdits,
3475
+ isEditing,
3476
+ getEditValue,
3477
+ setEditValue,
3478
+ getChangedValues
2726
3479
  });
2727
3480
  onMounted(async () => {
2728
3481
  await nextTick();
@@ -2752,7 +3505,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2752
3505
  expandAll,
2753
3506
  collapseAll,
2754
3507
  tableRef,
2755
- searchFormRef
3508
+ searchFormRef,
3509
+ // 编辑相关方法
3510
+ startEdit,
3511
+ saveEdit,
3512
+ cancelEdit,
3513
+ deleteRow,
3514
+ addRow,
3515
+ getEditingRows,
3516
+ saveAllEdits,
3517
+ cancelAllEdits,
3518
+ isEditing,
3519
+ getEditValue,
3520
+ setEditValue,
3521
+ getChangedValues
2756
3522
  };
2757
3523
  const formInstance = {
2758
3524
  getFieldsValue: () => {
@@ -2854,7 +3620,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2854
3620
  const _component_a_table = resolveComponent("a-table");
2855
3621
  return openBlock(), createElementBlock("div", _hoisted_1$2, [
2856
3622
  getSearchConfig.value.show ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
2857
- createVNode(unref(_sfc_main$3), mergeProps({
3623
+ createVNode(unref(_sfc_main$5), mergeProps({
2858
3624
  ref_key: "searchFormRef",
2859
3625
  ref: searchFormRef
2860
3626
  }, getSearchFormProps.value, {
@@ -3055,84 +3821,103 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3055
3821
  renderList(getViewColumns.value.filter((c) => c.slotName), (col) => {
3056
3822
  return {
3057
3823
  name: col.slotName,
3058
- fn: withCtx((slotProps) => [
3059
- col.slotName === "__index__" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3060
- createTextVNode(toDisplayString(getIndexNumber(slotProps.rowIndex)), 1)
3061
- ], 64)) : col.slotName === "action" ? renderSlot(_ctx.$slots, "action", {
3062
- key: 1,
3063
- record: slotProps.record
3064
- }, () => [
3065
- createVNode(_component_a_space, null, {
3066
- default: withCtx(() => [
3067
- (openBlock(true), createElementBlock(Fragment, null, renderList(getActionButtons(slotProps.record), (action) => {
3068
- return openBlock(), createElementBlock(Fragment, {
3069
- key: action.label
3070
- }, [
3071
- action.popConfirm ? (openBlock(), createBlock(_component_a_popconfirm, {
3072
- key: 0,
3073
- content: action.popConfirm.title,
3074
- "ok-text": action.popConfirm.okText,
3075
- "cancel-text": action.popConfirm.cancelText,
3076
- onOk: ($event) => {
3077
- var _a, _b;
3078
- return (_b = (_a = action.popConfirm).onConfirm) == null ? void 0 : _b.call(_a, slotProps.record);
3079
- },
3080
- onCancel: action.popConfirm.onCancel
3081
- }, {
3082
- default: withCtx(() => [
3083
- createVNode(_component_a_link, {
3084
- status: action.color,
3085
- disabled: getActionDisabled(action, slotProps.record),
3086
- onClick: _cache[1] || (_cache[1] = withModifiers(() => {
3087
- }, ["stop"]))
3088
- }, createSlots({
3089
- default: withCtx(() => [
3090
- createTextVNode(" " + toDisplayString(action.label), 1)
3091
- ]),
3092
- _: 2
3093
- }, [
3094
- action.icon ? {
3095
- name: "icon",
3096
- fn: withCtx(() => [
3097
- (openBlock(), createBlock(resolveDynamicComponent(action.icon)))
3098
- ]),
3099
- key: "0"
3100
- } : void 0
3101
- ]), 1032, ["status", "disabled"])
3102
- ]),
3103
- _: 2
3104
- }, 1032, ["content", "ok-text", "cancel-text", "onOk", "onCancel"])) : (openBlock(), createBlock(_component_a_link, {
3105
- key: 1,
3106
- status: action.color,
3107
- disabled: getActionDisabled(action, slotProps.record),
3108
- onClick: ($event) => handleActionClick(action, slotProps.record)
3109
- }, createSlots({
3110
- default: withCtx(() => [
3111
- createTextVNode(" " + toDisplayString(action.label), 1)
3112
- ]),
3113
- _: 2
3824
+ fn: withCtx((slotProps) => {
3825
+ var _a, _b;
3826
+ return [
3827
+ col.slotName === "__index__" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3828
+ createTextVNode(toDisplayString(getIndexNumber(slotProps.rowIndex)), 1)
3829
+ ], 64)) : col.slotName === "action" ? renderSlot(_ctx.$slots, "action", {
3830
+ key: 1,
3831
+ record: slotProps.record
3832
+ }, () => [
3833
+ createVNode(_component_a_space, null, {
3834
+ default: withCtx(() => [
3835
+ (openBlock(true), createElementBlock(Fragment, null, renderList(getActionButtons(slotProps.record), (action) => {
3836
+ return openBlock(), createElementBlock(Fragment, {
3837
+ key: action.label
3114
3838
  }, [
3115
- action.icon ? {
3116
- name: "icon",
3117
- fn: withCtx(() => [
3118
- (openBlock(), createBlock(resolveDynamicComponent(action.icon)))
3839
+ action.popConfirm ? (openBlock(), createBlock(_component_a_popconfirm, {
3840
+ key: 0,
3841
+ content: action.popConfirm.title,
3842
+ "ok-text": action.popConfirm.okText,
3843
+ "cancel-text": action.popConfirm.cancelText,
3844
+ onOk: ($event) => {
3845
+ var _a2, _b2;
3846
+ return (_b2 = (_a2 = action.popConfirm).onConfirm) == null ? void 0 : _b2.call(_a2, slotProps.record);
3847
+ },
3848
+ onCancel: action.popConfirm.onCancel
3849
+ }, {
3850
+ default: withCtx(() => [
3851
+ createVNode(_component_a_link, {
3852
+ status: action.color,
3853
+ disabled: getActionDisabled(action, slotProps.record),
3854
+ onClick: _cache[1] || (_cache[1] = withModifiers(() => {
3855
+ }, ["stop"]))
3856
+ }, createSlots({
3857
+ default: withCtx(() => [
3858
+ createTextVNode(" " + toDisplayString(action.label), 1)
3859
+ ]),
3860
+ _: 2
3861
+ }, [
3862
+ action.icon ? {
3863
+ name: "icon",
3864
+ fn: withCtx(() => [
3865
+ (openBlock(), createBlock(resolveDynamicComponent(action.icon)))
3866
+ ]),
3867
+ key: "0"
3868
+ } : void 0
3869
+ ]), 1032, ["status", "disabled"])
3119
3870
  ]),
3120
- key: "0"
3121
- } : void 0
3122
- ]), 1032, ["status", "disabled", "onClick"]))
3123
- ], 64);
3124
- }), 128))
3125
- ]),
3126
- _: 2
3127
- }, 1024)
3128
- ], true) : _ctx.$slots[col.dataIndex] ? renderSlot(_ctx.$slots, col.dataIndex, normalizeProps(mergeProps({ key: 2 }, slotProps)), void 0, true) : col.customRender ? (openBlock(), createBlock(resolveDynamicComponent(renderCustomCell(col, slotProps)), { key: 3 })) : col.format ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
3129
- createTextVNode(toDisplayString(col.format(
3130
- slotProps.record[col.dataIndex],
3131
- slotProps.record,
3132
- slotProps.rowIndex
3133
- )), 1)
3134
- ], 64)) : createCommentVNode("", true)
3135
- ])
3871
+ _: 2
3872
+ }, 1032, ["content", "ok-text", "cancel-text", "onOk", "onCancel"])) : (openBlock(), createBlock(_component_a_link, {
3873
+ key: 1,
3874
+ status: action.color,
3875
+ disabled: getActionDisabled(action, slotProps.record),
3876
+ onClick: ($event) => handleActionClick(action, slotProps.record)
3877
+ }, createSlots({
3878
+ default: withCtx(() => [
3879
+ createTextVNode(" " + toDisplayString(action.label), 1)
3880
+ ]),
3881
+ _: 2
3882
+ }, [
3883
+ action.icon ? {
3884
+ name: "icon",
3885
+ fn: withCtx(() => [
3886
+ (openBlock(), createBlock(resolveDynamicComponent(action.icon)))
3887
+ ]),
3888
+ key: "0"
3889
+ } : void 0
3890
+ ]), 1032, ["status", "disabled", "onClick"]))
3891
+ ], 64);
3892
+ }), 128))
3893
+ ]),
3894
+ _: 2
3895
+ }, 1024)
3896
+ ], true) : (col.edit || col.editable) && unref(isEditing)(slotProps.record, col) ? (openBlock(), createBlock(EditCell, {
3897
+ key: 2,
3898
+ column: col,
3899
+ record: slotProps.record,
3900
+ value: unref(getEditValue)(slotProps.record, col),
3901
+ error: unref(getValidationError)(slotProps.record, col),
3902
+ onChange: (val) => unref(setEditValue)(slotProps.record, col, val)
3903
+ }, null, 8, ["column", "record", "value", "error", "onChange"])) : _ctx.$slots[col.dataIndex] ? renderSlot(_ctx.$slots, col.dataIndex, normalizeProps(mergeProps({ key: 3 }, slotProps)), void 0, true) : col.customRender ? (openBlock(), createBlock(resolveDynamicComponent(renderCustomCell(col, slotProps)), { key: 4 })) : col.format ? (openBlock(), createElementBlock(Fragment, { key: 5 }, [
3904
+ createTextVNode(toDisplayString(col.format(
3905
+ slotProps.record[col.dataIndex],
3906
+ slotProps.record,
3907
+ slotProps.rowIndex
3908
+ )), 1)
3909
+ ], 64)) : col.dataIndex && ((_a = originalColumnsMap.value.get(col.dataIndex)) == null ? void 0 : _a.ellipsis) && typeof ((_b = originalColumnsMap.value.get(col.dataIndex)) == null ? void 0 : _b.ellipsis) === "object" ? (openBlock(), createBlock(unref(BasicTextEllipsis), {
3910
+ key: 6,
3911
+ text: String(slotProps.record[col.dataIndex] ?? ""),
3912
+ lines: originalColumnsMap.value.get(col.dataIndex).ellipsis.lines ?? 1,
3913
+ tooltip: originalColumnsMap.value.get(col.dataIndex).ellipsis.tooltip ?? true,
3914
+ tooltipTrigger: originalColumnsMap.value.get(col.dataIndex).ellipsis.tooltipTrigger ?? "hover",
3915
+ tooltipProps: originalColumnsMap.value.get(col.dataIndex).ellipsis.tooltipProps
3916
+ }, null, 8, ["text", "lines", "tooltip", "tooltipTrigger", "tooltipProps"])) : (openBlock(), createElementBlock(Fragment, { key: 7 }, [
3917
+ createTextVNode(toDisplayString(slotProps.record[col.dataIndex]), 1)
3918
+ ], 64))
3919
+ ];
3920
+ })
3136
3921
  };
3137
3922
  })
3138
3923
  ]), 1040, ["columns", "data", "loading", "pagination", "row-selection", "expandable", "scroll", "draggable", "bordered", "stripe", "show-header", "size", "row-key"])
@@ -3140,7 +3925,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3140
3925
  };
3141
3926
  }
3142
3927
  });
3143
- const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-7a27a6be"]]);
3928
+ const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-42280842"]]);
3144
3929
  function useTable(options = {}) {
3145
3930
  const tableRef = ref(null);
3146
3931
  const formRef = ref(null);
@@ -3343,6 +4128,96 @@ function useTable(options = {}) {
3343
4128
  }
3344
4129
  return form;
3345
4130
  };
4131
+ const startEdit = (record, column) => {
4132
+ const table = getTable();
4133
+ if (!table) return;
4134
+ if (table.startEdit) {
4135
+ table.startEdit(record, column);
4136
+ }
4137
+ };
4138
+ const saveEdit = async (record) => {
4139
+ const table = getTable();
4140
+ if (!table) return false;
4141
+ if (table.saveEdit) {
4142
+ return await table.saveEdit(record);
4143
+ }
4144
+ return false;
4145
+ };
4146
+ const cancelEdit = (record) => {
4147
+ const table = getTable();
4148
+ if (!table) return;
4149
+ if (table.cancelEdit) {
4150
+ table.cancelEdit(record);
4151
+ }
4152
+ };
4153
+ const deleteRow = async (record) => {
4154
+ const table = getTable();
4155
+ if (!table) return;
4156
+ if (table.deleteRow) {
4157
+ await table.deleteRow(record);
4158
+ }
4159
+ };
4160
+ const addRow = async () => {
4161
+ const table = getTable();
4162
+ if (!table) return;
4163
+ if (table.addRow) {
4164
+ await table.addRow();
4165
+ }
4166
+ };
4167
+ const getEditingRows = () => {
4168
+ const table = getTable();
4169
+ if (!table) return [];
4170
+ if (table.getEditingRows) {
4171
+ return table.getEditingRows();
4172
+ }
4173
+ return [];
4174
+ };
4175
+ const saveAllEdits = async () => {
4176
+ const table = getTable();
4177
+ if (!table) return false;
4178
+ if (table.saveAllEdits) {
4179
+ return await table.saveAllEdits();
4180
+ }
4181
+ return false;
4182
+ };
4183
+ const cancelAllEdits = () => {
4184
+ const table = getTable();
4185
+ if (!table) return;
4186
+ if (table.cancelAllEdits) {
4187
+ table.cancelAllEdits();
4188
+ }
4189
+ };
4190
+ const isEditing = (record, column) => {
4191
+ const table = getTable();
4192
+ if (!table) return false;
4193
+ if (table.isEditing) {
4194
+ return table.isEditing(record, column);
4195
+ }
4196
+ return false;
4197
+ };
4198
+ const getEditValue = (record, column) => {
4199
+ const table = getTable();
4200
+ if (!table) return void 0;
4201
+ if (table.getEditValue) {
4202
+ return table.getEditValue(record, column);
4203
+ }
4204
+ return void 0;
4205
+ };
4206
+ const setEditValue = (record, column, value) => {
4207
+ const table = getTable();
4208
+ if (!table) return;
4209
+ if (table.setEditValue) {
4210
+ table.setEditValue(record, column, value);
4211
+ }
4212
+ };
4213
+ const getChangedValues = (record) => {
4214
+ const table = getTable();
4215
+ if (!table) return {};
4216
+ if (table.getChangedValues) {
4217
+ return table.getChangedValues(record);
4218
+ }
4219
+ return {};
4220
+ };
3346
4221
  const tableMethods = {
3347
4222
  getDataSource,
3348
4223
  setDataSource,
@@ -3367,7 +4242,20 @@ function useTable(options = {}) {
3367
4242
  collapseAll,
3368
4243
  getForm,
3369
4244
  tableRef,
3370
- getTable
4245
+ getTable,
4246
+ // 编辑相关方法
4247
+ startEdit,
4248
+ saveEdit,
4249
+ cancelEdit,
4250
+ deleteRow,
4251
+ addRow,
4252
+ getEditingRows,
4253
+ saveAllEdits,
4254
+ cancelAllEdits,
4255
+ isEditing,
4256
+ getEditValue,
4257
+ setEditValue,
4258
+ getChangedValues
3371
4259
  };
3372
4260
  return [register, tableMethods];
3373
4261
  }
@@ -3622,7 +4510,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3622
4510
  watch(
3623
4511
  () => getProps.value.visible,
3624
4512
  (val) => {
3625
- visibleRef.value = val;
4513
+ visibleRef.value = val ?? false;
3626
4514
  },
3627
4515
  { immediate: true }
3628
4516
  );
@@ -3781,7 +4669,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3781
4669
  };
3782
4670
  }
3783
4671
  });
3784
- const BasicModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-1e847475"]]);
4672
+ const BasicModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-68fed17a"]]);
3785
4673
  function useModal(props) {
3786
4674
  const modalRef = ref(null);
3787
4675
  const loadedRef = ref(false);
@@ -4163,102 +5051,6 @@ function useDescription(props) {
4163
5051
  }
4164
5052
  ];
4165
5053
  }
4166
- function useUpload(props) {
4167
- const uploadRef = ref(null);
4168
- const fileListRef = ref((props == null ? void 0 : props.defaultFileList) || []);
4169
- const register = (uploadInstance) => {
4170
- uploadRef.value = uploadInstance;
4171
- if ((props == null ? void 0 : props.defaultFileList) && props.defaultFileList.length > 0) {
4172
- uploadInstance.setFileList(props.defaultFileList);
4173
- }
4174
- if (props && Object.keys(props).length > 0) {
4175
- const { defaultFileList, ...restProps } = props;
4176
- if (Object.keys(restProps).length > 0) {
4177
- setProps(restProps);
4178
- }
4179
- }
4180
- };
4181
- const getUpload = () => {
4182
- const upload2 = unref(uploadRef);
4183
- if (!upload2) {
4184
- throw new Error('Upload 实例未注册,请确保在组件上使用 @register="register"');
4185
- }
4186
- return upload2;
4187
- };
4188
- const submit = () => {
4189
- getUpload().submit();
4190
- };
4191
- const abort = (fileItem) => {
4192
- getUpload().abort(fileItem);
4193
- };
4194
- const clearFiles = () => {
4195
- getUpload().clearFiles();
4196
- fileListRef.value = [];
4197
- };
4198
- const getFileList = () => {
4199
- return getUpload().getFileList();
4200
- };
4201
- const upload = (fileItem) => {
4202
- getUpload().upload(fileItem);
4203
- };
4204
- const setFileList = (files) => {
4205
- fileListRef.value = files;
4206
- const upload2 = getUpload();
4207
- if (upload2.setFileList) {
4208
- upload2.setFileList(files);
4209
- }
4210
- };
4211
- const addFile = (file) => {
4212
- fileListRef.value.push(file);
4213
- const upload2 = getUpload();
4214
- if (upload2.addFile) {
4215
- upload2.addFile(file);
4216
- }
4217
- };
4218
- const removeFile = (fileItem) => {
4219
- const index = fileListRef.value.findIndex(
4220
- (item) => item.uid === fileItem.uid
4221
- );
4222
- if (index !== -1) {
4223
- fileListRef.value.splice(index, 1);
4224
- }
4225
- const upload2 = getUpload();
4226
- if (upload2.removeFile) {
4227
- upload2.removeFile(fileItem);
4228
- }
4229
- };
4230
- const updateFile = (fileItem) => {
4231
- const index = fileListRef.value.findIndex(
4232
- (item) => item.uid === fileItem.uid
4233
- );
4234
- if (index !== -1) {
4235
- fileListRef.value[index] = { ...fileListRef.value[index], ...fileItem };
4236
- }
4237
- const upload2 = getUpload();
4238
- if (upload2.updateFile) {
4239
- upload2.updateFile(fileItem);
4240
- }
4241
- };
4242
- const setProps = (uploadProps) => {
4243
- getUpload().setProps(uploadProps);
4244
- };
4245
- const methods = {
4246
- get fileList() {
4247
- return fileListRef.value;
4248
- },
4249
- submit,
4250
- abort,
4251
- upload,
4252
- clearFiles,
4253
- getFileList,
4254
- setFileList,
4255
- addFile,
4256
- removeFile,
4257
- updateFile,
4258
- setProps
4259
- };
4260
- return [register, methods];
4261
- }
4262
5054
  function formatDate(date, format = "YYYY-MM-DD HH:mm:ss") {
4263
5055
  const d = typeof date === "number" ? new Date(date) : date;
4264
5056
  const year = d.getFullYear();
@@ -4339,9 +5131,10 @@ function useToggle(initialValue = false) {
4339
5131
  }
4340
5132
  export {
4341
5133
  BasicDescription,
4342
- _sfc_main$3 as BasicForm,
5134
+ _sfc_main$5 as BasicForm,
4343
5135
  BasicModal,
4344
5136
  BasicTable,
5137
+ BasicTextEllipsis,
4345
5138
  BasicUpload,
4346
5139
  componentMap,
4347
5140
  createFormSchema,