@dt-frames/ui 2.0.6 → 2.0.7

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 (33) hide show
  1. package/es/components/curd/index.js +42 -67
  2. package/es/components/curd/src/components/Curd.d.ts +2 -8
  3. package/es/components/curd/src/hooks/useCurd.d.ts +3 -3
  4. package/es/components/curd/src/props.d.ts +1 -4
  5. package/es/components/curd/src/types/curd.type.d.ts +3 -9
  6. package/es/components/form/index.d.ts +30 -54
  7. package/es/components/form/index.js +87 -65
  8. package/es/components/form/index.less +1 -0
  9. package/es/components/form/src/components/FormButtons.d.ts +3 -3
  10. package/es/components/form/src/components/FormItem.d.ts +5 -8
  11. package/es/components/form/src/components/formIcon.d.ts +4 -4
  12. package/es/components/form/src/components/formInputUseDialog.d.ts +3 -3
  13. package/es/components/form/src/hooks/useFormEvent.d.ts +1 -1
  14. package/es/components/form/src/index.d.ts +24 -42
  15. package/es/components/form/src/props.d.ts +5 -8
  16. package/es/components/modal/index.js +3 -6
  17. package/es/components/modal/src/components/ModalFooter.d.ts +3 -3
  18. package/es/components/modal/src/index.d.ts +9 -9
  19. package/es/components/source/hooks/useSource.d.ts +14 -13
  20. package/es/components/source/index.js +62 -36
  21. package/es/components/table/index.js +151 -158
  22. package/es/components/table/src/index.d.ts +18 -54
  23. package/es/components/table/src/props.d.ts +6 -18
  24. package/es/components/table/src/types/table.type.d.ts +1 -4
  25. package/es/theme/index.d.ts +2 -2
  26. package/es/theme/index.js +299 -294
  27. package/es/theme/src/components/sider/index.d.ts +2 -1
  28. package/es/theme/src/components/sider/mix-sider.d.ts +2 -1
  29. package/es/theme/src/hooks/useMenu.d.ts +1 -1
  30. package/es/theme/src/index.d.ts +2 -1
  31. package/es/theme/src/types/theme.type.d.ts +0 -1
  32. package/index.js +3 -1
  33. package/package.json +1 -1
@@ -15,7 +15,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
15
15
  default: () => {};
16
16
  };
17
17
  layout: {
18
- type: import("vue").PropType<"vertical" | "horizontal" | "inline">;
18
+ type: import("vue").PropType<"vertical" | "inline" | "horizontal">;
19
19
  default: string;
20
20
  };
21
21
  labelWidth: {
@@ -59,7 +59,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
59
59
  default: () => {};
60
60
  };
61
61
  size: {
62
- type: import("vue").PropType<"small" | "middle" | "large">;
62
+ type: import("vue").PropType<"middle" | "small" | "large">;
63
63
  default: string;
64
64
  };
65
65
  disabled: {
@@ -102,10 +102,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
102
102
  type: import("vue").PropType<{
103
103
  [key: string]: import("vue").Ref<boolean>;
104
104
  }>;
105
- default: () => {
106
- onSearch: import("vue").Ref<boolean>;
107
- onReset: import("vue").Ref<boolean>;
108
- };
105
+ default: () => {};
109
106
  };
110
107
  onSearch: {
111
108
  type: import("vue").PropType<(params: Recordable<any>) => void>;
@@ -147,7 +144,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
147
144
  default: () => {};
148
145
  };
149
146
  layout: {
150
- type: import("vue").PropType<"vertical" | "horizontal" | "inline">;
147
+ type: import("vue").PropType<"vertical" | "inline" | "horizontal">;
151
148
  default: string;
152
149
  };
153
150
  labelWidth: {
@@ -191,7 +188,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
191
188
  default: () => {};
192
189
  };
193
190
  size: {
194
- type: import("vue").PropType<"small" | "middle" | "large">;
191
+ type: import("vue").PropType<"middle" | "small" | "large">;
195
192
  default: string;
196
193
  };
