refactor:foo

This commit is contained in:
PZ688 2025-02-28 18:35:37 +08:00
parent 1c00248143
commit 2162eed7a9
2 changed files with 49 additions and 46 deletions

View File

@ -10,20 +10,20 @@
<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto"> <el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="标题" prop="title" :rules="[{ required: true, message: '标题不能为空', trigger: 'blur' }]"> <el-form-item :label="$t('message.list.title')" prop="title" :rules="[{ required: true, message: $t('message.list.titleRequired'), trigger: 'blur' }]">
<el-input v-model="state.ruleForm.title" placeholder="标题" clearable /> <el-input v-model="state.ruleForm.title" :placeholder="$t('message.list.title')" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="类型" prop="type" :rules="[{ required: true, message: '类型不能为空', trigger: 'blur' }]"> <el-form-item :label="$t('message.list.type')" prop="type" :rules="[{ required: true, message: $t('message.list.typeRequired'), trigger: 'blur' }]">
<el-select v-model="state.ruleForm.type" placeholder="类型" filterable allow-create default-first-option style="width: 100%"> <el-select v-model="state.ruleForm.type" :placeholder="$t('message.list.type')" filterable allow-create default-first-option style="width: 100%">
<el-option label="通知" :value="1" /> <el-option :label="$t('message.list.notice')" :value="1" />
<el-option label="公告" :value="2" /> <el-option :label="$t('message.list.announcement')" :value="2" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
<el-form-item label="内容" prop="content" :rules="[{ required: true, message: '内容不能为空', trigger: 'blur' }]"> <el-form-item :label="$t('message.list.content')" prop="content" :rules="[{ required: true, message: $t('message.list.contentRequired'), trigger: 'blur' }]">
<Editor v-model:get-html="state.ruleForm.content" /> <Editor v-model:get-html="state.ruleForm.content" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -31,8 +31,8 @@
</el-form> </el-form>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button icon="ele-CircleCloseFilled" @click="cancel"> </el-button> <el-button icon="ele-CircleCloseFilled" @click="cancel">{{ $t('message.list.cancelButtonText') }}</el-button>
<el-button type="primary" icon="ele-CircleCheckFilled" @click="submit"> </el-button> <el-button type="primary" icon="ele-CircleCheckFilled" @click="submit">{{ $t('message.list.confirmButtonText') }}</el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>

View File

