| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 | 
							- <template>
 
-   <div class="table-box">
 
-     <ProTable ref="proTable" :columns="columns" row-key="roleId" :request-api="listRoleApi" :init-param="initParam">
 
-       <!-- 表格 header 按钮 -->
 
-       <template #tableHeader="scope">
 
-         <el-button type="primary" v-auth="['system:role:add']" :icon="CirclePlus" @click="openDialog(1, '角色信息新增')">
 
-           新增
 
-         </el-button>
 
-         <el-button type="primary" v-auth="['system:role:import']" :icon="Upload" plain @click="batchAdd"> 导入 </el-button>
 
-         <el-button type="primary" v-auth="['system:role:export']" :icon="Download" plain @click="downloadFile"> 导出 </el-button>
 
-         <el-button
 
-           type="danger"
 
-           v-auth="['system:user:remove']"
 
-           :icon="Delete"
 
-           plain
 
-           :disabled="!scope.isSelected"
 
-           @click="batchDelete(scope.selectedListIds)"
 
-         >
 
-           批量删除
 
-         </el-button>
 
-       </template>
 
-       <!-- 表格操作 -->
 
-       <template #operation="scope">
 
-         <el-button
 
-           type="primary"
 
-           link
 
-           :icon="EditPen"
 
-           v-auth="['system:role:edit']"
 
-           @click="openDialog(2, '角色信息编辑', scope.row)"
 
-         >
 
-           编辑
 
-         </el-button>
 
-         <el-button
 
-           type="primary"
 
-           link
 
-           :icon="View"
 
-           v-auth="['system:role:query']"
 
-           @click="openDialog(3, '角色信息查看', scope.row)"
 
-         >
 
-           查看
 
-         </el-button>
 
-         <el-button type="primary" link :icon="Delete" v-auth="['system:role:remove']" @click="deleteRole(scope.row)">
 
-           删除
 
-         </el-button>
 
-       </template>
 
-     </ProTable>
 
-     <FormDialog ref="formDialogRef" />
 
-     <ImportExcel ref="dialogRef" />
 
-   </div>
 
- </template>
 
- <script setup lang="tsx" name="Role">
 
- import { ref, reactive } from 'vue'
 
- import { useHandleData } from '@/hooks/useHandleData'
 
- import { useDownload } from '@/hooks/useDownload'
 
- import { ElMessageBox } from 'element-plus'
 
- import ProTable from '@/components/ProTable/index.vue'
 
- import ImportExcel from '@/components/ImportExcel/index.vue'
 
- import FormDialog from '@/components/FormDialog/index.vue'
 
- import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
 
- import { Delete, EditPen, Download, Upload, View, CirclePlus } from '@element-plus/icons-vue'
 
- import {
 
-   listRoleApi,
 
-   delRoleApi,
 
-   addRoleApi,
 
-   updateRoleApi,
 
-   importTemplateApi,
 
-   importDataApi,
 
-   exportApi,
 
-   getRoleApi
 
- } from '@/api/modules/system/role'
 
- // ProTable 实例
 
- const proTable = ref<ProTableInstance>()
 
- // 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
 
- const initParam = reactive({ type: 1 })
 
- // 删除角色信息信息
 
- const deleteRole = async (params: any) => {
 
-   await useHandleData(delRoleApi, params.roleId, `删除编号为【${params.roleId}】角色信息`)
 
-   proTable.value?.getTableList()
 
- }
 
- // 批量删除角色信息信息
 
- const batchDelete = async (ids: string[]) => {
 
-   await useHandleData(delRoleApi, ids, '删除所选角色信息信息')
 
-   proTable.value?.clearSelection()
 
-   proTable.value?.getTableList()
 
- }
 
- // 导出角色信息列表
 
- const downloadFile = async () => {
 
-   ElMessageBox.confirm('确认导出角色信息数据?', '温馨提示', { type: 'warning' }).then(() =>
 
-     useDownload(exportApi, '角色信息列表', proTable.value?.searchParam)
 
-   )
 
- }
 
- // 批量添加角色信息
 
- const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
 
- const batchAdd = () => {
 
-   const params = {
 
-     title: '角色信息',
 
-     tempApi: importTemplateApi,
 
-     importApi: importDataApi,
 
-     getTableList: proTable.value?.getTableList
 
-   }
 
-   dialogRef.value?.acceptParams(params)
 
- }
 
