Commit 4e415486eb26ce0a59e2922814e743a4929e008c
1 parent
2fcbee04
feat: add vxe-table
Showing
6 changed files
with
201 additions
and
3 deletions
yudao-ui-admin-vue3/package.json
| ... | ... | @@ -51,7 +51,9 @@ |
| 51 | 51 | "vue-i18n": "9.2.2", |
| 52 | 52 | "vue-router": "^4.1.5", |
| 53 | 53 | "vue-types": "^4.2.1", |
| 54 | - "web-storage-cache": "^1.1.1" | |
| 54 | + "vxe-table": "^4.3.5", | |
| 55 | + "web-storage-cache": "^1.1.1", | |
| 56 | + "xe-utils": "^3.5.7" | |
| 55 | 57 | }, |
| 56 | 58 | "devDependencies": { |
| 57 | 59 | "@commitlint/cli": "^17.1.2", | ... | ... |
yudao-ui-admin-vue3/src/components/ProTable/index.ts
0 → 100644
yudao-ui-admin-vue3/src/components/ProTable/src/ProTable.vue
0 → 100644
| 1 | +<script setup lang="ts"> | |
| 2 | +import { PropType, reactive, ref } from 'vue' | |
| 3 | +import { VxeGrid, VxeGridProps, VxeTableInstance } from 'vxe-table' | |
| 4 | + | |
| 5 | +const props = defineProps({ | |
| 6 | + options: { | |
| 7 | + type: Object as PropType<VxeGridProps>, | |
| 8 | + default: () => ({}) | |
| 9 | + } | |
| 10 | +}) | |
| 11 | +const xGrid = ref<VxeTableInstance>() | |
| 12 | + | |
| 13 | +const gridOptions = reactive<VxeGridProps>({ | |
| 14 | + height: 300, | |
| 15 | + align: null, | |
| 16 | + columnConfig: { | |
| 17 | + resizable: true | |
| 18 | + }, | |
| 19 | + columns: [], | |
| 20 | + toolbarConfig: {}, | |
| 21 | + data: [] | |
| 22 | +}) | |
| 23 | +const init = () => { | |
| 24 | + console.log(props.options) | |
| 25 | +} | |
| 26 | +init() | |
| 27 | +</script> | |
| 28 | + | |
| 29 | +<template> | |
| 30 | + <ContentWrap> | |
| 31 | + <vxe-grid ref="xGrid" v-bind="gridOptions" show-footer class="pro-table-scrollbar" /> | |
| 32 | + </ContentWrap> | |
| 33 | +</template> | |
| 34 | + | |
| 35 | +<style scoped> | |
| 36 | +/*滚动条整体部分*/ | |
| 37 | +.pro-table-scrollbar ::-webkit-scrollbar { | |
| 38 | + width: 10px; | |
| 39 | + height: 10px; | |
| 40 | +} | |
| 41 | +/*滚动条的轨道*/ | |
| 42 | +.pro-table-scrollbar ::-webkit-scrollbar-track { | |
| 43 | + background-color: #ffffff; | |
| 44 | +} | |
| 45 | +/*滚动条里面的小方块,能向上向下移动*/ | |
| 46 | +.pro-table-scrollbar ::-webkit-scrollbar-thumb { | |
| 47 | + background-color: #bfbfbf; | |
| 48 | + border-radius: 5px; | |
| 49 | + border: 1px solid #f1f1f1; | |
| 50 | + box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); | |
| 51 | +} | |
| 52 | +.pro-table-scrollbar ::-webkit-scrollbar-thumb:hover { | |
| 53 | + background-color: #a8a8a8; | |
| 54 | +} | |
| 55 | +.pro-table-scrollbar ::-webkit-scrollbar-thumb:active { | |
| 56 | + background-color: #787878; | |
| 57 | +} | |
| 58 | +/*边角,即两个滚动条的交汇处*/ | |
| 59 | +.pro-table-scrollbar ::-webkit-scrollbar-corner { | |
| 60 | + background-color: #ffffff; | |
| 61 | +} | |
| 62 | +</style> | ... | ... |
yudao-ui-admin-vue3/src/main.ts
| ... | ... | @@ -16,6 +16,9 @@ import { setupGlobCom } from '@/components' |
| 16 | 16 | // 引入element-plus |
| 17 | 17 | import { setupElementPlus } from '@/plugins/elementPlus' |
| 18 | 18 | |
| 19 | +// 引入vxe-table | |
| 20 | +import { setupVxeTable } from '@/plugins/vxeTable' | |
| 21 | + | |
| 19 | 22 | // 引入全局样式 |
| 20 | 23 | import '@/styles/index.less' |
| 21 | 24 | |
| ... | ... | @@ -44,6 +47,8 @@ const setupAll = async () => { |
| 44 | 47 | |
| 45 | 48 | setupElementPlus(app) |
| 46 | 49 | |
| 50 | + setupVxeTable(app) | |
| 51 | + | |
| 47 | 52 | setupRouter(app) |
| 48 | 53 | |
| 49 | 54 | setupAuth(app) | ... | ... |
yudao-ui-admin-vue3/src/plugins/vxeTable/index.ts
0 → 100644
| 1 | +import { App, unref } from 'vue' | |
| 2 | +import 'xe-utils' | |
| 3 | +import XEUtils from 'xe-utils' | |
| 4 | +import { i18n } from '@/plugins/vueI18n' | |
| 5 | +import zhCN from 'vxe-table/es/locale/lang/zh-CN' | |
| 6 | +import enUS from 'vxe-table/lib/locale/lang/en-US' | |
| 7 | +import { | |
| 8 | + // 全局对象 | |
| 9 | + VXETable, | |
| 10 | + | |
| 11 | + // 表格功能 | |
| 12 | + Filter, | |
| 13 | + Edit, | |
| 14 | + Menu, | |
| 15 | + Export, | |
| 16 | + Keyboard, | |
| 17 | + Validator, | |
| 18 | + | |
| 19 | + // 可选组件 | |
| 20 | + Icon, | |
| 21 | + Column, | |
| 22 | + Colgroup, | |
| 23 | + Grid, | |
| 24 | + Tooltip, | |
| 25 | + Toolbar, | |
| 26 | + Pager, | |
| 27 | + Form, | |
| 28 | + FormItem, | |
| 29 | + FormGather, | |
| 30 | + Checkbox, | |
| 31 | + CheckboxGroup, | |
| 32 | + Radio, | |
| 33 | + RadioGroup, | |
| 34 | + RadioButton, | |
| 35 | + Switch, | |
| 36 | + Input, | |
| 37 | + Select, | |
| 38 | + Optgroup, | |
| 39 | + Option, | |
| 40 | + Textarea, | |
| 41 | + Button, | |
| 42 | + Modal, | |
| 43 | + List, | |
| 44 | + Pulldown, | |
| 45 | + | |
| 46 | + // 表格 | |
| 47 | + Table | |
| 48 | +} from 'vxe-table' | |
| 49 | + | |
| 50 | +// 全局默认参数 | |
| 51 | +VXETable.setup({ | |
| 52 | + size: 'medium', // 全局尺寸 | |
| 53 | + version: 0, // 版本号,对于某些带数据缓存的功能有用到,上升版本号可以用于重置数据 | |
| 54 | + zIndex: 1008, // 全局 zIndex 起始值,如果项目的的 z-index 样式值过大时就需要跟随设置更大,避免被遮挡 | |
| 55 | + loadingText: '加载中...', // 全局loading提示内容,如果为null则不显示文本 | |
| 56 | + table: { | |
| 57 | + // 自动监听父元素的变化去重新计算表格 | |
| 58 | + autoResize: true, | |
| 59 | + emptyText: '暂无数据', | |
| 60 | + // 鼠标移到行是否要高亮显示 | |
| 61 | + highlightHoverRow: true | |
| 62 | + }, | |
| 63 | + pager: { | |
| 64 | + autoHidden: false, | |
| 65 | + perfect: true, | |
| 66 | + pageSize: 10, | |
| 67 | + pagerCount: 7, | |
| 68 | + pageSizes: [10, 15, 20, 50, 100], | |
| 69 | + layouts: ['PrevJump', 'PrevPage', 'Jump', 'PageCount', 'NextPage', 'NextJump', 'Sizes', 'Total'] | |
| 70 | + }, | |
| 71 | + input: { | |
| 72 | + clearable: true | |
| 73 | + }, | |
| 74 | + i18n: (key, args) => { | |
| 75 | + return unref(i18n.global.locale) === 'zh' | |
| 76 | + ? XEUtils.toFormatString(XEUtils.get(zhCN, key), args) | |
| 77 | + : XEUtils.toFormatString(XEUtils.get(enUS, key), args) | |
| 78 | + } | |
| 79 | +}) | |
| 80 | +export const setupVxeTable = (app: App<Element>) => { | |
| 81 | + // 表格功能 | |
| 82 | + app.use(Filter).use(Edit).use(Menu).use(Export).use(Keyboard).use(Validator) | |
| 83 | + | |
| 84 | + // 可选组件 | |
| 85 | + app | |
| 86 | + .use(Icon) | |
| 87 | + .use(Column) | |
| 88 | + .use(Colgroup) | |
| 89 | + .use(Grid) | |
| 90 | + .use(Tooltip) | |
| 91 | + .use(Toolbar) | |
| 92 | + .use(Pager) | |
| 93 | + .use(Form) | |
| 94 | + .use(FormItem) | |
| 95 | + .use(FormGather) | |
| 96 | + .use(Checkbox) | |
| 97 | + .use(CheckboxGroup) | |
| 98 | + .use(Radio) | |
| 99 | + .use(RadioGroup) | |
| 100 | + .use(RadioButton) | |
| 101 | + .use(Switch) | |
| 102 | + .use(Input) | |
| 103 | + .use(Select) | |
| 104 | + .use(Optgroup) | |
| 105 | + .use(Option) | |
| 106 | + .use(Textarea) | |
| 107 | + .use(Button) | |
| 108 | + .use(Modal) | |
| 109 | + .use(List) | |
| 110 | + .use(Pulldown) | |
| 111 | + | |
| 112 | + // 安装表格 | |
| 113 | + .use(Table) | |
| 114 | + | |
| 115 | + // 给 vue 实例挂载内部对象,例如: | |
| 116 | + // app.config.globalProperties.$XModal = VXETable.modal | |
| 117 | + // app.config.globalProperties.$XPrint = VXETable.print | |
| 118 | + // app.config.globalProperties.$XSaveFile = VXETable.saveFile | |
| 119 | + // app.config.globalProperties.$XReadFile = VXETable.readFile | |
| 120 | +} | ... | ... |
yudao-ui-admin-vue3/vite.config.ts
| ... | ... | @@ -6,7 +6,7 @@ import WindiCSS from 'vite-plugin-windicss' |
| 6 | 6 | import VueJsx from '@vitejs/plugin-vue-jsx' |
| 7 | 7 | import EslintPlugin from 'vite-plugin-eslint' |
| 8 | 8 | import VueI18n from '@intlify/vite-plugin-vue-i18n' |
| 9 | -import { createStyleImportPlugin, ElementPlusResolve } from 'vite-plugin-style-import' | |
| 9 | +import { createStyleImportPlugin, ElementPlusResolve, VxeTableResolve } from 'vite-plugin-style-import' | |
| 10 | 10 | import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' |
| 11 | 11 | import PurgeIcons from 'vite-plugin-purge-icons' |
| 12 | 12 | import { createHtmlPlugin } from 'vite-plugin-html' |
| ... | ... | @@ -56,13 +56,19 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { |
| 56 | 56 | VueJsx(), |
| 57 | 57 | WindiCSS(), |
| 58 | 58 | createStyleImportPlugin({ |
| 59 | - resolves: [ElementPlusResolve()], | |
| 59 | + resolves: [ElementPlusResolve(),VxeTableResolve()], | |
| 60 | 60 | libs: [{ |
| 61 | 61 | libraryName: 'element-plus', |
| 62 | 62 | esModule: true, |
| 63 | 63 | resolveStyle: (name) => { |
| 64 | 64 | return `element-plus/es/components/${name.substring(3)}/style/css` |
| 65 | 65 | } |
| 66 | + },{ | |
| 67 | + libraryName: 'vxe-table', | |
| 68 | + esModule: true, | |
| 69 | + resolveStyle: (name) => { | |
| 70 | + return `vxe-table/es/${name}/style.css` | |
| 71 | + } | |
| 66 | 72 | }] |
| 67 | 73 | }), |
| 68 | 74 | EslintPlugin({ | ... | ... |