From 79f2fd7d49d3316278c2a33aa5d0fc14a1fddf7f Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: 星期一, 30 六月 2025 09:41:59 +0800
Subject: [PATCH] 修改

---
 src/views/build/conpanyFunctionConsult/companyInfo/basicInfo/components/basicInfoDialog.vue |   92 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/src/views/build/conpanyFunctionConsult/companyInfo/basicInfo/components/basicInfoDialog.vue b/src/views/build/conpanyFunctionConsult/companyInfo/basicInfo/components/basicInfoDialog.vue
index 84bbb10..fd4945d 100644
--- a/src/views/build/conpanyFunctionConsult/companyInfo/basicInfo/components/basicInfoDialog.vue
+++ b/src/views/build/conpanyFunctionConsult/companyInfo/basicInfo/components/basicInfoDialog.vue
@@ -9,6 +9,27 @@
         :close-on-click-modal="false"
     >
       <el-form :model="state.form" size="default" ref="busRef" :rules="state.formRules" label-position="top" label-width="150px" >
+        <el-form-item label="企业名称:" prop="companyName" v-if="state.isAdmin">
+          <el-select
+              v-model="state.form.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="1.企业的基本情况,主要包括:法人证书编号,所属部门、法人代表姓名、身份证号、职务、人员总数、技术人员数、不良情况记录、保密等资质。" prop="basic" >
           <el-input v-model="state.form.basic" :rows="4" type="textarea" :disabled="title === '查看'"/>
         </el-form-item>
@@ -44,12 +65,12 @@
   </div>
 </template>
 <script setup>
-import {reactive, ref, toRefs} from 'vue'
+import {onMounted, reactive, ref, toRefs} from 'vue'
 import Editor from "@/components/Editor/index.vue";
 import {ElMessage} from "element-plus";
 import {addNotice} from "@/api/backManage/notice";
 import {addDict, editDict, getDictDetail} from "@/api/backManage/evaluate";
-import {addCompany, checkName, distributeCompany, editCompany} from "@/api/onlineEducation/company";
+import {addCompany, checkName, distributeCompany, editCompany, getCompany} from "@/api/onlineEducation/company";
 import {verifyPhone} from "@/utils/validate";
 import {addBasic, editBasic} from "@/api/companyInfo/basicInfo";
 import Cookies from "js-cookie";
@@ -74,6 +95,7 @@
     resource: '',
   },
   formRules:{
+    companyName: [{ required: true, message: '请选择企业', trigger: 'blur' }],
     basic: [{ required: true, message: '请输入', trigger: 'blur' }],
     introduce:[{ required: true, message: '请输入', trigger: 'blur' }],
     target: [{ required: true, message: '请输入', trigger: 'blur' }],
@@ -83,21 +105,38 @@
     epiboly: [{ required: true, message: '请输入', trigger: 'blur' }],
     resource: [{ required: true, message: '请输入', trigger: 'blur' }],
   },
+  isAdmin: false,
+  companyList: []
 })
 
+onMounted(() => {
 
+})
 const openDialog = async (type, value) => {
+
+
+  const userInfo = JSON.parse(Cookies.get('userInfo'))
+  state.isAdmin = userInfo.userType === 0;
+  if(state.isAdmin){
+    await   getCompanyList()
+  }
   title.value = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' ;
   if(type === 'edit' || type === 'review') {
     state.form = JSON.parse(JSON.stringify(value));
+    if(state.isAdmin){
+      state.form.companyId = value.companyId
+      state.form.companyName = value.companyName
+    }
   }
   dialogVisible.value = true;
 }
 
 const onSubmit = async () => {
   const valid = await busRef.value.validate();
-  const userInfo = JSON.parse(Cookies.get('userInfo'))
-  state.form.companyId = userInfo.companyId
+  if(!state.isAdmin){
+    const userInfo = JSON.parse(Cookies.get('userInfo'))
+    state.form.companyId = userInfo.companyId
+  }
   if(valid){
     if(title.value === '新增'){
       const {id, ...data} = JSON.parse(JSON.stringify(state.form))
@@ -143,8 +182,53 @@
 const reset = () => {
   state.form = {
     id: '',
+    companyId: null,
+    companyName: '',
+    basic: '',
+    introduce: '',
+    target: '',
+    quality: '',
+    activity: '',
+    audit: '',
+    epiboly: '',
+    resource: '',
 
   }
+  state.companyList = []
+}
+const selectValue = (val) => {
+  state.companyList.forEach(item => {
+    if(item.name === val){
+      state.form.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

--
Gitblit v1.9.2