2021-04-30 14:15:31 +08:00
|
|
|
<template>
|
|
|
|
<div class="app-container">
|
|
|
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
|
<el-form-item label="公告标题" prop="title">
|
|
|
|
<el-input v-model="queryParams.title" placeholder="请输入公告标题" clearable size="small" @keyup.enter.native="handleQuery"/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="操作人员" prop="createBy">
|
|
|
|
<el-input v-model="queryParams.createBy" placeholder="请输入操作人员" clearable size="small" @keyup.enter.native="handleQuery"/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="类型" prop="type">
|
|
|
|
<el-select v-model="queryParams.type" placeholder="公告类型" clearable size="small">
|
|
|
|
<el-option v-for="dict in noticeTypeDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
2022-02-15 18:59:22 +08:00
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
2021-04-30 14:15:31 +08:00
|
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
|
<el-col :span="1.5">
|
2022-02-15 18:59:22 +08:00
|
|
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
|
|
|
v-hasPermi="['system:notice:create']"s>新增</el-button>
|
2021-04-30 14:15:31 +08:00
|
|
|
</el-col>
|
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
<el-table v-loading="loading" :data="noticeList">
|
|
|
|
<el-table-column label="序号" align="center" prop="id" width="100" />
|
|
|
|
<el-table-column label="公告标题" align="center" prop="title" :show-overflow-tooltip="true"/>
|
2022-02-16 13:27:17 +08:00
|
|
|
<el-table-column label="公告类型" align="center" prop="type" width="100">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<dict-tag :type="DICT_TYPE.SYSTEM_NOTICE_TYPE" :value="scope.row.type"/>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="状态" align="center" prop="status" width="100">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2021-04-30 14:15:31 +08:00
|
|
|
<el-table-column label="创建者" align="center" prop="createBy" width="100" />
|
|
|
|
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
|
|
|
v-hasPermi="['system:notice:update']">修改</el-button>
|
|
|
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
|
|
|
v-hasPermi="['system:notice:delete']">删除</el-button>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
|
|
|
@pagination="getList"/>
|
|
|
|
|
|
|
|
<!-- 添加或修改公告对话框 -->
|
|
|
|
<el-dialog :title="title" :visible.sync="open" width="780px" append-to-body>
|
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
|
|
<el-row>
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-form-item label="公告标题" prop="title">
|
|
|
|
<el-input v-model="form.title" placeholder="请输入公告标题" />
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-form-item label="公告类型" prop="type">
|
|
|
|
<el-select v-model="form.type" placeholder="请选择">
|
|
|
|
<el-option
|
|
|
|
v-for="dict in noticeTypeDictDatas"
|
|
|
|
:key="parseInt(dict.value)"
|
|
|
|
:label="dict.label"
|
|
|
|
:value="parseInt(dict.value)"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
<el-col :span="24">
|
|
|
|
<el-form-item label="状态">
|
|
|
|
<el-radio-group v-model="form.status">
|
|
|
|
<el-radio
|
|
|
|
v-for="dict in statusDictDatas"
|
|
|
|
:key="parseInt(dict.value)"
|
|
|
|
:label="parseInt(dict.value)"
|
|
|
|
>{{dict.label}}</el-radio>
|
|
|
|
</el-radio-group>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
<el-col :span="24">
|
|
|
|
<el-form-item label="内容">
|
|
|
|
<editor v-model="form.content" :min-height="192"/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</el-form>
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice";
|
|
|
|
import Editor from '@/components/Editor';
|
|
|
|
|
2022-02-02 01:27:04 +08:00
|
|
|
import {CommonStatusEnum} from '@/utils/constants'
|
2022-02-16 13:27:17 +08:00
|
|
|
import { getDictDatas, DICT_TYPE } from '@/utils/dict'
|
2021-04-30 14:15:31 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "Notice",
|
|
|
|
components: {
|
|
|
|
Editor
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
// 遮罩层
|
|
|
|
loading: true,
|
|
|
|
// 显示搜索条件
|
|
|
|
showSearch: true,
|
|
|
|
// 总条数
|
|
|
|
total: 0,
|
|
|
|
// 公告表格数据
|
|
|
|
noticeList: [],
|
|
|
|
// 弹出层标题
|
|
|
|
title: "",
|
|
|
|
// 是否显示弹出层
|
|
|
|
open: false,
|
|
|
|
// 查询参数
|
|
|
|
queryParams: {
|
|
|
|
pageNo: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
title: undefined,
|
|
|
|
createBy: undefined,
|
|
|
|
status: undefined
|
|
|
|
},
|
|
|
|
// 表单参数
|
|
|
|
form: {},
|
|
|
|
// 表单校验
|
|
|
|
rules: {
|
|
|
|
title: [
|
|
|
|
{ required: true, message: "公告标题不能为空", trigger: "blur" }
|
|
|
|
],
|
|
|
|
type: [
|
|
|
|
{ required: true, message: "公告类型不能为空", trigger: "change" }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
// 枚举
|
2022-02-02 01:27:04 +08:00
|
|
|
CommonStatusEnum: CommonStatusEnum,
|
2021-04-30 14:15:31 +08:00
|
|
|
// 数据字典
|
2022-02-02 01:27:04 +08:00
|
|
|
noticeTypeDictDatas: getDictDatas(DICT_TYPE.SYSTEM_NOTICE_TYPE),
|
|
|
|
statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS)
|
2021-04-30 14:15:31 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.getList();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
/** 查询公告列表 */
|
|
|
|
getList() {
|
|
|
|
this.loading = true;
|
|
|
|
listNotice(this.queryParams).then(response => {
|
|
|
|
this.noticeList = response.data.list;
|
|
|
|
this.total = response.data.total;
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 取消按钮
|
|
|
|
cancel() {
|
|
|
|
this.open = false;
|
|
|
|
this.reset();
|
|
|
|
},
|
|
|
|
// 表单重置
|
|
|
|
reset() {
|
|
|
|
this.form = {
|
|
|
|
id: undefined,
|
|
|
|
title: undefined,
|
|
|
|
type: undefined,
|
|
|
|
content: undefined,
|
2022-02-02 01:27:04 +08:00
|
|
|
status: CommonStatusEnum.ENABLE
|
2021-04-30 14:15:31 +08:00
|
|
|
};
|
|
|
|
this.resetForm("form");
|
|
|
|
},
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
handleQuery() {
|
|
|
|
this.queryParams.pageNo = 1;
|
|
|
|
this.getList();
|
|
|
|
},
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
resetQuery() {
|
|
|
|
this.resetForm("queryForm");
|
|
|
|
this.handleQuery();
|
|
|
|
},
|
|
|
|
/** 新增按钮操作 */
|
|
|
|
handleAdd() {
|
|
|
|
this.reset();
|
|
|
|
this.open = true;
|
|
|
|
this.title = "添加公告";
|
|
|
|
},
|
|
|
|
/** 修改按钮操作 */
|
|
|
|
handleUpdate(row) {
|
|
|
|
this.reset();
|
|
|
|
const id = row.id || this.ids
|
|
|
|
getNotice(id).then(response => {
|
|
|
|
this.form = response.data;
|
|
|
|
this.open = true;
|
|
|
|
this.title = "修改公告";
|
|
|
|
});
|
|
|
|
},
|
|
|
|
/** 提交按钮 */
|
|
|
|
submitForm: function() {
|
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
|
if (valid) {
|
|
|
|
if (this.form.id !== undefined) {
|
|
|
|
updateNotice(this.form).then(response => {
|
2022-02-17 13:11:21 +08:00
|
|
|
this.$modal.msgSuccess("修改成功");
|
2021-04-30 14:15:31 +08:00
|
|
|
this.open = false;
|
|
|
|
this.getList();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
addNotice(this.form).then(response => {
|
2022-02-17 13:11:21 +08:00
|
|
|
this.$modal.msgSuccess("新增成功");
|
2021-04-30 14:15:31 +08:00
|
|
|
this.open = false;
|
|
|
|
this.getList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
handleDelete(row) {
|
|
|
|
const ids = row.id || this.ids
|
2022-02-17 13:11:21 +08:00
|
|
|
this.$modal.confirm('是否确认删除公告编号为"' + ids + '"的数据项?').then(function() {
|
2021-04-30 14:15:31 +08:00
|
|
|
return delNotice(ids);
|
|
|
|
}).then(() => {
|
|
|
|
this.getList();
|
2022-02-17 13:11:21 +08:00
|
|
|
this.$modal.msgSuccess("删除成功");
|
2022-02-15 21:51:24 +08:00
|
|
|
}).catch(() => {});
|
2021-04-30 14:15:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|