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