refactor:foo
This commit is contained in:
parent
1c00248143
commit
2162eed7a9
@ -10,20 +10,20 @@
|
||||
<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
|
||||
<el-row :gutter="10">
|
||||
<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-input v-model="state.ruleForm.title" placeholder="标题" clearable />
|
||||
<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="$t('message.list.title')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<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-select v-model="state.ruleForm.type" placeholder="类型" filterable allow-create default-first-option style="width: 100%">
|
||||
<el-option label="通知" :value="1" />
|
||||
<el-option label="公告" :value="2" />
|
||||
<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="$t('message.list.type')" filterable allow-create default-first-option style="width: 100%">
|
||||
<el-option :label="$t('message.list.notice')" :value="1" />
|
||||
<el-option :label="$t('message.list.announcement')" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<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" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -31,8 +31,8 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button icon="ele-CircleCloseFilled" @click="cancel">取 消</el-button>
|
||||
<el-button type="primary" icon="ele-CircleCheckFilled" @click="submit">确 定</el-button>
|
||||
<el-button icon="ele-CircleCloseFilled" @click="cancel">{{ $t('message.list.cancelButtonText') }}</el-button>
|
||||
<el-button type="primary" icon="ele-CircleCheckFilled" @click="submit">{{ $t('message.list.confirmButtonText') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
@ -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-row :gutter="10">
|
||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="state.queryParams.title" placeholder="标题" clearable @keyup.enter.native="handleQuery(true)" />
|
||||
<el-form-item :label="$t('message.list.title')" prop="title">
|
||||
<el-input v-model="state.queryParams.title" :placeholder="$t('message.list.title')" clearable @keyup.enter="handleQuery(true)" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select v-model="state.queryParams.type" placeholder="类型" clearable @clear="state.queryParams.type = undefined">
|
||||
<el-option label="通知" :value="1" />
|
||||
<el-option label="公告" :value="2" />
|
||||
<el-form-item :label="$t('message.list.type')" prop="type">
|
||||
<el-select v-model="state.queryParams.type" :placeholder="$t('message.list.type')" clearable @clear="state.queryParams.type = undefined">
|
||||
<el-option :label="$t('message.list.notice')" :value="1" />
|
||||
<el-option :label="$t('message.list.announcement')" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -24,8 +24,8 @@
|
||||
<el-row>
|
||||
<el-col>
|
||||
<el-button-group>
|
||||
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" v-auth="'sysNotice/page'" :loading="options.loading"> 查询 </el-button>
|
||||
<el-button icon="ele-Refresh" @click="resetQuery" :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"> {{ $t('message.list.reset') }} </el-button>
|
||||
</el-button-group>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -34,31 +34,31 @@
|
||||
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
|
||||
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
|
||||
<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 #toolbar_tools> </template>
|
||||
<template #empty>
|
||||
<el-empty :image-size="200" />
|
||||
</template>
|
||||
<template #row_type="{ row }">
|
||||
<el-tag v-if="row.type === 1" type="success">通知</el-tag>
|
||||
<el-tag v-else type="warning">公告</el-tag>
|
||||
<el-tag v-if="row.type === 1" type="success">{{ $t('message.list.notice') }}</el-tag>
|
||||
<el-tag v-else type="warning">{{ $t('message.list.announcement') }}</el-tag>
|
||||
</template>
|
||||
<template #row_status="{ row }">
|
||||
<el-tag v-if="row.status === 1" type="info">已发布</el-tag>
|
||||
<el-tag v-else type="warning">未发布</el-tag>
|
||||
<el-tag v-if="row.status === 1" type="info">{{ $t('message.list.published') }}</el-tag>
|
||||
<el-tag v-else type="warning">{{ $t('message.list.unpublished') }}</el-tag>
|
||||
</template>
|
||||
<template #row_record="{ row }">
|
||||
<ModifyRecord :data="row" />
|
||||
</template>
|
||||
<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-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-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>
|
||||
</vxe-grid>
|
||||
</el-card>
|
||||
@ -81,6 +81,9 @@ import ModifyRecord from '/@/components/table/modifyRecord.vue';
|
||||
import { getAPI } from '/@/utils/axios-utils';
|
||||
import { SysNoticeApi } from '/@/api-services/api';
|
||||
import { SysNotice, PageNoticeInput } from '/@/api-services/models';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const i18n = useI18n();
|
||||
|
||||
const xGrid = ref<VxeGridInstance>();
|
||||
const editNoticeRef = ref<InstanceType<typeof EditNotice>>();
|
||||
@ -104,19 +107,19 @@ const localPageParamKey = 'localPageParam:sysNotice';
|
||||
const options = useVxeTable<SysNotice>(
|
||||
{
|
||||
id: 'sysNotice',
|
||||
name: '通知公告',
|
||||
name: i18n.t('message.list.notice'),
|
||||
columns: [
|
||||
// { type: 'checkbox', width: 40, fixed: 'left' },
|
||||
{ field: 'seq', type: 'seq', title: '序号', width: 60, fixed: 'left' },
|
||||
{ field: 'title', title: '标题', minWidth: 200, showOverflow: 'tooltip' },
|
||||
{ field: 'content', title: '内容', minWidth: 180, showOverflow: 'tooltip', slots: { default: (scope: any) => removeHtml(scope.row.content) } },
|
||||
{ field: 'type', title: '类型', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_type' } },
|
||||
{ field: 'createTime', title: '创建时间', minWidth: 150, showOverflow: 'tooltip' },
|
||||
{ field: 'status', title: '状态', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_status' } },
|
||||
{ field: 'publicUserName', title: '发布者', minWidth: 120, showOverflow: 'tooltip' },
|
||||
{ field: 'publicTime', title: '发布时间', minWidth: 150, showOverflow: 'tooltip' },
|
||||
{ field: 'record', title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
|
||||
{ field: 'buttons', title: '操作', fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } },
|
||||
{ field: 'seq', type: 'seq', title: i18n.t('message.list.seq'), width: 60, fixed: 'left' },
|
||||
{ field: 'title', title: i18n.t('message.list.title'), minWidth: 200, showOverflow: 'tooltip' },
|
||||
{ field: 'content', title: i18n.t('message.list.content'), minWidth: 180, showOverflow: 'tooltip', slots: { default: (scope: any) => removeHtml(scope.row.content) } },
|
||||
{ field: 'type', title: i18n.t('message.list.type'), minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_type' } },
|
||||
{ field: 'createTime', title: i18n.t('message.list.createTime'), minWidth: 150, showOverflow: 'tooltip' },
|
||||
{ field: 'status', title: i18n.t('message.list.status'), minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_status' } },
|
||||
{ field: 'publicUserName', title: i18n.t('message.list.publisher'), minWidth: 120, showOverflow: 'tooltip' },
|
||||
{ field: 'publicTime', title: i18n.t('message.list.publishTime'), minWidth: 150, showOverflow: 'tooltip' },
|
||||
{ field: 'record', title: i18n.t('message.list.record'), width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
|
||||
{ field: 'buttons', title: i18n.t('message.list.operation'), fixed: 'right', width: 180, showOverflow: true, slots: { default: 'row_buttons' } },
|
||||
],
|
||||
},
|
||||
// vxeGrid配置参数(此处可覆写任何参数),参考vxe-table官方文档
|
||||
@ -159,27 +162,27 @@ const resetQuery = async () => {
|
||||
|
||||
// 打开新增页面
|
||||
const handleAdd = () => {
|
||||
state.title = '添加通知公告';
|
||||
state.title = i18n.t('message.list.addNoticeAnnouncement');
|
||||
editNoticeRef.value?.openDialog({ type: 1 });
|
||||
};
|
||||
|
||||
// 打开编辑页面
|
||||
const handleEdit = (row: any) => {
|
||||
state.title = '编辑通知公告';
|
||||
state.title = i18n.t('message.list.editNoticeAnnouncement');
|
||||
editNoticeRef.value?.openDialog(row);
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = (row: any) => {
|
||||
ElMessageBox.confirm(`确定删除通知公告:【${row.title}】?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm(`${i18n.t('message.list.confirmDeleteNoticeAnnouncement')}【${row.title}】?`, i18n.t('message.list.hint'), {
|
||||
confirmButtonText: i18n.t('message.list.confirmButtonText'),
|
||||
cancelButtonText: i18n.t('message.list.cancelButtonText'),
|
||||
type: 'warning',
|
||||
})
|
||||
.then(async () => {
|
||||
await getAPI(SysNoticeApi).apiSysNoticeDeletePost({ id: row.id });
|
||||
handleQuery();
|
||||
ElMessage.success('删除成功');
|
||||
ElMessage.success(i18n.t('message.list.successDelete'));
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
@ -200,15 +203,15 @@ const gridEvents: VxeGridListeners<SysNotice> = {
|
||||
|
||||
// 发布
|
||||
const handlePublic = (row: any) => {
|
||||
ElMessageBox.confirm(`确定发布通知公告:【${row.title}】,不可撤销?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
ElMessageBox.confirm(`${i18n.t('message.list.confirmPublishNoticeAnnouncement')}【${row.title}】,${i18n.t('message.list.irreversible')}?`, i18n.t('message.list.hint'), {
|
||||
confirmButtonText: i18n.t('message.list.confirmButtonText'),
|
||||
cancelButtonText: i18n.t('message.list.cancelButtonText'),
|
||||
type: 'warning',
|
||||
})
|
||||
.then(async () => {
|
||||
await getAPI(SysNoticeApi).apiSysNoticePublicPost({ id: row.id });
|
||||
handleQuery();
|
||||
ElMessage.success('发布成功');
|
||||
ElMessage.success(i18n.t('message.list.publishSuccess'));
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user