浏览代码

供应商信息

Lijingyang 2 月之前
父节点
当前提交
25b75e989a
共有 1 个文件被更改,包括 128 次插入31 次删除
  1. 128 31
      src/views/supplier/aptitude/index.vue

+ 128 - 31
src/views/supplier/aptitude/index.vue

@@ -70,7 +70,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="24">
             <el-form-item label="资质级别" prop="qualificationLevel">
@@ -78,7 +78,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="12">
             <el-form-item label="证件编号" prop="certificateNo">
@@ -91,7 +91,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="24">
             <el-form-item label="资质到期日">
@@ -122,11 +122,11 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="24">
             <el-form-item label="上传附件">
-              <FileUpload 
+              <FileUpload
                 v-model="formData.attachmentUrl"
                 :limit="1"
                 :file-size="10"
@@ -135,15 +135,15 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="24">
             <el-form-item label="备注">
-              <el-input 
-                v-model="formData.remark" 
-                type="textarea" 
-                :rows="4" 
-                placeholder="请输入内容" 
+              <el-input
+                v-model="formData.remark"
+                type="textarea"
+                :rows="4"
+                placeholder="请输入内容"
               />
             </el-form-item>
           </el-col>
@@ -170,7 +170,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="24">
             <el-form-item label="资质级别">
@@ -178,7 +178,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="12">
             <el-form-item label="证件编号">
@@ -191,7 +191,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="24">
             <el-form-item label="资质到期日">
@@ -222,7 +222,7 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="24">
             <el-form-item label="上传附件">
@@ -235,14 +235,14 @@
             </el-form-item>
           </el-col>
         </el-row>
-        
+
         <el-row :gutter="20">
           <el-col :span="24">
             <el-form-item label="备注">
-              <el-input 
-                v-model="viewData.remark" 
-                type="textarea" 
-                :rows="4" 
+              <el-input
+                v-model="viewData.remark"
+                type="textarea"
+                :rows="4"
                 readonly
               />
             </el-form-item>
@@ -258,19 +258,29 @@
 
 <script setup lang="ts">
 import { ref, onMounted } from 'vue';
+import { useRoute } from 'vue-router';
 import { ElMessage, ElMessageBox } from 'element-plus';
 import { listQualification, addQualification, updateQualification, delQualification } from '@/api/supplier/qualification';
 import type { QualificationVO, QualificationForm, QualificationQuery } from '@/api/supplier/qualification/types';
 import { listByIds } from '@/api/system/oss';
+import { getInfo, getInfoTemporary, updateInfo } from '@/api/supplier/info';
 import FileUpload from '@/components/FileUpload/index.vue';
 
 defineOptions({
   name: 'Aptitude'
 });
 
+const route = useRoute();
+
+
 const qualificationList = ref<QualificationVO[]>([]);
 const loading = ref(false);
 
