Files
pqs-9100_client/frontend/src/views/system/dictionary/dictTree/index.vue

102 lines
3.0 KiB
Vue
Raw Normal View History

2024-11-11 11:09:20 +08:00
<template>
<div class='table-box' ref='popupBaseView'>
<ProTable
ref='proTable'
:columns='columns'
:request-api='getDictTreeList'
2024-11-11 15:40:49 +08:00
:pagination="false"
2024-11-11 11:09:20 +08:00
>
<template #tableHeader>
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
</template>
<template #operation='scope'>
2024-11-11 15:40:49 +08:00
<el-button type='primary' link :icon='CirclePlus' @click="openDialog('add',scope.row)">新增</el-button>
2024-11-11 11:09:20 +08:00
<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>
<TreePopup :refresh-table='proTable?.getTableList' ref='treePopup'/>
</template>
<script setup lang='tsx' name='dict'>
2024-11-14 11:47:42 +08:00
import {CirclePlus, Delete, EditPen} from '@element-plus/icons-vue'
2024-11-11 11:09:20 +08:00
import {type Dict} from '@/api/system/dictionary/interface'
import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
import TreePopup from '@/views/system/dictionary/dictTree/components/treePopup.vue'
import {useDictStore} from '@/stores/modules/dict'
import {useHandleData} from '@/hooks/useHandleData'
import {
getDictTreeList,
deleteDictTree,
} from '@/api/system/dictionary/dictTree'
import { reactive, ref } from 'vue'
const dictStore = useDictStore()
const proTable = ref<ProTableInstance>()
const treePopup = ref()
const columns = reactive<ColumnProps<Dict.ResDictTree>[]>([
2024-11-14 18:26:34 +08:00
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
2024-11-11 11:09:20 +08:00
{
prop: 'name',
label: '字典名称',
},
{
prop: 'code',
label: '编码',
},
{
prop: 'remark',
label: '描述',
2024-11-14 18:26:34 +08:00
},
{
prop: 'sort',
label: '排序',
width:70,
render: scope => {
return String(scope.row.sort) // 将数字转换为字符串
},
2024-11-11 11:09:20 +08:00
},
{
2024-11-11 15:40:49 +08:00
prop: 'state',
2024-11-11 11:09:20 +08:00
label: '状态',
2024-11-11 15:40:49 +08:00
minWidth:30,
2024-11-14 18:26:34 +08:00
isShow:false,
2024-11-11 15:40:49 +08:00
enum: dictStore.getDictData('state'),
fieldNames: { label: 'label', value: 'code' },
render: scope => {
return (
<el-tag type={scope.row.state === 0 ? 'success' : (scope.row.state === 1 ? 'warning' : 'danger')}>
{scope.row.state === 0 ? '正常' : (scope.row.state === 1 ? '停用' : '删除')}
</el-tag>
2024-11-14 18:26:34 +08:00
2024-11-11 15:40:49 +08:00
)
},
2024-11-11 11:09:20 +08:00
},
{
prop: 'operation',
label: '操作',
fixed: 'right',
2024-11-14 18:26:34 +08:00
width:250,
2024-11-14 18:36:00 +08:00
2024-11-11 11:09:20 +08:00
},
])
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<Dict.ResDictTree> = {}) => {
treePopup.value?.open(titleType, row)
}
// 删除字典类型
const handleDelete = async (params: Dict.ResDictTree) => {
2024-11-11 15:40:49 +08:00
await useHandleData(deleteDictTree, params, `删除【${params.name}】树形字典类型`)
2024-11-11 11:09:20 +08:00
proTable.value?.getTableList()
}
</script>