2021-10-20 14:32:09 +08:00
|
|
|
<template>
|
2022-03-10 09:47:29 +08:00
|
|
|
<BasicTable @register="registerTable">
|
|
|
|
<template #tableTitle>
|
|
|
|
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="handleCreate"> 新增</a-button>
|
|
|
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
|
|
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
|
|
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
|
|
|
<template #overlay>
|
|
|
|
<a-menu>
|
|
|
|
<a-menu-item key="1" @click="batchHandleDelete">
|
|
|
|
<Icon icon="ant-design:delete-outlined"></Icon>
|
|
|
|
删除
|
|
|
|
</a-menu-item>
|
|
|
|
</a-menu>
|
2021-10-20 14:32:09 +08:00
|
|
|
</template>
|
2022-03-10 09:47:29 +08:00
|
|
|
<a-button>批量操作
|
|
|
|
<Icon icon="mdi:chevron-down"></Icon>
|
|
|
|
</a-button>
|
|
|
|
</a-dropdown>
|
|
|
|
</template>
|
|
|
|
<template #action="{ record }">
|
|
|
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
|
|
|
|
</template>
|
|
|
|
</BasicTable>
|
|
|
|
<!--角色用户表格-->
|
|
|
|
<RoleUserTable @register="roleUserDrawer" />
|
|
|
|
<!--角色编辑抽屉-->
|
|
|
|
<RoleDrawer @register="registerDrawer" @success="reload" :showFooter="showFooter"/>
|
|
|
|
<RoleDesc @register="registerDesc"></RoleDesc>
|
|
|
|
<!--角色菜单授权抽屉-->
|
|
|
|
<RolePermissionDrawer @register="rolePermissionDrawer"/>
|
|
|
|
<!--角色工单授权-->
|
|
|
|
<RoleDesignModal @register="registerModal"/>
|
2022-04-27 19:19:39 +08:00
|
|
|
<!--角色工单授权-->
|
|
|
|
<RoleIndexModal @register="registerIndexModal"/>
|
2021-10-20 14:32:09 +08:00
|
|
|
</template>
|
2022-03-10 09:47:29 +08:00
|
|
|
<script lang="ts" name="system-role" setup>
|
2021-10-20 14:32:09 +08:00
|
|
|
import {ref} from 'vue'
|
2022-03-10 09:47:29 +08:00
|
|
|
import {BasicTable, TableAction} from '/@/components/Table';
|
2021-10-20 14:32:09 +08:00
|
|
|
import {useDrawer} from '/@/components/Drawer';
|
2022-03-10 09:47:29 +08:00
|
|
|
import {useModal} from '/@/components/Modal';
|
|
|
|
import RoleDrawer from './components/RoleDrawer.vue';
|
|
|
|
import RoleDesc from './components/RoleDesc.vue';
|
|
|
|
import RolePermissionDrawer from './components/RolePermissionDrawer.vue';
|
|
|
|
import RoleDesignModal from './components/RoleDesignModal.vue';
|
2022-04-27 19:19:39 +08:00
|
|
|
import RoleIndexModal from './components/RoleIndexModal.vue';
|
2022-03-10 09:47:29 +08:00
|
|
|
import RoleUserTable from './components/RoleUserTable.vue';
|
2021-10-20 14:32:09 +08:00
|
|
|
import {columns, searchFormSchema} from './role.data';
|
2022-03-10 09:47:29 +08:00
|
|
|
import {list, deleteRole, batchDeleteRole, getExportUrl,getImportUrl} from './role.api';
|
|
|
|
import { useListPage } from '/@/hooks/system/useListPage'
|
|
|
|
const showFooter = ref(true);
|
|
|
|
const [roleUserDrawer, {openDrawer:openRoleUserDrawer}] = useDrawer();
|
2021-10-20 14:32:09 +08:00
|
|
|
const [registerDrawer, {openDrawer}] = useDrawer();
|
2022-03-10 09:47:29 +08:00
|
|
|
const [registerModal, {openModal}] = useModal();
|
2022-04-27 19:19:39 +08:00
|
|
|
const [registerIndexModal, {openModal:openIndexModal}] = useModal();
|
2022-03-10 09:47:29 +08:00
|
|
|
const [rolePermissionDrawer, {openDrawer: openRolePermissionDrawer}] = useDrawer();
|
|
|
|
const [registerDesc, {openDrawer: openRoleDesc}] = useDrawer();
|
|
|
|
|
|
|
|
// 列表页面公共参数、方法
|
|
|
|
const { prefixCls, tableContext,onImportXls,onExportXls } = useListPage({
|
|
|
|
designScope: 'role-template',
|
|
|
|
tableProps: {
|
|
|
|
title: '角色列表',
|
|
|
|
api: list,
|
|
|
|
columns: columns,
|
|
|
|
formConfig: {
|
|
|
|
schemas: searchFormSchema
|
|
|
|
},
|
|
|
|
actionColumn: {
|
|
|
|
width: 120,
|
|
|
|
},
|
|
|
|
rowSelection:null
|
2021-10-20 14:32:09 +08:00
|
|
|
},
|
2022-03-10 09:47:29 +08:00
|
|
|
exportConfig: {
|
|
|
|
name:"角色列表",
|
|
|
|
url: getExportUrl
|
2021-10-20 14:32:09 +08:00
|
|
|
},
|
2022-03-10 09:47:29 +08:00
|
|
|
importConfig: {
|
|
|
|
url: getImportUrl
|
|
|
|
}
|
|
|
|
})
|
|
|
|
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] =tableContext;
|
|
|
|
|
2021-10-20 14:32:09 +08:00
|
|
|
/**
|
|
|
|
* 新增
|
|
|
|
*/
|
|
|
|
function handleCreate() {
|
2022-03-10 09:47:29 +08:00
|
|
|
showFooter.value = true;
|
2021-10-20 14:32:09 +08:00
|
|
|
openDrawer(true, {
|
|
|
|
isUpdate: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 编辑
|
|
|
|
*/
|
|
|
|
function handleEdit(record: Recordable) {
|
2022-03-10 09:47:29 +08:00
|
|
|
showFooter.value = true;
|
2021-10-20 14:32:09 +08:00
|
|
|
openDrawer(true, {
|
|
|
|
record,
|
|
|
|
isUpdate: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 详情
|
|
|
|
*/
|
2022-03-10 09:47:29 +08:00
|
|
|
function handleDetail(record) {
|
|
|
|
showFooter.value = false;
|
|
|
|
openRoleDesc(true, {
|
2021-10-20 14:32:09 +08:00
|
|
|
record,
|
|
|
|
isUpdate: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 删除事件
|
|
|
|
*/
|
|
|
|
async function handleDelete(record) {
|
|
|
|
await deleteRole({id: record.id}, reload);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 批量删除事件
|
|
|
|
*/
|
|
|
|
async function batchHandleDelete() {
|
2022-03-10 09:47:29 +08:00
|
|
|
await batchDeleteRole({ids: selectedRowKeys.value}, reload);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 角色授权弹窗
|
|
|
|
*/
|
|
|
|
function handlePerssion(record) {
|
|
|
|
openRolePermissionDrawer(true, {roleId: record.id});
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
|
|
|
/**
|
2022-03-10 09:47:29 +08:00
|
|
|
* 工单授权弹窗
|
2021-10-20 14:32:09 +08:00
|
|
|
*/
|
2022-03-10 09:47:29 +08:00
|
|
|
function handleDesign(id) {
|
|
|
|
openModal(true, {roleId: id});
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
2022-04-27 19:19:39 +08:00
|
|
|
/**
|
|
|
|
* 首页配置弹窗
|
|
|
|
*/
|
|
|
|
function handleIndexConfig(roleCode) {
|
|
|
|
openIndexModal(true, {roleCode});
|
|
|
|
}
|
2021-10-20 14:32:09 +08:00
|
|
|
/**
|
2022-03-10 09:47:29 +08:00
|
|
|
* 角色用户
|
2021-10-20 14:32:09 +08:00
|
|
|
*/
|
2022-03-10 09:47:29 +08:00
|
|
|
function handleUser(record) {
|
|
|
|
//onSelectChange(selectedRowKeys)
|
|
|
|
openRoleUserDrawer(true,record)
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 操作栏
|
|
|
|
*/
|
|
|
|
function getTableAction(record) {
|
|
|
|
return [
|
|
|
|
{
|
2022-03-10 09:47:29 +08:00
|
|
|
label: '用户',
|
|
|
|
onClick: handleUser.bind(null, record),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '授权',
|
|
|
|
onClick: handlePerssion.bind(null, record),
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 下拉操作栏
|
|
|
|
*/
|
|
|
|
function getDropDownAction(record) {
|
|
|
|
return [
|
|
|
|
{
|
2022-03-10 09:47:29 +08:00
|
|
|
label: '编辑',
|
|
|
|
onClick: handleEdit.bind(null, record),
|
2021-10-20 14:32:09 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '详情',
|
|
|
|
onClick: handleDetail.bind(null, record),
|
|
|
|
}, {
|
|
|
|
label: '删除',
|
|
|
|
popConfirm: {
|
|
|
|
title: '是否确认删除',
|
|
|
|
confirm: handleDelete.bind(null, record),
|
|
|
|
},
|
2022-04-27 19:19:39 +08:00
|
|
|
},{
|
|
|
|
label: '首页配置',
|
|
|
|
onClick: handleIndexConfig.bind(null, record.roleCode),
|
2022-03-10 09:47:29 +08:00
|
|
|
}, {
|
|
|
|
label: '工单?',
|
|
|
|
onClick: handleDesign.bind(null, record.id),
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|