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

162 lines
5.3 KiB
Vue
Raw Normal View History

2024-01-24 15:42:54 +08:00
<template>
2024-01-31 14:14:51 +08:00
<div class="dictiontary-list-detail">
2024-01-24 15:42:54 +08:00
<TableHeader>
<template #select>
2024-01-31 14:14:51 +08:00
<el-page-header @back="$emit('close')" style="display: flex; align-items: center; height: 32px">
2024-01-25 11:04:07 +08:00
<template #content>
2024-01-31 14:14:51 +08:00
<span class="text-large font-600 mr-3">{{ props.detail.name }}详情信息</span>
2024-01-25 11:04:07 +08:00
</template>
</el-page-header>
2024-01-31 14:14:51 +08:00
<el-form-item label="过滤筛选">
2024-01-24 15:42:54 +08:00
<el-input
2024-01-31 14:14:51 +08:00
style="width: 240px"
v-model="tableStore.table.params.searchValue"
2024-01-24 15:42:54 +08:00
clearable
2024-01-31 14:14:51 +08:00
placeholder="请输入名称或编码筛选"
2024-01-24 15:42:54 +08:00
/>
</el-form-item>
</template>
<template #operation>
2024-01-31 14:14:51 +08:00
<el-button :icon="Plus" type="primary" @click="add">新增</el-button>
2024-01-24 15:42:54 +08:00
</template>
</TableHeader>
2024-01-31 14:14:51 +08:00
<Table ref="tableRef" />
<PopupDetailEdit ref="popupEditRef"></PopupDetailEdit>
2024-01-24 15:42:54 +08:00
</div>
</template>
2024-01-31 14:14:51 +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'
2024-01-25 11:04:07 +08:00
import PopupDetailEdit from './popupDetailEdit.vue'
import { dictDataDelete } from '@/api/system-boot/dicData'
2024-01-24 15:42:54 +08:00
defineOptions({
name: 'setting/dictionary/list/detail'
})
2024-01-25 11:04:07 +08:00
interface Props {
detail: anyObj
}
const props = withDefaults(defineProps<Props>(), {
detail: () => {
return {}
}
})
2024-01-24 15:42:54 +08:00
const popupEditRef = ref()
const tableStore = new TableStore({
2024-01-25 11:04:07 +08:00
url: '/system-boot/dictData/getTypeIdData',
2024-01-24 15:42:54 +08:00
method: 'POST',
column: [
{ title: '名称', field: 'name' },
{ title: '编码', field: 'code' },
2024-01-25 11:04:07 +08:00
{ title: '排序', field: 'sort' },
{ title: '计算值', field: 'value' },
{ title: '事件等级', field: 'levelName' },
{ title: '算法描述', field: 'algoDescribe' },
2024-01-24 15:42:54 +08:00
{ title: '状态', field: 'stateName' },
{
title: '操作',
width: '180',
render: 'buttons',
fixed: 'right',
buttons: [
{
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 => {
2024-01-25 11:04:07 +08:00
popupEditRef.value.open('编辑', {
...row,
openDescribe: props.detail.openDescribe,
openLevel: props.detail.openLevel,
typeName: props.detail.name + row.name,
typeId: props.detail.id
})
2024-01-24 15:42:54 +08:00
}
},
{
title: '删除',
type: 'danger',
icon: 'el-icon-Delete',
render: 'confirmButton',
popconfirm: {
confirmButtonText: '确认',
cancelButtonText: '取消',
confirmButtonType: 'danger',
title: '确定删除该字典类型吗?'
},
click: row => {
2024-01-25 11:04:07 +08:00
dictDataDelete([row.id]).then(() => {
2024-01-24 15:42:54 +08:00
ElMessage.success('删除成功')
tableStore.index()
})
}
}
]
}
],
loadCallback: () => {
tableStore.table.data.forEach((item: any) => {
item.stateName = item.state === 1 ? '正常' : '删除'
2024-01-25 11:04:07 +08:00
switch (item.level) {
case 0:
item.levelName = '普通'
break
case 1:
item.levelName = '中等'
break
case 2:
item.levelName = '严重'
break
default:
item.levelName = '未知'
break
}
for (let key in item) {
if (typeof item[key] !== 'number') {
item[key] = item[key] || '/'
}
}
2024-01-24 15:42:54 +08:00
})
}
})
provide('tableStore', tableStore)
tableStore.table.params.searchValue = ''
tableStore.table.params.searchState = 0
2024-01-25 11:04:07 +08:00
tableStore.table.params.typeId = props.detail.id
if (props.detail.openLevel !== 1) {
2024-01-31 14:14:51 +08:00
tableStore.table.column = tableStore.table.column.filter((item: any) => item.field !== 'levelName')
2024-01-25 11:04:07 +08:00
}
if (props.detail.openDescribe !== 1) {
tableStore.table.column = tableStore.table.column.filter((item: any) => item.field !== 'algoDescribe')
}
2024-01-24 15:42:54 +08:00
onMounted(() => {
tableStore.index()
})
const add = () => {
2024-01-25 11:04:07 +08:00
popupEditRef.value.open('新增', {
openLevel: props.detail.openLevel,
openDescribe: props.detail.openDescribe,
typeName: props.detail.name,
typeId: props.detail.id
})
2024-01-24 15:42:54 +08:00
}
2024-01-25 11:04:07 +08:00
</script>
2024-01-31 14:14:51 +08:00
<style lang="scss">
2024-01-25 11:04:07 +08:00
.dictiontary-list-detail {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: #fff;
}
2024-01-31 14:14:51 +08:00
</style>