This commit is contained in:
zhangyc
2022-12-08 08:49:57 +08:00
parent 18ae75da41
commit bfbe1d9550
2 changed files with 82 additions and 84 deletions

View File

@@ -4,14 +4,14 @@
<div class="noticeTitle">
<!-- <div class="notitle"><span class="titlespan">公告</span></div> -->
<div class="switch">
<a-switch v-model:checked="noticeChecked" size="small" /><span
<a-switch v-model:checked="noticeChecked" @click="noticeFlag" size="small" /><span
style="margin-left: 16px"
>
开启
</span>
</div>
<template v-if="noticeChecked">
<p>当前公告内容</p>
<p>当前公告内容</p>
<!-- 预览 -->
<template v-if="!editOn">
<div class="txt-content">
@@ -44,11 +44,11 @@
</template>
</template>
</div>
</template>s
</template>
<script>
import { message } from "ant-design-vue";
import { reactive, toRefs, onMounted } from "vue";
import { getTask } from "../../api/indexTaskadd";
import { editProj, getTask } from "../../api/indexTaskadd";
// import { editProj } from "../../api/indexTaskadd";
import { publishNotice } from "../../api/indexNotice";
import emitter from "../../utils/bus";
@@ -62,7 +62,7 @@ export default {
},
setup(props) {
const state = reactive({
noticeChecked: true,
noticeChecked: false,
projectInfo: {},
noticeContent1: "",
noticeContent: "",
@@ -74,31 +74,42 @@ export default {
state.projectInfo = res.data.data.projectInfo;
state.noticeContent1 = state.projectInfo.notice;
state.noticeContent = state.projectInfo.notice;
state.noticeChecked = state.projectInfo.noticeFlag==0?false:true;
});
console.log("state.noticeChecked",state.noticeChecked);
};
const handleEdit = () => {
state.editOn = true;
};
const handleCancel = () => {
state.editOn = false;
};
const noticeFlag =()=>{
//state.noticeChecked = !state.noticeChecked;
console.log("111",state.projectInfo);
state.projectInfo.noticeFlag = state.noticeChecked?1:0;
editProj(state.projectInfo).then((res)=>{
console.log("res",res.data.data.projectInfo);
}).catch((error)=>{
console.log(error);
});
console.log("222",state.projectInfo);
}
const pubNotice = () => {
if (state.noticeContent == "") {
message.destroy();
return message.warning("请输入公告内容");
} else {
let obj = {
// createId: state.projectInfo.createId,
// createName: state.projectInfo.createName,
notice: state.noticeContent,
// noticeId: 0,
notice: state.noticeContent1,
projectId: props.projectId,
title: "",
};
publishNotice(obj)
.then((res) => {
publishNotice(obj);//加入历史
state.projectInfo.notice =state.noticeContent;
editProj(state.projectInfo).then((res) => {
// console.log("res");
// console.log(res);
if (res.data.code === 200) {
@@ -114,6 +125,8 @@ export default {
message.warning("发布失败");
console.log(err);
});
}
};
onMounted(() => {
@@ -125,6 +138,7 @@ export default {
pubNotice,
handleEdit,
handleCancel,
noticeFlag,
};
},
};