197
194
  disabled: {
@@ -234,10 +231,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
234
231
  type: import("vue").PropType<{
235
232
  [key: string]: import("vue").Ref<boolean>;
236
233
  }>;
237
- default: () => {
238
- onSearch: import("vue").Ref<boolean>;
239
- onReset: import("vue").Ref<boolean>;
240
- };
234
+ default: () => {};
241
235
  };
242
236
  onSearch: {
243
237
  type: import("vue").PropType<(params: Recordable<any>) => void>;
@@ -285,7 +279,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
285
279
  default: () => {};
286
280
  };
287
281
  layout: {
288
- type: import("vue").PropType<"vertical" | "horizontal" | "inline">;
282
+ type: import("vue").PropType<"vertical" | "inline" | "horizontal">;
289
283
  default: string;
290
284
  };
291
285
  labelWidth: {
@@ -329,7 +323,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
329
323
  default: () => {};
330
324
  };
331
325
  size: {
332
- type: import("vue").PropType<"small" | "middle" | "large">;
326
+ type: import("vue").PropType<"middle" | "small" | "large">;
333
327
  default: string;
334
328
  };
335
329
  disabled: {
@@ -372,10 +366,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
372
366
  type: import("vue").PropType<{
373
367
  [key: string]: import("vue").Ref<boolean>;
374
368
  }>;
375
- default: () => {
376
- onSearch: import("vue").Ref<boolean>;
377
- onReset: import("vue").Ref<boolean>;
378
- };
369
+ default: () => {};
379
370
  };
