refactor: ♻️ 通知公告、字典重构问题修复和优化

This commit is contained in:
ray
2024-10-08 01:02:48 +08:00
parent 42f7782d56
commit ff53ed6060
18 changed files with 341 additions and 269 deletions

View File

@@ -174,8 +174,8 @@ import DictDataAPI, {
const route = useRoute();
const dictCode = route.query.dictCode as string;
const dictName = route.query.dictName as string;
const dictCode = ref(route.query.dictCode as string);
const dictName = ref(route.query.dictName as string);
const queryFormRef = ref(ElForm);
const dataFormRef = ref(ElForm);
@@ -201,15 +201,15 @@ const formData = reactive<DictDataForm>({});
// 监听路由参数变化,更新字典数据
watch(
() => route.query.dictCode,
(newDictCode) => {
if (newDictCode !== queryParams.dictCode) {
queryParams.dictCode = newDictCode as string;
handleQuery();
}
() => [route.query.dictCode, route.query.dictName],
([newDictCode, newDictName]) => {
queryParams.dictCode = newDictCode as string;
dictCode.value = newDictCode as string;
dictName.value = newDictName as string;
handleQuery();
}
);
const computedRules = computed(() => {
const rules: Partial<Record<string, any>> = {
value: [{ required: true, message: "请输入字典值", trigger: "blur" }],
@@ -291,6 +291,8 @@ function handleCloseDialog() {
dataFormRef.value.clearValidate();
formData.id = undefined;
formData.sort = 1;
formData.status = 1;
}
/**
* 删除字典

View File

@@ -43,13 +43,8 @@
<el-descriptions-item label="发布时间:">
{{ notice.publishTime }}
</el-descriptions-item>
<el-descriptions-item label="内容:">
<el-input
v-model="notice.content"
type="textarea"
style="max-height: 400px"
:readonly="true"
/>
<el-descriptions-item label="公告内容:">
<div v-html="notice.content"></div>
</el-descriptions-item>
</el-descriptions>
</el-dialog>

View File

@@ -70,27 +70,21 @@
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column type="index" label="序号" width="60" />
<el-table-column
align="center"
key="title"
label="通知标题"
prop="title"
min-width="150"
/>
<el-table-column align="center" label="通知类型" min-width="150">
<el-table-column label="通知标题" prop="title" min-width="200" />
<el-table-column align="center" label="通知类型" width="150">
<template #default="scope">
<DictLabel :dictCode="'notice_type'" :value="scope.row.type" />
<DictLabel :code="'notice_type'" v-model="scope.row.type" />
</template>
</el-table-column>
<el-table-column
align="center"
label="发布人"
prop="publisherName"
min-width="100"
width="150"
/>
<el-table-column align="center" label="通知等级" min-width="100">
<el-table-column align="center" label="通知等级" width="100">
<template #default="scope">
<DictLabel :dictCode="'notice_level'" :value="scope.row.level" />
<DictLabel code="notice_level" v-model="scope.row.level" />
</template>
</el-table-column>
<el-table-column
@@ -121,7 +115,7 @@
</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="操作时间" min-width="220">
<el-table-column label="操作时间" width="250">
<template #default="scope">
<div class="flex-x-start">
<span>创建时间</span>
@@ -141,7 +135,7 @@
</div>
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="220">
<el-table-column align="center" fixed="right" label="操作" width="150">
<template #default="scope">
<el-button
type="primary"
@@ -230,16 +224,16 @@
<el-form-item label="通知类型" prop="type">
<dictionary
type="button"
v-model="formData.type"
code="notice_type"
v-model="formData.type"
/>
</el-form-item>
<el-form-item label="优先级" prop="level">
<el-radio-group v-model="formData.level">
<el-radio value="L"></el-radio>
<el-radio value="M"></el-radio>
<el-radio value="H"></el-radio>
</el-radio-group>
<el-form-item label="通知等级" prop="level">
<dictionary
type="button"
code="notice_level"
v-model="formData.level"
/>
</el-form-item>
<el-form-item label="目标类型" prop="targetType">
<el-radio-group v-model="formData.targetType">

View File

@@ -31,27 +31,21 @@
highlight-current-row
>
<el-table-column type="index" label="序号" width="60" />
<el-table-column
align="center"
key="title"
label="通知标题"
prop="title"
min-width="150"
/>
<el-table-column align="center" label="通知类型" min-width="150">
<el-table-column label="通知标题" prop="title" min-width="200" />
<el-table-column align="center" label="通知类型" width="150">
<template #default="scope">
<DictLabel :dictCode="'notice_type'" :value="scope.row.type" />
<DictLabel code="notice_type" v-model="scope.row.type" />
</template>
</el-table-column>
<el-table-column
align="center"
label="发布人"
prop="publisherName"
min-width="100"
width="100"
/>
<el-table-column align="center" label="通知等级" min-width="100">
<el-table-column align="center" label="通知等级" width="100">
<template #default="scope">
<DictLabel :dictCode="'notice_level'" :value="scope.row.type" />
<DictLabel code="notice_level" v-model="scope.row.level" />
</template>
</el-table-column>
<el-table-column
@@ -59,19 +53,19 @@
key="releaseTime"
label="发布时间"
prop="publishTime"
min-width="100"
width="150"
/>
<el-table-column
align="center"
label="发布人"
prop="publisherName"
min-width="100"
width="150"
/>
<el-table-column align="center" label="状态" min-width="100">
<el-table-column align="center" label="状态" width="100">
<template #default="scope">
<el-tag v-if="scope.row.isRead == 1" type="success">已读</el-tag>
<el-tag v-if="scope.row.isRead == 0" type="warning">未读</el-tag>
<el-tag v-else type="info">未读</el-tag>
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="80">

View File

@@ -168,7 +168,7 @@
<el-input
v-model="permKeywords"
clearable
class="w-[200px]"
class="w-[150px]"
placeholder="菜单权限名称"
>
<template #prefix>
@@ -176,7 +176,7 @@
</template>
</el-input>
<div class="flex-center">
<div class="flex-center ml-5">
<el-button type="primary" size="small" plain @click="togglePermTree">
<i-ep-switch />
{{ isExpanded ? "收缩" : "展开" }}