信息公告

This commit is contained in:
xiaofajia 2024-10-09 15:04:39 +08:00
parent 4a0fcff248
commit e124a1c539
5 changed files with 355 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import request from "@/utils/request";
const preUrl = "/base/notice";
// 分页
export function pageNotice(params) {
return request({
url: preUrl + "/page",
method: "get",
params
})
}
// 新增、修改
export function updateNotice(data){
return request({
url: preUrl + "/update",
method: "post",
data
})
}
// 删除
export function removeNotice(ids){
return request({
url: preUrl + "/remove?ids=" + ids,
method: "delete"
})
}
// 查询单条
export function getNoticeById(id){
return request({
url: preUrl + "/get?id=" + id,
method: "get"
})
}

View File

@ -101,6 +101,8 @@ export const DICT_TYPE = {
PROMOTION_CHANNEL : 'promotion_channel',
//用户类型
SYSTEM_USER_TYPE : 'system_user_type',
// 分类字典通知公告
NOTICE_SERVER: 'notice_server',
// ------- carMain模块 -------
//车辆性质
@ -206,6 +208,8 @@ export const DICT_TYPE = {
REPAIR_TICKETS_STATUS: 'repair_tickets_status',
//维修工单配件状态
REPAIR_PART_STATUS: 'repair_part_status',
// 维修通知公告
REPAIR_NOTICE_SERVER: 'weixiu',
// ---------会员相关---------member_coupon_typemember_coupon_out_rulemember_carmember_active
//卡券类型

View File

@ -0,0 +1,147 @@
<template>
<div>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="公告标题" prop="title">
<el-input v-model="queryParams.title" placeholder="请输入公告标题" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="公告状态" prop="status">
<el-select v-model="queryParams.status" placeholder="公告状态" clearable>
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)" :label="dict.label"
:value="parseInt(dict.value)"/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleUpdate"
>新增
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="noticeList">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="公告标题" align="center" prop="title" :show-overflow-tooltip="true"/>
<el-table-column label="公告类型" align="center" prop="type" width="100">
<template v-slot="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 v-slot="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="内容" align="center" prop="content" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
>修改
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
>删除
</el-button>
<!-- <el-button size="mini" type="text" @click="handlePush(scope.row.id)"-->
<!-- >推送-->
<!-- </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"/>
<BaseNoticeForm ref="baseNoticeForm" :server="server" :parent-server="parentServer" @success="getList"/>
</div>
</template>
<script>
import {pageNotice, removeNotice} from '@/api/base/notice'
import BaseNoticeForm from "@/views/base/notice/form/BaseNoticeForm.vue";
export default {
name: "BaseNotice",
components: {BaseNoticeForm},
props:{
parentServer:{
type: String,
default: null,
required: true,
},
server:{
type: String,
default: null,
required: true
}
},
data(){
return{
queryParams: {
pageNo: 1,
pageSize: 10,
server: this.server,
parentServer: this.parentServer,
title: null,
status: null,
},
showSearch: true,
loading: false,
noticeList: [],
total: 0,
}
},
mounted() {
this.getList();
},
methods:{
/** 查询公告列表 */
async getList(){
this.loading = true
try {
const res = await pageNotice(this.queryParams)
this.noticeList = res.data.records
this.total = res.data.total
}finally {
this.loading = false
}
},
/** 搜索按钮操作 */
handleQuery(){
this.queryParams.pageNo = 1
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleUpdate(row) {
this.$refs.baseNoticeForm.open(row?.id)
},
/** 删除按钮操作 */
async handleDelete(row) {
try {
await this.$modal.confirm('是否确认删除选中数据?')
const ids = [row.id]
await removeNotice(ids)
await this.getList()
this.$modal.msgSuccess("删除成功")
}catch {}
},
/** 推送按钮操作 */
handlePush(id){
}
}
}
</script>
<style scoped lang="scss">
</style>

View File

@ -0,0 +1,124 @@
<template>
<div class="app-container">
<el-dialog :title="title" :visible.sync="dialogVisible" width="80%" 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 this.getDictDatas(DICT_TYPE.SYSTEM_NOTICE_TYPE)"
: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 this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
: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="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import Editor from "@/components/Editor/index.vue";
import {getNoticeById, updateNotice} from "@/api/base/notice";
export default {
name: "BaseNoticeForm",
props:{
parentServer:{
type: String,
default: null,
required: true,
},
server:{
type: String,
default: null,
required: true
}
},
components: {Editor},
data() {
return {
title: null,
form: {
title: null,
type: null,
status: 0,
content: null,
server: this.server,
parentServer: this.parentServer,
},
rules: {
title: [{required: true, message:"标题不能为空", trigger: "blur"}],
type: [{required: true, message:"类型不能为空",trigger: "blur"}],
},
dialogVisible: false,
}
},
methods: {
async open(id){
this.title = id ? "修改通知公告" : "新增通知公告"
this.reset()
if (id){
const res = await getNoticeById(id)
this.form = res.data;
}
this.dialogVisible = true
},
/** 提交按钮 */
async submitForm() {
try {
await this.$refs.form.validate()
await updateNotice(this.form)
this.dialogVisible = false
this.$modal.msgSuccess(this.form?.id ? "修改成功" : "添加成功")
this.$emit("success")
}catch{}
},
reset(){
this.form = {
title: null,
type: null,
status: 0,
content: null,
server: this.server,
parentServer: this.parentServer,
}
this.resetForm('form')
}
}
}
</script>
<style scoped lang="scss">
</style>

View File

@ -0,0 +1,43 @@
<template>
<div class="app-container">
<el-tabs v-model="activeName">
<el-tab-pane v-for="server in serverList" :label="server.name" :name="server.code">
<BaseNotice :server="server.code" :parent-server="parentServer" />
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import BaseNotice from "@/views/base/notice/BaseNotice.vue";
import {listCategory} from "@/api/system/category";
import {DICT_TYPE} from "@/utils/dict";
export default {
name: "RepairNotice",
components: {BaseNotice},
data(){
return{
parentServer: DICT_TYPE.REPAIR_NOTICE_SERVER,
serverList: [],
activeName: null
}
},
created() {
this.getServerList()
},
methods:{
async getServerList(){
const res = await listCategory()
this.serverList = this.handleTree(res.data, 'id', 'pid', 'children', '0')
.find(item => item.code === DICT_TYPE.NOTICE_SERVER).children
.find(item => item.code === DICT_TYPE.REPAIR_NOTICE_SERVER).children
this.activeName = this.serverList[0].code
},
}
}
</script>
<style scoped lang="scss">
</style>