fix:修改公告内容

This commit is contained in:
lixg
2022-12-19 21:44:20 +08:00
parent 23f3d134c5
commit 360b068a1b
4 changed files with 57 additions and 32 deletions

View File

@@ -12,9 +12,9 @@
<div class="itemtime">{{ item.pubtime }}</div> <div class="itemtime">{{ item.pubtime }}</div>
</div> </div>
</div> </div>
</template>s </template>
<script> <script>
import { reactive, toRefs, onMounted } from "vue"; import { reactive, toRefs, onMounted, watch } from "vue";
import { getTask } from "../../api/indexTaskadd"; import { getTask } from "../../api/indexTaskadd";
import { noticeList } from "../../api/indexNotice"; import { noticeList } from "../../api/indexNotice";
import emitter from "../../utils/bus"; import emitter from "../../utils/bus";
@@ -26,6 +26,10 @@ export default {
type: Number, type: Number,
default: null, default: null,
}, },
show: {
type: String,
default: null,
},
}, },
setup(props) { setup(props) {
@@ -89,6 +93,19 @@ export default {
getTaskInfo(); getTaskInfo();
getNotice(); getNotice();
}); });
watch(
() => props.show,
() => {
console.log("props.show", props.show);
if (props.show == 12) {
getTaskInfo();
getNotice();
}
},
{
deep: true,
}
);
return { return {
...toRefs(state), ...toRefs(state),
getTaskInfo, getTaskInfo,

View File

@@ -4,11 +4,11 @@
<div class="noticeTitle"> <div class="noticeTitle">
<!-- <div class="notitle"><span class="titlespan">公告</span></div> --> <!-- <div class="notitle"><span class="titlespan">公告</span></div> -->
<div class="switch"> <div class="switch">
<a-switch v-model:checked="noticeChecked" @click="noticeFlag" size="small" /><span <a-switch
style="margin-left: 16px" v-model:checked="noticeChecked"
> @click="noticeFlag"
开启 size="small"
</span> /><span style="margin-left: 16px"> 开启 </span>
</div> </div>
<template v-if="noticeChecked"> <template v-if="noticeChecked">
<p>当前公告内容</p> <p>当前公告内容</p>
@@ -23,10 +23,8 @@
</template> </template>
<!-- 编辑 --> <!-- 编辑 -->
<template v-if="editOn"> <template v-if="editOn">
<div class="txt-content">
<div class="txt-content"> {{ noticeContent1 ? noticeContent1 : "暂无公告" }}
{{ noticeContent1 ? noticeContent1 : "暂无公告" }}
</div> </div>
<p>编辑新公告</p> <p>编辑新公告</p>
<a-textarea <a-textarea
@@ -74,29 +72,30 @@ export default {
state.projectInfo = res.data.data.projectInfo; state.projectInfo = res.data.data.projectInfo;
state.noticeContent1 = state.projectInfo.notice; state.noticeContent1 = state.projectInfo.notice;
state.noticeContent = state.projectInfo.notice; state.noticeContent = state.projectInfo.notice;
state.noticeChecked = state.projectInfo.noticeFlag==0?false:true; state.noticeChecked = state.projectInfo.noticeFlag == 0 ? false : true;
}); });
console.log("state.noticeChecked",state.noticeChecked); console.log("state.noticeChecked", state.noticeChecked);
}; };
const handleEdit = () => { const handleEdit = () => {
state.editOn = true; state.editOn = true;
}; };
const handleCancel = () => { const handleCancel = () => {
state.editOn = false; state.editOn = false;
}; };
const noticeFlag =()=>{ const noticeFlag = () => {
//state.noticeChecked = !state.noticeChecked; //state.noticeChecked = !state.noticeChecked;
console.log("111",state.projectInfo); console.log("111", state.projectInfo);
state.projectInfo.noticeFlag = state.noticeChecked?1:0; state.projectInfo.noticeFlag = state.noticeChecked ? 1 : 0;
editProj(state.projectInfo).then((res)=>{ editProj(state.projectInfo)
console.log("res",res.data.data.projectInfo); .then((res) => {
}).catch((error)=>{ console.log("res5555555555", res);
console.log(error); })
}); .catch((error) => {
console.log("222",state.projectInfo); console.log(error);
} });
console.log("222", state.projectInfo);
};
const pubNotice = () => { const pubNotice = () => {
if (state.noticeContent == "") { if (state.noticeContent == "") {
message.destroy(); message.destroy();
@@ -107,15 +106,22 @@ export default {
projectId: props.projectId, projectId: props.projectId,
title: "", title: "",
}; };
publishNotice(obj);//加入历史 publishNotice(obj); //加入历史
state.projectInfo.notice =state.noticeContent; state.projectInfo.notice = state.noticeContent;
editProj(state.projectInfo).then((res) => { console.log("222444444", state.projectInfo);
state.noticeContent1 =
state.noticeContent == "" ? "暂无公告" : state.noticeContent;
message.success("发布成功");
handleCancel();
editProj(state.projectInfo)
.then((res) => {
// console.log("res"); // console.log("res");
// console.log(res); // console.log(res);
if (res.data.code === 200) { if (res.data.code === 200) {
message.destroy(); message.destroy();
message.success("发布成功", res); message.success("发布成功");
state.noticeContent1 = res.data.data.notice==""?"暂无公告":res.data.data.notice; state.noticeContent1 =
res.data.data.notice == "" ? "暂无公告" : res.data.data.notice;
handleCancel(); handleCancel();
emitter.emit("setNotice", false); emitter.emit("setNotice", false);
} }
@@ -125,8 +131,6 @@ export default {
message.warning("发布失败"); message.warning("发布失败");
console.log(err); console.log(err);
}); });
} }
}; };
onMounted(() => { onMounted(() => {

View File

@@ -203,6 +203,7 @@ function changePagination(page) {
function getStuList() { function getStuList() {
tableData.value.loading = true; tableData.value.loading = true;
getStuPage(tableParam.value).then((res) => { getStuPage(tableParam.value).then((res) => {
console.log("学员管理-获取学员", res.data);
tableData.value.total = res.data.data.total; tableData.value.total = res.data.data.total;
tableData.value.list = res.data.data.records; tableData.value.list = res.data.data.records;
tableData.value.loading = false; tableData.value.loading = false;

View File

@@ -708,7 +708,10 @@
<NoticePub v-model:projectId="projectId"></NoticePub> <NoticePub v-model:projectId="projectId"></NoticePub>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="12" tab="历史公告" force-render> <a-tab-pane key="12" tab="历史公告" force-render>
<NoticeHis v-model:projectId="projectId"></NoticeHis> <NoticeHis
v-model:projectId="projectId"
:show="activeKeyNotice"
></NoticeHis>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</a-tab-pane> </a-tab-pane>