1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

add the function of deleteNoticeType and modify the router of notice.ts

This commit is contained in:
cccccyb
2023-05-25 01:27:57 +08:00
parent c060a762af
commit 16325f21de
10 changed files with 243 additions and 165 deletions

View File

@@ -35,7 +35,7 @@ public class NoticeController {
//根据公告id查公告信息及发布人 //根据公告id查公告信息及发布人
@GetMapping("/{nid}") @GetMapping("/{nid}")
public ResponseResult selectByNoticeId(@PathVariable Long nid) { public ResponseResult<Notice> selectByNoticeId(@PathVariable Long nid) {
Notice noticeById = noticeService.selectByNoticeId(nid); Notice noticeById = noticeService.selectByNoticeId(nid);
Integer code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; Integer code = noticeById != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticeById != null ? "" : "数据查询失败,请重试!"; String msg = noticeById != null ? "" : "数据查询失败,请重试!";
@@ -44,7 +44,7 @@ public class NoticeController {
//查询所有公告或模糊查询 //查询所有公告或模糊查询
@GetMapping @GetMapping
public ResponseResult selectAllNotice(String title, String type, String startTime, String endTime) { public ResponseResult<List<Notice>> selectAllNotice(String title, String type, String startTime, String endTime) {
List<Notice> noticeList; List<Notice> noticeList;
if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) { if (!StringUtils.hasText(title) && !StringUtils.hasText(type) && !StringUtils.hasText(startTime) && !StringUtils.hasText(endTime)) {
noticeList = noticeService.selectAllNotice(); noticeList = noticeService.selectAllNotice();
@@ -59,7 +59,7 @@ public class NoticeController {
//根据登录用户id查询所接收的公告 //根据登录用户id查询所接收的公告
@GetMapping("/self") @GetMapping("/self")
public ResponseResult selectByUserId(Integer readStatus) { public ResponseResult<List<Notice>> selectByUserId(Integer readStatus) {
List<Notice> noticesByUserId = noticeReceiveService.selectByUserId(readStatus); List<Notice> noticesByUserId = noticeReceiveService.selectByUserId(readStatus);
Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticesByUserId != null ? "" : "数据查询失败,请重试!"; String msg = noticesByUserId != null ? "" : "数据查询失败,请重试!";
@@ -68,52 +68,52 @@ public class NoticeController {
//修改登录用户所接收公告的阅读状态 //修改登录用户所接收公告的阅读状态
@PutMapping("/modify_notice_read") @PutMapping("/modify_notice_read")
public ResponseResult modifyNoticeIsRead(@RequestBody Notice notice) { public ResponseResult<?> modifyNoticeIsRead(@RequestBody Notice notice) {
boolean updateById = false; boolean updateById = false;
if (null != notice) { if (null != notice) {
updateById = noticeReceiveService.modifyNoticeIsRead(notice); updateById = noticeReceiveService.modifyNoticeIsRead(notice);
} }
String msg = updateById ? "" : "服务器出错,请重试!"; String msg = updateById ? "" : "服务器出错,请重试!";
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById); return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
} }
//更新公告 //更新公告
@PutMapping @PutMapping
public ResponseResult updateNotice(@RequestBody Notice notice) { public ResponseResult<?> updateNotice(@RequestBody Notice notice) {
boolean updateById = noticeService.updateNotice(notice); boolean updateById = noticeService.updateNotice(notice);
String msg = updateById ? "" : "数据修改失败,请重试!"; String msg = updateById ? "" : "数据修改失败,请重试!";
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateById); return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
} }
//修改公告置顶状态 //修改公告置顶状态
@PutMapping("/update_notice_top") @PutMapping("/update_notice_top")
public ResponseResult updateNoticeTop(@RequestBody Notice notice) { public ResponseResult<?> updateNoticeTop(@RequestBody Notice notice) {
String operationMessage = notice.getTop() == 1 ? "取消置顶" : "置顶"; String operationMessage = notice.getTop() == 1 ? "取消置顶" : "置顶";
boolean updateResult = noticeService.updateNoticeTop(notice); boolean updateResult = noticeService.updateNoticeTop(notice);
String msg = updateResult ? "已成功" + operationMessage : operationMessage + "失败,请重试!"; String msg = updateResult ? "已成功" + operationMessage : operationMessage + "失败,请重试!";
return ResponseResult.build(updateResult ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateResult); return ResponseResult.build(updateResult ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
} }
//添加公告 //添加公告
@PostMapping @PostMapping
public ResponseResult addNotice(@RequestBody Notice notice) { public ResponseResult<?> addNotice(@RequestBody Notice notice) {
Boolean insertNotice = noticeService.addNotice(notice); Boolean insertNotice = noticeService.addNotice(notice);
String msg = insertNotice ? "" : "数据添加失败,请重试!"; String msg = insertNotice ? "" : "数据添加失败,请重试!";
return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, insertNotice); return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg,null);
} }
//删除公告 //删除公告
@DeleteMapping("/{nid}") @DeleteMapping("/{nid}")
public ResponseResult deleteByNoticeId(@PathVariable Long nid) { public ResponseResult<?> deleteByNoticeId(@PathVariable Long nid) {
boolean removeById = noticeService.deleteById(nid); boolean removeById = noticeService.deleteById(nid);
String msg = removeById ? "" : "数据删除失败,请重试!"; String msg = removeById ? "" : "数据删除失败,请重试!";
return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, removeById); return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null);
} }
//分页查询所有公告或分页模糊查询 //分页查询所有公告或分页模糊查询
@GetMapping("/page") @GetMapping("/page")
public ResponseResult selectPageAllNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) { public ResponseResult<List<Notice>> selectPageAllNotice(Integer currentPage, Integer pageSize, String title, String type, String startTime, String endTime) {
IPage<Notice> noticePageList; IPage<Notice> noticePageList;
Page<?> page = new Page(); Page<?> page = new Page();
if (null != currentPage && null != pageSize) { if (null != currentPage && null != pageSize) {

View File

@@ -32,7 +32,7 @@ public class NoticeTypeController {
//查询已启用的公告类型 //查询已启用的公告类型
@GetMapping("/enable") @GetMapping("/enable")
public ResponseResult selectEnableTypeList(){ public ResponseResult<List<NoticeType>> selectEnableTypeList(){
List<NoticeType> selectTypeName = noticeTypeService.selectEnableTypeList(); List<NoticeType> selectTypeName = noticeTypeService.selectEnableTypeList();
Integer code = selectTypeName != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; Integer code = selectTypeName != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = selectTypeName != null ? "" : "数据查询失败,请重试!"; String msg = selectTypeName != null ? "" : "数据查询失败,请重试!";
@@ -41,7 +41,7 @@ public class NoticeTypeController {
//查询所有公告类型 //查询所有公告类型
@GetMapping @GetMapping
public ResponseResult selectTypeList(){ public ResponseResult<List<NoticeType>> selectTypeList(){
List<NoticeType> selectTypeList = noticeTypeService.selectTypeList(); List<NoticeType> selectTypeList = noticeTypeService.selectTypeList();
Integer code = selectTypeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR; Integer code = selectTypeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = selectTypeList != null ? "" : "数据查询失败,请重试!"; String msg = selectTypeList != null ? "" : "数据查询失败,请重试!";
@@ -50,14 +50,14 @@ public class NoticeTypeController {
//修改公告类型启用或禁用 //修改公告类型启用或禁用
@GetMapping("/update") @GetMapping("/update")
public ResponseResult updateTypeEnableById(String typeId,Integer enable){ public ResponseResult<?> updateTypeEnableById(String typeId,Integer enable){
Long tid=null; Long tid=null;
if (StringUtils.hasText(typeId)){ if (StringUtils.hasText(typeId)){
tid = Long.parseLong(typeId); tid = Long.parseLong(typeId);
} }
Boolean updateEnableById = noticeTypeService.updateTypeEnableById(tid, enable); Boolean updateEnableById = noticeTypeService.updateTypeEnableById(tid, enable);
String msg = updateEnableById ? "" : "修改失败,请重试!"; String msg = updateEnableById ? "" : "修改失败,请重试!";
return ResponseResult.build(updateEnableById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, updateEnableById); return ResponseResult.build(updateEnableById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
} }
//添加公告类型 //添加公告类型
@@ -67,4 +67,20 @@ public class NoticeTypeController {
String msg = insertNotice ? "" : "数据添加失败,请重试!"; String msg = insertNotice ? "" : "数据添加失败,请重试!";
return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, insertNotice); return ResponseResult.build(insertNotice ? ResponseCode.DATABASE_SAVE_OK : ResponseCode.DATABASE_SAVE_ERROR, msg, insertNotice);
} }
//修改公告类型
@PutMapping
public ResponseResult<?> updateNoticeType(@RequestBody NoticeType noticeType){
boolean updateById =noticeTypeService.updateNoticeType(noticeType);
String msg = updateById ? "" : "数据修改失败,请重试!";
return ResponseResult.build(updateById ? ResponseCode.DATABASE_UPDATE_OK : ResponseCode.DATABASE_UPDATE_ERROR, msg, null);
}
//删除公告类型
@DeleteMapping("/{typeId}")
public ResponseResult<?> deleteNoticeTypeById(@PathVariable Long typeId) {
boolean removeById = noticeTypeService.deleteNoticeTypeById(typeId);
String msg = removeById ? "" : "数据删除失败,请重试!";
return ResponseResult.build(removeById ? ResponseCode.DATABASE_DELETE_OK : ResponseCode.DATABASE_DELETE_ERROR, msg, null);
}
} }

View File

@@ -21,4 +21,9 @@ public interface INoticeTypeService extends IService<NoticeType> {
Boolean addNoticeType(NoticeType noticeType); Boolean addNoticeType(NoticeType noticeType);
Boolean updateNoticeType(NoticeType noticeType);
Boolean deleteNoticeTypeById(Long typeId);
} }

View File

@@ -54,4 +54,14 @@ public class NoticeTypeServiceImpl extends ServiceImpl<NoticeTypeMapper, NoticeT
public Boolean addNoticeType(NoticeType noticeType) { public Boolean addNoticeType(NoticeType noticeType) {
return noticeTypeMapper.insert(noticeType)>0; return noticeTypeMapper.insert(noticeType)>0;
} }
@Override
public Boolean updateNoticeType(NoticeType noticeType) {
return noticeTypeMapper.updateById(noticeType)>0;
}
@Override
public Boolean deleteNoticeTypeById(Long typeId) {
return noticeTypeMapper.deleteById(typeId)>0;
}
} }

View File

@@ -1,113 +1,123 @@
<template> <template>
<el-form :model="addData" :rules="rules" ref="addData" label-width="150px"> <el-scrollbar max-height="60vh">
<el-form-item label="公告标题" prop="title"> <el-form :model="addData" :rules="this.myRule" ref="addData" label-width="150px">
<el-input v-model="addData.title"></el-input> <el-form-item label="公告标题" prop="title">
</el-form-item> <el-input v-model="addData.title"></el-input>
<el-form-item label="公告类型" prop="typeId"> </el-form-item>
<el-select v-model="addData.typeId" filterable placeholder="请选择公告类型"> <el-form-item label="公告类型" prop="typeId">
<el-option <el-select v-model="addData.typeId" filterable placeholder="请选择公告类型">
v-for="item in enableNoticeTypeList" <el-option
:key="item.id" v-for="item in enableNoticeTypeList"
:label="item.name" :key="item.id"
:value="item.id" :label="item.name"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-row>
<el-form-item label="生效时间" required>
<el-col>
<el-form-item prop="sendTime">
<el-date-picker
type="datetime"
placeholder="选择生效日期"
v-model="addData.sendTime"
style="width: 100%"
size="large"
></el-date-picker>
</el-form-item>
</el-col>
</el-form-item>
<el-col :span="2"></el-col>
<el-form-item label="失效时间" required>
<el-col>
<el-form-item prop="endTime">
<el-date-picker
type="datetime"
placeholder="选择失效日期"
v-model="addData.endTime"
style="width: 100%"
size="large"
></el-date-picker>
</el-form-item>
</el-col>
</el-form-item>
</el-row>
<el-form-item label="是否置顶" prop="top">
<el-switch
v-model="addData.top"
inline-prompt
active-text=""
inactive-text=""
:active-value="1"
:inactive-value="0"
/>
</el-form-item>
<el-form-item label="公告优先级" prop="priority">
<el-slider
v-model="addData.priority"
show-input
show-stops
:max="15"
size="large"
/>
</el-form-item>
<el-form-item label="是否仅自己可见:">
<el-switch v-model="visible" inline-prompt active-text="是" inactive-text="否" />
</el-form-item>
<el-form-item label="发送至:" prop="receivers" v-show="!visible">
<el-cascader
v-model="addData.receivers"
collapse-tags
clearable
:options="departmentList"
:props="{
multiple: true,
value: 'id',
label: 'name',
children: 'userList'
}"
placeholder="选择公告接收者"
> >
</el-option> <template #default="scope">
</el-select> <span v-if="scope.node.level === 1">{{
</el-form-item> ((scope.node.value = scope.data.id),
<el-row> (scope.node.label = scope.data.name))
<el-form-item label="生效时间" required> }}</span>
<el-col> <span v-if="scope.node.level === 2">{{
<el-form-item prop="sendTime"> ((scope.node.value = scope.data.id),
<el-date-picker (scope.node.label = scope.data.username))
type="datetime" }}</span>
placeholder="选择生效日期" </template>
v-model="addData.sendTime" </el-cascader>
style="width: 100%"
size="large"
></el-date-picker>
</el-form-item>
</el-col>
</el-form-item> </el-form-item>
<el-col :span="2"></el-col> <el-form-item label="公告内容" prop="content">
<el-form-item label="失效时间" required> <el-input type="textarea" v-model="addData.content"></el-input>
<el-col>
<el-form-item prop="endTime">
<el-date-picker
type="datetime"
placeholder="选择失效日期"
v-model="addData.endTime"
style="width: 100%"
size="large"
></el-date-picker>
</el-form-item>
</el-col>
</el-form-item> </el-form-item>
</el-row> <el-form-item>
<el-form-item label="是否置顶" prop="top"> <el-button type="primary" @click="submitForm">发布</el-button>
<el-switch <el-button type="primary" @click="closeForm">取消</el-button>
v-model="addData.top" <el-button @click="resetForm()">重置</el-button>
inline-prompt </el-form-item>
active-text="" </el-form>
inactive-text="" </el-scrollbar>
:active-value="1"
:inactive-value="0"
/>
</el-form-item>
<el-form-item label="公告优先级" prop="priority">
<el-slider v-model="addData.priority" show-input show-stops :max="15" size="large" />
</el-form-item>
<el-form-item label="是否仅自己可见:">
<el-switch v-model="visible" inline-prompt active-text="是" inactive-text="否" />
</el-form-item>
<el-form-item label="发送至:" prop="receivers" v-show="!visible">
<el-cascader
v-model="addData.receivers"
collapse-tags
clearable
:options="departmentList"
:props="{
multiple: true,
value: 'id',
label: 'name',
children: 'userList'
}"
placeholder="选择公告接收者"
>
<template #default="scope">
<span v-if="scope.node.level === 1">{{
((scope.node.value = scope.data.id), (scope.node.label = scope.data.name))
}}</span>
<span v-if="scope.node.level === 2">{{
((scope.node.value = scope.data.id),
(scope.node.label = scope.data.username))
}}</span>
</template>
</el-cascader>
</el-form-item>
<el-form-item label="公告内容" prop="content">
<el-input type="textarea" v-model="addData.content"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm">发布</el-button>
<el-button type="primary" @click="closeForm">取消</el-button>
<el-button @click="resetForm()">重置</el-button>
</el-form-item>
</el-form>
</template> </template>
<script lang="js"> <script lang="ts">
import { useNoticeStore, useNoticeTypeStore } from '@/store/notice' import { useNoticeStore, useNoticeTypeStore } from '@/store/notice'
import { mapState } from 'pinia' import { mapState } from 'pinia'
const noticeStore = useNoticeStore() const noticeStore = useNoticeStore()
export default { export default {
computed:{ computed: {
...mapState(useNoticeStore,['departmentList','noticeShowData']), ...mapState(useNoticeStore, ['departmentList', 'noticeShowData']),
...mapState(useNoticeTypeStore,['enableNoticeTypeList']) ...mapState(useNoticeTypeStore, ['enableNoticeTypeList'])
}, },
data() { data() {
return { return {
visible:false, visible: false,
rightClickVisible:false, rightClickVisible: false,
addData: { addData: {
title: '', title: '',
typeId: '', typeId: '',
@@ -116,70 +126,70 @@ export default {
top: 0, top: 0,
priority: 1, priority: 1,
content: '', content: '',
receivers:[] receivers: []
}, },
rules: { myRule: {
title: [ title: [
{ required: true, message: '请输入公告标题', trigger: 'blur' }, { required: true, message: '请输入公告标题', trigger: 'blur' },
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' } { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
], ],
typeId: [ typeId: [{ required: true, message: '请选择公告类型', trigger: 'change' }],
{ required: true, message: '请选择公告类型', trigger: 'change' }
],
sendTime: [ sendTime: [
{ type: 'date', required: true, message: '请选择生效时间', trigger: 'change' } { type: 'date', required: true, message: '请选择生效时间', trigger: 'change' }
], ],
endTime: [ endTime: [
{ type: 'date', required: true, message: '请选择失效时间', trigger: 'change' } { type: 'date', required: true, message: '请选择失效时间', trigger: 'change' }
], ],
content: [ content: [{ required: true, message: '请填写公告内容', trigger: 'blur' }],
{ required: true, message: '请填写公告内容', trigger: 'blur' }
],
receivers: [ receivers: [
{ type:'array',required: true, message: '请选择公告接收者', trigger: 'change' } {
type: 'array',
required: true,
message: '请选择公告接收者',
trigger: 'change'
}
] ]
} }
} }
}, },
methods: { methods: {
submitForm() { submitForm() {
const receiveId=[] const receiveId = []
if (this.addData.receivers.length!=null){ if (this.addData.receivers.length != null) {
for (let i = 0; i < this.addData.receivers.length; i++) { for (let i = 0; i < this.addData.receivers.length; i++) {
receiveId.push(this.addData.receivers[i][1]) receiveId.push(this.addData.receivers[i][1])
} }
} }
this.addData.receivers=receiveId this.addData.receivers = receiveId
this.$refs.addData.validate((valid) => { this.$refs.addData.validate((valid) => {
if (valid) { if (valid) {
if (noticeStore.editFlag===true){ if (noticeStore.editFlag === true) {
// 编辑操作 // 编辑操作
noticeStore.handleUpdateNotice(this.addData) noticeStore.handleUpdateNotice(this.addData)
}else { } else {
// 添加操作 // 添加操作
noticeStore.handleAddNotice(this.addData) noticeStore.handleAddNotice(this.addData)
} }
} else { } else {
return false; return false
} }
}); })
}, },
closeForm(){ closeForm() {
noticeStore.$patch(state=>{ noticeStore.$patch((state) => {
state.dialogAddVisible=false state.dialogAddVisible = false
state.dialogEditVisible=false state.dialogEditVisible = false
state.hackReset=false state.hackReset = false
state.editFlag=false state.editFlag = false
}) })
}, },
resetForm() { resetForm() {
this.$refs.addData.resetFields(); this.$refs.addData.resetFields()
} }
}, },
created() { created() {
// 编辑操作 // 编辑操作
if (noticeStore.editFlag===true) { if (noticeStore.editFlag === true) {
this.addData = noticeStore.noticeShowData this.addData = noticeStore.noticeShowData
} }
}, },
@@ -192,15 +202,19 @@ export default {
.el-button { .el-button {
margin: 0 auto; margin: 0 auto;
} }
.el-button--text { .el-button--text {
margin-right: 15px; margin-right: 15px;
} }
.el-select { .el-select {
width: 300px; width: 300px;
} }
.el-input { .el-input {
width: 300px; width: 300px;
} }
.el-slider { .el-slider {
margin-left: 20px; margin-left: 20px;
} }

View File

@@ -38,7 +38,7 @@
<el-button size="default" type="primary" @click="handleOpenEditDialog(scope.row)" <el-button size="default" type="primary" @click="handleOpenEditDialog(scope.row)"
>编辑</el-button >编辑</el-button
> >
<el-button size="default" type="danger" @click="handleDeleteById(scope.row)" <el-button size="default" type="danger" @click="deleteTypeById(scope.row.id)"
>删除</el-button >删除</el-button
> >
</template> </template>
@@ -89,6 +89,7 @@ const noticeStore = useNoticeStore()
const noticeTypeStore = useNoticeTypeStore() const noticeTypeStore = useNoticeTypeStore()
export default { export default {
emits: ['deleteTypeById'],
computed: { computed: {
...mapState(useNoticeTypeStore, [ ...mapState(useNoticeTypeStore, [
'total', 'total',
@@ -124,14 +125,15 @@ export default {
handleOpenEditDialog(row) { handleOpenEditDialog(row) {
noticeTypeStore.$patch((state) => { noticeTypeStore.$patch((state) => {
state.hackReset = true state.hackReset = true
state.showTypeData.id = row.id
state.showTypeData.name = row.name state.showTypeData.name = row.name
state.showTypeData.enable = row.enable state.showTypeData.enable = row.enable
state.editFlag = true state.editFlag = true
state.dialogEditTypeVisible = true state.dialogEditTypeVisible = true
}) })
}, },
handleDeleteById(deleteId) { deleteTypeById(deleteId) {
this.$emit('handleDeleteById', deleteId) this.$emit('deleteTypeById', deleteId)
}, },
handleSizeChange(pageSize) { handleSizeChange(pageSize) {
// pageSize每页多少条数据 // pageSize每页多少条数据
@@ -144,7 +146,7 @@ export default {
submitEditForm() { submitEditForm() {
this.$refs.editForm.$refs.addTypeData.validate((valid) => { this.$refs.editForm.$refs.addTypeData.validate((valid) => {
if (valid) { if (valid) {
// noticeTypeStore.handleUpdateNoticeType(this.addTypeData) noticeTypeStore.handleUpdateNoticeType(this.addTypeData)
} else { } else {
return false return false
} }

View File

@@ -40,7 +40,7 @@
</el-dialog> </el-dialog>
</el-header> </el-header>
<el-main> <el-main>
<notice-type-table /> <notice-type-table @deleteTypeById="deleteTypeById" />
</el-main> </el-main>
</el-container> </el-container>
</template> </template>
@@ -48,6 +48,8 @@
import { SIZE_ICON_MD } from '@/constants/Common.constants' import { SIZE_ICON_MD } from '@/constants/Common.constants'
import { useNoticeTypeStore } from '@/store/notice' import { useNoticeTypeStore } from '@/store/notice'
import { mapState } from 'pinia' import { mapState } from 'pinia'
import { ElMessage, ElMessageBox } from 'element-plus'
import request from '@/services'
const noticeTypeStore = useNoticeTypeStore() const noticeTypeStore = useNoticeTypeStore()
@@ -99,6 +101,30 @@ export default {
}, },
resetForm() { resetForm() {
this.$refs.addForm.$refs.addTypeData.resetFields() this.$refs.addForm.$refs.addTypeData.resetFields()
},
deleteTypeById(typeId) {
ElMessageBox.confirm('确定是否要删除?该操作将无法回退', '警告', {
confirmButtonText: '确定',
cancelButtonText: '我再想想',
type: 'warning'
})
.then(() => {
request.delete('/notice_type/' + typeId).then((response) => {
if (response.data.code === 20024) {
ElMessage({
message: '删除成功.',
type: 'success'
})
noticeTypeStore.selectNoticeType()
} else if (response.data.code === 20034) {
ElMessage({
message: response.data.msg,
type: 'error'
})
}
})
})
.catch(() => {})
} }
}, },
mounted() {} mounted() {}

View File

@@ -5,9 +5,9 @@
</el-header> </el-header>
<el-main> <el-main>
<el-menu :default-active="$route.path" class="el-menu-demo" mode="horizontal" router> <el-menu :default-active="$route.path" class="el-menu-demo" mode="horizontal" router>
<el-menu-item index="/notice/noticeView/all">所有公告</el-menu-item> <el-menu-item index="/notice/view/all">所有公告</el-menu-item>
<el-menu-item index="/notice/noticeView/toRead">未读</el-menu-item> <el-menu-item index="/notice/view/toRead">未读</el-menu-item>
<el-menu-item index="/notice/noticeView/alRead">已读</el-menu-item> <el-menu-item index="/notice/view/alRead">已读</el-menu-item>
</el-menu> </el-menu>
<router-view /> <router-view />
</el-main> </el-main>

View File

@@ -4,30 +4,17 @@ const noticeRouter = {
meta: { meta: {
title: '公告', title: '公告',
icon: shallowRef(IconPinnacleNotice), icon: shallowRef(IconPinnacleNotice),
requiresMenu: true,
requiresScrollbar: false, requiresScrollbar: false,
requiresPadding: true requiresPadding: true
}, },
children: [ children: [
{ {
path: 'noticeManage', path: 'view',
component: async () => await import('@/pages/notice/NoticeManage.vue'),
name: 'noticeManage',
meta: {
title: '公告管理',
requiresMenu: true,
requiresScrollbar: false,
requiresPadding: true
}
},
{
path: 'noticeView',
component: async () => await import('@/pages/notice/NoticeView.vue'), component: async () => await import('@/pages/notice/NoticeView.vue'),
name: 'noticeView', name: 'noticeView',
redirect: '/notice/noticeView/all', redirect: '/notice/view/all',
meta: { meta: {
title: '公告查看', title: '公告查看',
requiresMenu: true,
requiresScrollbar: false, requiresScrollbar: false,
requiresPadding: true requiresPadding: true
}, },
@@ -50,12 +37,21 @@ const noticeRouter = {
] ]
}, },
{ {
path: 'noticeTypeManage', path: 'manage',
component: async () => await import('@/pages/notice/NoticeManage.vue'),
name: 'noticeManage',
meta: {
title: '公告管理',
requiresScrollbar: false,
requiresPadding: true
}
},
{
path: 'typeManage',
component: async () => await import('@/pages/notice/NoticeTypeManage.vue'), component: async () => await import('@/pages/notice/NoticeTypeManage.vue'),
name: 'noticeTypeManage', name: 'noticeTypeManage',
meta: { meta: {
title: '公告类型管理', title: '公告类型管理',
requiresMenu: true,
requiresScrollbar: false, requiresScrollbar: false,
requiresPadding: true requiresPadding: true
} }

View File

@@ -13,6 +13,7 @@ export interface IAddNoticeData {
receivers: [] receivers: []
} }
export interface IAddNoticeTypeData { export interface IAddNoticeTypeData {
id: string
name: string name: string
enable: number enable: number
} }
@@ -238,10 +239,12 @@ export const useNoticeTypeStore = defineStore('notice_type', {
} }
], ],
addTypeData: { addTypeData: {
id: '',
name: '', name: '',
enable: 1 enable: 1
}, },
showTypeData: { showTypeData: {
id: '',
name: '', name: '',
enable: 1 enable: 1
} }
@@ -309,6 +312,12 @@ export const useNoticeTypeStore = defineStore('notice_type', {
if (response.data.code === 20023) { if (response.data.code === 20023) {
this.dialogEditTypeVisible = false this.dialogEditTypeVisible = false
this.editFlag = false this.editFlag = false
this.hackReset = false
this.addTypeData = {
id: '',
name: '',
enable: 1
}
ElMessage({ ElMessage({
message: '修改成功.', message: '修改成功.',
type: 'success' type: 'success'