字典管理ok
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
<template>
|
||||
<div class='default-main'>
|
||||
<div class='dictiontary-list-detail'>
|
||||
<TableHeader>
|
||||
<template #select>
|
||||
<el-page-header @back="$emit('close')" style='display: flex;align-items: center'>
|
||||
<template #content>
|
||||
<span class='text-large font-600 mr-3'> {{ props.detail.name }}详情信息 </span>
|
||||
</template>
|
||||
</el-page-header>
|
||||
<el-form-item label='过滤筛选'>
|
||||
<el-input
|
||||
style='width: 240px'
|
||||
@@ -12,11 +17,11 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template #operation>
|
||||
<el-button :icon='Plus' type='primary' @click='add'>新增字典类型</el-button>
|
||||
<el-button :icon='Plus' type='primary' @click='add'>新增</el-button>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref='tableRef' />
|
||||
<PopupEdit ref='popupEditRef'></PopupEdit>
|
||||
<PopupDetailEdit ref='popupEditRef'></PopupDetailEdit>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang='ts'>
|
||||
@@ -26,49 +31,54 @@ 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 PopupDetailEdit from './popupDetailEdit.vue'
|
||||
import { dictTypeDelete } from '@/api/system-boot/dictType'
|
||||
import router from '@/router'
|
||||
|
||||
import { dictDataDelete } from '@/api/system-boot/dicData'
|
||||
|
||||
defineOptions({
|
||||
name: 'setting/dictionary/list/detail'
|
||||
})
|
||||
|
||||
interface Props {
|
||||
detail: anyObj
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
detail: () => {
|
||||
return {}
|
||||
}
|
||||
})
|
||||
const popupEditRef = ref()
|
||||
const tableStore = new TableStore({
|
||||
url: '/system-boot/dictType/list',
|
||||
url: '/system-boot/dictData/getTypeIdData',
|
||||
method: 'POST',
|
||||
column: [
|
||||
{ title: '序号', type: 'seq', width: '60' },
|
||||
{ title: '名称', field: 'name' },
|
||||
{ title: '编码', field: 'code' },
|
||||
{ title: '开启等级', field: 'openLevelName' },
|
||||
{ title: '开启算法', field: 'openDescribeName' },
|
||||
{ title: '排序', field: 'sort' },
|
||||
{ title: '计算值', field: 'value' },
|
||||
{ title: '事件等级', field: 'levelName' },
|
||||
{ title: '算法描述', field: 'algoDescribe' },
|
||||
{ title: '状态', field: 'stateName' },
|
||||
{ title: '字典描述', field: 'remark' },
|
||||
{ title: '创建时间', field: 'createTime' },
|
||||
{ title: '更新时间', field: 'updateTime' },
|
||||
{
|
||||
title: '操作',
|
||||
width: '180',
|
||||
render: 'buttons',
|
||||
fixed: 'right',
|
||||
buttons: [
|
||||
{
|
||||
title: '查看',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-ZoomIn',
|
||||
render: 'tipButton',
|
||||
click: row => {
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '编辑',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'tipButton',
|
||||
click: row => {
|
||||
popupEditRef.value.open('编辑字典类型', row)
|
||||
popupEditRef.value.open('编辑', {
|
||||
...row,
|
||||
openDescribe: props.detail.openDescribe,
|
||||
openLevel: props.detail.openLevel,
|
||||
typeName: props.detail.name + row.name,
|
||||
typeId: props.detail.id
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -83,7 +93,7 @@ const tableStore = new TableStore({
|
||||
title: '确定删除该字典类型吗?'
|
||||
},
|
||||
click: row => {
|
||||
dictTypeDelete([row.id]).then(() => {
|
||||
dictDataDelete([row.id]).then(() => {
|
||||
ElMessage.success('删除成功')
|
||||
tableStore.index()
|
||||
})
|
||||
@@ -95,8 +105,25 @@ const tableStore = new TableStore({
|
||||
loadCallback: () => {
|
||||
tableStore.table.data.forEach((item: any) => {
|
||||
item.stateName = item.state === 1 ? '正常' : '删除'
|
||||
item.openLevelName = item.openLevel === 1 ? '开启' : '不开启'
|
||||
item.openDescribeName = item.openDescribe === 1 ? '开启' : '不开启'
|
||||
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] || '/'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -104,11 +131,34 @@ const tableStore = new TableStore({
|
||||
provide('tableStore', tableStore)
|
||||
tableStore.table.params.searchValue = ''
|
||||
tableStore.table.params.searchState = 0
|
||||
tableStore.table.params.typeId = props.detail.id
|
||||
if (props.detail.openLevel !== 1) {
|
||||
tableStore.table.column = tableStore.table.column.filter((item: any) => item.field !== 'levelName' )
|
||||
}
|
||||
if (props.detail.openDescribe !== 1) {
|
||||
tableStore.table.column = tableStore.table.column.filter((item: any) => item.field !== 'algoDescribe')
|
||||
}
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
const add = () => {
|
||||
popupEditRef.value.open('新增字典类型')
|
||||
|
||||
popupEditRef.value.open('新增', {
|
||||
openLevel: props.detail.openLevel,
|
||||
openDescribe: props.detail.openDescribe,
|
||||
typeName: props.detail.name,
|
||||
typeId: props.detail.id
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<style lang='scss'>
|
||||
.dictiontary-list-detail {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class='default-main'>
|
||||
<div class='default-main' style='position: relative;'>
|
||||
<TableHeader>
|
||||
<template #select>
|
||||
<el-form-item label='过滤筛选'>
|
||||
@@ -17,6 +17,7 @@
|
||||
</TableHeader>
|
||||
<Table ref='tableRef' />
|
||||
<PopupEdit ref='popupEditRef'></PopupEdit>
|
||||
<Detail ref='detailRef' :detail='detail' @close='detail = null' v-if='detail'></Detail>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang='ts'>
|
||||
@@ -28,14 +29,13 @@ 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'
|
||||
import router from '@/router/index'
|
||||
|
||||
|
||||
import Detail from './detail.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'setting/dictionary/list'
|
||||
name: 'system-boot/dictType/list'
|
||||
})
|
||||
const popupEditRef = ref()
|
||||
const detail = ref<anyObj | null>(null)
|
||||
const tableStore = new TableStore({
|
||||
url: '/system-boot/dictType/list',
|
||||
method: 'POST',
|
||||
@@ -61,12 +61,7 @@ const tableStore = new TableStore({
|
||||
icon: 'el-icon-ZoomIn',
|
||||
render: 'tipButton',
|
||||
click: row => {
|
||||
// router.push({
|
||||
// path: '/admin/setting/dictionary/list/detail',
|
||||
// params: {
|
||||
// id: row.id
|
||||
// }
|
||||
// })
|
||||
detail.value = row
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -78,7 +73,6 @@ const tableStore = new TableStore({
|
||||
popupEditRef.value.open('编辑字典类型', row)
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: '删除',
|
||||
type: 'danger',
|
||||
@@ -118,4 +112,4 @@ onMounted(() => {
|
||||
const add = () => {
|
||||
popupEditRef.value.open('新增字典类型')
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
135
src/views/setting/dictionary/list/popupDetailEdit.vue
Normal file
135
src/views/setting/dictionary/list/popupDetailEdit.vue
Normal file
@@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<el-dialog class='cn-operate-dialog' v-model='dialogVisible' :title='title'>
|
||||
<el-scrollbar>
|
||||
<el-form :inline='false' :model='form' label-width='120px' :rules='rules' ref='formRef'>
|
||||
<el-form-item label='名称:' class='top' prop='name'>
|
||||
<el-input v-model='form.name'></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label='计算值:' class='top'>
|
||||
<el-input v-model='form.value'></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item class='top' label='对应算法:' prop='algoDescribe' v-if='form.openDescribe == 1'>
|
||||
<el-input v-model='form.algoDescribe' placeholder='请输入数字'></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item class='top'
|
||||
label='编码:'
|
||||
prop='code'
|
||||
>
|
||||
<el-input v-model='form.code'></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label='排序:' prop='sort' class='top'>
|
||||
<el-input-number v-model='form.sort' :min='0' />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if='form.openLevel === 1'
|
||||
label='事件等级:'
|
||||
>
|
||||
<el-select v-model='form.level' placeholder='选择开启等级'>
|
||||
<el-option
|
||||
v-for='item in EventOpenLevel'
|
||||
:key='item.value'
|
||||
:label='item.label'
|
||||
:value='item.value'
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
|
||||
<template #footer>
|
||||
<span class='dialog-footer'>
|
||||
<el-button @click='dialogVisible = false'>取消</el-button>
|
||||
<el-button type='primary' @click='submit'>确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang='ts' setup>
|
||||
import { ref, inject } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { add, update } from '@/api/user-boot/role'
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
import { dictDataAdd, dictDataUpdate } from '@/api/system-boot/dicData'
|
||||
|
||||
defineOptions({
|
||||
name: 'diction/list/detail/popupDetailEdit'
|
||||
})
|
||||
const adminInfo = useAdminInfo()
|
||||
const tableStore = inject('tableStore') as TableStore
|
||||
const formRef = ref()
|
||||
// do not use same name with ref
|
||||
const form = reactive({
|
||||
algoDescribe: '',
|
||||
code: '',
|
||||
level: 0,
|
||||
name: '',
|
||||
value: '',
|
||||
sort: 0,
|
||||
typeId: '',
|
||||
openLevel: 0,
|
||||
openDescribe: 0,
|
||||
typeName: '',
|
||||
id: ''
|
||||
})
|
||||
const EventOpenLevel = [
|
||||
{ value: 0, label: '普通' },
|
||||
{ value: 1, label: '中等' },
|
||||
{ value: 2, label: '严重' }
|
||||
]
|
||||
const rules = {
|
||||
algoDescribe: [
|
||||
{ required: false, message: '对应算法不能为空', trigger: 'blur' },
|
||||
{
|
||||
pattern: /^\d+$|^\d+[.]?\d+$/,
|
||||
message: '请您数字对应算法',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
name: [
|
||||
{ required: true, message: '名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
code: [
|
||||
{ required: true, message: '编码不能为空', trigger: 'blur' }
|
||||
],
|
||||
sort: [
|
||||
{ required: true, message: '排序不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('新增')
|
||||
const open = (text: string, data: anyObj) => {
|
||||
dialogVisible.value = true
|
||||
if (text === '编辑') {
|
||||
for (let key in form) {
|
||||
form[key] = data[key] === '/' ? '' : data[key]
|
||||
}
|
||||
} else if (text === '新增') {
|
||||
for (let key in form) {
|
||||
form[key] = ''
|
||||
}
|
||||
form.level = 0
|
||||
form.sort = 0
|
||||
form.typeId = data.typeId
|
||||
form.openLevel = data.openLevel
|
||||
form.typeName = data.typeName
|
||||
form.openDescribe = data.openDescribe
|
||||
}
|
||||
title.value = form.typeName + text
|
||||
}
|
||||
const submit = async () => {
|
||||
await formRef.value.validate()
|
||||
if (form.id) {
|
||||
await dictDataUpdate(form)
|
||||
} else {
|
||||
await dictDataAdd(form)
|
||||
}
|
||||
ElMessage.success('保存成功')
|
||||
tableStore.index()
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
Reference in New Issue
Block a user