From 397f5b5d8f6f15270b158a91ba3b173d00051df5 Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: 星期五, 27 六月 2025 17:00:41 +0800
Subject: [PATCH] 修改

---
 src/views/build/conpanyFunctionConsult/companyInfo/policy/components/policyDialog.vue |   61 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/src/views/build/conpanyFunctionConsult/companyInfo/policy/components/policyDialog.vue b/src/views/build/conpanyFunctionConsult/companyInfo/policy/components/policyDialog.vue
index 310c34e..46f1420 100644
--- a/src/views/build/conpanyFunctionConsult/companyInfo/policy/components/policyDialog.vue
+++ b/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,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.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
@@ -129,9 +159,10 @@
 
 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){
@@ -197,6 +228,28 @@
     companyId:null,
     companyName: ''
   }
+  state.companyList = []
+}
+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)
+    }
+  }
 }
 
 defineExpose({

--
Gitblit v1.9.2