zhouwx
6 天以前 79f2fd7d49d3316278c2a33aa5d0fc14a1fddf7f
src/views/build/conpanyFunctionConsult/companyInfo/policy/components/policyDialog.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 == '查看' || 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.policy" ></t-editor>
        </el-form-item>
@@ -40,6 +61,7 @@
import {addCom, editCom} from "@/api/companyInfo/overview";
import Cookies from "js-cookie";
import {addPolicy, editPolicy} from "@/api/companyInfo/policy";
import {getCompany} from "@/api/onlineEducation/company";
const emit = defineEmits(["getList"]);
@@ -59,8 +81,11 @@
    companyName: ''
  },
  formRules:{
    companyName: [{ required: true, message: '请选择企业', trigger: 'blur' }],
    policy: [{ required: true, message: '质量方针', trigger: 'blur' }],
  },
  isAdmin: false,
  companyList: []
})
@@ -68,13 +93,21 @@
});
const openDialog = async (type, value) => {
  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') {
    state.noticeForm.policy = value.policy
    state.noticeForm.id = value.id
    if(state.isAdmin){
      state.noticeForm.companyId = value.companyId
      state.noticeForm.companyName = value.companyName
    }
  }
  if(type === 'review') {
    showEditor.value = false
@@ -128,10 +161,12 @@
}
const onSubmit = async () => {
  state.noticeForm.policy = 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
  }
  // // myEditor.value.submit();
  const valid = await noticeRef.value.validate();
  if(valid){
@@ -198,6 +233,38 @@
    companyName: ''
  }
}
const selectValue = (val) => {
  state.companyList.forEach(item => {
    if(item.name === val){
      state.noticeForm.companyId = item.id
    }
  })
}
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)
    }
  }
}
defineExpose({
  openDialog