按照标准框架修改角色界面
This commit is contained in:
@@ -4,9 +4,9 @@ import type { ReqPage } from '@/api/interface'
|
|||||||
export namespace Role {
|
export namespace Role {
|
||||||
|
|
||||||
export interface Permission{
|
export interface Permission{
|
||||||
id: string; //权限名称
|
key: string; //权限名称
|
||||||
name: string; //权限ID
|
label: string; //权限ID
|
||||||
havePermission:boolean; //是否拥有该权限
|
disabled:boolean; //是否拥有该权限
|
||||||
}
|
}
|
||||||
|
|
||||||
// 角色列表
|
// 角色列表
|
||||||
@@ -39,9 +39,9 @@ export namespace Role {
|
|||||||
|
|
||||||
//角色权限列表
|
//角色权限列表
|
||||||
export interface ResPermissionList {
|
export interface ResPermissionList {
|
||||||
id: string;
|
key: string;
|
||||||
name: string;
|
label: string;
|
||||||
permissionList?: Permission[];
|
disable?: Permission[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// export interface ResRole {
|
// export interface ResRole {
|
||||||
|
|||||||
@@ -6,19 +6,19 @@ const data = [
|
|||||||
describe:"可以对待检设备的台账进行操作并执行检测功能",
|
describe:"可以对待检设备的台账进行操作并执行检测功能",
|
||||||
permissionList: [
|
permissionList: [
|
||||||
{
|
{
|
||||||
name: "台账管理",
|
label: "台账管理",
|
||||||
id: "dataManager",
|
key: "dataManager",
|
||||||
havePermission: false,
|
disable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "系统配置",
|
label: "系统配置",
|
||||||
id: "sysManager",
|
key: "sysManager",
|
||||||
havePermission: false,
|
disable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "设备检测",
|
label: "设备检测",
|
||||||
id: "devTest",
|
key: "devTest",
|
||||||
havePermission: true,
|
disable: true,
|
||||||
},
|
},
|
||||||
]},
|
]},
|
||||||
{
|
{
|
||||||
@@ -28,19 +28,19 @@ const data = [
|
|||||||
describe:"可以设置检测脚本、误差体系、新增操作人员",
|
describe:"可以设置检测脚本、误差体系、新增操作人员",
|
||||||
permissionList: [
|
permissionList: [
|
||||||
{
|
{
|
||||||
name: "台账管理",
|
label: "台账管理",
|
||||||
id: "dataManager",
|
key: "dataManager",
|
||||||
havePermission: true,
|
disable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "系统配置",
|
label: "系统配置",
|
||||||
id: "sysManager",
|
key: "sysManager",
|
||||||
havePermission: false,
|
disable: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "设备检测",
|
label: "设备检测",
|
||||||
id: "devTest",
|
key: "devTest",
|
||||||
havePermission: true,
|
disable: true,
|
||||||
},
|
},
|
||||||
]},
|
]},
|
||||||
{
|
{
|
||||||
@@ -50,19 +50,19 @@ const data = [
|
|||||||
describe:"可以修改程序的底层配置,例如检测指标的具体类型",
|
describe:"可以修改程序的底层配置,例如检测指标的具体类型",
|
||||||
permissionList: [
|
permissionList: [
|
||||||
{
|
{
|
||||||
name: "台账管理",
|
label: "台账管理",
|
||||||
id: "dataManager",
|
key: "dataManager",
|
||||||
havePermission: true,
|
disable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "系统配置",
|
label: "系统配置",
|
||||||
id: "sysManager",
|
key: "sysManager",
|
||||||
havePermission: true,
|
disable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "设备检测",
|
label: "设备检测",
|
||||||
id: "devTest",
|
key: "devTest",
|
||||||
havePermission: true,
|
disable: true,
|
||||||
},
|
},
|
||||||
]},
|
]},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 权限信息弹出框 -->
|
||||||
|
<el-dialog :model-value="dialogVisible" :title="title" @close="handleCancel" width="800" draggable>
|
||||||
|
<div>
|
||||||
|
<el-transfer v-model="value" :data="data" :titles="['未具备的权限', '已具备的权限']"/>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="handleCancel">取消</el-button>
|
||||||
|
<el-button type="primary" @click="handleCancel">
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
const {dialogVisible,data} = defineProps(['dialogVisible','title','data'])
|
||||||
|
const value = ref()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e:'update:visible',value:boolean):void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
emit('update:visible',false)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
60
frontend/src/views/authority/role/components/roleUnit.vue
Normal file
60
frontend/src/views/authority/role/components/roleUnit.vue
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 基础信息弹出框 -->
|
||||||
|
<el-dialog :model-value="dialogVisible" :title="title" @close="handleCancel" width="800" draggable>
|
||||||
|
<div>
|
||||||
|
<el-form :model="data">
|
||||||
|
<el-form-item label="角色类型名称" :label-width="100">
|
||||||
|
<el-input v-model="data.rolename" placeholder="请输入类型名称" autocomplete="off" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="角色类型编码" :label-width="100">
|
||||||
|
<el-input v-model="data.id" placeholder="请输入角色类型编码" autocomplete="off" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="角色类型状态" :label-width="100">
|
||||||
|
<el-switch
|
||||||
|
v-model=value
|
||||||
|
inline-prompt
|
||||||
|
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
|
||||||
|
active-text="启用"
|
||||||
|
inactive-text="禁用"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="角色类型备注" :label-width="100">
|
||||||
|
<el-input v-model="data.describe" placeholder="请输入备注" autocomplete="off" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button @click="handleCancel">取消</el-button>
|
||||||
|
<el-button type="primary" @click="handleCancel">
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
const value = ref(true)
|
||||||
|
const {dialogVisible,title,data} = defineProps<{
|
||||||
|
dialogVisible:boolean;
|
||||||
|
title:string;
|
||||||
|
data:{
|
||||||
|
rolename:string;
|
||||||
|
id:string;
|
||||||
|
status:number;
|
||||||
|
describe:string;
|
||||||
|
}
|
||||||
|
}>();
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e:'update:visible',value:boolean):void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
emit('update:visible',false)
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
>
|
>
|
||||||
<!-- 表格 header 按钮 -->
|
<!-- 表格 header 按钮 -->
|
||||||
<template #tableHeader='scope'>
|
<template #tableHeader='scope'>
|
||||||
<el-button type='primary' :icon='CirclePlus' @click="openDrawer('新增')">新增角色类型</el-button>
|
<el-button type='primary' :icon='CirclePlus' @click="openDrawer('新增')">新增角色</el-button>
|
||||||
<el-button type='primary' :icon='Download' plain @click='downloadFile'>导出角色类型数据</el-button>
|
<el-button type='primary' :icon='Download' plain @click='downloadFile'>导出角色数据</el-button>
|
||||||
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||||
@click='batchDelete(scope.selectedListIds)'>
|
@click='batchDelete(scope.selectedListIds)'>
|
||||||
批量删除角色
|
批量删除角色
|
||||||
@@ -16,44 +16,26 @@
|
|||||||
</template>
|
</template>
|
||||||
<!-- 表格操作 -->
|
<!-- 表格操作 -->
|
||||||
<template #operation='scope'>
|
<template #operation='scope'>
|
||||||
<el-button type='primary' link :icon='View' @click="openDrawer('编辑', scope.row)">编辑</el-button>
|
<el-button type='primary' link :icon='EditPen' @click="openDrawer('编辑', scope.row)">编辑</el-button>
|
||||||
<el-button type='primary' link :icon='Delete' @click='deleteAccount(scope.row)'>删除</el-button>
|
<el-button type='primary' link :icon='Delete' @click='deleteAccount(scope.row)'>删除</el-button>
|
||||||
<!-- <el-button type='primary' link :icon='EditPen' @click='resetPass(scope.row)'>设置权限</el-button> -->
|
<el-button type='primary' link :icon='Share' @click="openDrawer('设置权限', scope.row)">设置权限</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</ProTable>
|
</ProTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 弹出的对话框 -->
|
<roleUnit
|
||||||
<el-dialog v-model="dialogVisible" :title="dialogType ==='add' ? '新增角色类型' : '修改角色类型'" width="500" draggable>
|
:dialogVisible = roleUnitVisible
|
||||||
<div>
|
:title = roleUnitTitle
|
||||||
<el-form :model="dialogForm">
|
:data = roleUnitData
|
||||||
<el-form-item label="角色类型名称" :label-width="100">
|
@update:visible="roleUnitVisible = $event"
|
||||||
<el-input v-model="dialogForm.rolename" placeholder="请输入类型名称" autocomplete="off" />
|
/>
|
||||||
</el-form-item>
|
<permissionUnit
|
||||||
<el-form-item label="角色类型编码" :label-width="100">
|
:dialogVisible = permissionUnitVisible
|
||||||
<el-input v-model="dialogForm.id" placeholder="请输入角色类型编码" autocomplete="off" />
|
:title = permissionUnitTitle
|
||||||
</el-form-item>
|
:data = permissionUnitData
|
||||||
<el-form-item label="角色类型状态" :label-width="100">
|
@update:visible="permissionUnitVisible = $event"
|
||||||
<el-input v-model="dialogForm.status" placeholder="请输入状态" autocomplete="off" />
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="角色类型备注" :label-width="100">
|
|
||||||
<el-input v-model="dialogForm.describe" placeholder="请输入备注" autocomplete="off" />
|
|
||||||
</el-form-item>
|
|
||||||
<!-- <el-form-item label="权限" :label-width="60">
|
|
||||||
<el-input v-model="drawerForm.rolePermission" placeholder="请输入地址" autocomplete="off" />
|
|
||||||
</el-form-item> -->
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
<template #footer>
|
|
||||||
<div class="dialog-footer">
|
|
||||||
<el-button @click="dialogVisible = false">取消</el-button>
|
|
||||||
<el-button type="primary" @click="dialogVisible = false">
|
|
||||||
保存
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang='tsx' name='useRole'>
|
<script setup lang='tsx' name='useRole'>
|
||||||
@@ -62,35 +44,13 @@
|
|||||||
import { useDownload } from '@/hooks/useDownload'
|
import { useDownload } from '@/hooks/useDownload'
|
||||||
import { useAuthButtons } from '@/hooks/useAuthButtons'
|
import { useAuthButtons } from '@/hooks/useAuthButtons'
|
||||||
import ProTable from '@/components/ProTable/index.vue'
|
import ProTable from '@/components/ProTable/index.vue'
|
||||||
|
import roleUnit from './components/roleUnit.vue'
|
||||||
|
import permissionUnit from './components/permissionUnit.vue'
|
||||||
import ImportExcel from '@/components/ImportExcel/index.vue'
|
import ImportExcel from '@/components/ImportExcel/index.vue'
|
||||||
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||||
import { CirclePlus, Delete, EditPen, Download, Upload, View, Refresh } from '@element-plus/icons-vue'
|
import { CirclePlus, Delete, EditPen, Share, Download, Upload, View, Refresh } from '@element-plus/icons-vue'
|
||||||
import roleDataList from '@/api/role/roleData'
|
import roleDataList from '@/api/role/roleData'
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
|
|
||||||
const {dialogVisible,dialogType,dialogForm} = useCount();
|
|
||||||
function useCount() {
|
|
||||||
const dialogVisible = ref(false)
|
|
||||||
const dialogType = ref('新增')
|
|
||||||
|
|
||||||
const dialogForm = ref({
|
|
||||||
rolename:"",
|
|
||||||
id: "",
|
|
||||||
status: 0,
|
|
||||||
describe:"",
|
|
||||||
})
|
|
||||||
//const dialogForm = ref<Role.ReqRoleParams>({
|
|
||||||
// rolename:"",
|
|
||||||
// id: "",
|
|
||||||
// status: 0,
|
|
||||||
// describe:"",
|
|
||||||
// })
|
|
||||||
|
|
||||||
return {dialogVisible,dialogType,dialogForm};
|
|
||||||
}
|
|
||||||
|
|
||||||
const dictStore = useDictStore()
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getRoleList,
|
getRoleList,
|
||||||
addRole,
|
addRole,
|
||||||
@@ -100,13 +60,21 @@
|
|||||||
changeRoleStatus,
|
changeRoleStatus,
|
||||||
exportRoleInfo,
|
exportRoleInfo,
|
||||||
getRoleDepartment,
|
getRoleDepartment,
|
||||||
// deleteUser,
|
|
||||||
// changeUserStatus,
|
|
||||||
// exportUserInfo,
|
|
||||||
// BatchAddUser,
|
|
||||||
getRoleStatus,
|
getRoleStatus,
|
||||||
} from '@/api/role/role'
|
} from '@/api/role/role'
|
||||||
import { describe } from 'node:test'
|
|
||||||
|
const {roleUnitVisible,permissionUnitVisible,roleUnitTitle,permissionUnitTitle,roleUnitData,permissionUnitData} = useCount();
|
||||||
|
function useCount() {
|
||||||
|
const roleUnitVisible = ref(false)
|
||||||
|
const permissionUnitVisible = ref(false)
|
||||||
|
const roleUnitTitle = ref()
|
||||||
|
const permissionUnitTitle = ref()
|
||||||
|
const roleUnitData = ref<Role.ResRoleList>({} as Role.ResRoleList)
|
||||||
|
const permissionUnitData = ref<Role.Permission[]>([])
|
||||||
|
return {roleUnitVisible,permissionUnitVisible,roleUnitTitle,permissionUnitTitle,roleUnitData,permissionUnitData};
|
||||||
|
}
|
||||||
|
|
||||||
|
const dictStore = useDictStore()
|
||||||
|
|
||||||
const roleData = roleDataList
|
const roleData = roleDataList
|
||||||
|
|
||||||
@@ -144,41 +112,33 @@ import { describe } from 'node:test'
|
|||||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||||
{
|
{
|
||||||
prop: 'rolename',
|
prop: 'rolename',
|
||||||
label: '角色名称',
|
label: '名称',
|
||||||
search: { el: 'input' },
|
search: { el: 'input' },
|
||||||
|
minWidth: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'id',
|
prop: 'id',
|
||||||
label: '角色编码',
|
label: '编码',
|
||||||
search: { el: 'input' },
|
search: { el: 'input' },
|
||||||
|
minWidth: 180,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'status',
|
prop: 'status',
|
||||||
label: '角色状态',
|
label: '状态',
|
||||||
enum: dictStore.getDictData('status'),
|
enum: dictStore.getDictData('status'),
|
||||||
search: { el: 'tree-select', props: { filterable: true } },
|
search: { el: 'tree-select', props: { filterable: true } },
|
||||||
fieldNames: { label: 'roleLabel', value: 'roleStatus' },
|
minWidth: 100,
|
||||||
|
fieldNames: { label: 'label', value: 'code' },
|
||||||
render: scope => {
|
render: scope => {
|
||||||
return (
|
return (
|
||||||
<>
|
<el-tag type={scope.row.status ? 'success' : 'danger'}>{scope.row.status ? '启用' : '禁用'}</el-tag>
|
||||||
{BUTTONS.value.status ? (
|
|
||||||
<el-switch
|
|
||||||
model-value={scope.row.status}
|
|
||||||
active-text={scope.row.status ? '启用' : '禁用'}
|
|
||||||
active-value={1}
|
|
||||||
inactive-value={0}
|
|
||||||
onClick={() => changeStatus(scope.row)}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<el-tag type={scope.row.status ? 'success' : 'danger'}>{scope.row.status ? '启用' : '禁用'}</el-tag>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'describe',
|
prop: 'describe',
|
||||||
label: '角色描述',
|
label: '描述',
|
||||||
|
minWidth: 380,
|
||||||
},
|
},
|
||||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 330 },
|
{ prop: 'operation', label: '操作', fixed: 'right', width: 330 },
|
||||||
])
|
])
|
||||||
@@ -196,11 +156,6 @@ import { describe } from 'node:test'
|
|||||||
proTable.value?.getTableList()
|
proTable.value?.getTableList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置用户密码
|
|
||||||
// const resetPass = async (params: User.ResUserList) => {
|
|
||||||
// await useHandleData(resetUserPassWord, { id: params.id }, `重置【${params.username}】用户密码`)
|
|
||||||
// proTable.value?.getTableList()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 切换角色状态
|
// 切换角色状态
|
||||||
const changeStatus = async (row: Role.ResRoleList) => {
|
const changeStatus = async (row: Role.ResRoleList) => {
|
||||||
@@ -232,11 +187,33 @@ import { describe } from 'node:test'
|
|||||||
|
|
||||||
// 打开 drawer(新增、查看、编辑)
|
// 打开 drawer(新增、查看、编辑)
|
||||||
const openDrawer = (title: string, row: Partial<Role.ResRoleList> = {}) => {
|
const openDrawer = (title: string, row: Partial<Role.ResRoleList> = {}) => {
|
||||||
dialogVisible.value = true
|
|
||||||
dialogType.value = title
|
|
||||||
// dialogForm = row
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(title === "新增" || title === '编辑' )
|
||||||
|
{
|
||||||
|
roleUnitVisible.value = true
|
||||||
|
roleUnitTitle.value = title
|
||||||
|
|
||||||
|
const safeRow: Role.ResRoleList = {
|
||||||
|
id: row.id || '',
|
||||||
|
rolename: row.rolename || '',
|
||||||
|
status: row.status || 0,
|
||||||
|
describe: row.describe || '',
|
||||||
|
permissionList: row.permissionList || []
|
||||||
|
};
|
||||||
|
|
||||||
|
roleUnitData.value = safeRow;
|
||||||
|
}
|
||||||
|
else if(title === "设置权限")
|
||||||
|
{
|
||||||
|
permissionUnitVisible.value = true
|
||||||
|
permissionUnitTitle.value = title
|
||||||
|
|
||||||
|
if (row.permissionList)
|
||||||
|
{
|
||||||
|
permissionUnitData.value = row.permissionList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
Reference in New Issue
Block a user