@dt-frames/ui 2.0.0 → 2.0.2

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 (220) hide show
  1. package/es/assets/data/icons/actions.d.ts +1 -0
  2. package/es/assets/data/icons/actions.ts +423 -0
  3. package/es/assets/data/icons/code.d.ts +1 -0
  4. package/es/assets/data/icons/code.ts +10 -0
  5. package/es/assets/data/icons/commuticate.d.ts +1 -0
  6. package/es/assets/data/icons/commuticate.ts +182 -0
  7. package/es/assets/data/icons/currency.d.ts +1 -0
  8. package/es/assets/data/icons/currency.ts +44 -0
  9. package/es/assets/data/icons/devices.d.ts +1 -0
  10. package/es/assets/data/icons/devices.ts +126 -0
  11. package/es/assets/data/icons/edit.d.ts +1 -0
  12. package/es/assets/data/icons/edit.ts +163 -0
  13. package/es/assets/data/icons/file.d.ts +1 -0
  14. package/es/assets/data/icons/file.ts +99 -0
  15. package/es/assets/data/icons/math.d.ts +1 -0
  16. package/es/assets/data/icons/math.ts +53 -0
  17. package/es/assets/data/icons/message.d.ts +1 -0
  18. package/es/assets/data/icons/message.ts +68 -0
  19. package/es/assets/data/icons/navigate.d.ts +1 -0
  20. package/es/assets/data/icons/navigate.ts +181 -0
  21. package/es/assets/data/icons/other.d.ts +1 -0
  22. package/es/assets/data/icons/other.ts +324 -0
  23. package/es/assets/data/index.d.ts +4 -0
  24. package/es/assets/data/index.ts +58 -0
  25. package/es/assets/icons/iconfont.css +7266 -0
  26. package/es/assets/icons/iconfont.eot +0 -0
  27. package/es/assets/icons/iconfont.svg +5445 -0
  28. package/es/assets/icons/iconfont.ttf +0 -0
  29. package/es/assets/icons/iconfont.woff +0 -0
  30. package/es/assets/icons/iconfont.woff2 +0 -0
  31. package/es/assets/imgs/header/avatar.png +0 -0
  32. package/es/assets/imgs/logo/logo.png +0 -0
  33. package/es/assets/imgs/table/empty.png +0 -0
  34. package/es/assets/locales/en.d.ts +101 -0
  35. package/es/assets/locales/en.ts +101 -0
  36. package/es/assets/locales/index.d.ts +2 -0
  37. package/es/assets/locales/index.ts +5 -0
  38. package/es/assets/locales/zh.d.ts +103 -0
  39. package/es/assets/locales/zh.ts +103 -0
  40. package/es/components/container/index.d.ts +93 -0
  41. package/es/components/container/index.js +288 -0
  42. package/es/components/container/index.less +64 -0
  43. package/es/components/container/src/components/bar.d.ts +14 -0
  44. package/es/components/container/src/components/scroll-bar.d.ts +70 -0
  45. package/es/components/container/src/hooks/scroll.d.ts +10 -0
  46. package/es/components/container/src/scroll-container.d.ts +76 -0
  47. package/es/components/container/src/slot-container.d.ts +18 -0
  48. package/es/components/container/src/types/scroll.type.d.ts +22 -0
  49. package/es/components/container/src/utils/scroll.d.ts +5 -0
  50. package/es/components/curd/index.d.ts +2 -0
  51. package/es/components/curd/index.js +3098 -0
  52. package/es/components/curd/src/components/Curd.d.ts +1451 -0
  53. package/es/components/curd/src/hooks/useCurd.d.ts +112 -0
  54. package/es/components/curd/src/props.d.ts +188 -0
  55. package/es/components/curd/src/types/curd.type.d.ts +19 -0
  56. package/es/components/drawer/index.d.ts +8041 -0
  57. package/es/components/drawer/index.js +837 -0
  58. package/es/components/drawer/index.less +10 -0
  59. package/es/components/drawer/src/components/DrawerFooter.d.ts +139 -0
  60. package/es/components/drawer/src/components/DrawerHeader.d.ts +13 -0
  61. package/es/components/drawer/src/hooks/useDrawer.d.ts +3 -0
  62. package/es/components/drawer/src/index.d.ts +8043 -0
  63. package/es/components/drawer/src/props.d.ts +64 -0
  64. package/es/components/drawer/src/types/index.type.d.ts +48 -0
  65. package/es/components/form/index.d.ts +3367 -0
  66. package/es/components/form/index.js +1895 -0
  67. package/es/components/form/index.less +141 -0
  68. package/es/components/form/src/components/FormButtons.d.ts +88 -0
  69. package/es/components/form/src/components/FormItem.d.ts +313 -0
  70. package/es/components/form/src/components/componentMap.d.ts +4 -0
  71. package/es/components/form/src/components/formIcon.d.ts +1231 -0
  72. package/es/components/form/src/components/formInputUseDialog.d.ts +911 -0
  73. package/es/components/form/src/components/index.d.ts +4 -0
  74. package/es/components/form/src/components/radioButton.d.ts +34 -0
  75. package/es/components/form/src/enums/index.d.ts +7 -0
  76. package/es/components/form/src/hooks/helper.d.ts +14 -0
  77. package/es/components/form/src/hooks/useForm.d.ts +6 -0
  78. package/es/components/form/src/hooks/useFormActions.d.ts +12 -0
  79. package/es/components/form/src/hooks/useFormEvent.d.ts +25 -0
  80. package/es/components/form/src/hooks/useFormValue.d.ts +3 -0
  81. package/es/components/form/src/hooks/useFormValues.d.ts +11 -0
  82. package/es/components/form/src/hooks/useLabelWidth.d.ts +22 -0
  83. package/es/components/form/src/index.d.ts +3113 -0
  84. package/es/components/form/src/props.d.ts +133 -0
  85. package/es/components/form/src/types/actions.type.d.ts +15 -0
  86. package/es/components/form/src/types/form.type.d.ts +70 -0
  87. package/es/components/icons/index.d.ts +3 -0
  88. package/es/components/icons/index.js +1969 -0
  89. package/es/components/icons/index.less +42 -0
  90. package/es/components/icons/src/pick-icon.d.ts +455 -0
  91. package/es/components/icons/src/svg-icon.d.ts +44 -0
  92. package/es/components/modal/index.d.ts +3 -0
  93. package/es/components/modal/index.js +1192 -0
  94. package/es/components/modal/index.less +54 -0
  95. package/es/components/modal/src/components/CloseIcon.d.ts +40 -0
  96. package/es/components/modal/src/components/Modal.d.ts +215 -0
  97. package/es/components/modal/src/components/ModalFooter.d.ts +139 -0
  98. package/es/components/modal/src/components/ModalWrap.d.ts +153 -0
  99. package/es/components/modal/src/hooks/useDrag.d.ts +7 -0
  100. package/es/components/modal/src/hooks/useFullScreen.d.ts +6 -0
  101. package/es/components/modal/src/hooks/useModal.d.ts +5 -0
  102. package/es/components/modal/src/index.d.ts +881 -0
  103. package/es/components/modal/src/props.d.ts +100 -0
  104. package/es/components/modal/src/types/modal.type.d.ts +17 -0
  105. package/es/components/source/hooks/useDownload.d.ts +8 -0
  106. package/es/components/source/hooks/useSource.d.ts +40 -0
  107. package/es/components/source/index.d.ts +2 -0
  108. package/es/components/source/index.js +331 -0
  109. package/es/components/source/types/source.type.d.ts +37 -0
  110. package/es/components/source/utils/index.d.ts +8 -0
  111. package/es/components/table/index.d.ts +3 -0
  112. package/es/components/table/index.js +4414 -0
  113. package/es/components/table/index.less +183 -0
  114. package/es/components/table/src/components/TableAction.d.ts +70 -0
  115. package/es/components/table/src/components/TableHeader.d.ts +1243 -0
  116. package/es/components/table/src/components/TableRender.d.ts +13 -0
  117. package/es/components/table/src/components/editTable/CellComponent.d.ts +22 -0
  118. package/es/components/table/src/components/editTable/EditTableCell.d.ts +93 -0
  119. package/es/components/table/src/components/editTable/componentMap.d.ts +4 -0
  120. package/es/components/table/src/components/editTable/index.d.ts +9 -0
  121. package/es/components/table/src/components/editTable/props.d.ts +27 -0
  122. package/es/components/table/src/components/tableSetting/Column.d.ts +69 -0
  123. package/es/components/table/src/components/tableSetting/Download.d.ts +1029 -0
  124. package/es/components/table/src/components/tableSetting/DownloadCtrl.d.ts +995 -0
  125. package/es/components/table/src/components/tableSetting/Fullscreen.d.ts +22 -0
  126. package/es/components/table/src/components/tableSetting/index.d.ts +1137 -0
  127. package/es/components/table/src/hooks/useColumns.d.ts +14 -0
  128. package/es/components/table/src/hooks/useCustomRow.d.ts +20 -0
  129. package/es/components/table/src/hooks/useDataSource.d.ts +16 -0
  130. package/es/components/table/src/hooks/useHeader.d.ts +8 -0
  131. package/es/components/table/src/hooks/useHeaderCode.d.ts +3 -0
  132. package/es/components/table/src/hooks/useLoading.d.ts +6 -0
  133. package/es/components/table/src/hooks/usePagination.d.ts +122 -0
  134. package/es/components/table/src/hooks/useRow.d.ts +5 -0
  135. package/es/components/table/src/hooks/useRowSelection.d.ts +12 -0
  136. package/es/components/table/src/hooks/useTable.d.ts +9 -0
  137. package/es/components/table/src/hooks/useTableInstance.d.ts +16 -0
  138. package/es/components/table/src/hooks/useTableScroll.d.ts +13 -0
  139. package/es/components/table/src/index.d.ts +990 -0
  140. package/es/components/table/src/props.d.ts +244 -0
  141. package/es/components/table/src/types/actions.type.d.ts +22 -0
  142. package/es/components/table/src/types/header.type.d.ts +23 -0
  143. package/es/components/table/src/types/table.type.d.ts +92 -0
  144. package/es/directives/icon.d.ts +2 -0
  145. package/es/directives/index.d.ts +7 -0
  146. package/es/directives/index.js +2015 -0
  147. package/es/directives/permission.d.ts +2 -0
  148. package/es/global.d.ts +7 -0
  149. package/es/index.d.ts +1 -0
  150. package/es/index.js +3242 -0
  151. package/es/theme/index.d.ts +10 -0
  152. package/es/theme/index.js +3242 -0
  153. package/es/theme/index.less +603 -0
  154. package/es/theme/src/components/content/index.d.ts +27 -0
  155. package/es/theme/src/components/feature/back-top.d.ts +5 -0
  156. package/es/theme/src/components/feature/index.d.ts +7 -0
  157. package/es/theme/src/components/footer/index.d.ts +31 -0
  158. package/es/theme/src/components/header/components/bread-crumb.d.ts +6 -0
  159. package/es/theme/src/components/header/components/fullscreen.d.ts +5 -0
  160. package/es/theme/src/components/header/components/index.d.ts +11 -0
  161. package/es/theme/src/components/header/components/lang-picker.d.ts +23 -0
  162. package/es/theme/src/components/header/components/logo.d.ts +36 -0
  163. package/es/theme/src/components/header/components/menu-filter.d.ts +22 -0
  164. package/es/theme/src/components/header/components/notify.d.ts +23 -0
  165. package/es/theme/src/components/header/components/setting-theme.d.ts +222 -0
  166. package/es/theme/src/components/header/components/size.d.ts +282 -0
  167. package/es/theme/src/components/header/components/theme-drawer/feature.d.ts +138 -0
  168. package/es/theme/src/components/header/components/theme-drawer/index.d.ts +3 -0
  169. package/es/theme/src/components/header/components/theme-drawer/menu-type.d.ts +16 -0
  170. package/es/theme/src/components/header/components/theme-drawer/select.d.ts +58 -0
  171. package/es/theme/src/components/header/components/theme-drawer/switch.d.ts +49 -0
  172. package/es/theme/src/components/header/components/trigger.d.ts +10 -0
  173. package/es/theme/src/components/header/components/user-info.d.ts +36 -0
  174. package/es/theme/src/components/header/helper/change-theme.d.ts +13 -0
  175. package/es/theme/src/components/header/helper/menu-tree.d.ts +3 -0
  176. package/es/theme/src/components/header/index.d.ts +698 -0
  177. package/es/theme/src/components/header/multiple-header.d.ts +787 -0
  178. package/es/theme/src/components/sider/components/basic-menu/basic-menu-item.d.ts +62 -0
  179. package/es/theme/src/components/sider/components/basic-menu/basic-menu.d.ts +207 -0
  180. package/es/theme/src/components/sider/components/basic-menu/basic-sub-menu-item.d.ts +127 -0
  181. package/es/theme/src/components/sider/components/basic-menu/menu-item-content.d.ts +26 -0
  182. package/es/theme/src/components/sider/components/drag-bar.d.ts +14 -0
  183. package/es/theme/src/components/sider/components/layout-menu.d.ts +22 -0
  184. package/es/theme/src/components/sider/components/props.d.ts +69 -0
  185. package/es/theme/src/components/sider/components/sider-trigger.d.ts +18 -0
  186. package/es/theme/src/components/sider/helper/sider.d.ts +12 -0
  187. package/es/theme/src/components/sider/helper/split-menu.d.ts +10 -0
  188. package/es/theme/src/components/sider/index.d.ts +70 -0
  189. package/es/theme/src/components/tabs/components/TabContent.d.ts +6 -0
  190. package/es/theme/src/components/tabs/components/TabRedo.d.ts +21 -0
  191. package/es/theme/src/components/tabs/components/index.d.ts +3 -0
  192. package/es/theme/src/components/tabs/hooks/useMultifyTabs.d.ts +7 -0
  193. package/es/theme/src/components/tabs/hooks/useTabDropdown.d.ts +6 -0
  194. package/es/theme/src/components/tabs/index.d.ts +63 -0
  195. package/es/theme/src/components/tabs/types/tabs.type.d.ts +7 -0
  196. package/es/theme/src/enums/index.d.ts +1 -0
  197. package/es/theme/src/enums/theme.enum.d.ts +33 -0
  198. package/es/theme/src/hooks/index.d.ts +6 -0
  199. package/es/theme/src/hooks/useDragLine.d.ts +2 -0
  200. package/es/theme/src/hooks/useHeader.d.ts +25 -0
  201. package/es/theme/src/hooks/useMenu.d.ts +27 -0
  202. package/es/theme/src/hooks/useMultifyTab.d.ts +7 -0
  203. package/es/theme/src/hooks/useOpenKeys.d.ts +7 -0
  204. package/es/theme/src/hooks/useTheme.d.ts +9 -0
  205. package/es/theme/src/index.d.ts +1644 -0
  206. package/es/theme/src/setting/theme.setting.d.ts +2 -0
  207. package/es/theme/src/stores/index.d.ts +3 -0
  208. package/es/theme/src/stores/routeReuse.store.d.ts +23 -0
  209. package/es/theme/src/stores/theme.store.d.ts +15 -0
  210. package/es/theme/src/types/index.d.ts +3 -0
  211. package/es/theme/src/types/menu.type.d.ts +15 -0
  212. package/es/theme/src/types/theme.type.d.ts +60 -0
  213. package/es/utils/withInstall.d.ts +4 -0
  214. package/index.d.ts +10 -0
  215. package/index.js +34 -0
  216. package/package.json +1 -5
  217. package/tailwind.config.cjs +11 -0
  218. package/tsconfig.json +41 -0
  219. package/tsconfig.node.json +9 -0
  220. package/vite.config.ts +78 -0
