rax-medical/src/views/permissions-manage/role-manage.vue

134 lines
5.3 KiB
Vue
Raw Normal View History

2023-12-17 16:05:38 +08:00
<template>
2023-12-18 17:16:47 +08:00
<div class="table-page">
2023-12-27 16:49:37 +08:00
<div class="search-part" v-show="isSearch">
2023-12-18 17:16:47 +08:00
<div class="search-cell">
<span class="label">角色名称</span>
2024-04-24 19:35:24 +08:00
<el-input v-model="queryParams" placeholder="请输入角色名称"></el-input>
2023-12-18 17:16:47 +08:00
</div>
<el-button type="primary" icon="Search" @click="queryData(queryParams)">查询</el-button>
<el-button icon="Refresh" @click="queryParams = {}">重置</el-button>
</div>
2023-12-27 14:06:02 +08:00
<div class="button-part" style="justify-content: space-between;">
<div>
<el-button type="primary" icon="FirstAidKit" @click="addData">新增</el-button>
<el-button icon="FirstAidKit" @click="importData">导入</el-button>
<el-button icon="Delete" @click="removeData()">删除</el-button>
</div>
2023-12-27 16:49:37 +08:00
<TableAbility @searchBtn="isSearch = !isSearch" @refreshBtn="queryData({})" @downloadBtn="exportData('角色数据', tableData)"></TableAbility>
2023-12-18 17:16:47 +08:00
</div>
<div class="table-part">
2023-12-27 16:49:37 +08:00
<el-table ref="tableRef" v-loading="loading" :data="tableData" height="100%" border show-overflow-tooltip
2023-12-18 17:16:47 +08:00
@row-click="tableRowClick">
<el-table-column type="selection" width="55" />
<el-table-column type="index" label="#" width="55" align="center" />
<el-table-column property="roleName" label="角色名称" width="120" align="center" />
<el-table-column property="roleMark" label="角色标识" width="180" align="center" />
<el-table-column property="roleRemark" label="角色描述" width="120" align="center" />
<el-table-column property="dataPermissions" label="数据权限" width="120" align="center" />
<el-table-column label="创建时间" width="220" align="center">
2023-12-27 16:49:37 +08:00
<template #default="scope">{{ scope.row.createdTime }}</template>
2023-12-18 17:16:47 +08:00
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<span @click.stop>
<el-button link icon="RefreshLeft" @click="empower(scope.row)">授权</el-button>
<el-button link icon="EditPen" @click="editData(scope.row)">修改</el-button>
<el-button link icon="Delete" @click="removeData(scope.row)">删除</el-button>
</span>
</template>
</el-table-column>
</el-table>
</div>
<div class="pagination-part">
<CommonPagination :total="100" @paginationChange="paginationChange" />
</div>
2023-12-17 16:05:38 +08:00
</div>
2023-12-27 16:49:37 +08:00
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="30%">
<RoleForm ref="RoleFormRef" :type="formDialogTitle === '添加' ? 'add' : 'edit'" @close="isFormDialog = false" />
</el-dialog>
2023-12-18 17:16:47 +08:00
<ImportDialog ref="importDialogRef" title="角色导入" templateUrl="#" importUrl="#" />
<EmpowerDialog ref="empowerDialogRef" />
2023-12-17 16:05:38 +08:00
</template>
<script lang='ts' setup>
2024-04-24 19:35:24 +08:00
import {ref} from 'vue'
import {dateFormater} from '@/utils/date-util'
import {exportData, tableRemoveRow} from '@/utils/table-util'
2023-12-18 17:16:47 +08:00
import CommonPagination from '@/components/common-pagination.vue'
import RoleForm from './form/role-form.vue'
import ImportDialog from '@/components/import-dialog.vue'
import EmpowerDialog from './form/empower-dialog.vue'
2023-12-17 16:05:38 +08:00
2023-12-18 17:16:47 +08:00
const tableRef = ref()
const RoleFormRef = ref()
const importDialogRef = ref()
const empowerDialogRef = ref()
2023-12-27 16:49:37 +08:00
const isSearch = ref(true)
const loading = ref(true)
2023-12-18 17:16:47 +08:00
const isFormDialog = ref(false)
const formDialogTitle = ref('')
2024-04-24 19:35:24 +08:00
const queryParams = ref("")
2023-12-18 17:16:47 +08:00
const tableData = ref([] as any)
2023-12-17 16:05:38 +08:00
2023-12-27 16:49:37 +08:00
queryData({ roleName: '测试' })
2023-12-18 17:16:47 +08:00
2023-12-27 16:49:37 +08:00
function queryData(e: any) {
loading.value = true
2023-12-18 17:16:47 +08:00
tableData.value = []
2023-12-27 16:49:37 +08:00
setTimeout(() => {
while (tableData.value.length < 10) {
tableData.value.push({
roleName: e.roleName || '测试',
roleMark: 'ROLE_ADMIN',
roleRemark: '超级管理员',
dataPermissions: '全部',
createdTime: dateFormater('yyyy-MM-dd HH:mm:ss'),
})
}
loading.value = false
}, 200);
2023-12-18 17:16:47 +08:00
}
const addData = () => {
isFormDialog.value = true
formDialogTitle.value = '添加'
setTimeout(() => {
RoleFormRef.value.resetData()
}, 0)
}
const importData = () => {
setTimeout(() => {
importDialogRef.value.open()
}, 0);
}
const removeData = (e?: any) => {
const selectRow = e || tableRef.value.getSelectionRows()
tableRemoveRow({ data: selectRow }, (res: boolean) => {
if (res) {
2023-12-28 17:58:59 +08:00
// console.log('调用删除', selectRow)
2023-12-18 17:16:47 +08:00
}
})
}
const empower = (e: any) => {
setTimeout(() => {
empowerDialogRef.value.open()
})
}
const editData = (e: any) => {
isFormDialog.value = true
formDialogTitle.value = '修改'
setTimeout(() => {
RoleFormRef.value.resetData()
2023-12-24 16:15:33 +08:00
RoleFormRef.value.formData = JSON.parse(JSON.stringify(e))
2023-12-18 17:16:47 +08:00
}, 0)
}
const tableRowClick = (row: any) => {
tableRef.value.toggleRowSelection(row)
}
2024-04-24 19:35:24 +08:00
2023-12-18 17:16:47 +08:00
const paginationChange = (page: number, size: number) => {
}
2023-12-17 16:05:38 +08:00
</script>
2023-12-27 16:49:37 +08:00
<style lang='scss' scoped></style>