|
@@ -1,13 +1,6 @@
|
|
<template>
|
|
<template>
|
|
<div class="table-box">
|
|
<div class="table-box">
|
|
- <ProTable
|
|
|
|
- ref="proTable"
|
|
|
|
- :columns="columns"
|
|
|
|
- row-key="roleId"
|
|
|
|
- :request-api="listRoleApi"
|
|
|
|
- :init-param="initParam"
|
|
|
|
- :data-callback="dataCallback"
|
|
|
|
- >
|
|
|
|
|
|
+ <ProTable ref="proTable" :columns="columns" row-key="roleId" :request-api="listRoleApi" :init-param="initParam">
|
|
<!-- 表格 header 按钮 -->
|
|
<!-- 表格 header 按钮 -->
|
|
<template #tableHeader="scope">
|
|
<template #tableHeader="scope">
|
|
<el-button type="primary" v-auth="['system:role:add']" :icon="CirclePlus" @click="openDialog(1, '角色信息新增')">
|
|
<el-button type="primary" v-auth="['system:role:add']" :icon="CirclePlus" @click="openDialog(1, '角色信息新增')">
|
|
@@ -31,21 +24,22 @@
|
|
<el-button
|
|
<el-button
|
|
type="primary"
|
|
type="primary"
|
|
link
|
|
link
|
|
- :icon="View"
|
|
|
|
- v-auth="['system:role:query']"
|
|
|
|
- @click="openDialog(3, '角色信息查看', scope.row)"
|
|
|
|
|
|
+ :icon="EditPen"
|
|
|
|
+ v-auth="['system:role:edit']"
|
|
|
|
+ @click="openDialog(2, '角色信息编辑', scope.row)"
|
|
>
|
|
>
|
|
- 查看
|
|
|
|
|
|
+ 编辑
|
|
</el-button>
|
|
</el-button>
|
|
<el-button
|
|
<el-button
|
|
type="primary"
|
|
type="primary"
|
|
link
|
|
link
|
|
- :icon="EditPen"
|
|
|
|
- v-auth="['system:role:edit']"
|
|
|
|
- @click="openDialog(2, '角色信息编辑', scope.row)"
|
|
|
|
|
|
+ :icon="View"
|
|
|
|
+ v-auth="['system:role:query']"
|
|
|
|
+ @click="openDialog(3, '角色信息查看', scope.row)"
|
|
>
|
|
>
|
|
- 编辑
|
|
|
|
|
|
+ 查看
|
|
</el-button>
|
|
</el-button>
|
|
|
|
+
|
|
<el-button type="primary" link :icon="Delete" v-auth="['system:role:remove']" @click="deleteRole(scope.row)">
|
|
<el-button type="primary" link :icon="Delete" v-auth="['system:role:remove']" @click="deleteRole(scope.row)">
|
|
删除
|
|
删除
|
|
</el-button>
|
|
</el-button>
|
|
@@ -63,7 +57,7 @@ import { useDownload } from '@/hooks/useDownload'
|
|
import { ElMessageBox } from 'element-plus'
|
|
import { ElMessageBox } from 'element-plus'
|
|
import ProTable from '@/components/ProTable/index.vue'
|
|
import ProTable from '@/components/ProTable/index.vue'
|
|
import ImportExcel from '@/components/ImportExcel/index.vue'
|
|
import ImportExcel from '@/components/ImportExcel/index.vue'
|
|
-import FormDialog from '@/components/DialogOld/form.vue'
|
|
|
|
|
|
+import FormDialog from '@/components/FormDialog/index.vue'
|
|
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
|
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
|
import { Delete, EditPen, Download, Upload, View, CirclePlus } from '@element-plus/icons-vue'
|
|
import { Delete, EditPen, Download, Upload, View, CirclePlus } from '@element-plus/icons-vue'
|
|
import {
|
|
import {
|
|
@@ -83,20 +77,15 @@ const proTable = ref<ProTableInstance>()
|
|
// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
|
|
// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
|
|
const initParam = reactive({ type: 1 })
|
|
const initParam = reactive({ type: 1 })
|
|
|
|
|
|
-// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total && pageNum && pageSize 这些字段,可以在这里进行处理成这些字段
|
|
|
|
-const dataCallback = (data: any) => {
|
|
|
|
- return data
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// 删除角色信息信息
|
|
// 删除角色信息信息
|
|
const deleteRole = async (params: any) => {
|
|
const deleteRole = async (params: any) => {
|
|
- await useHandleData(delRoleApi, { id: [params.roleId] }, `删除【${params.id}】角色信息`)
|
|
|
|
|
|
+ await useHandleData(delRoleApi, params.roleId, `删除编号为【${params.roleId}】角色信息`)
|
|
proTable.value?.getTableList()
|
|
proTable.value?.getTableList()
|
|
}
|
|
}
|
|
|
|
|
|
// 批量删除角色信息信息
|
|
// 批量删除角色信息信息
|
|
-const batchDelete = async (id: string[]) => {
|
|
|
|
- await useHandleData(delRoleApi, { id }, '删除所选角色信息信息')
|
|
|
|
|
|
+const batchDelete = async (ids: string[]) => {
|
|
|
|
+ await useHandleData(delRoleApi, ids, '删除所选角色信息信息')
|
|
proTable.value?.clearSelection()
|
|
proTable.value?.clearSelection()
|
|
proTable.value?.getTableList()
|
|
proTable.value?.getTableList()
|
|
}
|
|
}
|
|
@@ -128,15 +117,15 @@ const openDialog = async (type: number, title: string, row?: any) => {
|
|
res = await getRoleApi(row?.roleId || null)
|
|
res = await getRoleApi(row?.roleId || null)
|
|
}
|
|
}
|
|
// 重置表单
|
|
// 重置表单
|
|
- setFieldList()
|
|
|
|
|
|
+ setFormItems()
|
|
const params = {
|
|
const params = {
|
|
title,
|
|
title,
|
|
width: 580,
|
|
width: 580,
|
|
- isEdit: type !== 3,
|
|
|
|
- fieldList: fieldList,
|
|
|
|
- model: type == 1 ? {} : res.data,
|
|
|
|
- api: type == 1 ? addRoleApi : updateRoleApi,
|
|
|
|
- getTableList: proTable.value?.getTableList
|
|
|
|
|
|
+ isEdit: type !== 3, // 是否编辑
|
|
|
|
+ itemsOptions: formItems,
|
|
|
|
+ model: type == 1 ? {} : res.data, // 表单数据
|
|
|
|
+ api: type == 1 ? addRoleApi : updateRoleApi, // 提交api
|
|
|
|
+ getTableList: proTable.value?.getTableList // 刷新表格
|
|
}
|
|
}
|
|
formDialogRef.value?.openDialog(params)
|
|
formDialogRef.value?.openDialog(params)
|
|
}
|
|
}
|
|
@@ -183,58 +172,69 @@ const columns = reactive<ColumnProps<any>[]>([
|
|
},
|
|
},
|
|
{ prop: 'operation', label: '操作', width: 230, fixed: 'right' }
|
|
{ prop: 'operation', label: '操作', width: 230, fixed: 'right' }
|
|
])
|
|
])
|
|
-// 表单配置项
|
|
|
|
-let fieldList: Form.FieldItem[] = []
|
|
|
|
-const setFieldList = () => {
|
|
|
|
- fieldList = [
|
|
|
|
|
|
+
|
|
|
|
+let formItems: ProForm.ItemsOptions[] = []
|
|
|
|
+const setFormItems = () => {
|
|
|
|
+ formItems = [
|
|
{
|
|
{
|
|
label: '角色名称',
|
|
label: '角色名称',
|
|
- field: 'roleName',
|
|
|
|
|
|
+ prop: 'roleName',
|
|
rules: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
|
|
rules: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
|
|
- placeholder: '请输入角色名称'
|
|
|
|
|
|
+ compOptions: {
|
|
|
|
+ placeholder: '请输入角色名称'
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '角色权限字符串',
|
|
label: '角色权限字符串',
|
|
- field: 'roleKey',
|
|
|
|
|
|
+ prop: 'roleKey',
|
|
rules: [{ required: true, message: '角色权限字符串不能为空', trigger: 'blur' }],
|
|
rules: [{ required: true, message: '角色权限字符串不能为空', trigger: 'blur' }],
|
|
- placeholder: '请输入角色权限字符串'
|
|
|
|
|
|
+ compOptions: {
|
|
|
|
+ placeholder: '请输入角色权限字符串'
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '显示顺序',
|
|
label: '显示顺序',
|
|
- field: 'roleSort',
|
|
|
|
|
|
+ prop: 'roleSort',
|
|
rules: [{ required: true, message: '显示顺序不能为空', trigger: 'blur' }],
|
|
rules: [{ required: true, message: '显示顺序不能为空', trigger: 'blur' }],
|
|
- placeholder: '请输入显示顺序'
|
|
|
|
|
|
+ compOptions: {
|
|
|
|
+ placeholder: '请输入显示顺序'
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '数据范围',
|
|
label: '数据范围',
|
|
- field: 'dataScope',
|
|
|
|
- placeholder: '请输入数据范围'
|
|
|
|
|
|
+ prop: 'dataScope',
|
|
|
|
+ compOptions: {
|
|
|
|
+ placeholder: '请输入数据范围'
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '菜单树选择项是否关联显示',
|
|
label: '菜单树选择项是否关联显示',
|
|
- field: 'menuCheckStrictly',
|
|
|
|
- placeholder: '请输入菜单树选择项是否关联显示'
|
|
|
|
|
|
+ prop: 'menuCheckStrictly',
|
|
|
|
+ compOptions: {
|
|
|
|
+ placeholder: '请输入菜单树选择项是否关联显示'
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '部门树选择项是否关联显示',
|
|
label: '部门树选择项是否关联显示',
|
|
- field: 'deptCheckStrictly',
|
|
|
|
- placeholder: '请输入部门树选择项是否关联显示'
|
|
|
|
|
|
+ prop: 'deptCheckStrictly',
|
|
|
|
+ compOptions: {
|
|
|
|
+ placeholder: '请输入部门树选择项是否关联显示'
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '角色状态',
|
|
label: '角色状态',
|
|
- field: 'status',
|
|
|
|
|
|
+ prop: 'status',
|
|
rules: [{ required: true, message: '角色状态不能为空', trigger: 'blur' }],
|
|
rules: [{ required: true, message: '角色状态不能为空', trigger: 'blur' }],
|
|
- placeholder: '请输入角色状态'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '删除标志',
|
|
|
|
- field: 'delFlag',
|
|
|
|
- placeholder: '请输入删除标志'
|
|
|
|
|
|
+ compOptions: {
|
|
|
|
+ placeholder: '请输入角色状态'
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '备注',
|
|
label: '备注',
|
|
- field: 'remark',
|
|
|
|
- placeholder: '请输入备注'
|
|
|
|
|
|
+ prop: 'remark',
|
|
|
|
+ compOptions: {
|
|
|
|
+ placeholder: '请输入备注'
|
|
|
|
+ }
|
|
}
|
|
}
|
|
]
|
|
]
|
|
}
|
|
}
|