130 lines
3.7 KiB
Vue
130 lines
3.7 KiB
Vue
<template>
|
|
<div class='table-box'>
|
|
<ProTable
|
|
ref='proTable'
|
|
:columns='columns'
|
|
:request-api='getFunctionList'
|
|
:pagination="false"
|
|
>
|
|
<!-- :data='userData' -->
|
|
<!-- 表格 header 按钮 -->
|
|
<template #tableHeader>
|
|
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
|
</template>
|
|
<!-- 表格操作 -->
|
|
<template #operation='scope'>
|
|
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
|
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
|
</template>
|
|
</ProTable>
|
|
|
|
|
|
</div>
|
|
<ResourcePopup :refresh-table='proTable?.getTableList' ref='resourcePopup' />
|
|
|
|
</template>
|
|
<script setup lang='tsx' name='useProTable'>
|
|
import { ref ,reactive} from 'vue'
|
|
import { useHandleData } from '@/hooks/useHandleData'
|
|
import type { Function } from "@/api/user/interface/function"
|
|
import ProTable from '@/components/ProTable/index.vue'
|
|
import {CirclePlus, Delete, EditPen,HomeFilled} from '@element-plus/icons-vue'
|
|
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
|
import { useDictStore } from '@/stores/modules/dict'
|
|
import ResourcePopup from './components/resourcePopup.vue'
|
|
import {deleteFunction,getFunctionList} from '@/api/user/function/index'
|
|
const dictStore = useDictStore()
|
|
const resourcePopup = ref()
|
|
// ProTable 实例
|
|
const proTable = ref<ProTableInstance>()
|
|
|
|
// 表格配置项
|
|
const columns = reactive<ColumnProps<Function.ResFunction>[]>([
|
|
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
|
{
|
|
prop: 'name',
|
|
label: '名称',
|
|
minWidth: 150,
|
|
search: { el: 'input' },
|
|
},
|
|
{
|
|
prop: 'code',
|
|
label: '编码',
|
|
minWidth: 100,
|
|
},
|
|
{
|
|
prop: 'type',
|
|
label: '类型',
|
|
width: 100,
|
|
render: (scope) => {
|
|
const typeMap: { [key: number]: { label: string; type: string } } = {
|
|
0: { label: '菜单', type: 'primary' },
|
|
1: { label: '按钮', type: 'success' },
|
|
2: { label: '公共资源', type: 'info' },
|
|
3: { label: '服务间调用资源', type: 'warning' },
|
|
};
|
|
const typeInfo = typeMap[scope.row.type] || { label: '未知', type: 'danger' };
|
|
return (
|
|
<el-tag type={typeInfo.type}>{typeInfo.label}</el-tag>
|
|
);
|
|
},
|
|
},
|
|
{
|
|
prop: 'icon',
|
|
label: '图标',
|
|
minWidth: 100,
|
|
|
|
},
|
|
{
|
|
prop: 'path',
|
|
label: '路由地址',
|
|
minWidth: 200,
|
|
},
|
|
{
|
|
prop: 'component',
|
|
label: '组件地址',
|
|
minWidth: 200,
|
|
},
|
|
{
|
|
prop: 'sort',
|
|
label: '排序',
|
|
width: 70,
|
|
},
|
|
|
|
{
|
|
prop: 'state',
|
|
label: '状态',
|
|
minWidth: 70,
|
|
render: scope => {
|
|
return (
|
|
<el-tag type={scope.row.state ? 'success' : 'danger'} > {scope.row.state ? '正常' : '禁用'} </el-tag>
|
|
)
|
|
},
|
|
},
|
|
{ prop: 'operation', label: '操作', fixed: 'right',width: 200 },
|
|
])
|
|
|
|
|
|
|
|
// 打开 drawer(新增、编辑)
|
|
const openDialog = (titleType: string, row: Partial<Function.ResFunction> = {}) => {
|
|
resourcePopup.value?.open(titleType, row)
|
|
}
|
|
|
|
// 删除用户信息
|
|
const handleDelete = async (params: Function.ResFunction) => {
|
|
await useHandleData(deleteFunction, params , `删除【${params.name}】用户`)
|
|
proTable.value?.getTableList()
|
|
}
|
|
|
|
|
|
|
|
// 批量删除用户信息
|
|
const batchDelete = async (id: string[]) => {
|
|
await useHandleData(deleteFunction, { id }, '删除所选用户信息')
|
|
proTable.value?.clearSelection()
|
|
proTable.value?.getTableList()
|
|
}
|
|
|
|
|
|
</script> |