Explorar el Código

售后服务提交流程bug

hezhanp hace 7 meses
padre
commit
41d0fdae5d

+ 6 - 23
src/BIZComponents/processSubmitDialog/processSubmitDialog.vue

@@ -11,11 +11,6 @@
     :maxable="true"
     :resizable="true"
   >
-    <!--    <el-steps :active="active" align-center style="transform: scale(0.8)">-->
-    <!--      <el-step title="流程发起"></el-step>-->
-    <!--      <el-step title="流程通知"></el-step>-->
-    <!--    </el-steps>-->
-
     <el-form
       ref="form"
       :rules="rules"
@@ -146,20 +141,6 @@
     </el-form>
 
     <div slot="footer">
-      <!--      <el-button-->
-      <!--        type="primary"-->
-      <!--        size="small"-->
-      <!--        v-if="active == 0"-->
-      <!--        @click="() => (active = 1)"-->
-      <!--        >下一步-->
-      <!--      </el-button>-->
-      <!--      <el-button-->
-      <!--        type="primary"-->
-      <!--        size="small"-->
-      <!--        v-if="active == 1"-->
-      <!--        @click="() => (active = 0)"-->
-      <!--        >上一步-->
-      <!--      </el-button>-->
       <el-button type="primary" size="small" @click="submit" :loading="loading"
         >提交</el-button
       >
@@ -223,7 +204,7 @@
       },
       callBack: {
         type: Function,
-        default: ''
+        default: null
       },
       // 关闭弹窗时是否刷新列表
       isCloseRefresh: {
@@ -241,7 +222,8 @@
           businessId: '',
           noticeScope: [],
           businessKey: '',
-          formCreateUserId: ''
+          formCreateUserId: '',
+          variables: {}
         },
         businessOpportunityUpdateStatusAPI,
         quoteUpdateStatusAPI,
@@ -485,9 +467,10 @@
           ...this.form,
             variables: {
               // businessName: data.supplierName,
+              ...this.form.variables
             }
           };
-          await processInstanceCreateAPI(this.form);
+          await processInstanceCreateAPI(params);
           this.loading = false;
           this.$message('提交审核成功');
           // this.$emit('reload');
@@ -517,4 +500,4 @@
     }
   };
 </script>
-<style scoped lang="scss"></style>
+<style scoped lang="scss"></style>

+ 161 - 29
src/views/salesServiceManagement/demandList/components/addDialog.vue

@@ -19,6 +19,7 @@
       v-if="processSubmitDialogFlag"
       ref="processSubmitDialogRef"
       @reload="savExit"
+      :callBack="processCallBack"
     ></process-submit-dialog>
     <div slot="footer" class="footer">
       <el-button
@@ -103,7 +104,9 @@ export default {
       isAftertypeThree: false,
       watchInterval: null,
 
-      processSubmitDialogFlag: false
+      processSubmitDialogFlag: false,
+      // 保存处理后的参数,用于流程提交
+      processedData: null
     };
   },
   created() {
@@ -164,55 +167,183 @@ export default {
       }
     },
 
