mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-06 07:21:24 +08:00
use pinia to modify notice add,delete,select function
This commit is contained in:
@@ -15,17 +15,11 @@
|
||||
<template #header>
|
||||
<h2 style="color: red">发布公告</h2>
|
||||
</template>
|
||||
<commitForm
|
||||
:noticeTypeList="this.noticeTypeList"
|
||||
:departmentList="this.departmentList"
|
||||
@handleAddNotice="handleAddNotice"
|
||||
></commitForm>
|
||||
<commitForm />
|
||||
</el-dialog>
|
||||
<notice-manage-table
|
||||
:noticeTypeList="noticeTypeList"
|
||||
:departmentList="departmentList"
|
||||
:dialogUpdateVisible="dialogUpdateVisible"
|
||||
@handleDelete="handleDelete"
|
||||
@handleDeleteById="handleDeleteById"
|
||||
@clearFilter="clearFilter"
|
||||
@handleUpdateNotice="handleUpdateNotice"
|
||||
></notice-manage-table>
|
||||
@@ -38,21 +32,21 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import 'element-plus/theme-chalk/el-message.css'
|
||||
import 'element-plus/theme-chalk/el-message-box.css'
|
||||
import request from '@/services'
|
||||
import { useNoticeStore } from '@/store/notice'
|
||||
import { mapState } from 'pinia'
|
||||
const noticeStore = useNoticeStore()
|
||||
|
||||
export default {
|
||||
name: 'NoticeHome',
|
||||
data() {
|
||||
return {
|
||||
noticeTypeList: [],
|
||||
dialogAddVisible: false,
|
||||
dialogUpdateVisible: false,
|
||||
departmentList: []
|
||||
dialogUpdateVisible: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
selectByCond(search) {
|
||||
request
|
||||
.get('http://localhost:8621/notice', {
|
||||
.get('/notice', {
|
||||
title: search.title,
|
||||
type: search.type,
|
||||
startTime: search.startTime,
|
||||
@@ -60,7 +54,7 @@ export default {
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.data.code === 20021) {
|
||||
// this.selectData = response.data.data
|
||||
noticeStore.selectData = response.data.data
|
||||
ElMessage({
|
||||
message: '查询成功.',
|
||||
type: 'success'
|
||||
@@ -73,20 +67,20 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDelete(deleteID) {
|
||||
handleDeleteById(deleteID) {
|
||||
ElMessageBox.confirm('确定是否要删除?该操作将无法回退', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '我再想想',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
request.delete('http://localhost:8621/notice/' + deleteID).then((response) => {
|
||||
request.delete('/notice/' + deleteID).then((response) => {
|
||||
if (response.data.code === 20024) {
|
||||
this.dialogAddVisible = false
|
||||
ElMessage({
|
||||
message: '删除成功.',
|
||||
type: 'success'
|
||||
})
|
||||
noticeStore.selectAllNotice()
|
||||
} else if (response.data.code === 20034) {
|
||||
ElMessage({
|
||||
message: response.data.msg,
|
||||
@@ -94,44 +88,16 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
this.$router.go(0)
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
selectNoticeType() {
|
||||
request.get('http://localhost:8621/noticeType').then((response) => {
|
||||
this.noticeTypeList = response.data.data
|
||||
})
|
||||
},
|
||||
selectDepartment() {
|
||||
request.get('http://localhost:8621/department').then((response) => {
|
||||
this.departmentList = response.data.data
|
||||
})
|
||||
},
|
||||
openAddNoticeDialog() {
|
||||
this.dialogAddVisible = true
|
||||
this.selectNoticeType()
|
||||
this.selectDepartment()
|
||||
},
|
||||
handleAddNotice(addFormData) {
|
||||
request.post('http://localhost:8621/notice', addFormData).then((response) => {
|
||||
if (response.data.code === 20022) {
|
||||
this.dialogAddVisible = false
|
||||
ElMessage({
|
||||
message: '发布成功.',
|
||||
type: 'success'
|
||||
})
|
||||
} else if (response.data.code === 20032) {
|
||||
ElMessage({
|
||||
message: response.data.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
noticeStore.$patch((state) => {
|
||||
state.dialogAddVisible = true
|
||||
})
|
||||
this.$router.go(0)
|
||||
},
|
||||
handleUpdateNotice(updateNotice) {
|
||||
request.put('http://localhost:8621/notice', updateNotice).then((response) => {
|
||||
request.put('/notice', updateNotice).then((response) => {
|
||||
if (response.data.code === 20023) {
|
||||
this.dialogUpdateVisible = false
|
||||
ElMessage({
|
||||
@@ -153,7 +119,12 @@ export default {
|
||||
this.$router.go(0)
|
||||
}
|
||||
},
|
||||
mounted() {}
|
||||
mounted() {
|
||||
noticeStore.selectNoticeType()
|
||||
},
|
||||
computed: {
|
||||
...mapState(useNoticeStore, ['dialogAddVisible'])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user