@ -4,15 +4,15 @@
<el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true" label-width="auto" style="flex: 1 1 0%"> <el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true" label-width="auto" style="flex: 1 1 0%">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6"> <el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="标题" prop="title"> <el-form-item :label="$t('message.list.title')" prop="title">
<el-input v-model="state.queryParams.title" placeholder="标题" clearable @keyup.enter.native="handleQuery(true)" /> <el-input v-model="state.queryParams.title" :placeholder="$t('message.list.title')" clearable @keyup.enter="handleQuery(true)" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6"> <el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="类型" prop="type"> <el-form-item :label="$t('message.list.type')" prop="type">
<el-select v-model="state.queryParams.type" placeholder="类型" clearable @clear="state.queryParams.type = undefined"> <el-select v-model="state.queryParams.type" :placeholder="$t('message.list.type')" clearable @clear="state.queryParams.type = undefined">
<el-option label="通知" :value="1" /> <el-option :label="$t('message.list.notice')" :value="1" />
<el-option label="公告" :value="2" /> <el-option :label="$t('message.list.announcement')" :value="2" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -24,8 +24,8 @@
<el-row> <el-row>
<el-col> <el-col>
<el-button-group> <el-button-group>
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" v-auth="'sysNotice/page'" :loading="options.loading"> 查询 </el-button> <el-button type="primary" icon="ele-Search" @click="handleQuery(true)" v-auth="'sysNotice/page'" :loading="options.loading"> {{ $t('message.list.query') }} </el-button>
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button> <el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> {{ $t('message.list.reset') }} </el-button>
</el-button-group> </el-button-group>
</el-col> </el-col>
</el-row> </el-row>
@ -34,31 +34,31 @@
<el-card class="full-table" shadow="hover" style="margin-top: 5px"> <el-card class="full-table" shadow="hover" style="margin-top: 5px">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents"> <vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
<template #toolbar_buttons> <template #toolbar_buttons>
<el-button type="primary" icon="ele-Plus" @click="handleAdd" v-auth="'sysNotice/add'"> 新增 </el-button> <el-button type="primary" icon="ele-Plus" @click="handleAdd" v-auth="'sysNotice/add'"> {{ $t('message.list.add') }} </el-button>
</template> </template>
<template #toolbar_tools> </template> <template #toolbar_tools> </template>
<template #empty> <template #empty>
<el-empty :image-size="200" /> <el-empty :image-size="200" />
</template> </template>
<template #row_type="{ row }"> <template #row_type="{ row }">
<el-tag v-if="row.type === 1" type="success">通知</el-tag> <el-tag v-if="row.type === 1" type="success">{{ $t('message.list.notice') }}</el-tag>
<el-tag v-else type="warning">公告</el-tag> <el-tag v-else type="warning">{{ $t('message.list.announcement') }}</el-tag>
</template> </template>
<template #row_status="{ row }"> <template #row_status="{ row }">
<el-tag v-if="row.status === 1" type="info">已发布</el-tag> <el-tag v-if="row.status === 1" type="info">{{ $t('message.list.published') }}</el-tag>
<el-tag v-else type="warning">未发布</el-tag> <el-tag v-else type="warning">{{ $t('message.list.unpublished') }}</el-tag>
</template> </template>
<template #row_record="{ row }"> <template #row_record="{ row }">
<ModifyRecord :data="row" /> <ModifyRecord :data="row" />
</template> </template>
<template #row_buttons="{ row }"> <template #row_buttons="{ row }">
<el-tooltip content="编辑" placement="top"> <el-tooltip :content="$t('message.list.edit')" placement="top">
<el-button icon="ele-Edit" size="small" text type="primary" @click="handleEdit(row)" v-auth="'sysNotice/update'" :disabled="row.status === 1" /> <el-button icon="ele-Edit" size="small" text type="primary" @click="handleEdit(row)" v-auth="'sysNotice/update'" :disabled="row.status === 1" />
</el-tooltip> </el-tooltip>
<el-tooltip content="删除" placement="top"> <el-tooltip :content="$t('message.list.delete')" placement="top">
<el-button icon="ele-Delete" size="small" text type="danger" @click="handleDelete(row)" v-auth="'sysNotice/delete'" :disabled="row.status === 1" /> <el-button icon="ele-Delete" size="small" text type="danger" @click="handleDelete(row)" v-auth="'sysNotice/delete'" :disabled="row.status === 1" />
</el-tooltip> </el-tooltip>
<el-button icon="ele-Position" size="small" text type="primary" @click="handlePublic(row)" v-auth="'sysNotice/public'" :disabled="row.status === 1">发布</el-button> <el-button icon="ele-Position" size="small" text type="primary" @click="handlePublic(row)" v-auth="'sysNotice/public'" :disabled="row.status === 1">{{ $t('message.list.publish') }}</el-button>
</template> </template>
</vxe-grid> </vxe-grid>
</el-card> </el-card>
@ -81,6 +81,9 @@ import ModifyRecord from '/@/components/table/modifyRecord.vue';
import { getAPI } from '/@/utils/axios-utils'; import { getAPI } from '/@/utils/axios-utils';
import { SysNoticeApi } from '/@/api-services/api'; import { SysNoticeApi } from '/@/api-services/api';
import { SysNotice, PageNoticeInput } from '/@/api-services/models'; import { SysNotice, PageNoticeInput } from '/@/api-services/models';
import { useI18n } from 'vue-i18n';
const i18n = useI18n();
const xGrid = ref<VxeGridInstance>(); const xGrid = ref<VxeGridInstance>();
const editNoticeRef = ref<InstanceType<typeof EditNotice>>(); const editNoticeRef = ref<InstanceType<typeof EditNotice>>();
@ -104,19 +107,19 @@ const localPageParamKey = 'localPageParam:sysNotice';
const options = useVxeTable<SysNotice>( const options = useVxeTable<SysNotice>(
{ {
id: 'sysNotice', id: 'sysNotice',
name: '通知公告', name: i18n.t('message.list.notice'),
columns: [ columns: [
// { type: 'checkbox', width: 40, fixed: 'left' }, // { type: 'checkbox', width: 40, fixed: 'left' },
{ field: 'seq', type: 'seq', title: '序号', width: 60, fixed: 'left' }, { field: 'seq', type: 'seq', title: i18n.t('message.list.seq'), width: 60, fixed: 'left' },
{ field: 'title', title: '标题', minWidth: 200, showOverflow: 'tooltip' }, { field: 'title', title: i18n.t('message.list.title'), minWidth: 200, showOverflow: 'tooltip' },
{ field: 'content', title: '内容', minWidth: 180, showOverflow: 'tooltip', slots: { default: (scope: any) => removeHtml(scope.row.content) } }, { field: 'content', title: i18n.t('message.list.content'), minWidth: 180, showOverflow: 'tooltip', slots: { default: (scope: any) => removeHtml(scope.row.content) } },
{ field: 'type', title: '类型', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_type' } }, { field: 'type', title: i18n.t('message.list.type'), minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_type' } },
{ field: 'createTime', title: '创建时间', minWidth: 150, showOverflow: 'tooltip' }, { field: 'createTime', title: i18n.t('message.list.createTime'), minWidth: 150, showOverflow: 'tooltip' },
{ field: 'status', title: '状态', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_status' } }, { field: 'status', title: i18n.t('message.list.status'), minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_status' } },
{ field: 'publicUserName', title: '发布者', minWidth: 120, showOverflow: 'tooltip' }, { field: 'publicUserName', title: i18n.t('message.list.publisher'), minWidth: 120, showOverflow: 'tooltip' },
{ field: 'publicTime', title: '发布时间', minWidth: 150, showOverflow: 'tooltip' }, { field: 'publicTime', title: i18n.t('message.list.publishTime'), minWidth: 150, showOverflow: 'tooltip' },
{ field: 'record', title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } }, { field: 'record', title: i18n.t('message.list.record'), width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
{ field: 'buttons', title: '操作', fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } }, { field: 'buttons', title: i18n.t('message.list.operation'), fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } },
], ],
}, },
// vxeGrid()vxe-table // vxeGrid()vxe-table
@ -159,27 +162,27 @@ const resetQuery = async () => {
// //
const handleAdd = () => { const handleAdd = () => {
state.title = '添加通知公告'; state.title = i18n.t('message.list.addNoticeAnnouncement');
editNoticeRef.value?.openDialog({ type: 1 }); editNoticeRef.value?.openDialog({ type: 1 });
}; };
// //
const handleEdit = (row: any) => { const handleEdit = (row: any) => {
state.title = '编辑通知公告'; state.title = i18n.t('message.list.editNoticeAnnouncement');
editNoticeRef.value?.openDialog(row); editNoticeRef.value?.openDialog(row);
}; };
// //
const handleDelete = (row: any) => { const handleDelete = (row: any) => {
ElMessageBox.confirm(`确定删除通知公告:${row.title}】?`, '提示', { ElMessageBox.confirm(`${i18n.t('message.list.confirmDeleteNoticeAnnouncement')}${row.title}】?`, i18n.t('message.list.hint'), {
confirmButtonText: '确定', confirmButtonText: i18n.t('message.list.confirmButtonText'),
cancelButtonText: '取消', cancelButtonText: i18n.t('message.list.cancelButtonText'),
type: 'warning', type: 'warning',
}) })
.then(async () => { .then(async () => {
await getAPI(SysNoticeApi).apiSysNoticeDeletePost({ id: row.id }); await getAPI(SysNoticeApi).apiSysNoticeDeletePost({ id: row.id });
handleQuery(); handleQuery();
ElMessage.success('删除成功'); ElMessage.success(i18n.t('message.list.successDelete'));
}) })
.catch(() => {}); .catch(() => {});
}; };
@ -200,15 +203,15 @@ const gridEvents: VxeGridListeners<SysNotice> = {
// //
const handlePublic = (row: any) => { const handlePublic = (row: any) => {
ElMessageBox.confirm(`确定发布通知公告:${row.title}】,不可撤销?`, '提示', { ElMessageBox.confirm(`${i18n.t('message.list.confirmPublishNoticeAnnouncement')}${row.title}】,${i18n.t('message.list.irreversible')}?`, i18n.t('message.list.hint'), {
confirmButtonText: '确定', confirmButtonText: i18n.t('message.list.confirmButtonText'),
cancelButtonText: '取消', cancelButtonText: i18n.t('message.list.cancelButtonText'),
type: 'warning', type: 'warning',
}) })
.then(async () => { .then(async () => {
await getAPI(SysNoticeApi).apiSysNoticePublicPost({ id: row.id }); await getAPI(SysNoticeApi).apiSysNoticePublicPost({ id: row.id });
handleQuery(); handleQuery();
ElMessage.success('发布成功'); ElMessage.success(i18n.t('message.list.publishSuccess'));
}) })
.catch(() => {}); .catch(() => {});
}; };