| | |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item v-if="!isReview" style="margin-left: -80px" prop="noticeContent"> |
| | | <!-- <tinymce v-model="state.noticeForm.noticeContent"></tinymce>--> |
| | | <editor ref="myQuillEditor" v-model="state.noticeForm.noticeContent" :height="300"></editor> |
| | | |
| | | </el-form-item> |
| | | <el-form-item label="公告内容:" v-else> |
| | | <div class="ql-container ql-snow" style="height: 300px;width: 100%;margin-top: 10px;" > |
| | |
| | | import {reactive, ref, toRefs} from 'vue' |
| | | import Editor from "@/components/Editor/index.vue"; |
| | | import {ElMessage} from "element-plus"; |
| | | import {addNotice, editNotice, getNoticeDetail} from "@/api/backManage/notice"; |
| | | const emit = defineEmits(["getList"]); |
| | | |
| | | const dialogVisible = ref(false); |
| | | const title = ref(""); |
| | |
| | | const isReview = ref(false); |
| | | const state = reactive({ |
| | | noticeForm: { |
| | | id: '', |
| | | noticeTitle: '', |
| | | noticeContent: '', |
| | | fileList: [] |
| | | }, |
| | | formRules:{ |
| | | noticeTitle: [{ required: true, message: '请填写公告标题', trigger: 'blur' }], |
| | | noticeContent: [{ required: true, message: '请输入公告内容', trigger: 'change' }], |
| | | noticeContent: [{ required: true, message: '请输入公告内容', trigger: 'blur' }], |
| | | }, |
| | | |
| | | }) |
| | | |
| | | const openDialog = (type, value) => { |
| | | const openDialog = async (type, value) => { |
| | | isReview.value = false; |
| | | title.value = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' ; |
| | | if(type === 'edit') { |
| | | state.noticeForm = value; |
| | | if(type === 'edit' || type === 'review') { |
| | | const param = { |
| | | noticeId: value.id |
| | | } |
| | | const res = await getNoticeDetail(param); |
| | | if(res.code === 200){ |
| | | state.noticeForm.id = res.data.id |
| | | state.noticeForm.noticeTitle = res.data.title |
| | | state.noticeForm.noticeContent = res.data.content |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | if(type === 'review') { |
| | | isReview.value = true; |
| | | state.noticeForm = value; |
| | | } |
| | | if(type === 'add'){ |
| | | reset() |
| | | } |
| | | dialogVisible.value = true; |
| | | } |
| | |
| | | }); |
| | | return; |
| | | } |
| | | console.log('file, fileList',state.noticeForm.noticeContent); |
| | | noticeRef.value.clearValidate(); |
| | | reset(); |
| | | dialogVisible.value = false; |
| | | |
| | | if(title.value === '新增'){ |
| | | const param = { |
| | | content: state.noticeForm.noticeContent, |
| | | title: state.noticeForm.noticeTitle |
| | | } |
| | | const res = await addNotice(param) |
| | | if(res.code === 200){ |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '新增成功' |
| | | }); |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | emit("getList") |
| | | reset(); |
| | | noticeRef.value.clearValidate(); |
| | | dialogVisible.value = false; |
| | | }else if(title.value === '编辑') { |
| | | const nowDate = new Date() |
| | | const param = { |
| | | id: state.noticeForm.id, |
| | | content: state.noticeForm.noticeContent, |
| | | title: state.noticeForm.noticeTitle |
| | | } |
| | | const res = await editNotice(param) |
| | | if(res.code === 200){ |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '编辑成功' |
| | | }); |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | emit("getList") |
| | | reset(); |
| | | noticeRef.value.clearValidate(); |
| | | dialogVisible.value = false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | const handleClose = () => { |
| | | noticeRef.value.clearValidate(); |
| | | reset(); |
| | | dialogVisible.value = false; |
| | | |
| | | } |
| | | const reset = () => { |
| | | state.noticeForm = { |
| | | id: '', |
| | | noticeTitle: '', |
| | | noticeContent: '' |
| | | } |