Files
admin-govern/src/views/setting/dictionary/list/index.vue

125 lines
4.4 KiB
Vue
Raw Normal View History

2024-01-24 15:42:54 +08:00
<template>
2024-01-25 16:42:56 +08:00
<div class="default-main" style="position: relative">
2024-01-24 15:42:54 +08:00
<TableHeader>
<template #select>
2024-01-25 16:42:56 +08:00
<el-form-item label="过滤筛选">
2024-12-13 14:36:23 +08:00
<el-input maxlength="32" show-word-limit style="width: 240px"
2024-12-25 10:53:07 +08:00
v-model.trim="tableStore.table.params.searchValue" clearable placeholder="请输入名称或编码筛选" />
2024-01-24 15:42:54 +08:00
</el-form-item>
</template>
<template #operation>
2024-01-25 16:42:56 +08:00
<el-button :icon="Plus" type="primary" @click="add">新增字典类型</el-button>
2024-01-24 15:42:54 +08:00
</template>
</TableHeader>
2024-01-25 16:42:56 +08:00
<Table ref="tableRef" />
<PopupEdit ref="popupEditRef"></PopupEdit>
<Detail ref="detailRef" :detail="detail" @close="detail = null" v-if="detail"></Detail>
2024-01-24 15:42:54 +08:00
</div>
</template>
2024-01-25 16:42:56 +08:00
<script setup lang="ts">
2024-01-24 15:42:54 +08:00
import { Plus } from '@element-plus/icons-vue'
import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { ElMessage } from 'element-plus'
import PopupEdit from './popupEdit.vue'
import { dictTypeDelete } from '@/api/system-boot/dictType'
2024-01-25 11:04:07 +08:00
import Detail from './detail.vue'
2024-01-24 15:42:54 +08:00
defineOptions({
2024-01-25 11:04:07 +08:00
name: 'system-boot/dictType/list'
2024-01-24 15:42:54 +08:00
})
const popupEditRef = ref()
2024-01-25 11:04:07 +08:00
const detail = ref<anyObj | null>(null)
2024-01-24 15:42:54 +08:00
const tableStore = new TableStore({
url: '/system-boot/dictType/list',
method: 'POST',
column: [
2024-12-13 14:36:23 +08:00
{
title: '序号', width: 80, formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
2024-01-24 15:42:54 +08:00
{ title: '名称', field: 'name' },
{ title: '编码', field: 'code' },
{ title: '开启等级', field: 'openLevelName' },
{ title: '开启算法', field: 'openDescribeName' },
{ title: '字典描述', field: 'remark' },
{ title: '创建时间', field: 'createTime' },
{ title: '更新时间', field: 'updateTime' },
2024-01-26 09:08:20 +08:00
{
title: '状态',
field: 'stateName',
width: '80',
render: 'tag',
custom: {
'正常': 'success',
'删除': 'danger'
},
},
2024-01-24 15:42:54 +08:00
{
title: '操作',
width: '180',
render: 'buttons',
fixed: 'right',
buttons: [
{
title: '查看',
type: 'primary',
icon: 'el-icon-ZoomIn',
2024-01-30 14:11:29 +08:00
render: 'basicButton',
2024-01-24 15:42:54 +08:00
click: row => {
2024-01-25 11:04:07 +08:00
detail.value = row
2024-01-24 15:42:54 +08:00
}
},
{
title: '编辑',
type: 'primary',
icon: 'el-icon-EditPen',
2024-01-30 14:11:29 +08:00
render: 'basicButton',
2024-01-24 15:42:54 +08:00
click: row => {
popupEditRef.value.open('编辑字典类型', row)
}
},
{
title: '删除',
type: 'danger',
icon: 'el-icon-Delete',
render: 'confirmButton',
popconfirm: {
confirmButtonText: '确认',
cancelButtonText: '取消',
confirmButtonType: 'danger',
title: '确定删除该字典类型吗?'
},
click: row => {
dictTypeDelete([row.id]).then(() => {
ElMessage.success('删除成功')
tableStore.index()
})
}
}
]
}
],
loadCallback: () => {
tableStore.table.data.forEach((item: any) => {
item.stateName = item.state === 1 ? '正常' : '删除'
item.openLevelName = item.openLevel === 1 ? '开启' : '不开启'
item.openDescribeName = item.openDescribe === 1 ? '开启' : '不开启'
})
}
})
provide('tableStore', tableStore)
tableStore.table.params.searchValue = ''
tableStore.table.params.searchState = 0
onMounted(() => {
tableStore.index()
})
const add = () => {
popupEditRef.value.open('新增字典类型')
}
2024-01-25 11:04:07 +08:00
</script>