😎调整机构管理页面

This commit is contained in:
zuohuaijun 2024-07-11 00:38:57 +08:00
parent db117fe8ed
commit c1789fa20d
6 changed files with 95 additions and 79 deletions

View File

@ -154,14 +154,6 @@ const resetQuery = async () => {
await xGrid.value?.commitProxy('reload'); await xGrid.value?.commitProxy('reload');
}; };
//
const gridEvents: VxeGridListeners<SysMenu> = {
// proxy-config.ajax.query
async proxyQuery() {
state.menuData = xGrid.value?.getTableData().tableData ?? [];
},
};
// //
const handleAdd = () => { const handleAdd = () => {
state.title = '添加菜单'; state.title = '添加菜单';
@ -189,6 +181,14 @@ const handleDelete = (row: any) => {
.catch(() => {}); .catch(() => {});
}; };
//
const gridEvents: VxeGridListeners<SysMenu> = {
// proxy-config.ajax.query
async proxyQuery() {
state.menuData = xGrid.value?.getTableData().tableData ?? [];
},
};
// //
const handleExpand = () => { const handleExpand = () => {
xGrid.value?.setAllTreeExpand(true); xGrid.value?.setAllTreeExpand(true);

View File

@ -42,7 +42,7 @@
</el-card> </el-card>
<el-card class="full-table" shadow="hover" style="margin-top: 5px; flex: 1"> <el-card class="full-table" shadow="hover" style="margin-top: 5px; flex: 1">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" :tree-config="{}"> <vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
<template #toolbar_buttons> <template #toolbar_buttons>
<el-button type="primary" icon="ele-Plus" @click="handleAdd" v-auth="'sysOrg:add'"> 新增 </el-button> <el-button type="primary" icon="ele-Plus" @click="handleAdd" v-auth="'sysOrg:add'"> 新增 </el-button>
<el-button-group style="padding-left: 12px"> <el-button-group style="padding-left: 12px">
@ -82,8 +82,8 @@
import { onMounted, reactive, ref, nextTick } from 'vue'; import { onMounted, reactive, ref, nextTick } from 'vue';
import { ElMessageBox, ElMessage } from 'element-plus'; import { ElMessageBox, ElMessage } from 'element-plus';
import { auth } from '/@/utils/authFunction'; import { auth } from '/@/utils/authFunction';
import { VxeGridInstance } from 'vxe-table'; import { VxeGridInstance, VxeGridListeners } from 'vxe-table';
import { useVxeTable } from '/@/hooks/vxeTableOptionsHook'; import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import OrgTree from '/@/views/system/org/component/orgTree.vue'; import OrgTree from '/@/views/system/org/component/orgTree.vue';
import EditOrg from '/@/views/system/org/component/editOrg.vue'; import EditOrg from '/@/views/system/org/component/editOrg.vue';
@ -125,11 +125,19 @@ const options = useVxeTable<SysOrg>(
{ field: '', title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } }, { field: '', title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
{ title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } }, { title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
], ],
enableExport: auth('sysOrg:export'),
searchCallback: () => handleQuery(),
queryAllCallback: () => fetchData({ pageSize: 99999 }),
}, },
{ stripe: false, checkboxConfig: { range: false } } // vxeGrid()vxe-table
{
stripe: false,
checkboxConfig: { range: false },
//
proxyConfig: { autoLoad: true, ajax: { query: () => handleQueryApi() } },
//
pagerConfig: { enabled: false },
//
toolbarConfig: { export: false },
treeConfig: { expandAll: false },
}
); );
// //
@ -143,10 +151,16 @@ onMounted(async () => {
}); });
}); });
// api
const handleQueryApi = async () => {
const params = Object.assign(state.queryParams);
return getAPI(SysOrgApi).apiSysOrgListGet(params.id, params.name, params.code, params.type);
};
// //
const handleQuery = async (updateTree: boolean = false) => { const handleQuery = async (updateTree: boolean = false) => {
options.loading = true; options.loading = true;
var res = await fetchData(null); var res = await handleQueryApi();
xGrid.value?.loadData(res.data.result ?? []); xGrid.value?.loadData(res.data.result ?? []);
options.loading = false; options.loading = false;
// //
@ -159,19 +173,13 @@ const handleQuery = async (updateTree: boolean = false) => {
state.treeData = res.data.result ?? []; state.treeData = res.data.result ?? [];
}; };
//
const fetchData = async (tableParams: any) => {
let params = Object.assign(state.queryParams, tableParams);
return getAPI(SysOrgApi).apiSysOrgListGet(params.id, params.name, params.code, params.type);
};
// //
const resetQuery = async () => { const resetQuery = async () => {
state.queryParams.id = 0; state.queryParams.id = 0;
state.queryParams.name = undefined; state.queryParams.name = undefined;
state.queryParams.code = undefined; state.queryParams.code = undefined;
state.queryParams.type = undefined; state.queryParams.type = undefined;
await handleQuery(); await xGrid.value?.commitProxy('reload');
}; };
// //
@ -201,6 +209,14 @@ const handleDelete = (row: any) => {
.catch(() => {}); .catch(() => {});
}; };
//
const gridEvents: VxeGridListeners<SysOrg> = {
// proxy-config.ajax.query
async proxyQuery() {
state.treeData = xGrid.value?.getTableData().tableData ?? [];
},
};
// //
const handleNodeChange = async (node: any) => { const handleNodeChange = async (node: any) => {
state.queryParams.id = node.id; state.queryParams.id = node.id;

View File

@ -191,6 +191,20 @@ const handleDelete = (row: any) => {
.catch(() => {}); .catch(() => {});
}; };
//
const gridEvents: VxeGridListeners<SysRegion> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
// //
const handleNodeChange = async (node: any) => { const handleNodeChange = async (node: any) => {
state.queryParams.pid = node.id; state.queryParams.pid = node.id;
@ -227,18 +241,4 @@ const handleExpand = () => {
const handleFold = () => { const handleFold = () => {
xGrid.value?.clearTreeExpand(); xGrid.value?.clearTreeExpand();
}; };
//
const gridEvents: VxeGridListeners<SysRegion> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
</script> </script>

View File

@ -192,6 +192,20 @@ const handleDelete = (row: any) => {
.catch(() => {}); .catch(() => {});
}; };
//
const gridEvents: VxeGridListeners<PageRoleOutput> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
// //
const openGrantData = (row: any) => { const openGrantData = (row: any) => {
grantDataRef.value?.openDialog(row); grantDataRef.value?.openDialog(row);
@ -206,18 +220,4 @@ const openGrantApi = (row: any) => {
const openBaseApi = () => { const openBaseApi = () => {
baseApiRef.value?.openDrawer(); baseApiRef.value?.openDrawer();
}; };
//
const gridEvents: VxeGridListeners<PageRoleOutput> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
</script> </script>

View File

@ -221,6 +221,20 @@ const handleDelete = (row: any) => {
.catch(() => {}); .catch(() => {});
}; };
//
const gridEvents: VxeGridListeners<TenantOutput> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
// //
const openGrantMenu = async (row: any) => { const openGrantMenu = async (row: any) => {
grantMenuRef.value?.openDialog(row); grantMenuRef.value?.openDialog(row);
@ -290,18 +304,4 @@ const syncTenantDb = (row: any) => {
}) })
.catch(() => {}); .catch(() => {});
}; };
//
const gridEvents: VxeGridListeners<TenantOutput> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
</script> </script>

View File

@ -228,6 +228,20 @@ const handleDelete = (row: any) => {
.catch(() => {}); .catch(() => {});
}; };
//
const gridEvents: VxeGridListeners<UserOutput> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
// //
const changeStatus = (row: any) => { const changeStatus = (row: any) => {
getAPI(SysUserApi) getAPI(SysUserApi)
@ -282,18 +296,4 @@ const handleNodeChange = async (node: any) => {
state.queryParams.phone = undefined; state.queryParams.phone = undefined;
await handleQuery(); await handleQuery();
}; };
//
const gridEvents: VxeGridListeners<UserOutput> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
</script> </script>