This commit is contained in:
sjl
2024-11-11 15:40:49 +08:00
parent f05369556c
commit 0797ea046f
13 changed files with 97 additions and 70 deletions

View File

@@ -62,7 +62,7 @@ const columns = reactive<ColumnProps<Dict.ResDictData>[]>([
{
prop: 'name',
label: '名称',
width: 180,
minWidth: 180,
search: {
el: 'input'
}
@@ -70,7 +70,7 @@ const columns = reactive<ColumnProps<Dict.ResDictData>[]>([
{
prop: 'code',
label: '编码',
width: 180,
minWidth: 180,
search: {
el: 'input'
}
@@ -78,12 +78,12 @@ const columns = reactive<ColumnProps<Dict.ResDictData>[]>([
{
prop: 'value',
label: '值',
width: 180
minWidth: 180
},
{
prop: 'level',
label: '事件等级',
width: 180,
minWidth: 180,
render: scope => {
return (
<>
@@ -99,13 +99,13 @@ const columns = reactive<ColumnProps<Dict.ResDictData>[]>([
{
prop: 'createTime',
label: '创建时间',
width: 180
minWidth: 180
},
{
prop: 'operation',
label: '操作',
fixed: 'right',
minWidth: 300
width: 200
},
])

View File

@@ -52,7 +52,7 @@
<el-form-item label='数据统计类型' :label-width='140' prop='statMethod'>
<el-select v-model="selectedStatMethods" multiple placeholder="请选择数据统计类型">
<el-option
v-for="item in dictStore.getDictData('Event_Type')"
v-for="item in dictStore.getDictData('stat_Method')"
:key="item.value"
:label="item.name"
:value="item.code"

View File

@@ -125,7 +125,7 @@
prop: 'statMethod',
label: '数据统计类型',
width: 250,
enum: dictStore.getDictData('Event_Type'),
enum: dictStore.getDictData('stat_Method'),
fieldNames: { label: 'name', value: 'code' },
render: (scope) => {
// 假设 statMethod 是一个数组,包含多个 'code' 值

View File

@@ -33,8 +33,8 @@
import { addDictTree, updateDictTree } from '@/api/system/dictionary/dictTree'
import { computed, type Ref, ref } from 'vue';
import { useDictStore } from '@/stores/modules/dict'
import { type ResultData } from '@/api/interface';
const dictStore = useDictStore()
const selectedStatMethods = ref<string[]>([])
// 定义弹出组件元信息
const dialogFormRef = ref()
function useMetaInfo() {
@@ -48,7 +48,7 @@
code: ' ',
sort: 100,
remark: '',
status: 1,
state: 0,
children: [],
})
return { dialogVisible, titleType, formContent }
@@ -59,13 +59,13 @@
const resetFormContent = () => {
formContent.value = {
id: '',
pid: '',
pids: '',
pid: '0',
pids: '0',
name: '',
code: ' ',
sort: 100,
remark: '',
status: 1,
state: 0,
children: [],
}
}
@@ -76,8 +76,8 @@
// 定义表单校验规则
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
dataType: [{ required: true, message: '数据模型必选', trigger: 'change' }],
name: [{ required: true, message: '指标名称必填!', trigger: 'blur' }],
name: [{ required: true, message: '字典名称必填', trigger: 'blur' }],
code: [{ required: true, message: '编码必填!', trigger: 'blur' }],
})
// 关闭弹窗
@@ -87,7 +87,6 @@
resetFormContent()
// 重置表单
dialogFormRef.value?.resetFields()
selectedStatMethods.value = []
}
// 保存数据
@@ -96,13 +95,18 @@
dialogFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (formContent.value.id) {
const result = await updateDictTree(formContent.value);
let result: ResultData<unknown>;
if( titleType.value == 'add'){
result = await addDictTree(formContent.value);
}else{
result = await updateDictTree(formContent.value);
}
if(result.code != 'A0000'){
ElMessage.error({ message: result.message})
}else{
ElMessage.success({ message: `${dialogTitle.value}成功!` })
}
} else {
const result = await addDictTree(formContent.value);
if(result.code != 'A0000'){
@@ -126,7 +130,12 @@
titleType.value = sign
dialogVisible.value = true
if (data.id) {
formContent.value = { ...data }
if(sign == 'add'){
resetFormContent()
formContent.value.pid = data.id
}else{
formContent.value = { ...data }
}
} else {
resetFormContent()
}

View File

@@ -4,13 +4,14 @@
ref='proTable'
:columns='columns'
:request-api='getDictTreeList'
:pagination="false"
>
<template #tableHeader>
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
</template>
<template #operation='scope'>
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
<el-button type='primary' link :icon='CirclePlus' @click="openDialog('add',scope.row)">新增</el-button>
<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>
@@ -41,42 +42,49 @@
{
prop: 'name',
label: '字典名称',
width: 180,
},
{
prop: 'code',
label: '编码',
width: 180,
},
{
prop: 'remark',
label: '描述',
width: 180,
},
{
prop: 'status',
prop: 'state',
label: '状态',
width: 180,
minWidth:30,
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>
)
},
},
{
prop: 'operation',
label: '操作',
fixed: 'right',
minWidth: 200,
},
])
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<Dict.ResDictTree> = {}) => {
treePopup.value?.open(titleType, row)
}
// 删除字典类型
const handleDelete = async (params: Dict.ResDictTree) => {
await useHandleData(deleteDictTree, [params.id], `删除【${params.name}】树形字典类型`)
console.log(params)
await useHandleData(deleteDictTree, params, `删除【${params.name}】树形字典类型`)
proTable.value?.getTableList()
}

View File

@@ -49,7 +49,7 @@ const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
{
prop: 'name',
label: '类型名称',
width: 180,
minWidth: 180,
search: {
el: 'input',
},
@@ -57,7 +57,7 @@ const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
{
prop: 'code',
label: '类型编码',
width: 180,
minWidth: 200,
search: {
el: 'input',
},
@@ -67,16 +67,21 @@ const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
label: '描述',
minWidth: 300,
},
{
prop: 'sort',
label: '排序',
minWidth: 70,
},
{
prop: 'createTime',
label: '创建时间',
width: 180,
minWidth: 180,
},
{
prop: 'operation',
label: '操作',
fixed: 'right',
width: 330,
minWidth: 300,
},
])