| | |
| | | :before-close="handleClose" |
| | | > |
| | | <el-form :model="state.noticeForm" size="default" ref="noticeRef" :rules="title === '新增' || title === '编辑' ? state.formRules : {}" label-width="110px" > |
| | | <el-form-item label="企业名称:" prop="companyName" v-if="state.isAdmin"> |
| | | <el-select |
| | | v-model="state.noticeForm.companyName" |
| | | filterable |
| | | remote |
| | | :disabled="title == '查看' || title == '编辑' || !state.isAdmin" |
| | | @change="selectValue" |
| | | reserve-keyword |
| | | placeholder="请输入企业名称" |
| | | remote-show-suffix |
| | | :remote-method="getCompanyList" |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="item in state.companyList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.name" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="企业概括:" v-if="showEditor" required> |
| | | <t-editor style="width: 800px" ref="myEditor" :value="state.noticeForm.noticeContent" ></t-editor> |
| | | <t-editor style="width: 800px" ref="myEditor" :value="state.noticeForm.companySummary" ></t-editor> |
| | | </el-form-item> |
| | | <el-form-item label="公告内容:" v-else> |
| | | <el-form-item label="企业概括:" v-else> |
| | | <div class="ql-container ql-snow" style="height: 500px;width: 100%;margin-top: 10px;" > |
| | | <div class="ql-editor"> |
| | | <div class="reviewTable" v-html="state.noticeForm.noticeContent" @click="showFile($event)"></div> |
| | | <div class="reviewTable" v-html="state.noticeForm.companySummary" @click="showFile($event)"></div> |
| | | </div> |
| | | </div> |
| | | </el-form-item> |
| | |
| | | </div> |
| | | </template> |
| | | <script setup> |
| | | import {nextTick, reactive, ref, toRefs, watch} from 'vue' |
| | | import {nextTick, onMounted, reactive, ref, toRefs, watch} from 'vue' |
| | | import WeEditor from "@/components/WeEditor/index.vue"; |
| | | import TEditor from "@/components/Tinymce/Tinymce.vue" |
| | | import {ElMessage} from "element-plus"; |
| | |
| | | import {getToken} from "@/utils/auth"; |
| | | import {handleThemeStyle} from "@/utils/theme"; |
| | | import useSettingsStore from "@/store/modules/settings"; |
| | | import {addCom, editCom} from "@/api/companyInfo/overview"; |
| | | import Cookies from "js-cookie"; |
| | | import {getCompany} from "@/api/onlineEducation/company"; |
| | | |
| | | |
| | | const emit = defineEmits(["getList"]); |
| | |
| | | const state = reactive({ |
| | | noticeForm: { |
| | | id: '', |
| | | noticeTitle: '', |
| | | noticeContent: '', |
| | | companySummary: '', |
| | | companyId:null, |
| | | companyName: '' |
| | | }, |
| | | formRules:{ |
| | | // noticeContent: [{ required: true, message: '请输入公告内容', trigger: 'blur' }], |
| | | companyName: [{ required: true, message: '请选择企业', trigger: 'blur' }], |
| | | companySummary: [{ required: true, message: '企业概况', trigger: 'blur' }], |
| | | }, |
| | | isAdmin: false, |
| | | companyList: [] |
| | | |
| | | }) |
| | | |
| | | onMounted(() => { |
| | | }); |
| | | const openDialog = async (type, value) => { |
| | | dialogVisible.value = true; |
| | | // state.noticeForm.noticeContent = "" |
| | | |
| | | const userInfo = JSON.parse(Cookies.get('userInfo')) |
| | | state.isAdmin = userInfo.userType === 0; |
| | | if(state.isAdmin){ |
| | | await getCompanyList() |
| | | } |
| | | isReview.value = false; |
| | | showEditor.value = false |
| | | title.value = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' ; |
| | | 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) |
| | | // } |
| | | |
| | | state.noticeForm.companySummary = value.companySummary |
| | | state.noticeForm.id = value.id |
| | | if(state.isAdmin){ |
| | | state.noticeForm.companyId = value.companyId |
| | | state.noticeForm.companyName = value.companyName |
| | | } |
| | | } |
| | | if(type === 'review') { |
| | | showEditor.value = false |
| | |
| | | if(type === 'add'){ |
| | | reset() |
| | | } |
| | | |
| | | |
| | | dialogVisible.value = true; |
| | | } |
| | | const getEditorData = (val) =>{ |
| | | state.noticeForm.noticeContent = val; |
| | | state.noticeForm.companySummary = val; |
| | | } |
| | | |
| | | const showFile = (e) => { |
| | |
| | | }) |
| | | } |
| | | } |
| | | const getCompanyList = async (val)=>{ |
| | | if(val){ |
| | | const queryParams = { |
| | | name: val |
| | | } |
| | | const res = await getCompany(queryParams) |
| | | if (res.code == 200) { |
| | | state.companyList = res.data.list |
| | | |
| | | } else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }else { |
| | | const queryParams = { |
| | | pageSize: 10, |
| | | pageNum: 1, |
| | | } |
| | | const res = await getCompany(queryParams) |
| | | if (res.code == 200) { |
| | | state.companyList = res.data.list |
| | | } else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | } |
| | | |
| | | const onSubmit = async () => { |
| | | state.noticeForm.noticeContent = tinyMCE.activeEditor.getContent(); |
| | | console.log("点击提交") |
| | | console.log('data',state.noticeForm.noticeContent) |
| | | state.noticeForm.companySummary = tinyMCE.activeEditor.getContent(); |
| | | if(!state.isAdmin){ |
| | | const userInfo = JSON.parse(Cookies.get('userInfo')) |
| | | state.noticeForm.companyId = userInfo.companyId |
| | | state.noticeForm.companyName = userInfo.companyName |
| | | } |
| | | // // myEditor.value.submit(); |
| | | const valid = await noticeRef.value.validate(); |
| | | if(valid){ |
| | | |
| | | if(state.noticeForm.noticeContent == "") { |
| | | if(state.noticeForm.companySummary == "") { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '请输入公司概况' |
| | | message: '请输入企业概况' |
| | | }); |
| | | return; |
| | | } |
| | | if(title.value === '新增'){ |
| | | const param = { |
| | | content: state.noticeForm.noticeContent, |
| | | } |
| | | const res = await addNotice(param) |
| | | const {id,...data} = JSON.parse(JSON.stringify(state.noticeForm)) |
| | | const res = await addCom(data) |
| | | if(res.code === 200){ |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | noticeRef.value.clearValidate(); |
| | | dialogVisible.value = false; |
| | | }else if(title.value === '编辑') { |
| | | const param = { |
| | | id: state.noticeForm.id, |
| | | content: state.noticeForm.noticeContent, |
| | | } |
| | | const res = await editNotice(param) |
| | | const {...data} = JSON.parse(JSON.stringify(state.noticeForm)) |
| | | const res = await editCom(data) |
| | | if(res.code === 200){ |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | } |
| | | } |
| | | |
| | | const selectValue = (val) => { |
| | | state.companyList.forEach(item => { |
| | | if(item.name === val){ |
| | | state.noticeForm.companyId = item.id |
| | | } |
| | | }) |
| | | } |
| | | const handleClose = () => { |
| | | if(title.value ==="新增"|| title.value ==='编辑'){ |
| | | myEditor.value.clear(); |
| | |
| | | } |
| | | |
| | | // reset() |
| | | state.companyList = [] |
| | | noticeRef.value.clearValidate(); |
| | | dialogVisible.value = false; |
| | | } |
| | | const reset = () => { |
| | | state.noticeForm = { |
| | | id: '', |
| | | noticeTitle: '', |
| | | noticeContent: '' |
| | | id: '', |
| | | companySummary: '', |
| | | companyId:null, |
| | | companyName: '' |
| | | } |
| | | } |
| | | |