zhouwx
9 天以前 2be66e2a590bc719c6ecdb0bbd0aaa4c9b91fd98
src/views/build/conpanyFunctionConsult/companyInfo/overview/components/overviewDialog.vue
@@ -7,6 +7,27 @@
            :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 == '查看' || !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.companySummary" ></t-editor>
                </el-form-item>
@@ -39,6 +60,7 @@
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"]);
@@ -58,8 +80,11 @@
        companyName: ''
    },
    formRules:{
      companyName: [{ required: true, message: '请选择企业', trigger: 'blur' }],
      companySummary: [{ required: true, message: '企业概况', trigger: 'blur' }],
    },
  isAdmin: false,
  companyList: []
})
@@ -67,13 +92,18 @@
});
const openDialog = async (type, value) => {
    const userInfo = JSON.parse(Cookies.get('userInfo'))
    state.isAdmin = userInfo.userType === 0;
    isReview.value = false;
    showEditor.value = false
    title.value = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' ;
    if(type === 'edit' || type === 'review') {
      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
@@ -125,12 +155,28 @@
        })
    }
}
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)
    }
  }
}
const onSubmit = async () => {
    state.noticeForm.companySummary = tinyMCE.activeEditor.getContent();
    const userInfo = JSON.parse(Cookies.get('userInfo'))
    state.noticeForm.companyId = userInfo.companyId
    state.noticeForm.companyName = userInfo.companyName
    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){
@@ -179,6 +225,13 @@
    }
}
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();
@@ -186,6 +239,7 @@
    }
    // reset()
    state.companyList = []
    noticeRef.value.clearValidate();
    dialogVisible.value = false;
}
@@ -196,6 +250,7 @@
      companyId:null,
      companyName: ''
    }
  state.companyList = []
}
defineExpose({