@@ -0,0 +1,100 @@
1
+ import { ButtonProps } from '../../form/src/types/form.type';
2
+ import { ComputedRef, CSSProperties, PropType } from "vue";
3
+ export declare const basicProps: {
4
+ t: {
5
+ type: StringConstructor;
6
+ };
7
+ visible: {
8
+ type: BooleanConstructor;
9
+ };
10
+ closable: {
11
+ type: BooleanConstructor;
12
+ default: boolean;
13
+ };
14
+ destroyOnClose: {
15
+ type: BooleanConstructor;
16
+ };
17
+ scrollTop: {
18
+ type: BooleanConstructor;
19
+ default: boolean;
20
+ };
21
+ height: {
22
+ type: NumberConstructor;
23
+ };
24
+ minHeight: {
25
+ type: NumberConstructor;
26
+ };
27
+ width: {
28
+ type: PropType<String | Number>;
29
+ };
30
+ draggable: {
31
+ type: BooleanConstructor;
32
+ default: boolean;
33
+ };
34
+ defaultFullscreen: {
35
+ type: BooleanConstructor;
36
+ };
37
+ canFullscreen: {
38
+ type: BooleanConstructor;
39
+ default: boolean;
40
+ };
41
+ title: {
42
+ type: PropType<String | ComputedRef<String>>;
43
+ };
44
+ loading: {
45
+ type: BooleanConstructor;
46
+ default: boolean;
47
+ };
48
+ loadingTip: {
49
+ type: StringConstructor;
50
+ default: string;
51
+ };
52
+ useWrapper: {
53
+ type: BooleanConstructor;
54
+ default: boolean;
55
+ };
56
+ wrapClassName: {
57
+ type: StringConstructor;
58
+ };
59
+ zIndex: {
60
+ type: NumberConstructor;
61
+ };
62
+ centered: {
63
+ type: BooleanConstructor;
64
+ };
65
+ showOkBtn: {
66
+ type: BooleanConstructor;
67
+ default: boolean;
68
+ };
69
+ showCancelBtn: {
70
+ type: BooleanConstructor;
71
+ default: boolean;
72
+ };
73
+ okText: {
74
+ type: StringConstructor;
75
+ };
76
+ cancelText: {
77
+ type: StringConstructor;
78
+ };
79
+ mask: {
80
+ type: BooleanConstructor;
81
+ default: boolean;
82
+ };
83
+ maskClosable: {
84
+ type: BooleanConstructor;
85
+ default: boolean;
86
+ };
87
+ keyboard: {
88
+ type: BooleanConstructor;
89
+ default: boolean;
90
+ };
91
+ maskStyle: PropType<CSSProperties>;
92
+ footer: {
93
+ type: PropType<ButtonProps[]>;
94
+ };
95
+ bodyStyle: PropType<CSSProperties>;
96
+ wrapperProps: ObjectConstructor;
97
+ getContainer: PropType<() => any>;
98
+ closeFunc: PropType<() => Promise<boolean>>;
99
+ afterClose: FunctionConstructor;
100
+ };
@@ -0,0 +1,17 @@
1
+ import { ExtractPropTypes } from "vue";
2
+ import { basicProps } from "../props";
3
+ export declare type ModalMethods = {
4
+ setModalProps: (props: Partial<ExtractPropTypes<typeof basicProps>>) => void;
5
+ redoModalHeight?: () => void;
6
+ };
7
+ export interface ReturnMethods extends ModalMethods {
8
+ openModal: <T = any, U = any>(params?: T, afterClose?: (res: U) => void) => void;
9
+ closeModal: () => void;
10
+ }
11
+ export interface ReturnInnerMethods extends ModalMethods {
12
+ closeModal: <T = any>(res?: T) => void;
13
+ setLoading: (loading: boolean) => void;
14
+ }
15
+ export declare type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void;
16
+ export declare type UseModalReturnType = [RegisterFn, ReturnMethods];
17
+ export declare type UseModalInnerReturnType = [RegisterFn, ReturnInnerMethods];
@@ -0,0 +1,8 @@
1
+ import { DownloadType } from '../../table/src/types/header.type';
2
+ import { Recordable, ApiType } from "@dt-frames/core";
3
+ import { ComputedRef } from "vue";
4
+ export declare function useDownload(exportUrl: string | ApiType, exportName: string | ComputedRef): {
5
+ download: (excelData: DownloadType & {
6
+ params: Recordable;
7
+ }, extraData?: any[]) => void;
8
+ };
@@ -0,0 +1,40 @@
1
+ import { CurdActionType } from '../../curd/src/types/curd.type';
2
+ import { FormActionType } from '../../form/src/types/actions.type';
3
+ import { TableActionType } from '../../table/src/types/actions.type';
4
+ import { DownloadType } from '../../table/src/types/header.type';
5
+ import { Key } from "ant-design-vue/es/table/interface";
6
+ import { SourceOption, TableParamsType } from "../types/source.type";
7
+ export declare function useSource(props: SourceOption): {
8
+ form: {
9
+ onSearch: () => void;
10
+ onReset: () => void;
11
+ loading: {
12
+ [key: string]: import("vue").Ref<boolean>;
13
+ };
14
+ registerInstance: (instance: FormActionType) => FormActionType;
15
+ };
16
+ table: {
17
+ dataSource: import("vue").Ref<any[]>;
18
+ pagination: import("vue").Ref<{
19
+ current: number;
20
+ pageSize: number;
21
+ total: number;
22
+ }>;
23
+ loading: import("vue").Ref<boolean>;
24
+ onTableChange: (params: TableParamsType) => void;
25
+ onAdd: () => void;
26
+ onUpdate: (arg: any) => void;
27
+ onDelete: (arg: any) => void;
28
+ onDeletes: (ids: Key[]) => void;
29
+ onDownload: (excelData: DownloadType, extraData?: any[]) => void;
30
+ registerInstance: (instance: TableActionType) => TableActionType;
31
+ };
32
+ curd: {
33
+ onSave: () => void;
34
+ onDeletes: (ids: Key[]) => void;
35
+ onQueryById: (id: Key) => Promise<unknown>;
36
+ registerInstance: (instance: CurdActionType) => CurdActionType;
37
+ };
38
+ onSearch: () => void;
39
+ onTableChange: (params: TableParamsType) => void;
40
+ };
@@ -0,0 +1,2 @@
1
+ import { useSource } from "./hooks/useSource";
2
+ export { useSource };
@@ -0,0 +1,331 @@
1
+ import { isString, http, isObject, useAppStore, error, getDictValueByCode, formatNumber, useI18n, useMessage, isArray } from "@dt-frames/core";
2
+ import { isObject as isObject$1 } from "@vueuse/core";
3
+ import { capitalize } from "lodash-es";
4
+ import * as xlsx from "xlsx";
5
+ import dayjs from "dayjs";
6
+ const getApi = (api, baseUrl) => {
7
+ const loading = {
8
+ onSearch: ref(false),
9
+ onReset: ref(false)
10
+ };
11
+ const newApi = {};
12
+ const testIsFullApi = (str) => str.startsWith("/") ? str : baseUrl + str;
13
+ for (let it in api) {
14
+ loading["on" + capitalize(it)] = ref(false);
15
+ const item = api[it];
16
+ if (isString(item)) {
17
+ newApi[it] = testIsFullApi(item);
18
+ } else {
19
+ newApi[it] = {
20
+ ...item,
21
+ api: testIsFullApi(item.api)
22
+ };
23
+ }
24
+ }
25
+ return {
26
+ api: newApi,
27
+ loading
28
+ };
29
+ };
30
+ function useDownload(exportUrl, exportName) {
31
+ function download(excelData, extraData = []) {
32
+ const { params: searchDTO, type, columns } = excelData;
33
+ switch (type) {
34
+ case "all":
35
+ http.exportFile(
36
+ exportUrl,
37
+ {
38
+ fields: setDownloadAllHeaders(columns),
39
+ tableName: unref(exportName),
40
+ fileType: "xlsx",
41
+ searchDTO
42
+ },
43
+ `${unref(exportName)}.xlsx`
44
+ );
45
+ break;
46
+ case "current":
47
+ case "select":
48
+ handleDownloadPage(excelData, unref(exportName), extraData);
49
+ break;
50
+ }
51
+ }
52
+ function setDownloadAllHeaders(columns) {
53
+ return columns.map((it) => {
54
+ let column = {
55
+ propertyName: it.dataIndex,
56
+ head: it.title
57
+ };
58
+ if (it.render && isObject(it.render)) {
59
+ const { dict, date, number } = it.render;
60
+ if (isString(dict)) {
61
+ column.dictCode = dict;
62
+ } else if (isObject(dict)) {
63
+ column.struCode = dict.struCode;
64
+ column.struKey = dict.label;
65
+ } else if (date) {
66
+ column.format = date;
67
+ } else if (number) {
68
+ column.format = number;
69
+ }
70
+ }
71
+ return column;
72
+ });
73
+ }
74
+ function handleDownloadPage({ columns = [], rows = [] }, exportName2 = "", extraData = []) {
75
+ const titles = columns.map((it) => it.title);
76
+ const content = rows.reduce((total, it) => {
77
+ const rowData = columns.map((column) => {
78
+ let value = it[column.dataIndex.toString()];
79
+ if (column.render && isObject(column.render) && value !== void 0) {
80
+ const { dict, date, number, percent, struc } = column.render;
81
+ if (struc) {
82
+ const { appConf } = useAppStore();
83
+ let apiStruc = appConf.structure[struc];
84
+ if (!apiStruc) {
85
+ error(`${struc}\u672A\u5728structure\u4E2D\u914D\u7F6E`);
86
+ } else {
87
+ return getDictValueByCode(value, apiStruc);
88
+ }
89
+ } else if (date) {
90
+ return dayjs(value).format(date);
91
+ } else if (dict) {
92
+ return unref(getDictValueByCode(value, dict));
93
+ } else if (percent) {
94
+ return formatNumber((value || 0) * 100, percent) + "%";
95
+ } else if (number) {
96
+ return formatNumber(value, number);
97
+ }
98
+ }
99
+ return value;
100
+ });
101
+ total.push(rowData);
102
+ return total;
103
+ }, []);
104
+ let excelHeader = [titles];
105
+ if (extraData && extraData.length > 0) {
106
+ excelHeader = [...extraData, titles];
107
+ }
108
+ export2Excel(
109
+ excelHeader.concat(content),
110
+ exportName2
111
+ );
112
+ }
113
+ function export2Excel(data = [], exportName2 = "") {
114
+ const worksheet = xlsx.utils.aoa_to_sheet(data);
115
+ const fileName = exportName2.substring(0, 26) + ".xlsx";
116
+ const workbook = {
117
+ SheetNames: [fileName],
118
+ Sheets: {
119
+ [fileName]: worksheet
120
+ }
121
+ };
122
+ xlsx.writeFile(
123
+ workbook,
124
+ fileName,
125
+ { bookType: "xlsx" }
126
+ );
127
+ }
128
+ return {
129
+ download
130
+ };
131
+ }
132
+ function useSource(props) {
133
+ const { t } = useI18n("UI");
134
+ const { confirm, message } = useMessage();
135
+ const { appConf } = useAppStore();
136
+ const { baseUrl, api: orgApi, immediateSearch = true, exportName, beforeUpdate, afterUpdate } = props;
137
+ const pagination = ref({
138
+ current: appConf?.ui?.table?.defaultPageNo || 1,
139
+ pageSize: appConf?.ui?.table?.defaultPageSize || 20,
140
+ total: 0
141
+ });
142
+ const { loading, api } = getApi(orgApi, baseUrl);
143
+ const dataSource = ref([]);
144
+ const baseData = reactive({
145
+ entityDTO: {},
146
+ orderDTOs: []
147
+ });
148
+ let tableInstance = null;
149
+ let formInstance = null;
150
+ let curdInstance = null;
151
+ function onSearch() {
152
+ tableInstance?.clearSelectedRowKeys();
153
+ const { defaultPageSize } = tableInstance?.getPagination() || {};
154
+ baseData.pageDTO = {
155
+ pageNo: 0,
156
+ pageSize: defaultPageSize
157
+ };
158
+ loading.onSearch.value = true;
159
+ setPage();
160
+ }
161
+ function onReset() {
162
+ baseData.entityDTO = { ...formInstance?.getFormValues() ?? {} };
163
+ baseData.pageDTO.pageNo = 0;
164
+ loading.onReset.value = true;
165
+ tableInstance?.clearSelectedRowKeys();
166
+ setPage();
167
+ }
168
+ function setPage(params = {}) {
169
+ if (!api.queryPage)
170
+ return;
171
+ fetch(api.queryPage, {
172
+ ...toRaw(baseData),
173
+ ...params
174
+ }).then((rsp) => {
175
+ if (isArray(rsp)) {
176
+ dataSource.value.splice(0, dataSource.value.length, ...rsp);
177
+ return;
178
+ }
179
+ const { records, pageDTO } = rsp;
180
+ dataSource.value.splice(0, dataSource.value.length, ...records);
181
+ pagination.value = {
182
+ current: (pageDTO?.pageNo ?? 0) + 1,
183
+ pageSize: pageDTO?.pageSize ?? appConf?.ui?.table?.defaultPageSize,
184
+ total: pageDTO?.totalCount ?? 0
185
+ };
186
+ }).finally(() => {
187
+ loading.onSearch.value = false;
188
+ loading.onQuerypage.value = false;
189
+ loading.onReset.value = false;
190
+ });
191
+ }
192
+ function onTableChange(params) {
193
+ const { pagination: pagination2, sort, filter } = params;
194
+ baseData.pageDTO = {
195
+ pageNo: pagination2.current - 1,
196
+ pageSize: pagination2.pageSize
197
+ };
198
+ baseData.orderDTOs = (isObject$1(sort) ? [sort] : sort).map((it) => {
199
+ if (it.order) {
200
+ return {
201
+ propertyName: it.field,
202
+ dir: it.order === "ascend" ? "asc" : "desc"
203
+ };
204
+ }
205
+ }).filter((it) => it);
206
+ setPage(filter);
207
+ }
208
+ function onAdd() {
209
+ curdInstance && curdInstance.add();
210
+ }
211
+ function onUpdate(arg) {
212
+ curdInstance && curdInstance.update(arg);
213
+ }
214
+ function onDelete(arg) {
215
+ curdInstance && curdInstance.del(arg);
216
+ }
217
+ function onQueryById(id) {
218
+ return fetch(api.queryById, { id });
219
+ }
220
+ function onSave() {
221
+ let model = curdInstance && curdInstance.curdFormMethods.getFormValues();
222
+ curdInstance.curdFormMethods.validate().then((rsp) => {
223
+ if (!model.id) {
224
+ loading.onAdd.value = true;
225
+ fetch(api.add, { ...model }, false).then((rsp2) => {
226
+ if (rsp2?.code === 0) {
227
+ message.success(t("ADD_SUCCESS"));
228
+ curdInstance.closeModal();
229
+ onSearch();
230
+ }
231
+ loading.onAdd.value = false;
232
+ });
233
+ } else {
234
+ loading.onUpdate.value = true;
235
+ fetch(api.update, { ...model }, false).then((rsp2) => {
236
+ if (rsp2?.code === 0) {
237
+ message.success(t("UPDATE_SUCCESS"));
238
+ curdInstance.closeModal();
239
+ onSearch();
240
+ }
241
+ loading.onUpdate.value = false;
242
+ });
243
+ }
244
+ });
245
+ }
246
+ function onDeletes(ids) {
247
+ if (!tableInstance)
248
+ return;
249
+ if (!api.deletes) {
250
+ message.error(t("EMPTY_URL"));
251
+ return;
252
+ }
253
+ const _ids = ids || tableInstance.getSelectedRowKeys();
254
+ if (!_ids.length) {
255
+ message.error(t("EMPTY"));
256
+ return;
257
+ }
258
+ const isSingleDelete = !!ids;
259
+ !isSingleDelete && (loading.onDeletes.value = true);
260
+ confirm({
261
+ title: isSingleDelete ? t("DELETE_CONFIRM") : t("MULTIFY_DELETE_CONFIRM"),
262
+ content: isSingleDelete ? t("CONFIRM_DELETE") : t("CONFIRM_MULTIFY_DELETE", { length: _ids.length }),
263
+ iconType: "warning",
264
+ onOk() {
265
+ fetch(api.deletes, toRaw(_ids), false).then((rsp) => {
266
+ if (rsp?.code === 0) {
267
+ message.success((isSingleDelete ? "" : t("MULTIFY")) + t("DELETE_SUCCESS"));
268
+ !isSingleDelete && tableInstance.clearSelectedRowKeys();
269
+ onSearch();
270
+ }
271
+ }).finally(() => {
272
+ isSingleDelete && (loading.onDeletes.value = false);
273
+ });
274
+ }
275
+ });
276
+ }
277
+ function onDownload(excelData, extraData = []) {
278
+ const { download } = useDownload(api.export, exportName);
279
+ download({ ...excelData, params: baseData }, extraData);
280
+ }
281
+ function fetch(api2, params, onlyData = true) {
282
+ const { type = "post", header = {} } = isObject$1(api2) ? api2 : {};
283
+ return new Promise((resolve, reject) => {
284
+ http[type](api2, params, {
285
+ ...header,
286
+ onlyData: false
287
+ }).then(
288
+ (data) => {
289
+ resolve(onlyData ? data?.data : data);
290
+ },
291
+ (error2) => {
292
+ reject(error2);
293
+ }
294
+ );
295
+ });
296
+ }
297
+ const form = {
298
+ onSearch,
299
+ onReset,
300
+ loading,
301
+ registerInstance: (instance) => formInstance = instance
302
+ };
303
+ const table = {
304
+ dataSource,
305
+ pagination,
306
+ loading: loading.onQuerypage,
307
+ onTableChange,
308
+ onAdd,
309
+ onUpdate,
310
+ onDelete,
311
+ onDeletes,
312
+ onDownload,
313
+ registerInstance: (instance) => tableInstance = instance
314
+ };
315
+ const curd = {
316
+ onSave,
317
+ onDeletes,
318
+ onQueryById,
319
+ registerInstance: (instance) => curdInstance = instance
320
+ };
321
+ return {
322
+ form,
323
+ table,
324
+ curd,
325
+ onSearch,
326
+ onTableChange
327
+ };
328
+ }
329
+ export {
330
+ useSource
331
+ };
@@ -0,0 +1,37 @@
1
+ import { ApiType, Recordable } from "@dt-frames/core";
2
+ import { ComputedRef } from "vue";
3
+ export declare type ApiObjType = {
4
+ add?: string | ApiType;
5
+ update?: string | ApiType;
6
+ save?: string | ApiType;
7
+ deletes?: string | ApiType;
8
+ queryById?: string | ApiType;
9
+ queryPage?: string | ApiType;
10
+ [key: string]: string | ApiType;
11
+ };
12
+ export declare type SourceOption = {
13
+ baseUrl?: string;
14
+ exportName?: string | ComputedRef;
15
+ immediateSearch?: boolean;
16
+ beforeUpdate?: () => boolean | undefined;
17
+ afterUpdate?: () => void;
18
+ api?: ApiObjType;
19
+ };
20
+ export declare type orderType = {
21
+ field: string | number;
22
+ order: 'asc' | 'desc';
23
+ };
24
+ export declare type BaseDataType = {
25
+ entityDTO?: any;
26
+ pageDTO?: {
27
+ pageNo: Number;
28
+ pageSize: Number;
29
+ } | null;
30
+ orderDTOs: orderType[];
31
+ };
32
+ export declare type TableParamsType = {
33
+ pagination: any;
34
+ showBtnLoading: boolean;
35
+ sort: Recordable;
36
+ filter: any;
37
+ };
@@ -0,0 +1,8 @@
1
+ import { Ref } from "vue";
2
+ import { ApiObjType } from "../types/source.type";
3
+ export declare const getApi: (api: ApiObjType, baseUrl: string) => {
4
+ api: ApiObjType;
5
+ loading: {
6
+ [key: string]: Ref<boolean>;
7
+ };
8
+ };
@@ -0,0 +1,3 @@
1
+ import { useTable } from "./src/hooks/useTable";
2
+ import DtTable from "./src/index";
3
+ export { DtTable, useTable };