- const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
 
- // 打开弹框的功能
 
- const openDialog = async (type: number, title: string, row?: any) => {
 
-   let res = { data: {} }
 
-   if (row?.roleId) {
 
-     res = await getRoleApi(row?.roleId || null)
 
-   }
 
-   // 重置表单
 
-   setFormItems()
 
-   const params = {
 
-     title,
 
-     width: 580,
 
-     isEdit: type !== 3, // 是否编辑
 
-     itemsOptions: formItems,
 
-     model: type == 1 ? {} : res.data, // 表单数据
 
-     api: type == 1 ? addRoleApi : updateRoleApi, // 提交api
 
-     getTableList: proTable.value?.getTableList // 刷新表格
 
-   }
 
-   formDialogRef.value?.openDialog(params)
 
- }
 
- // 表格配置项
 
- const columns = reactive<ColumnProps<any>[]>([
 
-   { type: 'selection', fixed: 'left', width: 70 },
 
-   { prop: 'roleId', label: '角色编号' },
 
-   {
 
-     prop: 'roleName',
 
-     label: '角色名称',
 
-     search: {
 
-       el: 'input'
 
-     }
 
-   },
 
-   {
 
-     prop: 'roleKey',
 
-     label: '角色权限字符串',
 
-     search: {
 
-       el: 'input'
 
-     }
 
-   },
 
-   {
 
-     prop: 'roleSort',
 
-     label: '显示顺序',
 
-     search: {
 
-       el: 'input'
 
-     }
 
-   },
 
-   {
 
-     prop: 'status',
 
-     label: '角色状态',
 
-     search: {
 
-       el: 'input'
 
-     }
 
-   },
 
-   {
 
-     prop: 'createTime',
 
-     label: '创建时间',
 
-     search: {
 
-       el: 'date-picker',
 
-       props: { type: 'datetimerange', valueFormat: 'YYYY-MM-DD HH:mm:ss' }
 
-     }
 
-   },
 
-   { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
 
- ])
 
- let formItems: ProForm.ItemsOptions[] = []
 
- const setFormItems = () => {
 
-   formItems = [
 
-     {
 
-       label: '角色名称',
 
-       prop: 'roleName',
 
-       rules: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
 
-       compOptions: {
 
-         placeholder: '请输入角色名称'
 
-       }
 
-     },
 
-     {
 
-       label: '角色权限字符串',
 
-       prop: 'roleKey',
 
-       rules: [{ required: true, message: '角色权限字符串不能为空', trigger: 'blur' }],
 
-       compOptions: {
 
-         placeholder: '请输入角色权限字符串'
 
-       }
 
-     },
 
-     {
 
-       label: '显示顺序',
 
-       prop: 'roleSort',
 
-       rules: [{ required: true, message: '显示顺序不能为空', trigger: 'blur' }],
 
-       compOptions: {
 
-         placeholder: '请输入显示顺序'
 
-       }
 
-     },
 
-     {
 
-       label: '数据范围',
 
-       prop: 'dataScope',
 
-       compOptions: {
 
-         placeholder: '请输入数据范围'
 
-       }
 
-     },
 
-     {
 
-       label: '菜单树选择项是否关联显示',
 
-       prop: 'menuCheckStrictly',
 
-       compOptions: {
 
-         placeholder: '请输入菜单树选择项是否关联显示'
 
-       }
 
-     },
 
-     {
 
-       label: '部门树选择项是否关联显示',
 
-       prop: 'deptCheckStrictly',
 
-       compOptions: {
 
-         placeholder: '请输入部门树选择项是否关联显示'
 
-       }
 
-     },
 
-     {
 
-       label: '角色状态',
 
-       prop: 'status',
 
-       rules: [{ required: true, message: '角色状态不能为空', trigger: 'blur' }],
 
-       compOptions: {
 
-         placeholder: '请输入角色状态'
 
-       }
 
-     },
 
-     {
 
-       label: '备注',
 
-       prop: 'remark',
 
-       compOptions: {
 
-         placeholder: '请输入备注'
 
-       }
 
-     }
 
-   ]
 
- }
 
- </script>
 
 
  |