Selaa lähdekoodia

feat(supplier): 添加ERP供应商信息管理功能并优化合同审核流程

- 在供应商基本信息中集成ERP供应商信息的保存和更新功能
- 实现供应商详情页面中ERP供应商信息的自动同步保存
- 为合同管理添加审核按钮和审核对话框功能
- 优化品牌审核界面,仅对待审核状态显示操作按钮
- 限制合同供应审核权限,仅允许特定状态下进行审核操作
- 产品组件中添加已选择商品的状态标识和禁用重复选择功能
- 修复供应商详情页面数据加载逻辑,确保编辑模式下正确加载数据
肖路 3 päivää sitten
vanhempi
sitoutus
dee1a2a2f6

+ 2 - 1
src/views/customer/info/components/BasicInfoTab.vue

@@ -618,8 +618,9 @@ const loadErpSupplierInfo = async (supplierId: string | number) => {
 };
 
 watch(
-  () => props.detailData?.id,
+  () => props.detailData?.supplierId,
   (newId) => {
+    console.log('detailData变化:', props.detailData);
     console.log('detailData.id变化:', newId);
     if (newId) {
       loadErpSupplierInfo(newId);

+ 30 - 3
src/views/customer/info/detail.vue

@@ -578,6 +578,8 @@ import { InvoiceTypeVO } from '@/api/system/invoiceType/types';
 import { listBank as listSystemBank } from '@/api/system/bank';
 import { BankVO as SystemBankVO } from '@/api/system/bank/types';
 import { getInfoTemporary, addInfoTemporary } from '@/api/supplier/infoTemporary';
+import { addErpSupplierInfo, updateErpSupplierInfo } from '@/api/supplier/erpSupplierInfo';
+import { ErpSupplierInfoForm } from '@/api/supplier/erpSupplierInfo/types';
 import { getChinaArea } from '@/api/system/addressarea/index';
 import download from '@/plugins/download';
 import { listQualification } from '@/api/supplier/qualification';
@@ -1070,7 +1072,7 @@ const handleGetBusinessInfo = async () => {
 };
 
 /** 保存数据 */
-const handleSave = async () => {
+const handleSave = async (erpSupplierInfoForm?: ErpSupplierInfoForm) => {
   try {
     // 验证必填字段
     if (!detailData.value.ownedCompany) {
@@ -1170,6 +1172,9 @@ const handleSave = async () => {
         isBasicInfoSaved.value = true;
         detailData.value.id = newId;
 
+        // 保存ERP供应商信息
+        await saveErpSupplierInfo(erpSupplierInfoForm, newId);
+
         // 重新加载供应商详情以获取完整信息(包括supplierNo)
         try {
           const detailRes = await getInfo(newId);
@@ -1193,6 +1198,8 @@ const handleSave = async () => {
     } else {
       // 编辑模式,直接刷新当前数据
       if (detailData.value.id) {
+        // 保存ERP供应商信息
+        await saveErpSupplierInfo(erpSupplierInfoForm, detailData.value.supplierId);
         await getDetail();
       }
     }
@@ -1201,6 +1208,24 @@ const handleSave = async () => {
   }
 };
 
+/** 保存ERP供应商信息 */
+const saveErpSupplierInfo = async (erpSupplierInfoForm: ErpSupplierInfoForm | undefined, supplierId: string | number) => {
+  if (!erpSupplierInfoForm || !supplierId) return;
+  try {
+    const erpData: ErpSupplierInfoForm = {
+      ...erpSupplierInfoForm,
+      supplierId
+    };
+    if (erpData.id) {
+      await updateErpSupplierInfo(erpData);
+    } else {
+      await addErpSupplierInfo(erpData);
+    }
+  } catch (e) {
+    console.error('保存ERP供应商信息失败:', e);
+  }
+};
+
 /** 初始化省市区级联选择器数据 */
 const initRegionOptions = async () => {
   try {
@@ -1297,8 +1322,10 @@ const getDetail = async () => {
     // 新增模式
     isAddMode.value = true;
     if (id) {
-      // 如果有ID,说明基础信息已保存
+      // 如果有ID,说明基础信息已保存,加载已有数据
       isBasicInfoSaved.value = true;
+      const res = await getInfo(id);
+      detailData.value = res.data;
     }
     return;
   } else if (mode === 'edit' && id) {
@@ -2660,7 +2687,7 @@ const getAddressList = async () => {
   const id = route.query.id as string;
 
   // add状态不查询地址列表(新增时没有地址)
-  if (!id || isAddMode.value) {
+  if (!id || (isAddMode.value && !isBasicInfoSaved.value)) {
     addressList.value = [];
     return;
   }

+ 2 - 2
src/views/product/brandexam/index.vue

@@ -60,8 +60,8 @@
             <div class="action-btns flex items-center justify-center gap-1 whitespace-nowrap">
               <el-button link type="primary" @click="handleView(scope.row)" v-hasPermi="['product:brand:query']">查看</el-button>
               <el-button link type="primary" @click="handleEdit(scope.row)" v-hasPermi="['product:brand:edit']">编辑</el-button>
-              <el-button link type="primary" @click="openAuditDialog(scope.row, 'approve')">审核</el-button>
-              <el-button link type="danger" @click="openAuditDialog(scope.row, 'reject')">驳回</el-button>
+              <el-button v-if="String(scope.row.brandStatus) === '0'" link type="primary" @click="openAuditDialog(scope.row, 'approve')">审核</el-button>
+              <el-button v-if="String(scope.row.brandStatus) === '0'" link type="danger" @click="openAuditDialog(scope.row, 'reject')">驳回</el-button>
             </div>
           </template>
         </el-table-column>

+ 28 - 7
src/views/supplier/contract/detail.vue

@@ -112,10 +112,11 @@
         </el-table-column>
         <el-table-column label="操作" align="center" width="150">
           <template #default="scope">
-            <!-- 待审核状态:可以修改和查看 -->
+            <!-- 待审核状态:可以修改、查看和审核 -->
             <template v-if="scope.row.contractStatus === 0 || scope.row.contractStatus === '0'">
               <el-button link type="primary" @click="handleEdit(scope.row)">修改</el-button>
               <el-button link type="success" @click="handleView(scope.row)">查看</el-button>
+              <el-button link type="warning" @click="handleAudit(scope.row)">审核</el-button>
             </template>
             
             <!-- 已生效状态:只能查看 -->
@@ -284,12 +285,17 @@
 
       <template #footer>
         <div class="dialog-footer">
-          <el-button
-            v-if="contractDialogReadonly"
-            type="primary"
-            @click="handleApprove"
-            :loading="approveLoading"
-          >审核通过</el-button>
+          <template v-if="contractDialogAudit">
+            <el-button @click="contractDialogVisible = false">取消</el-button>
+            <el-button
+              type="primary"
+              @click="handleApprove"
+              :loading="approveLoading"
+            >审核通过</el-button>
+          </template>
+          <template v-else-if="contractDialogReadonly">
+            <el-button @click="contractDialogVisible = false">关闭</el-button>
+          </template>
           <template v-else>
             <el-button @click="contractDialogVisible = false">取消</el-button>
             <el-button type="primary" @click="handleContractSubmit" :loading="contractSubmitLoading">确定</el-button>
@@ -361,6 +367,7 @@ const contractList = ref<any[]>([]);
 const contractDialogVisible = ref(false);
 const contractDialogTitle = ref('');
 const contractDialogReadonly = ref(false);
+const contractDialogAudit = ref(false);
 const contractSubmitLoading = ref(false);
 const approveLoading = ref(false);
 const contractFormRef = ref();
@@ -550,6 +557,7 @@ const handleView = (row: any) => {
   };
   contractDialogTitle.value = '查看合同';
   contractDialogReadonly.value = true;
+  contractDialogAudit.value = false;
   contractDialogVisible.value = true;
 };
 
@@ -561,6 +569,19 @@ const handleEdit = (row: any) => {
   };
   contractDialogTitle.value = '修改合同';
   contractDialogReadonly.value = false;
+  contractDialogAudit.value = false;
+  contractDialogVisible.value = true;
+};
+
+/** 审核合同 */
+const handleAudit = (row: any) => {
+  contractForm.value = {
+    ...row,
+    contractAmount: yuanToWanString(row?.contractAmount)
+  };
+  contractDialogTitle.value = '审核合同';
+  contractDialogReadonly.value = true;
+  contractDialogAudit.value = true;
   contractDialogVisible.value = true;
 };
 

+ 7 - 1
src/views/supplier/contractsupply/components/Product.vue

@@ -92,7 +92,8 @@
           </el-table-column>
           <el-table-column label="操作" align="center" width="100" fixed="right"> <!-- 固定右侧,避免空白 -->
             <template #default="scope">
-              <el-button link type="primary" @click="handleAddToList(scope.row)">加入清单</el-button>
+              <el-button v-if="isProductSelected(scope.row.id)" link type="success" disabled>已选</el-button>
+              <el-button v-else link type="primary" @click="handleAddToList(scope.row)">加入清单</el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -325,6 +326,11 @@ const handleSelectionChange = (selection: BaseVO[]) => {
   multiple.value = !selection.length;
 };
 
+/** 判断商品是否已加入清单 */
+const isProductSelected = (productId: string | number) => {
+  return props.modelValue.some(item => item.productId === productId);
+};
+
 /** 加入清单 */
 const handleAddToList = (row: BaseVO) => {
   const existsInModelValue = props.modelValue.some(item => item.productId === row.id);

+ 2 - 2
src/views/supplier/contractsupply/index.vue

@@ -72,7 +72,7 @@
         </el-table-column>
         <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
           <template #default="scope">
-            <el-button link type="primary" @click="handleAudit(scope.row)" v-hasPermi="['supplier:contractsupply:edit']">审核</el-button>
+            <el-button link type="primary" @click="handleAudit(scope.row)" v-hasPermi="['supplier:contractsupply:edit']" v-if="scope.row.status !== 0 && scope.row.status !== '0' && scope.row.status !== 1 && scope.row.status !== '1'">审核</el-button>
             <el-divider direction="vertical" />
             <el-button link type="primary" @click="handleUpdate(scope.row)" v-hasPermi="['supplier:contractsupply:edit']">编辑</el-button>
           </template>
@@ -290,7 +290,7 @@ const handleExport = () => {
   }, `contractsupply_${new Date().getTime()}.xlsx`)
 }
 
-onMounted(() => {
+onActivated(() => {
   getList();
 });
 </script>