@dt-frames/ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/es/assets/app-antd-dark-theme-style.e3b0c442.css +0 -0
- package/es/assets/app-theme-style.e3b0c442.css +0 -0
- package/es/assets/data/icon.d.ts +4 -0
- package/es/assets/data/icon.ts +69 -0
- package/es/assets/data/icon11.ts +69 -0
- package/es/assets/data/icons/actions.d.ts +1 -0
- package/es/assets/data/icons/actions.ts +427 -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 +190 -0
- package/es/assets/data/icons/currency.d.ts +1 -0
- package/es/assets/data/icons/currency.ts +46 -0
- package/es/assets/data/icons/devices.d.ts +1 -0
- package/es/assets/data/icons/devices.ts +128 -0
- package/es/assets/data/icons/edit.d.ts +1 -0
- package/es/assets/data/icons/edit.ts +165 -0
- package/es/assets/data/icons/file.d.ts +1 -0
- package/es/assets/data/icons/file.ts +104 -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 +75 -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 +333 -0
- package/es/assets/data/icons.d.ts +4 -0
- package/es/assets/data/icons.ts +58 -0
- package/es/assets/imgs/logo/logo.png +0 -0
- package/es/assets/locales/en_US.json +3 -0
- package/es/assets/locales/zh_CN.json +3 -0
- package/es/assets/style/index.less +10 -0
- package/es/assets/style/reset.less +20 -0
- package/es/assets/style/var.less +42 -0
- package/es/components/container/index.d.ts +3 -0
- package/es/components/container/src/bar.d.ts +14 -0
- package/es/components/container/src/scroll-bar.d.ts +93 -0
- package/es/components/container/src/scroll-container.d.ts +99 -0
- package/es/components/curd/index.d.ts +2 -0
- package/es/components/curd/src/components/dialog.d.ts +1494 -0
- package/es/components/curd/src/components/props.d.ts +33 -0
- package/es/components/curd/src/hooks/useCurd.d.ts +11 -0
- package/es/components/curd/src/types/curd.type.d.ts +19 -0
- package/es/components/excel/index.d.ts +2 -0
- package/es/components/excel/src/export2Excel.d.ts +3 -0
- package/es/components/forms/index.d.ts +5 -0
- package/es/components/forms/src/componentMap.d.ts +4 -0
- package/es/components/forms/src/components/formButton.d.ts +75 -0
- package/es/components/forms/src/components/formIcon.d.ts +2845 -0
- package/es/components/forms/src/components/formItem.d.ts +59 -0
- package/es/components/forms/src/components/radioButton.d.ts +33 -0
- package/es/components/forms/src/const/form.const.d.ts +7 -0
- package/es/components/forms/src/hooks/helper.d.ts +6 -0
- package/es/components/forms/src/hooks/useForm.d.ts +5 -0
- package/es/components/forms/src/hooks/useFormActions.d.ts +13 -0
- package/es/components/forms/src/hooks/useFormEvents.d.ts +26 -0
- package/es/components/forms/src/hooks/useFormValue.d.ts +3 -0
- package/es/components/forms/src/hooks/useFormValues.d.ts +14 -0
- package/es/components/forms/src/hooks/useLabelWidth.d.ts +35 -0
- package/es/components/forms/src/index.d.ts +186 -0
- package/es/components/forms/src/prop.d.ts +79 -0
- package/es/components/forms/src/types/form.type.d.ts +124 -0
- package/es/components/icons/index.d.ts +3 -0
- package/es/components/icons/pick-icon.d.ts +529 -0
- package/es/components/icons/src/pick-icon.d.ts +432 -0
- package/es/components/icons/src/svg-icon.d.ts +44 -0
- package/es/components/icons/svg-icon.d.ts +44 -0
- package/es/components/iframe/index.d.ts +2 -0
- package/es/components/iframe/src/index.d.ts +967 -0
- package/es/components/index.d.ts +14 -0
- package/es/components/modal/index.d.ts +3 -0
- package/es/components/modal/src/components/close-icon.d.ts +344 -0
- package/es/components/modal/src/components/modal-wrap.d.ts +236 -0
- package/es/components/modal/src/components/modal.d.ts +194 -0
- package/es/components/modal/src/components/modalFooter.d.ts +102 -0
- package/es/components/modal/src/hooks/useDrag.d.ts +7 -0
- package/es/components/modal/src/hooks/useFullScreen.d.ts +12 -0
- package/es/components/modal/src/hooks/useModal.d.ts +4 -0
- package/es/components/modal/src/index.d.ts +1187 -0
- package/es/components/modal/src/props.d.ts +89 -0
- package/es/components/modal/src/types/modal.type.d.ts +22 -0
- package/es/components/router/base-router.d.ts +2 -0
- package/es/components/router/index.d.ts +2 -0
- package/es/components/source/index.d.ts +1 -0
- package/es/components/source/src/hooks/useFetch.d.ts +5 -0
- package/es/components/source/src/hooks/useSource.d.ts +33 -0
- package/es/components/source/src/index.d.ts +2 -0
- package/es/components/source/src/types/source.type.d.ts +31 -0
- package/es/components/source/src/types/table.type.d.ts +7 -0
- package/es/components/table/index.d.ts +3 -0
- package/es/components/table/src/components/TableActions.d.ts +1279 -0
- package/es/components/table/src/components/TableHeader.d.ts +28 -0
- package/es/components/table/src/components/TableRender.d.ts +25 -0
- package/es/components/table/src/components/setting/Column.d.ts +1349 -0
- package/es/components/table/src/components/setting/Download.d.ts +1144 -0
- package/es/components/table/src/components/setting/Fullscreen.d.ts +270 -0
- package/es/components/table/src/components/setting/Size.d.ts +1145 -0
- package/es/components/table/src/components/setting/index.d.ts +26 -0
- package/es/components/table/src/const.d.ts +12 -0
- package/es/components/table/src/hooks/useColumns.d.ts +12 -0
- package/es/components/table/src/hooks/useDataSource.d.ts +16 -0
- package/es/components/table/src/hooks/useFormat.d.ts +2 -0
- package/es/components/table/src/hooks/useLoading.d.ts +6 -0
- package/es/components/table/src/hooks/usePagination.d.ts +122 -0
- package/es/components/table/src/hooks/useRowSelection.d.ts +13 -0
- package/es/components/table/src/hooks/useRows.d.ts +5 -0
- package/es/components/table/src/hooks/useTable.d.ts +5 -0
- package/es/components/table/src/hooks/useTableHeader.d.ts +8 -0
- package/es/components/table/src/hooks/useTableInstance.d.ts +13 -0
- package/es/components/table/src/hooks/useTableScroll.d.ts +12 -0
- package/es/components/table/src/hooks/useVirtualScroll.d.ts +5 -0
- package/es/components/table/src/index.d.ts +565 -0
- package/es/components/table/src/props.d.ts +192 -0
- package/es/components/table/src/types/table.type.d.ts +89 -0
- package/es/components/table/src/types/tableHeader.type.d.ts +23 -0
- package/es/components/table/src/utils/format.d.ts +1 -0
- package/es/directives/icon.d.ts +2 -0
- package/es/directives/index.d.ts +6 -0
- package/es/directives/permission.d.ts +2 -0
- package/es/global.d.ts +8 -0
- package/es/index.css +1 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +8867 -0
- package/es/style/assets/style/index.less +10 -0
- package/es/style/assets/style/reset.less +20 -0
- package/es/style/assets/style/var.less +42 -0
- package/es/style/components/container/index.less +85 -0
- package/es/style/components/forms/src/index.less +82 -0
- package/es/style/components/icons/index.less +96 -0
- package/es/style/components/icons/src/index.less +96 -0
- package/es/style/components/iframe/src/index.less +3 -0
- package/es/style/components/modal/src/index.less +60 -0
- package/es/style/components/table/src/index.less +162 -0
- package/es/style/theme/footer/index.less +16 -0
- package/es/style/theme/header/index.less +438 -0
- package/es/style/theme/header/set-theme.less +68 -0
- package/es/style/theme/sider/index.less +203 -0
- package/es/style/theme/tabs/index.less +165 -0
- package/es/style/theme/theme.less +66 -0
- package/es/style/theme/transition.less +99 -0
- package/es/theme/content/index.d.ts +29 -0
- package/es/theme/feature/back-top.d.ts +105 -0
- package/es/theme/feature/index.d.ts +107 -0
- package/es/theme/footer/index.d.ts +30 -0
- package/es/theme/header/components/bread-crumb.d.ts +127 -0
- package/es/theme/header/components/fullscreen.d.ts +5 -0
- package/es/theme/header/components/handler.d.ts +2 -0
- package/es/theme/header/components/index.d.ts +10 -0
- package/es/theme/header/components/lang-picker.d.ts +290 -0
- package/es/theme/header/components/logo.d.ts +40 -0
- package/es/theme/header/components/menu-search.d.ts +528 -0
- package/es/theme/header/components/notify.d.ts +269 -0
- package/es/theme/header/components/setting-theme.d.ts +2550 -0
- package/es/theme/header/components/theme-drawer/enum.d.ts +5 -0
- package/es/theme/header/components/theme-drawer/feature.d.ts +1096 -0
- package/es/theme/header/components/theme-drawer/index.d.ts +3 -0
- package/es/theme/header/components/theme-drawer/menu-type.d.ts +273 -0
- package/es/theme/header/components/theme-drawer/select-item.d.ts +778 -0
- package/es/theme/header/components/theme-drawer/switch-item.d.ts +289 -0
- package/es/theme/header/components/trigger.d.ts +14 -0
- package/es/theme/header/components/user-info.d.ts +452 -0
- package/es/theme/header/const/index.d.ts +20 -0
- package/es/theme/header/helper/menu-tree.d.ts +3 -0
- package/es/theme/header/index.d.ts +4369 -0
- package/es/theme/header/multiple-header.d.ts +2001 -0
- package/es/theme/index.d.ts +2 -0
- package/es/theme/sider/components/basic-menu/basic-menu-item.d.ts +121 -0
- package/es/theme/sider/components/basic-menu/basic-menu.d.ts +752 -0
- package/es/theme/sider/components/basic-menu/basic-sub-menu-item.d.ts +250 -0
- package/es/theme/sider/components/basic-menu/menu-item-content.d.ts +34 -0
- package/es/theme/sider/components/drag-bar.d.ts +14 -0
- package/es/theme/sider/components/layout-menu.d.ts +22 -0
- package/es/theme/sider/components/props.d.ts +69 -0
- package/es/theme/sider/components/sider-trigger.d.ts +68 -0
- package/es/theme/sider/helper/sider.d.ts +12 -0
- package/es/theme/sider/helper/split-menu.d.ts +10 -0
- package/es/theme/sider/hooks/useDragLine.d.ts +2 -0
- package/es/theme/sider/hooks/useOpenKeys.d.ts +13 -0
- package/es/theme/sider/index.d.ts +152 -0
- package/es/theme/styles/hooks/changeTheme.d.ts +1 -0
- package/es/theme/styles/hooks/generate.d.ts +13 -0
- package/es/theme/styles/index.d.ts +2 -0
- package/es/theme/tabs/components/TabContent.d.ts +887 -0
- package/es/theme/tabs/components/TabRedo.d.ts +49 -0
- package/es/theme/tabs/hooks/useMultifyTabs.d.ts +7 -0
- package/es/theme/tabs/hooks/useTabDropdown.d.ts +6 -0
- package/es/theme/tabs/index.d.ts +1399 -0
- package/es/theme/tabs/types/tabs.type.d.ts +7 -0
- package/es/theme/theme/initTheme.d.ts +3 -0
- package/es/theme/theme/util.d.ts +5 -0
- package/es/theme/theme.d.ts +4911 -0
- package/es/themes/generate.ts +74 -0
- package/es/themes/index.ts +10 -0
- package/es/themes/modifyVars.ts +33 -0
- package/es/themes/themePlugiin.ts +74 -0
- package/package.json +49 -0
- package/src/assets/data/icons/actions.ts +427 -0
- package/src/assets/data/icons/code.ts +10 -0
- package/src/assets/data/icons/commuticate.ts +190 -0
- package/src/assets/data/icons/currency.ts +46 -0
- package/src/assets/data/icons/devices.ts +128 -0
- package/src/assets/data/icons/edit.ts +165 -0
- package/src/assets/data/icons/file.ts +104 -0
- package/src/assets/data/icons/math.ts +53 -0
- package/src/assets/data/icons/message.ts +75 -0
- package/src/assets/data/icons/navigate.ts +181 -0
- package/src/assets/data/icons/other.ts +333 -0
- package/src/assets/data/icons.ts +58 -0
- package/src/assets/imgs/logo/logo.png +0 -0
- package/src/assets/locales/en_US.json +3 -0
- package/src/assets/locales/zh_CN.json +3 -0
- package/src/assets/style/index.less +10 -0
- package/src/assets/style/reset.less +20 -0
- package/src/components/container/index.less +85 -0
- package/src/components/container/index.ts +8 -0
- package/src/components/container/src/bar.ts +107 -0
- package/src/components/container/src/lazy-container.vue +9 -0
- package/src/components/container/src/scroll-bar.vue +117 -0
- package/src/components/container/src/scroll-container.vue +61 -0
- package/src/components/curd/index.ts +5 -0
- package/src/components/curd/src/components/dialog.vue +65 -0
- package/src/components/curd/src/components/props.ts +32 -0
- package/src/components/curd/src/hooks/useCurd.tsx +72 -0
- package/src/components/curd/src/types/curd.type.ts +29 -0
- package/src/components/excel/index.ts +6 -0
- package/src/components/excel/src/export2Excel.ts +44 -0
- package/src/components/forms/index.ts +12 -0
- package/src/components/forms/src/componentMap.ts +44 -0
- package/src/components/forms/src/components/formButton.vue +150 -0
- package/src/components/forms/src/components/formIcon.vue +50 -0
- package/src/components/forms/src/components/formItem.vue +407 -0
- package/src/components/forms/src/components/radioButton.vue +58 -0
- package/src/components/forms/src/const/form.const.ts +7 -0
- package/src/components/forms/src/hooks/helper.ts +70 -0
- package/src/components/forms/src/hooks/useForm.ts +130 -0
- package/src/components/forms/src/hooks/useFormActions.ts +63 -0
- package/src/components/forms/src/hooks/useFormEvents.ts +247 -0
- package/src/components/forms/src/hooks/useFormValue.ts +49 -0
- package/src/components/forms/src/hooks/useFormValues.ts +131 -0
- package/src/components/forms/src/hooks/useLabelWidth.ts +57 -0
- package/src/components/forms/src/index.less +82 -0
- package/src/components/forms/src/index.vue +306 -0
- package/src/components/forms/src/prop.ts +80 -0
- package/src/components/forms/src/types/form.type.ts +269 -0
- package/src/components/icons/index.ts +7 -0
- package/src/components/icons/src/index.less +96 -0
- package/src/components/icons/src/pick-icon.vue +117 -0
- package/src/components/icons/src/svg-icon.vue +117 -0
- package/src/components/iframe/index.ts +5 -0
- package/src/components/iframe/src/index.less +3 -0
- package/src/components/iframe/src/index.vue +38 -0
- package/src/components/index.ts +46 -0
- package/src/components/modal/index.ts +8 -0
- package/src/components/modal/src/components/close-icon.vue +47 -0
- package/src/components/modal/src/components/modal-wrap.vue +118 -0
- package/src/components/modal/src/components/modal.tsx +30 -0
- package/src/components/modal/src/components/modalFooter.vue +38 -0
- package/src/components/modal/src/hooks/useDrag.ts +107 -0
- package/src/components/modal/src/hooks/useFullScreen.ts +27 -0
- package/src/components/modal/src/hooks/useModal.ts +177 -0
- package/src/components/modal/src/index.less +60 -0
- package/src/components/modal/src/index.vue +173 -0
- package/src/components/modal/src/props.ts +43 -0
- package/src/components/modal/src/types/modal.type.ts +27 -0
- package/src/components/router/base-router.vue +11 -0
- package/src/components/router/index.ts +3 -0
- package/src/components/source/index.ts +1 -0
- package/src/components/source/src/hooks/useFetch.ts +70 -0
- package/src/components/source/src/hooks/usePage.ts +3 -0
- package/src/components/source/src/hooks/useSource.ts +178 -0
- package/src/components/source/src/index.ts +5 -0
- package/src/components/source/src/types/source.type.ts +68 -0
- package/src/components/source/src/types/table.type.ts +8 -0
- package/src/components/table/index.ts +7 -0
- package/src/components/table/src/components/TableActions.vue +108 -0
- package/src/components/table/src/components/TableHeader.vue +77 -0
- package/src/components/table/src/components/TableRender.vue +76 -0
- package/src/components/table/src/components/setting/Column.vue +355 -0
- package/src/components/table/src/components/setting/Download.vue +55 -0
- package/src/components/table/src/components/setting/Fullscreen.vue +43 -0
- package/src/components/table/src/components/setting/Size.vue +42 -0
- package/src/components/table/src/components/setting/index.vue +64 -0
- package/src/components/table/src/const.ts +13 -0
- package/src/components/table/src/hooks/useColumns.ts +319 -0
- package/src/components/table/src/hooks/useCustomRow.ts +0 -0
- package/src/components/table/src/hooks/useDataSource.ts +99 -0
- package/src/components/table/src/hooks/useLoading.ts +29 -0
- package/src/components/table/src/hooks/usePagination.ts +76 -0
- package/src/components/table/src/hooks/useRowSelection.ts +146 -0
- package/src/components/table/src/hooks/useRows.ts +30 -0
- package/src/components/table/src/hooks/useTable.ts +77 -0
- package/src/components/table/src/hooks/useTableHeader.ts +48 -0
- package/src/components/table/src/hooks/useTableInstance.ts +29 -0
- package/src/components/table/src/hooks/useTableScroll.ts +227 -0
- package/src/components/table/src/index.less +162 -0
- package/src/components/table/src/index.vue +198 -0
- package/src/components/table/src/props.ts +152 -0
- package/src/components/table/src/types/table.type.ts +133 -0
- package/src/components/table/src/types/tableHeader.type.ts +27 -0
- package/src/components/type.ts +0 -0
- package/src/directives/icon.ts +36 -0
- package/src/directives/index.ts +26 -0
- package/src/directives/permission.ts +21 -0
- package/src/global.d.ts +8 -0
- package/src/index.ts +4 -0
- package/src/theme/content/index.vue +37 -0
- package/src/theme/feature/back-top.vue +11 -0
- package/src/theme/feature/index.vue +7 -0
- package/src/theme/footer/index.less +16 -0
- package/src/theme/footer/index.vue +24 -0
- package/src/theme/header/components/bread-crumb.vue +26 -0
- package/src/theme/header/components/fullscreen.vue +14 -0
- package/src/theme/header/components/handler.ts +81 -0
- package/src/theme/header/components/index.ts +21 -0
- package/src/theme/header/components/lang-picker.vue +36 -0
- package/src/theme/header/components/logo.vue +33 -0
- package/src/theme/header/components/menu-search.vue +62 -0
- package/src/theme/header/components/notify.vue +23 -0
- package/src/theme/header/components/setting-theme.vue +123 -0
- package/src/theme/header/components/theme-drawer/enum.ts +12 -0
- package/src/theme/header/components/theme-drawer/feature.vue +75 -0
- package/src/theme/header/components/theme-drawer/index.ts +7 -0
- package/src/theme/header/components/theme-drawer/menu-type.vue +40 -0
- package/src/theme/header/components/theme-drawer/select-item.vue +46 -0
- package/src/theme/header/components/theme-drawer/switch-item.vue +39 -0
- package/src/theme/header/components/theme-drawer/theme-color.vue +26 -0
- package/src/theme/header/components/trigger.vue +14 -0
- package/src/theme/header/components/user-info.vue +43 -0
- package/src/theme/header/const/index.ts +40 -0
- package/src/theme/header/helper/menu-tree.ts +67 -0
- package/src/theme/header/index.less +438 -0
- package/src/theme/header/index.ts +0 -0
- package/src/theme/header/index.vue +96 -0
- package/src/theme/header/multiple-header.vue +67 -0
- package/src/theme/header/set-theme.less +68 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/sider/components/basic-menu/basic-menu-item.vue +14 -0
- package/src/theme/sider/components/basic-menu/basic-menu.vue +122 -0
- package/src/theme/sider/components/basic-menu/basic-sub-menu-item.vue +46 -0
- package/src/theme/sider/components/basic-menu/menu-item-content.vue +13 -0
- package/src/theme/sider/components/drag-bar.vue +26 -0
- package/src/theme/sider/components/layout-menu.vue +132 -0
- package/src/theme/sider/components/props.ts +97 -0
- package/src/theme/sider/components/sider-trigger.vue +24 -0
- package/src/theme/sider/helper/sider.ts +52 -0
- package/src/theme/sider/helper/split-menu.ts +147 -0
- package/src/theme/sider/hooks/useDragLine.ts +86 -0
- package/src/theme/sider/hooks/useOpenKeys.ts +57 -0
- package/src/theme/sider/index.less +203 -0
- package/src/theme/sider/index.vue +88 -0
- package/src/theme/tabs/components/TabContent.vue +37 -0
- package/src/theme/tabs/components/TabRedo.vue +18 -0
- package/src/theme/tabs/hooks/useMultifyTabs.ts +96 -0
- package/src/theme/tabs/hooks/useTabDropdown.ts +89 -0
- package/src/theme/tabs/index.less +165 -0
- package/src/theme/tabs/index.vue +98 -0
- package/src/theme/tabs/types/tabs.type.ts +8 -0
- package/src/theme/theme.less +66 -0
- package/src/theme/theme.vue +89 -0
- package/src/theme/transition.less +99 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Tooltip placement="top">
|
|
3
|
+
<template #title>
|
|
4
|
+
<span v-if="!isFullscreen">全屏</span>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<span @click="toggle">
|
|
8
|
+
<span v-if="!isFullscreen" v-icon="'ic:baseline-fullscreen'"></span>
|
|
9
|
+
<span v-else v-icon="'ic:baseline-fullscreen-exit'"></span>
|
|
10
|
+
</span>
|
|
11
|
+
</Tooltip>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import { ref, watch } from 'vue'
|
|
16
|
+
import { useFullscreen } from '@vueuse/core';
|
|
17
|
+
import { Tooltip } from 'ant-design-vue'
|
|
18
|
+
import { DtIcon } from '../../../../icons/index'
|
|
19
|
+
import { getTableInstance } from '../../hooks/useTableInstance';
|
|
20
|
+
|
|
21
|
+
const table = getTableInstance()
|
|
22
|
+
const wrapEl = ref(null)
|
|
23
|
+
|
|
24
|
+
const { toggle, isFullscreen } = useFullscreen(wrapEl)
|
|
25
|
+
|
|
26
|
+
watch(
|
|
27
|
+
() => table.tableElRef.value,
|
|
28
|
+
( v: any ) => {
|
|
29
|
+
const getParent = ( el ) => {
|
|
30
|
+
if( !el || !el.parentNode ) return null
|
|
31
|
+
|
|
32
|
+
// 找到路由的下一层 进行全屏
|
|
33
|
+
if(el.parentNode.className.indexOf('dt-layout-content') !== -1) {
|
|
34
|
+
wrapEl.value = el.parentNode
|
|
35
|
+
} else {
|
|
36
|
+
getParent( el.parentNode )
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getParent(v.$el)
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
</script>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Tooltip>
|
|
3
|
+
<template #title>密度</template>
|
|
4
|
+
|
|
5
|
+
<Dropdown
|
|
6
|
+
placement="bottom"
|
|
7
|
+
:trigger="['click']"
|
|
8
|
+
:getPopupContainer="getPopupContainer"
|
|
9
|
+
>
|
|
10
|
+
<span v-icon="'ant-design:column-height-outlined'"></span>
|
|
11
|
+
|
|
12
|
+
<template #overlay>
|
|
13
|
+
<Menu
|
|
14
|
+
@click="handleTitleClick"
|
|
15
|
+
selectable
|
|
16
|
+
v-model:selectedKeys="selectedKeysRef"
|
|
17
|
+
>
|
|
18
|
+
<MenuItem key="default"> <span>默认</span> </MenuItem>
|
|
19
|
+
<MenuItem key="middle"> <span>中等</span> </MenuItem>
|
|
20
|
+
<MenuItem key="small"> <span>紧凑</span> </MenuItem>
|
|
21
|
+
</Menu>
|
|
22
|
+
</template>
|
|
23
|
+
</Dropdown>
|
|
24
|
+
</Tooltip>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script lang="ts" setup>
|
|
28
|
+
import { getPopupContainer } from '@dt-frames/core';
|
|
29
|
+
import { Tooltip, Dropdown, Menu, MenuItem } from 'ant-design-vue'
|
|
30
|
+
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
|
|
31
|
+
import { ref } from 'vue'
|
|
32
|
+
import { getTableInstance } from '../../hooks/useTableInstance';
|
|
33
|
+
import { SizeType } from '../../types/table.type';
|
|
34
|
+
|
|
35
|
+
const table = getTableInstance()
|
|
36
|
+
const selectedKeysRef = ref<SizeType[]>([table.getSize()])
|
|
37
|
+
|
|
38
|
+
function handleTitleClick({ key }: MenuInfo) {
|
|
39
|
+
selectedKeysRef.value = [key as SizeType]
|
|
40
|
+
table.setProps({ size: key as SizeType })
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Download></Download>
|
|
3
|
+
<SizeSetting v-if="getSetting.size" />
|
|
4
|
+
<ColumnSetting
|
|
5
|
+
v-if="getSetting.setting"
|
|
6
|
+
@columns-change="handleColumnChange"
|
|
7
|
+
/>
|
|
8
|
+
|
|
9
|
+
<FullscreenSetting v-if="getSetting.fullscreen"></FullscreenSetting>
|
|
10
|
+
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import { computed, defineComponent, unref } from "vue"
|
|
15
|
+
import type { PropType } from 'vue'
|
|
16
|
+
import { TableSetting } from "../../types/table.type"
|
|
17
|
+
import ColumnSetting from './Column.vue'
|
|
18
|
+
import FullscreenSetting from './Fullscreen.vue'
|
|
19
|
+
import SizeSetting from './Size.vue'
|
|
20
|
+
import Download from './Download.vue'
|
|
21
|
+
|
|
22
|
+
type ColumnChangeParam = {
|
|
23
|
+
dataIndex: string;
|
|
24
|
+
fixed: boolean | 'left' | 'right' | undefined;
|
|
25
|
+
visible: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default defineComponent({
|
|
29
|
+
name: 'table-setting',
|
|
30
|
+
components: {
|
|
31
|
+
ColumnSetting,
|
|
32
|
+
FullscreenSetting,
|
|
33
|
+
SizeSetting,
|
|
34
|
+
Download
|
|
35
|
+
},
|
|
36
|
+
props: {
|
|
37
|
+
setting: {
|
|
38
|
+
type: Object as PropType<TableSetting>,
|
|
39
|
+
default: () => ({}),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
emits: ['columns-change'],
|
|
43
|
+
setup(props, { emit }) {
|
|
44
|
+
const getSetting = computed((): TableSetting => {
|
|
45
|
+
return {
|
|
46
|
+
redo: true,
|
|
47
|
+
size: true,
|
|
48
|
+
setting: true,
|
|
49
|
+
fullscreen: true,
|
|
50
|
+
...props.setting,
|
|
51
|
+
};
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
function handleColumnChange(data: ColumnChangeParam[]) {
|
|
55
|
+
emit('columns-change', data);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
getSetting,
|
|
60
|
+
handleColumnChange
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
</script>
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import type { PaginationProps } from 'ant-design-vue/lib/pagination'
|
|
2
|
+
import { computed, ComputedRef, Ref, ref, unref, toRaw, watch, h } from "vue";
|
|
3
|
+
import { cloneDeep, isEqual } from 'lodash-es'
|
|
4
|
+
import { BasicColumn, BasicTableProps, CellFormat } from "../types/table.type";
|
|
5
|
+
import { SetColumnsParams } from '../types/tableHeader.type';
|
|
6
|
+
import { isArray, isBoolean, isFunction, isObject, isString, Recordable, useAppStore, getDictValueByCode } from '@dt-frames/core';
|
|
7
|
+
import TableAction from '../components/TableActions.vue'
|
|
8
|
+
|
|
9
|
+
// 索引列及操作列标识
|
|
10
|
+
const INDEX_FLAG = 'INDEX'
|
|
11
|
+
const ACTION_COLUMN = 'ACTION'
|
|
12
|
+
|
|
13
|
+
// 处理单条数据的ellipsis 对齐方式
|
|
14
|
+
function handleItem(item: BasicColumn, ellipsis: boolean) {
|
|
15
|
+
const { appConf } = useAppStore();
|
|
16
|
+
const { align } = appConf.ui.table
|
|
17
|
+
|
|
18
|
+
const { key, dataIndex, children } = item
|
|
19
|
+
item.align = item.align || align
|
|
20
|
+
|
|
21
|
+
if( ellipsis ) {
|
|
22
|
+
if (!key) item.key = dataIndex && dataIndex.toString()
|
|
23
|
+
|
|
24
|
+
if (!isBoolean(item.ellipsis)) {
|
|
25
|
+
item = Object.assign(item, {
|
|
26
|
+
ellipsis,
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (children && children.length) {
|
|
32
|
+
handleChildren(children, !!ellipsis);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function handleChildren(children: BasicColumn[] | undefined, ellipsis: boolean) {
|
|
37
|
+
if (!children) return
|
|
38
|
+
|
|
39
|
+
children.forEach((item) => {
|
|
40
|
+
const { children } = item
|
|
41
|
+
handleItem(item, ellipsis)
|
|
42
|
+
handleChildren(children, ellipsis)
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 重新排序列
|
|
47
|
+
function sortFixedColumn(columns: BasicColumn[]) {
|
|
48
|
+
const fixedLeftColumn: BasicColumn[] = []
|
|
49
|
+
const fixedRightColumn: BasicColumn[] = []
|
|
50
|
+
const defaultColumn: BasicColumn[] = []
|
|
51
|
+
|
|
52
|
+
for( let column of columns ) {
|
|
53
|
+
if( column.defaultHidden ) continue
|
|
54
|
+
|
|
55
|
+
if( column.fixed === 'left' ) {
|
|
56
|
+
fixedLeftColumn.push( column )
|
|
57
|
+
continue
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if( column.fixed === 'right' ) {
|
|
61
|
+
fixedRightColumn.push( column )
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
defaultColumn.push( column )
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return [
|
|
69
|
+
...fixedLeftColumn,
|
|
70
|
+
...defaultColumn,
|
|
71
|
+
...fixedRightColumn
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 处理序号
|
|
76
|
+
function handleIndexColumn(
|
|
77
|
+
propsRef: ComputedRef<BasicTableProps>,
|
|
78
|
+
getPaginationRef: ComputedRef<boolean | PaginationProps>,
|
|
79
|
+
columns: BasicColumn[]
|
|
80
|
+
) {
|
|
81
|
+
const { showIndexColumn, indexColumnProps, isTreeTable } = unref(propsRef)
|
|
82
|
+
|
|
83
|
+
let pushIndexColumns = false
|
|
84
|
+
if (unref(isTreeTable)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
columns.forEach(() => {
|
|
89
|
+
const indIndex = columns.findIndex((column) => column.flag === INDEX_FLAG);
|
|
90
|
+
if (showIndexColumn) {
|
|
91
|
+
pushIndexColumns = indIndex === -1;
|
|
92
|
+
} else if (!showIndexColumn && indIndex !== -1) {
|
|
93
|
+
columns.splice(indIndex, 1);
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
if (!pushIndexColumns) return
|
|
98
|
+
|
|
99
|
+
const isFixedLeft = columns.some((item) => item.fixed === 'left')
|
|
100
|
+
|
|
101
|
+
columns.unshift({
|
|
102
|
+
flag: INDEX_FLAG,
|
|
103
|
+
width: 50,
|
|
104
|
+
title: '序号',
|
|
105
|
+
align: 'center',
|
|
106
|
+
customRender: ( { index } ) => {
|
|
107
|
+
const getPagination = unref(getPaginationRef)
|
|
108
|
+
|
|
109
|
+
const { appConf } = useAppStore()
|
|
110
|
+
const { defaultPageSize } = appConf.ui.table
|
|
111
|
+
|
|
112
|
+
if (isBoolean(getPagination)) {
|
|
113
|
+
return `${index + 1}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const { current = 1, pageSize = defaultPageSize } = getPagination;
|
|
117
|
+
return ((current < 1 ? 1 : current) - 1) * pageSize + index + 1
|
|
118
|
+
},
|
|
119
|
+
...(isFixedLeft
|
|
120
|
+
? {
|
|
121
|
+
fixed: 'left',
|
|
122
|
+
}
|
|
123
|
+
: {}),
|
|
124
|
+
...indexColumnProps,
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 处理操作栏的列
|
|
129
|
+
function handleActionColumn(propsRef: ComputedRef<BasicTableProps>, columns: BasicColumn[]) {
|
|
130
|
+
const { operations } = unref(propsRef)
|
|
131
|
+
|
|
132
|
+
if (
|
|
133
|
+
!operations
|
|
134
|
+
|| (isObject( operations ) && !operations?.btns )
|
|
135
|
+
|| ( isArray(operations) && !operations )
|
|
136
|
+
) return
|
|
137
|
+
|
|
138
|
+
const hasIndex = columns.findIndex((column) => column.flag === ACTION_COLUMN)
|
|
139
|
+
|
|
140
|
+
if( hasIndex === -1 ) {
|
|
141
|
+
let column = isObject( operations ) ? operations
|
|
142
|
+
: isArray( operations ) ? { btns: operations } : {}
|
|
143
|
+
|
|
144
|
+
let expand = column.expand ? column.expand : false
|
|
145
|
+
let columnObj = {
|
|
146
|
+
fixed: 'right',
|
|
147
|
+
title: '操作',
|
|
148
|
+
align: 'center',
|
|
149
|
+
expand,
|
|
150
|
+
width: (expand ? (column.btns.length * 30 + 40) : 70) + 'px',
|
|
151
|
+
...column,
|
|
152
|
+
flag: ACTION_COLUMN,
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
columns.push({
|
|
156
|
+
...(columnObj as any),
|
|
157
|
+
customRender: ({ record, index}) => {
|
|
158
|
+
return h(
|
|
159
|
+
TableAction as any,
|
|
160
|
+
{
|
|
161
|
+
...columnObj,
|
|
162
|
+
record,
|
|
163
|
+
align: null,
|
|
164
|
+
index
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
export function useColumns(
|
|
174
|
+
propsRef: ComputedRef<BasicTableProps>,
|
|
175
|
+
getPaginationRef: ComputedRef<boolean | PaginationProps>,
|
|
176
|
+
) {
|
|
177
|
+
|
|
178
|
+
const columnsRef = ref(unref(propsRef).columns) as unknown as Ref<BasicColumn[]>
|
|
179
|
+
let cacheColumns = unref(propsRef).columns
|
|
180
|
+
|
|
181
|
+
const getColumnsRef = computed(() => {
|
|
182
|
+
const columns = cloneDeep(unref(columnsRef)) as BasicColumn[]
|
|
183
|
+
if (!columns) return []
|
|
184
|
+
|
|
185
|
+
const { ellipsis, resizable, minWidth = 50, maxWidth = 700 } = unref(propsRef)
|
|
186
|
+
|
|
187
|
+
columns.forEach( (it, index) => {
|
|
188
|
+
const { slots } = it
|
|
189
|
+
it.width = it.width || (index === columns.length - 1 ? 119.9 : 120)
|
|
190
|
+
if( Reflect.has(it, 'resizable') ? !!it.resizable : resizable ) {
|
|
191
|
+
it.resizable = true
|
|
192
|
+
it.minWidth = it.minWidth || minWidth
|
|
193
|
+
it.maxWidth = it.maxWidth || maxWidth
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
handleItem(
|
|
197
|
+
it,
|
|
198
|
+
Reflect.has(it, 'ellipsis') ? !!it.ellipsis : !!ellipsis && !slots
|
|
199
|
+
)
|
|
200
|
+
} )
|
|
201
|
+
|
|
202
|
+
handleIndexColumn(propsRef, getPaginationRef, columns)
|
|
203
|
+
handleActionColumn(propsRef, columns)
|
|
204
|
+
|
|
205
|
+
return columns
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
const getViewColumns = computed(() => {
|
|
209
|
+
const viewColumns = sortFixedColumn(unref(getColumnsRef))
|
|
210
|
+
const columns: BasicColumn[] = cloneDeep(viewColumns)
|
|
211
|
+
|
|
212
|
+
return columns
|
|
213
|
+
.filter( column => isIfShow(column) )
|
|
214
|
+
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
function isIfShow( column: BasicColumn ): boolean {
|
|
218
|
+
const ifShow = column.ifShow
|
|
219
|
+
|
|
220
|
+
return isBoolean(ifShow)
|
|
221
|
+
? ifShow
|
|
222
|
+
: isFunction(ifShow) ? ifShow(column) : true
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
watch(
|
|
227
|
+
() => unref(propsRef).columns,
|
|
228
|
+
columns => {
|
|
229
|
+
columnsRef.value = columns
|
|
230
|
+
cacheColumns = columns.filter( it => !it.flag ) ?? []
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
// 获取列信息
|
|
236
|
+
function getColumns(opt?: SetColumnsParams) {
|
|
237
|
+
const { ignoreIndex, ignoreAction, sort } = opt || {}
|
|
238
|
+
|
|
239
|
+
let columns = toRaw(unref(getColumnsRef))
|
|
240
|
+
|
|
241
|
+
if( ignoreIndex ) {
|
|
242
|
+
columns = columns.filter( it => it.flag !== INDEX_FLAG )
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if( ignoreAction ) {
|
|
246
|
+
columns = columns.filter( it => it.flag !== ACTION_COLUMN )
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// 重新排序
|
|
250
|
+
if( sort ) {
|
|
251
|
+
columns = sortFixedColumn( columns )
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return columns
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
// 设置列信息
|
|
259
|
+
function setColumns(columnList: Partial<BasicColumn>[] | string[]) {
|
|
260
|
+
const columns = cloneDeep(columnList)
|
|
261
|
+
|
|
262
|
+
if( !isArray( columns ) ) return
|
|
263
|
+
|
|
264
|
+
// 重置所有的列
|
|
265
|
+
if( !columns.length ) {
|
|
266
|
+
columnsRef.value = []
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const cacheKeys = cacheColumns.map((item) => item.dataIndex)
|
|
271
|
+
|
|
272
|
+
if( !isString( columns[0] ) ) {
|
|
273
|
+
columnsRef.value = columns as BasicColumn[]
|
|
274
|
+
} else {
|
|
275
|
+
const columnKeys = columns as string[]
|
|
276
|
+
const newColumns: BasicColumn[] = []
|
|
277
|
+
|
|
278
|
+
cacheColumns.forEach( it => {
|
|
279
|
+
newColumns.push({
|
|
280
|
+
...it,
|
|
281
|
+
defaultHidden: !columnKeys.includes((it.dataIndex! || it.key) as string),
|
|
282
|
+
})
|
|
283
|
+
} )
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
if( !isEqual(cacheKeys, columns) ) {
|
|
287
|
+
newColumns.sort((prev, next) => {
|
|
288
|
+
return columnKeys.indexOf(prev.dataIndex as string) - columnKeys.indexOf(next.dataIndex as string)
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
columnsRef.value = newColumns
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function setCacheColumnsByField(dataIndex: string | undefined, value: Partial<BasicColumn>) {
|
|
297
|
+
if (!dataIndex || !value) return
|
|
298
|
+
|
|
299
|
+
cacheColumns.forEach((item) => {
|
|
300
|
+
if (item.dataIndex === dataIndex) {
|
|
301
|
+
Object.assign(item, value);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function getCacheColumns() {
|
|
308
|
+
return cacheColumns;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
getViewColumns,
|
|
313
|
+
getColumnsRef,
|
|
314
|
+
getColumns,
|
|
315
|
+
setColumns,
|
|
316
|
+
setCacheColumnsByField,
|
|
317
|
+
getCacheColumns
|
|
318
|
+
}
|
|
319
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ComputedRef, ref, Ref, unref, toRaw, watch, computed, onMounted } from "vue"
|
|
2
|
+
import type { PaginationProps } from 'ant-design-vue/lib/pagination'
|
|
3
|
+
import { BasicTableProps, SorterResult } from "../types/table.type"
|
|
4
|
+
import { isFunction, Recordable, useAppStore, useTimeoutFn } from "@dt-frames/core"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 处理表格数据
|
|
8
|
+
*/
|
|
9
|
+
type ActionsType = {
|
|
10
|
+
getPaginationInfo: ComputedRef<boolean | PaginationProps>
|
|
11
|
+
setPagination: (info: Partial<PaginationProps>) => void
|
|
12
|
+
clearSelectedRowKeys: () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function useDataSource(
|
|
16
|
+
propsRef: ComputedRef<BasicTableProps>,
|
|
17
|
+
{
|
|
18
|
+
getPaginationInfo,
|
|
19
|
+
setPagination,
|
|
20
|
+
clearSelectedRowKeys,
|
|
21
|
+
}: ActionsType,
|
|
22
|
+
emit
|
|
23
|
+
) {
|
|
24
|
+
// 拷贝一份表格数据 然后再做数据处理
|
|
25
|
+
const dataSourceRef = ref<Recordable[]>([])
|
|
26
|
+
|
|
27
|
+
watch(
|
|
28
|
+
() => unref(propsRef).dataSource,
|
|
29
|
+
(dataSource) => {
|
|
30
|
+
dataSource && (dataSourceRef.value = dataSource)
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
immediate: true
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
const getDataSourceRef = computed( () => {
|
|
38
|
+
return unref(dataSourceRef)
|
|
39
|
+
} )
|
|
40
|
+
|
|
41
|
+
// 表单改变事件
|
|
42
|
+
function handleTableChange(
|
|
43
|
+
pagination: PaginationProps,
|
|
44
|
+
filters: Partial<Recordable<string[]>>,
|
|
45
|
+
sorter: SorterResult,
|
|
46
|
+
) {
|
|
47
|
+
const { sortFn, filterFn, onTableChange } = unref( propsRef )
|
|
48
|
+
const { appConf } = useAppStore()
|
|
49
|
+
const { current = 1, pageSize = appConf.ui.table.defaultPageSize } = pagination
|
|
50
|
+
|
|
51
|
+
// clearSelectedRowKeys()
|
|
52
|
+
|
|
53
|
+
setPagination( pagination )
|
|
54
|
+
|
|
55
|
+
const params: Recordable = {}
|
|
56
|
+
|
|
57
|
+
if( sorter && isFunction(sortFn) ) {
|
|
58
|
+
params.sortInfo = sortFn(sorter)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (filters && isFunction(filterFn)) {
|
|
62
|
+
params.filterInfo = filterFn( filters )
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
return onTableChange({
|
|
67
|
+
pagination: {
|
|
68
|
+
current,
|
|
69
|
+
pageSize
|
|
70
|
+
},
|
|
71
|
+
sort: unref( params.sortInfo ),
|
|
72
|
+
filter: toRaw(unref( params.filterInfo )),
|
|
73
|
+
showBtnLoading: false
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
onMounted(() => {
|
|
79
|
+
const { defSort, onTableChange } = unref( propsRef )
|
|
80
|
+
const { appConf } = useAppStore()
|
|
81
|
+
|
|
82
|
+
onTableChange({
|
|
83
|
+
pagination: {
|
|
84
|
+
current: 1,
|
|
85
|
+
pageSize: appConf.ui.table.defaultPageSize
|
|
86
|
+
},
|
|
87
|
+
sort:defSort,
|
|
88
|
+
filter: null,
|
|
89
|
+
showBtnLoading: false
|
|
90
|
+
}, false)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
getDataSourceRef,
|
|
96
|
+
handleTableChange
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设置表格的loading状态
|
|
3
|
+
* 这里做二次封装 主要原因是暴露一个方法 外面可以调用这个方法 从而改变loading状态
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ComputedRef, ref, unref, watch, computed } from "vue"
|
|
7
|
+
import { BasicTableProps } from "../types/table.type"
|
|
8
|
+
|
|
9
|
+
export function useLoading(props: ComputedRef<BasicTableProps>) {
|
|
10
|
+
const loadingRef = ref( unref(props).loading )
|
|
11
|
+
|
|
12
|
+
watch(
|
|
13
|
+
() => unref(props).loading,
|
|
14
|
+
(v) => {
|
|
15
|
+
loadingRef.value = v
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
const getLoading = computed(() => unref(loadingRef))
|
|
20
|
+
|
|
21
|
+
function setLoading( loading: boolean ) {
|
|
22
|
+
loadingRef.value = loading
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
getLoading,
|
|
27
|
+
setLoading
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { computed, ComputedRef, ref, unref, watch } from "vue"
|
|
2
|
+
import type { PaginationProps } from 'ant-design-vue/lib/pagination'
|
|
3
|
+
import { BasicTableProps } from "../types/table.type"
|
|
4
|
+
import { isBoolean, useAppStore } from "@dt-frames/core"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export function usePagination(props: ComputedRef<BasicTableProps>) {
|
|
8
|
+
const paginationRef = ref<PaginationProps>({})
|
|
9
|
+
const show = ref(true)
|
|
10
|
+
|
|
11
|
+
watch(
|
|
12
|
+
() => unref(props).pagination,
|
|
13
|
+
(pagination) => {
|
|
14
|
+
if( !isBoolean(pagination) && pagination ) {
|
|
15
|
+
paginationRef.value = {
|
|
16
|
+
...unref(paginationRef),
|
|
17
|
+
...(pagination ?? {})
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
// 获取分页数据
|
|
24
|
+
const getPaginationInfo = computed((): PaginationProps | boolean => {
|
|
25
|
+
const { pagination } = unref( props )
|
|
26
|
+
|
|
27
|
+
if( !unref(show) || isBoolean( pagination ) && !pagination ) {
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { appConf } = useAppStore()
|
|
32
|
+
const { defaultPageSize, pageSizeOptions, size } = appConf.ui.table
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
current: 1,
|
|
36
|
+
pageSize: defaultPageSize,
|
|
37
|
+
size: size === 'small' ? 'small' : 'default',
|
|
38
|
+
defaultPageSize,
|
|
39
|
+
showTotal: (total, range) => `总共${ total }页`,
|
|
40
|
+
showSizeChanger: true,
|
|
41
|
+
pageSizeOptions,
|
|
42
|
+
showQuickJumper: true,
|
|
43
|
+
...(isBoolean(pagination) ? {} : pagination),
|
|
44
|
+
...unref(paginationRef),
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
function setPagination(info: Partial<PaginationProps>) {
|
|
49
|
+
const paginationInfo = unref( getPaginationInfo )
|
|
50
|
+
|
|
51
|
+
paginationRef.value = {
|
|
52
|
+
...(!isBoolean(paginationInfo) ? paginationInfo : {}),
|
|
53
|
+
...info
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getPagination() {
|
|
58
|
+
return unref( getPaginationInfo )
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getShowPagination() {
|
|
62
|
+
return unref(show);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function setShowPagination(flag: boolean) {
|
|
66
|
+
show.value = flag;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
getPaginationInfo,
|
|
71
|
+
setPagination,
|
|
72
|
+
getPagination,
|
|
73
|
+
getShowPagination,
|
|
74
|
+
setShowPagination
|
|
75
|
+
}
|
|
76
|
+
}
|