380
371
  onSearch: {
381
372
  type: import("vue").PropType<(params: Recordable<any>) => void>;
@@ -2181,8 +2172,8 @@ declare const _sfc_main: import("vue").DefineComponent<{
2181
2172
  validator?: (rule: import("ant-design-vue/lib/form").RuleObject, value: any, callback: (error?: string) => void) => void | Promise<void>;
2182
2173
  } | any;
2183
2174
  required?: boolean;
2184
- validator?: (rule: import("ant-design-vue/lib/form").RuleObject, value: any, callback: (error?: string) => void) => void | Promise<void>;
2185
2175
  trigger?: "blur" | "change" | ("blur" | "change")[];
2176
+ validator?: (rule: import("ant-design-vue/lib/form").RuleObject, value: any, callback: (error?: string) => void) => void | Promise<void>;
2186
2177
  transform?: (value: any) => any;
2187
2178
  warningOnly?: boolean;
2188
2179
  message?: (string | number | boolean | void | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
@@ -2220,7 +2211,6 @@ declare const _sfc_main: import("vue").DefineComponent<{
2220
2211
  validateTrigger?: string | string[];
2221
2212
  };
2222
2213
  required?: boolean;
2223
- validator?: (rule: import("ant-design-vue/lib/form").RuleObject, value: any, callback: (error?: string) => void) => void | Promise<void>;
2224
2214
  trigger?: "blur" | "change" | ("blur" & ["change", "blur"]) | ("change" & ["change", "blur"]) | (("blur" | "change")[] & "blur") | (("blur" | "change")[] & "change") | {
2225
2215
  [x: number]: "blur" | "change";
2226
2216
  length: 2;
@@ -2292,6 +2282,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2292
2282
  0: "change";
2293
2283
  1: "blur";
2294
2284
  };
2285
+ validator?: (rule: import("ant-design-vue/lib/form").RuleObject, value: any, callback: (error?: string) => void) => void | Promise<void>;
2295
2286
  transform?: (value: any) => any;
2296
2287
  warningOnly?: boolean;
2297
2288
  message?: (string | number | boolean | void | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
@@ -2396,7 +2387,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2396
2387
  default: () => {};
2397
2388
  };
2398
2389
  layout: {
2399
- type: import("vue").PropType<"vertical" | "horizontal" | "inline">;
2390
+ type: import("vue").PropType<"vertical" | "inline" | "horizontal">;
2400
2391
  default: string;
2401
2392
  };
2402
2393
  labelWidth: {
@@ -2440,7 +2431,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2440
2431
  default: () => {};
2441
2432
  };
2442
2433
  size: {
2443
- type: import("vue").PropType<"small" | "middle" | "large">;
2434
+ type: import("vue").PropType<"middle" | "small" | "large">;
2444
2435
  default: string;
2445
2436
  };
2446
2437
  disabled: {
@@ -2483,10 +2474,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2483
2474
  type: import("vue").PropType<{
2484
2475
  [key: string]: import("vue").Ref<boolean>;
2485
2476
  }>;
2486
- default: () => {
2487
- onSearch: import("vue").Ref<boolean>;
2488
- onReset: import("vue").Ref<boolean>;
2489
- };
2477
+ default: () => {};
2490
2478
  };
2491
2479
  onSearch: {
2492
2480
  type: import("vue").PropType<(params: Recordable<any>) => void>;
@@ -2525,7 +2513,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2525
2513
  setFormValues: (values: Recordable<any>) => Promise<void>;
2526
2514
  appendFormItems: (schema: FormSchema[], prefixName?: string, first?: boolean) => void;
2527
2515
  validate: (nameList: (string | number)[]) => Promise<any>;
2528
- validateFields: (nameList: (string | number)[]) => Promise<any>;
2516
+ validateFields: (nameList: (string | number)[]) => Promise<void>;
2529
2517
  getFormValues: () => Recordable<any>;
2530
2518
  formActionMethods: {
2531
2519
  setProps: (formProps: FormProps) => any;
@@ -2537,7 +2525,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2537
2525
  setFormValues: (values: Recordable<any>) => Promise<void>;
2538
2526
  appendFormItems: (schema: FormSchema[], prefixName?: string, first?: boolean) => void;
2539
2527
  validate: (nameList: (string | number)[]) => Promise<any>;
2540
- validateFields: (nameList: (string | number)[]) => Promise<any>;
2528
+ validateFields: (nameList: (string | number)[]) => Promise<void>;
2541
2529
  getFormValues: () => Recordable<any>;
2542
2530
  };
2543
2531
  getActionsProps: import("vue").ComputedRef<Recordable<any>>;
@@ -2565,7 +2553,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2565
2553
  default: () => {};
2566
2554
  };
2567
2555
  layout: {
2568
- type: import("vue").PropType<"vertical" | "horizontal" | "inline">;
2556
+ type: import("vue").PropType<"vertical" | "inline" | "horizontal">;
2569
2557
  default: string;
2570
2558
  };
2571
2559
  labelWidth: {
@@ -2609,7 +2597,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2609
2597
  default: () => {};
2610
2598
  };
2611
2599
  size: {
2612
- type: import("vue").PropType<"small" | "middle" | "large">;
2600
+ type: import("vue").PropType<"middle" | "small" | "large">;
2613
2601
  default: string;
2614
2602
  };
2615
2603
  disabled: {
@@ -2652,10 +2640,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2652
2640
  type: import("vue").PropType<{
2653
2641
  [key: string]: import("vue").Ref<boolean>;
2654
2642
  }>;
2655
- default: () => {
2656
- onSearch: import("vue").Ref<boolean>;
2657
- onReset: import("vue").Ref<boolean>;
2658
- };
2643
+ default: () => {};
2659
2644
  };
2660
2645
  onSearch: {
2661
2646
  type: import("vue").PropType<(params: Recordable<any>) => void>;
@@ -2796,7 +2781,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2796
2781
  default: () => {};
2797
2782
  };
2798
2783
  layout: {
2799
- type: import("vue").PropType<"vertical" | "horizontal" | "inline">;
2784
+ type: import("vue").PropType<"vertical" | "inline" | "horizontal">;
2800
2785
  default: string;
2801
2786
  };
2802
2787
  labelWidth: {
@@ -2840,7 +2825,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2840
2825
  default: () => {};
2841
2826
  };
2842
2827
  size: {
2843
- type: import("vue").PropType<"small" | "middle" | "large">;
2828
+ type: import("vue").PropType<"middle" | "small" | "large">;
2844
2829
  default: string;
2845
2830
  };
2846
2831
  disabled: {
@@ -2883,10 +2868,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2883
2868
  type: import("vue").PropType<{
2884
2869
  [key: string]: import("vue").Ref<boolean>;
2885
2870
  }>;
2886
- default: () => {
2887
- onSearch: import("vue").Ref<boolean>;
2888
- onReset: import("vue").Ref<boolean>;
2889
- };
2871
+ default: () => {};
2890
2872
  };
2891
2873
  onSearch: {
2892
2874
  type: import("vue").PropType<(params: Recordable<any>) => void>;
@@ -2909,11 +2891,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
2909
2891
  }>> & {
2910
2892
  onRegister?: (...args: any[]) => any;
2911
2893
  }, {
2912
- size: "small" | "middle" | "large";
2913
2894
  mode: "search" | "dialog";
2914
2895
  autoFetch: boolean;
2915
2896
  model: {};
2916
- layout: "vertical" | "horizontal" | "inline";
2897
+ layout: "vertical" | "inline" | "horizontal";
2917
2898
  labelWidth: string | number;
2918
2899
  enLabelWidth: string | number;
2919
2900
  labelAlign: "left" | "right";
@@ -2921,6 +2902,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
2921
2902
  wrapperCol: {};
2922
2903
  rowProps: {};
2923
2904
  colProps: {};
2905
+ size: "middle" | "small" | "large";
2924
2906
  disabled: boolean;
2925
2907
  compact: boolean;
2926
2908
  schemas: FormSchema[];
@@ -16,7 +16,7 @@ export declare const BasicProps: {
16
16
  default: () => {};
17
17
  };
18
18
  layout: {
19
- type: PropType<"vertical" | "horizontal" | "inline">;
19
+ type: PropType<"vertical" | "inline" | "horizontal">;
20
20
  default: string;
21
21
  };
22
22
  labelWidth: {
@@ -41,8 +41,8 @@ export declare const BasicProps: {
41
41
  };
42
42
  rowProps: {
43
43
  type: PropType<Partial<import("vue").ExtractPropTypes<{
44
- align: PropType<"middle" | "top" | "bottom" | "stretch">;
45
- justify: PropType<"center" | "start" | "space-around" | "space-between" | "end">;
44
+ align: PropType<"stretch" | "bottom" | "top" | "middle">;
45
+ justify: PropType<"space-around" | "space-between" | "center" | "end" | "start">;
46
46
  prefixCls: StringConstructor;
47
47
  gutter: {
48
48
  type: PropType<import("ant-design-vue/lib/grid/Row").Gutter | [import("ant-design-vue/lib/grid/Row").Gutter, import("ant-design-vue/lib/grid/Row").Gutter]>;
@@ -60,7 +60,7 @@ export declare const BasicProps: {
60
60
  default: () => {};
61
61
  };
62
62
  size: {
63
- type: PropType<"small" | "large" | "middle">;
63
+ type: PropType<"middle" | "small" | "large">;
64
64
  default: string;
65
65
  };
66
66
  disabled: {
@@ -103,10 +103,7 @@ export declare const BasicProps: {
103
103
  type: PropType<{
104
104
  [key: string]: Ref<boolean>;
105
105
  }>;
106
- default: () => {
107
- onSearch: Ref<boolean>;
108
- onReset: Ref<boolean>;
109
- };
106
+ default: () => {};
110
107
  };
111
108
  onSearch: {
112
109
  type: PropType<(params: Recordable) => void>;
@@ -96,8 +96,6 @@ function useModal(props, setModalData) {
96
96
  };
97
97
  watchEffect(() => {
98
98
  const data = dataTransfer[unref(uidRef)];
99
- if (!data)
100
- return;
101
99
  if (!setModalData || !isFunction(setModalData))
102
100
  return;
103
101
  nextTick(() => {
@@ -216,7 +214,6 @@ function useDragMove(context) {
216
214
  const screenHeight = document.documentElement.clientHeight;
217
215
  const dragDomWidth = dragDom.offsetWidth;
218
216
  const dragDomheight = dragDom.offsetHeight;
219
- console.log(dragDomWidth, dragDomheight, screenHeight, screenWidth);
220
217
  const minDragDomLeft = dragDom.offsetLeft;
221
218
  const maxDragDomLeft = screenWidth - dragDom.offsetLeft - dragDomWidth;
222
219
  const minDragDomTop = dragDom.offsetTop;
@@ -888,8 +885,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
888
885
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.buttonList, (button) => {
889
886
  return openBlock(), createElementBlock(Fragment, null, [
890
887
  (button.show === void 0 ? true : button.show) ? withDirectives((openBlock(), createBlock(_component_AButton, {
888
+ class: normalizeClass(["items-center", button.class]),
891
889
  type: button.type,
892
- class: normalizeClass(button.class),
893
890
  loading: button.loading,
894
891
  disabled: button.disabled,
895
892
  key: unref(key),
@@ -955,8 +952,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
955
952
  if (props.buttons && props.buttons.length)
956
953
  return props.buttons;
957
954
  let buttonActions = [
958
- { t: "\u4FDD\u5B58", label: props.okText || t("SAVE"), preIcon: "mdi:content-save", type: "primary", flag: "OK" },
959
- { t: "\u5173\u95ED", label: props.cancelText || t("CLOSE"), preIcon: "mdi:close", flag: "CANCEL" }
955
+ { t: "\u5173\u95ED", label: props.cancelText || t("CLOSE"), preIcon: "mdi:close", flag: "CANCEL" },
956
+ { t: "\u4FDD\u5B58", label: props.okText || t("SAVE"), preIcon: "mdi:content-save", type: "primary", flag: "OK" }
960
957
  ];
961
958
  if (!props.showSave)
962
959
  buttonActions = buttonActions.filter((btn) => btn.flag !== "OK");
@@ -107,11 +107,11 @@ declare const _sfc_main: import("vue").DefineComponent<{
107
107
  "onHandle-method"?: (...args: any[]) => any;
108
108
  }, {
109
109
  mode: "search" | "dialog";
110
- show: boolean;
111
- showAdvancedButton: boolean;
112
110
  minShowColumn: number;
113
- buttonList: ButtonProps[];
111
+ showAdvancedButton: boolean;
112
+ show: boolean;
114
113
  isAdvanced: boolean;
114
+ buttonList: ButtonProps[];
115
115
  }>;
116
116
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("handleSave" | "handleCancel")[], "handleSave" | "handleCancel", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
117
117
  buttons: PropType<ButtonProps[]>;
@@ -100,7 +100,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
100
100
  afterClose: FunctionConstructor;
101
101
  }, {
102
102
  props: any;
103
- emits: (event: "visible-change" | "height-change" | "cancel" | "save" | "register" | "update:visible", ...args: any[]) => void;
103
+ emits: (event: "register" | "visible-change" | "height-change" | "cancel" | "save" | "update:visible", ...args: any[]) => void;
104
104
  visibleRef: import("vue").Ref<boolean>;
105
105
  propsRef: import("vue").Ref<Partial<ExtractPropTypes<{
106
106
  t: {
@@ -620,11 +620,11 @@ declare const _sfc_main: import("vue").DefineComponent<{
620
620
  "onHandle-method"?: (...args: any[]) => any;
621
621
  }, {
622
622
  mode: "search" | "dialog";
623
- show: boolean;
624
- showAdvancedButton: boolean;
625
623
  minShowColumn: number;
626
- buttonList: import("../../form/src/types/form.type").ButtonProps[];
624
+ showAdvancedButton: boolean;
625
+ show: boolean;
627
626
  isAdvanced: boolean;
627
+ buttonList: import("../../form/src/types/form.type").ButtonProps[];
628
628
  }>;
629
629
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("handleSave" | "handleCancel")[], "handleSave" | "handleCancel", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
630
630
  buttons: import("vue").PropType<import("../../form/src/types/form.type").ButtonProps[]>;
@@ -649,7 +649,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
649
649
  showSave: boolean;
650
650
  showCancel: boolean;
651
651
  }>;
652
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("visible-change" | "height-change" | "cancel" | "save" | "register" | "update:visible")[], "visible-change" | "height-change" | "cancel" | "save" | "register" | "update:visible", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
652
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("register" | "visible-change" | "height-change" | "cancel" | "save" | "update:visible")[], "register" | "visible-change" | "height-change" | "cancel" | "save" | "update:visible", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
653
653
  t: {
654
654
  type: StringConstructor;
655
655
  };
@@ -747,27 +747,27 @@ declare const _sfc_main: import("vue").DefineComponent<{
747
747
  closeFunc: import("vue").PropType<() => Promise<boolean>>;
748
748
  afterClose: FunctionConstructor;
749
749
  }>> & {
750
+ onRegister?: (...args: any[]) => any;
751
+ "onUpdate:visible"?: (...args: any[]) => any;
750
752
  "onVisible-change"?: (...args: any[]) => any;
751
753
  "onHeight-change"?: (...args: any[]) => any;
752
754
  onCancel?: (...args: any[]) => any;
753
755
  onSave?: (...args: any[]) => any;
754
- onRegister?: (...args: any[]) => any;
755
- "onUpdate:visible"?: (...args: any[]) => any;
756
756
  }, {
757
+ loading: boolean;
757
758
  visible: boolean;
759
+ mask: boolean;
758
760
  closable: boolean;
759
761
  destroyOnClose: boolean;
760
762
  scrollTop: boolean;
761
763
  draggable: boolean;
762
764
  defaultFullscreen: boolean;
763
765
  canFullscreen: boolean;
764
- loading: boolean;
765
766
  loadingTip: string;
766
767
  useWrapper: boolean;
767
768
  centered: boolean;
768
769
  showOkBtn: boolean;
769
770
  showCancelBtn: boolean;
770
- mask: boolean;
771
771
  maskClosable: boolean;
772
772
  keyboard: boolean;
773
773
  }>;
@@ -2,12 +2,13 @@ import { CurdActionType } from '../../curd/src/types/curd.type';
2
2
  import { FormActionType } from '../../form/src/types/actions.type';
3
3
  import { TableActionType } from '../../table/src/types/actions.type';
4
4
  import { DownloadType } from '../../table/src/types/header.type';
5
+ import { Recordable } from "@dt-frames/core";
5
6
  import { Key } from "ant-design-vue/es/table/interface";
6
7
  import { SourceOption, TableParamsType } from "../types/source.type";
7
8
  export declare function useSource(props: SourceOption): {
8
9
  form: {
9
- onSearch: () => void;
10
- onReset: () => void;
10
+ onSearch: (params?: Recordable) => void;
11
+ onReset: (params?: Recordable) => void;
11
12
  loading: {
12
13
  [key: string]: import("vue").Ref<boolean>;
13
14
  };
@@ -21,17 +22,17 @@ export declare function useSource(props: SourceOption): {
21
22
  total: number;
22
23
  }>;
23
24
  loading: import("vue").Ref<boolean>;
24
- onSearch: () => void;
25
+ onSearch: (params?: Recordable) => void;
25
26
  onTableChange: (params: TableParamsType) => void;
26
- onAdd: () => void;
27
- onUpdate: (arg: any) => void;
28
- onDelete: (arg: any) => void;
27
+ onOPenAddDialog: () => void;
28
+ onOpenUpdateDialog: (row?: Recordable) => Promise<void>;
29
+ onDelete: (row: Recordable) => void;
29
30
  onDeletes: (ids: Key[]) => void;
30
31
  onDownload: (excelData: DownloadType, extraData?: any[]) => void;
31
32
  registerInstance: (instance: TableActionType) => TableActionType;
32
33
  };
33
34
  curd: {
34
- onSave: () => void;
35
+ onSave: (params?: Recordable) => Promise<boolean>;
35
36
  onDeletes: (ids: Key[]) => void;
36
37
  onQueryById: (id: Key) => Promise<unknown>;
37
38
  registerInstance: (instance: CurdActionType) => CurdActionType;
@@ -41,14 +42,14 @@ export declare function useSource(props: SourceOption): {
41
42
  [key: string]: import("vue").Ref<boolean>;
42
43
  };
43
44
  dataSource: import("vue").Ref<any[]>;
44
- onAdd: () => void;
45
- onUpdate: (arg: any) => void;
46
- onDelete: (arg: any) => void;
45
+ onOPenAddDialog: () => void;
46
+ onOpenUpdateDialog: (row?: Recordable) => Promise<void>;
47
+ onDelete: (row: Recordable) => void;
47
48
  onDeletes: (ids: Key[]) => void;
48
49
  onQueryById: (id: Key) => Promise<unknown>;
49
50
  onDownload: (excelData: DownloadType, extraData?: any[]) => void;
50
- onSave: () => void;
51
- onSearch: () => void;
52
- onReset: () => void;
51
+ onSave: (params?: Recordable) => Promise<boolean>;
52
+ onSearch: (params?: Recordable) => void;
53
+ onReset: (params?: Recordable) => void;
53
54
  onTableChange: (params: TableParamsType) => void;
54
55
  };
@@ -149,11 +149,14 @@ function useSource(props) {
149
149
  let tableInstance = null;
150
150
  let formInstance = null;
151
151
  let curdInstance = null;
152
- function onSearch() {
152
+ function onSearch(params = {}) {
153
+ if (!api.queryPage)
154
+ return;
153
155
  tableInstance?.clearSelectedRowKeys();
154
156
  const { defaultPageSize } = tableInstance?.getPagination() || {};
155
157
  baseData = {
156
158
  ...formInstance?.getFormValues() ?? {},
159
+ ...params,
157
160
  pageNumber: 1,
158
161
  pageSize: defaultPageSize
159
162
  };
@@ -161,9 +164,10 @@ function useSource(props) {
161
164
  loading.onQuerypage.value = true;
162
165
  setPage();
163
166
  }
164
- function onReset() {
167
+ function onReset(params = {}) {
165
168
  const { defaultPageSize } = tableInstance?.getPagination() || {};
166
169
  baseData = {
170
+ ...params,
167
171
  ...formInstance?.getFormValues() ?? {},
168
172
  pageNumber: 1,
169
173
  pageSize: defaultPageSize
@@ -173,29 +177,32 @@ function useSource(props) {
173
177
  tableInstance?.clearSelectedRowKeys();
174
178
  setPage();
175
179
  }
176
- function setPage(params = {}) {
180
+ async function setPage(params = {}) {
177
181
  if (!api.queryPage)
178
182
  return;
179
- fetch(api.queryPage, {
180
- ...toRaw(baseData),
181
- ...params
182
- }).then((rsp) => {
183
- if (isArray(rsp)) {
184
- dataSource.value.splice(0, dataSource.value.length, ...rsp);
183
+ try {
184
+ const result = await fetch(api.queryPage, {
185
+ ...toRaw(baseData),
186
+ ...params
187
+ });
188
+ if (isArray(result)) {
189
+ dataSource.value.splice(0, dataSource.value.length, ...result);
185
190
  return;
186
191
  }
187
- const { records, total, size, current } = rsp;
192
+ const { records, total, size, current } = result;
188
193
  dataSource.value.splice(0, dataSource.value.length, ...records);
189
194
  pagination.value = {
190
195
  current,
191
196
  pageSize: size || appConf?.ui?.table?.defaultPageSize,
192
197
  total
193
198
  };
194
- }).finally(() => {
199
+ } catch (err) {
200
+ console.error(`\u5206\u9875\u67E5\u8BE2\u9519\u8BEF\uFF1A${err}`);
201
+ } finally {
195
202
  loading.onSearch.value = false;
196
203
  loading.onQuerypage.value = false;
197
204
  loading.onReset.value = false;
198
- });
205
+ }
199
206
  }
200
207
  function onTableChange(params) {
201
208
  const { pagination: pagination2, sort, filter } = params;
@@ -224,53 +231,72 @@ function useSource(props) {
224
231
  };
225
232
  setPage(filter);
226
233
  }
227
- function onAdd() {
228
- curdInstance && curdInstance.add();
234
+ function onOPenAddDialog() {
235
+ curdInstance && curdInstance.openAddDialog();
229
236
  }
230
- function onUpdate(arg) {
231
- curdInstance && curdInstance.update(arg);
237
+ async function onOpenUpdateDialog(row) {
238
+ curdInstance && curdInstance.openUpdateDialog(row);
232
239
  }
233
- function onDelete(arg) {
234
- curdInstance && curdInstance.del(arg);
240
+ function onDelete(row) {
241
+ if (curdInstance) {
242
+ curdInstance.del(row);
243
+ } else {
244
+ onDeletes([row?.id]);
245
+ }
235
246
  }
236
247
  function onQueryById(id) {
237
248
  return fetch(api.queryById, { id });
238
249
  }
239
- function onSave() {
240
- let model = curdInstance && curdInstance.curdFormMethods.getFormValues();
241
- curdInstance.curdFormMethods.validate().then((rsp) => {
250
+ async function onSave(params) {
251
+ const methods = curdInstance ? curdInstance.curdFormMethods : formInstance;
252
+ if (!methods) {
253
+ console.log("\u672A\u914D\u7F6E\u8868\u5355\u5B9E\u4F8B\uFF01");
254
+ return;
255
+ }
256
+ let model = {
257
+ ...params,
258
+ ...methods.getFormValues()
259
+ };
260
+ try {
261
+ await methods.validate();
242
262
  if (beforeUpdate && isFunction(beforeUpdate)) {
243
263
  let canUpdate = beforeUpdate(model);
244
264
  if (isBoolean(canUpdate) && canUpdate === false) {
245
265
  return false;
246
- } else if (!isBoolean(canUpdate)) {
247
- model = { ...canUpdate || {} };
248
266
  }
249
267
  }
250
268
  if (!model.id) {
251
269
  loading.onAdd.value = true;
252
- fetch(api.add, { ...model }, false).then((rsp2) => {
253
- if (rsp2?.code === appConf?.http?.okCode) {
270
+ try {
271
+ const result = await fetch(api.add, { ...model }, false);
272
+ if (result?.code === appConf?.http?.okCode) {
254
273
  message.success(t("ADD_SUCCESS"));
255
- curdInstance.closeModal();
274
+ curdInstance && curdInstance.closeModal();
256
275
  if (queryAfterUpdate !== false)
257
276
  onSearch();
258
277
  }
278
+ } catch (err) {
279
+ } finally {
259
280
  loading.onAdd.value = false;
260
- });
281
+ }
261
282
  } else {
262
283
  loading.onUpdate.value = true;
263
- fetch(api.update, { ...model }, false).then((rsp2) => {
264
- if (rsp2?.code === appConf?.http?.okCode) {
284
+ try {
285
+ const result = await fetch(api.update, { ...model }, false);
286
+ if (result?.code === appConf?.http?.okCode) {
265
287
  message.success(t("UPDATE_SUCCESS"));
266
- curdInstance.closeModal();
288
+ curdInstance && curdInstance.closeModal();
267
289
  if (queryAfterUpdate !== false)
268
290
  onSearch();
269
291
  }
292
+ } catch (err) {
293
+ } finally {
270
294
  loading.onUpdate.value = false;
271
- });
295
+ }
272
296
  }
273
- });
297
+ } catch (err) {
298
+ } finally {
299
+ }
274
300
  }
275
301
  function onDeletes(ids) {
276
302
  if (!tableInstance)
@@ -336,8 +362,8 @@ function useSource(props) {
336
362
  loading: loading.onQuerypage,
337
363
  onSearch,
338
364
  onTableChange,
339
- onAdd,
340
- onUpdate,
365
+ onOPenAddDialog,
366
+ onOpenUpdateDialog,
341
367
  onDelete,
342
368
  onDeletes,
343
369
  onDownload,
@@ -356,8 +382,8 @@ function useSource(props) {
356
382
  api,
357
383
  loading,
358
384
  dataSource,
359
- onAdd,
360
- onUpdate,
385
+ onOPenAddDialog,
386
+ onOpenUpdateDialog,
361
387
  onDelete,
362
388
  onDeletes,
363
389
  onQueryById,