+// 供应商相关
+const supplierId = ref<string | number>('');
+const isEditMode = ref(false); // 是否为编辑模式
+const supplierInfo = ref<any>({}); // 供应商基础信息
+
 // 分页参数
 const pagination = ref({
   pageNum: 1,
@@ -354,7 +364,7 @@ const handleAdd = () => {
 /** 查看 */
 const handleView = (row: QualificationVO) => {
   viewData.value = { ...row };
-  
+
   // 设置查看模式的日期
   if (row.startDate && row.endDate) {
     const startDateStr = row.startDate.split(' ')[0]; // 去掉时分秒
@@ -365,7 +375,7 @@ const handleView = (row: QualificationVO) => {
     viewStartDate.value = null;
     viewEndDate.value = null;
   }
-  
+
   viewDialogVisible.value = true;
 };
 
@@ -373,11 +383,11 @@ const handleView = (row: QualificationVO) => {
 const handleEdit = (row: QualificationVO) => {
   resetForm();
   dialogTitle.value = '编辑资质';
-  
+
   // 回显数据
   formData.value = { ...row };
   isLongValid.value = row.isLongValid == 1;
-  
+
   // 回显日期,去掉时分秒
   if (!isLongValid.value && row.startDate && row.endDate) {
     const startDateStr = row.startDate.split(' ')[0]; // 去掉时分秒
@@ -385,7 +395,7 @@ const handleEdit = (row: QualificationVO) => {
     startDate.value = new Date(startDateStr);
     endDate.value = new Date(endDateStr);
   }
-  
+
   dialogVisible.value = true;
 };
 
@@ -415,7 +425,7 @@ const handleDownload = async (row: QualificationVO) => {
     ElMessage.warning('暂无附件可下载');
     return;
   }
-  
+
   try {
     // 直接使用 attachmentUrl 进行下载
     const link = document.createElement('a');
@@ -465,9 +475,9 @@ const handleEndDateChange = (date: Date | null) => {
 const handleSubmit = async () => {
   try {
     await formRef.value.validate();
-    
+
     submitLoading.value = true;
-    
+
     // 如果有附件,获取文件详情(URL 和文件名)
     if (formData.value.attachmentUrl) {
       try {
@@ -482,17 +492,27 @@ const handleSubmit = async () => {
         // 如果获取文件信息失败,直接使用原始的 attachmentUrl
       }
     }
-    
+
     if (formData.value.id) {
       // 编辑
       await updateQualification(formData.value);
       ElMessage.success('更新成功');
+
+      // 如果是编辑模式,需要同步更新供应商主表信息
+      if (isEditMode.value && supplierId.value) {
+        await syncSupplierInfo();
+      }
     } else {
       // 新增
       await addQualification(formData.value);
       ElMessage.success('新增成功');
+
+      // 如果是编辑模式,需要同步更新供应商主表信息
+      if (isEditMode.value && supplierId.value) {
+        await syncSupplierInfo();
+      }
     }
-    
+
     dialogVisible.value = false;
     getQualificationList();
   } catch (e) {
@@ -503,6 +523,57 @@ const handleSubmit = async () => {
   }
 };
 
+/** 同步更新供应商主表信息(编辑模式下) */
+const syncSupplierInfo = async () => {
+  if (!isEditMode.value || !supplierId.value) {
+    return;
+  }
+
+  try {
+    // 先查询临时表
+    const tempRes = await getInfoTemporary(supplierId.value);
+    let submitData: any;
+
+    if (tempRes.data) {
+      // 临时表已有记录,使用临时表数据作为基础
+      const tempData = tempRes.data;
+      submitData = {
+        ...tempData,  // 临时表中的数据(保留之前的所有修改)
+        ...supplierInfo.value,  // 当前供应商基础信息
+        supplierType: String(supplierInfo.value.supplierType || tempData.supplierType),
+        cooperateLevel: String(supplierInfo.value.cooperateLevel || tempData.cooperateLevel),
+        supplyStatus: "4"
+      };
+    } else {
+      // 临时表没有记录,使用当前数据
+      submitData = {
+        ...supplierInfo.value,
+        supplierType: String(supplierInfo.value.supplierType),
+        cooperateLevel: String(supplierInfo.value.cooperateLevel),
+        supplyStatus: "4"
+      };
+    }
+
+    // 删除后端返回的展示字段
+    delete submitData.supplierTypeName;
+    delete submitData.cooperateLevelName;
+    delete submitData.membershipSizeName;
+    delete submitData.industrCategoryName;
+    delete submitData.productManager;
+    delete submitData.buyer;
+    delete submitData.brandName;
+    delete submitData.province;
+    delete submitData.city;
+
+    // 更新主表信息
+    await updateInfo(submitData);
+    console.log('供应商主表信息已同步更新');
+  } catch (e) {
+    console.error('同步供应商主表信息失败:', e);
+    // 不抛出错误,避免影响资质保存成功的提示
+  }
+};
+
 /** 重置表单 */
 const resetForm = () => {
   formData.value = {
@@ -543,8 +614,34 @@ const formatDate = (dateStr: string) => {
 };
 
 onMounted(() => {
+  // 从路由参数获取供应商ID和模式
+  const id = route.query.id as string;
+  const mode = route.query.mode as string;
+
+  if (id) {
+    supplierId.value = id;
+    // 判断是否为编辑模式
+    isEditMode.value = mode === 'edit';
+
+    // 获取供应商基础信息
+    getSupplierInfo();
+  }
+
   getQualificationList();
 });
+
+/** 获取供应商基础信息 */
+const getSupplierInfo = async () => {
+  if (!supplierId.value) return;
+
+  try {
+    const res = await getInfo(supplierId.value);
+    supplierInfo.value = res.data;
+    console.log('供应商基础信息:', supplierInfo.value);
+  } catch (e) {
+    console.error('获取供应商基础信息失败:', e);
+  }
+};
 </script>
 
 <style scoped>
@@ -605,4 +702,4 @@ onMounted(() => {
   border-radius: 4px;
   display: inline-block;
 }
-</style>
+</style>