+    // 流程对话框的回调函数
+    async processCallBack() {
+      try {
+        if (!this.processedData) {
+          this.$message.error('未获取到提交数据');
+          return 1;
+        }
+
+        // 调用提交接口
+        const businessId = await demandSubmit(this.processedData);
+        if (!businessId) {
+          this.$message.error('提交失败,未获取到业务ID');
+          return 1;
+        }
+
+        // 获取详情
+        const detailRes = await getSalesDemandById(businessId);
+        if (!detailRes) {
+          this.$message.error('获取详情失败');
+          return 1;
+        }
+
+        // 更新流程对话框的表单数据
+        this.$refs.processSubmitDialogRef.form.businessId = businessId;
+        this.$refs.processSubmitDialogRef.form.variables = {
+          businessCode: detailRes.code,
+          businessName: detailRes.name,
+          businessType: '质量问题反馈'
+        };
+
+        return 0; // 返回0表示成功
+      } catch (error) {
+        this.$message.error('提交失败:' + (error.message || '未知错误'));
+        return 1; // 返回1表示失败
+      }
+    },
+
     async submit() {
       try {
         this.loading = true;
-        const pData = await this.handleParameter();
-        if (!pData) return;
+
+        const isValid = await this.validateForm();
+        if (!isValid) {
+          this.loading = false;
+          return;
+        }
 
         const currentAftertype =
           this.$refs.infoRef?.form?.aftertype || this.form.aftertype;
-        const submitParams = {
-          ...pData,
-          submitSource: this.type === 'add' ? 1 : 2
-        };
 
         if (currentAftertype === '3') {
-          // 类型为3时,直接调用接口并打开流程对话框
-          const businessId = await demandSubmit(submitParams);
-          if (!businessId) {
-            console.log('未获取到id');
-            return;
-          }
-          const detailRes = await getSalesDemandById(businessId);
-          if (!detailRes) {
-            this.$message.error('获取详情失败');
+          const pData = await this.getParameterData();
+          if (!pData) {
+            this.loading = false;
             return;
           }
-          const processParams = {
-            businessId: businessId,
-            businessKey: 'after_sale_quality_issues_feedback',
-            formCreateUserId: getCurrentUser().id,
-            variables: {
-              businessCode: detailRes.code,
-              businessName: detailRes.name,
-              businessType: '质量问题反馈'
-            }
+          this.processedData = {
+            ...pData,
+            submitSource: this.type === 'add' ? 1 : 2
           };
           this.processSubmitDialogFlag = true;
           this.$nextTick(() => {
+            const processParams = {
+              businessKey: 'after_sale_quality_issues_feedback',
+              formCreateUserId: getCurrentUser().id
+            };
             this.$refs.processSubmitDialogRef.init(processParams);
           });
+          this.loading = false; // 新增:正常流程结束后重置
         } else {
-          // 类型不为3时,仅打开弹框,由弹框内操作触发提交
-          this.$refs.submitRef.open(submitParams, this.type); // 传递完整参数
+          const pData = await this.getParameterData();
+          if (!pData) {
+            this.loading = false;
+            return;
+          }
+          this.$refs.submitRef.open(pData, this.type);
+          this.loading = false; // 新增:正常流程结束后重置
         }
       } catch (error) {
         this.$message.error('提交失败:' + (error.message || '未知错误'));
-      } finally {
         this.loading = false;
       }
     },
+
+    // 只验证表单,不处理数据
+    async validateForm() {
+      try {
+        let data = this.$refs.infoRef.getValue();
+
+        if (!data.contactInfoVOS?.length) {
+          this.$message.warning('联系人信息至少有1条');
+          return false;
+        }
+
+        // 验证表单
+        await this.$refs.infoRef.getValidate();
+        return true;
+      } catch (err) {
+        return false;
+      }
+    },
+
+    // 只获取参数数据,不进行保存操作
+    async getParameterData() {
+      try {
+        let data = this.$refs.infoRef.getValue();
+        let sparePartsData = (this.$refs.infoRef.getSpareInfoData() || []).map(
+          (item) => ({
+            ...item,
+            typeId: item.typeId,
+            code: item.code,
+            name: item.name,
+            feeType: item.feeType,
+            modelType: item.categoryModel,
+            specification: item.specification,
+            content: item.content,
+            totalCount: item.totalCount,
+            measureUnit: item.measureUnit,
+            singlePrice: item.singlePrice,
+            settlementPrice: item.settlementPrice
+          })
+        );
+
+        let expectedTime = data.expectedTime
+          ? this.formatDate(data.expectedTime)
+          : '';
+        let pData = {
+          ...this.form,
+          name: data.name,
+          faultLevel: data.faultLevel,
+          expectedTime: expectedTime,
+          contactId: data.contractInfo.id,
+          contactCode: data.contractInfo.code,
+          contactName: data.contractInfo.name,
+          orderCode: data.orderCode,
+          orderId: data.orderId,
+          contactAddress: data.contactAddress,
+          productDetail: data.tableList.map((item) => {
+            item['produceTime'] = item['produceTime'] || null;
+            return item;
+          }),
+          contactInfoVOS: data.contactInfoVOS,
+
+          associationType: data.associationType,
+          afterSalesType: data.aftertype,
+          isFee: data.charge,
+          isPieCar: data.car,
+          pieCarType: data.pietype,
+          isWithAccessories: data.part,
+          costListVOS: sparePartsData,
+          salespersonId: data.salespersonId,
+          salespersonName: data.salespersonName,
+          involveDeptId: data.involveDeptId,
+          involveDeptName: data.involveDeptName,
+          remark: data.remark,
+          isOutsource: data.isOutsource,
+          isCreatePurchaseOrder: data.isCreatePurchaseOrder,
+          supplierId: data.supplierId,
+          supplierName: data.supplierName,
+          supplierCode: data.supplierCode
+        };
+
+        if (pData.associationType == '2' && pData.productDetail.length == 0) {
+          delete pData.productDetail;
+          pData.faultDetailList = data.faultDetailList;
+        }
+        if (pData.associationType == '3' && pData.productDetail.length == 0) {
+          delete pData.productDetail;
+          pData.faultDetailList = data.faultDetailList;
+        }
+        return pData;
+      } catch (err) {
+        this.$message.error('获取参数失败');
+        return null;
+      }
+    },
+
     async dispatch() {
       let pData = await this.handleParameter();
       if (!pData) {
@@ -238,6 +369,7 @@ export default {
       this.addRepairNotesDialog = false;
       this.form = {};
       this.isAftertypeThree = false;
+      this.processedData = null;
       this.stopWatchingAftertype();
       if (this.$refs.infoRef) {
         this.$refs.infoRef.catch();
@@ -262,7 +394,7 @@ export default {
         return dateString;
       }
     },
-    // 提取公共参数
+    // 提取公共参数(包含保存操作的完整流程)
     async handleParameter() {
       let data = this.$refs.infoRef.getValue();
       console.log('提交前的data:', data.salespersonId, data.salespersonName);