Просмотр исходного кода

解决售后服务提交失败

hezhanp 7 месяцев назад
Родитель
Сommit
6d999b5f3b

+ 48 - 67
src/views/salesServiceManagement/components/sparePartsList.vue

@@ -1,8 +1,5 @@
 <template>
   <div class="ele-body">
-    <!-- <el-card shadow="never" v-loading="loading"> -->
-    <!-- 数据表格 -->
-    <!-- :rules="[]" -->
     <el-form ref="form" :model="form" label-width="100px" class="create-form">
       <ele-pro-table
         ref="tableRef2"
@@ -34,7 +31,6 @@
               @change="typeIdChange(scope.row, scope.$index)"
               :disabled="schemeTableTool(scope.row)"
             >
-              <!-- :disabled="type == 'view' || scope.row.isApply == 1" -->
               <el-option
                 v-for="item in typeIdList"
                 :key="item.value"
@@ -42,8 +38,9 @@
                 :value="item.value"
               ></el-option>
             </el-select>
-          </el-form-item> </template
-        ><template v-slot:feeType="scope">
+          </el-form-item>
+        </template>
+        <template v-slot:feeType="scope">
           <el-form-item
             style="margin-bottom: 20px"
             :prop="'tableList.' + scope.$index + '.feeType'"
@@ -54,7 +51,6 @@
               class="w100"
               :disabled="schemeTableTool(scope.row)"
             >
-              <!-- :disabled="type == 'view' || scope.row.isApply == 1" -->
               <el-option
                 v-for="item in feeTypeList"
                 :key="item.value"
@@ -90,15 +86,11 @@
               trigger: ['blur', 'change']
             }"
           >
-            <!--:disabled="type == 'view' || scope.row.typeId == 2" -->
             <el-input
               :disabled="type == 'view' || scope.row.typeId == 2"
               v-model="scope.row.name"
               style="width: calc(100% - 62px)"
             ></el-input>
-            <!--    scope.row.typeId == 2 &&
-                scope.row.isApply != 1 &&
-            type == 'edit'-->
             <el-button
               v-if="chooseShow(scope)"
               size="small"
@@ -162,7 +154,6 @@
               type="number"
               :min="1"
             ></el-input>
-            <!-- :disabled="type == 'view' || scope.row.isApply == 1" -->
           </el-form-item>
         </template>
         <template v-slot:measureUnit="scope">
@@ -194,7 +185,6 @@
             ></el-input>
           </el-form-item>
         </template>
-        <!-- 现在如果是查主数据的话 还可以选择仓库 -->
         <template v-slot:warehouseId="scope">
           <el-form-item
             v-if="scope.row.typeId == '2'"
@@ -202,20 +192,19 @@
             :prop="'tableList.' + scope.$index + '.warehouseId'"
           >
             <el-select
-              v-if="obtain == '主数据'"
+              v-if="obtain == '主数据' || obtain == '售后'"
               v-model="scope.row.warehouseId"
               placeholder="请选择仓库"
               class="w100"
               :disabled="schemeTableTool(scope.row)"
+              @change="handleWarehouseChange(scope.row, scope.$index, $event)"
             >
               <el-option
                 v-for="item in scope.row.warehouseList"
-                @click="warehouseChange(item, scope.row, scope.$index)"
                 :key="item.warehouseId"
                 :label="item.warehouseName"
                 :value="item.warehouseId"
               ></el-option>
-              <!-- :disabled="type == 'view' || scope.row.isApply == 1" -->
             </el-select>
             <el-input
               v-model="scope.row.warehouseName"
@@ -233,11 +222,10 @@
               placeholder="请选择仓库"
               class="w100"
               :disabled="schemeTableTool(scope.row)"
+              @change="handleWarehouseChange(scope.row, scope.$index, $event)"
             >
-              <!-- :disabled="type == 'view' || scope.row.isApply == 1" -->
               <el-option
                 v-for="item in scope.row.warehouseList"
-                @click="warehouseChange(item, scope.row, scope.$index)"
                 :key="item.warehouseId"
                 :label="item.warehouseName"
                 :value="item.warehouseId"
@@ -254,7 +242,6 @@
             @click="del(row, $index)"
             >删除</el-link
           >
-          <!--  v-if="type != 'view' && row.isApply != 1 && source != '报工信息'" -->
         </template>
         <template v-slot:headerName="{ column }">
           <span class="is-required">{{ column.label }}</span>
@@ -269,7 +256,6 @@
       itemType="5"
       :isFirstRefreshTable="true"
     ></product-list>
-    <!-- <applyForSpare ref="edit" :inlet="1" /> -->
   </div>
 </template>
 
@@ -284,18 +270,15 @@ import productList from '@/BIZComponents/product-list.vue';
 
 export default {
   components: {
-    //   applyForSpare,
     AssetsDialog,
     productList
   },
   props: {
     type: '',
-    // 数据来源
     source: {
       default: '',
       type: String
     },
-    // 表格权限操作 状态
     state: {
       default: '',
       type: String
@@ -310,7 +293,7 @@ export default {
     },
     hideFeeType: {
       type: Boolean,
-      default: false // 默认显示
+      default: false
     }
   },
   data() {
@@ -324,7 +307,8 @@ export default {
       feeTypeList: [
         { label: '收入', value: '1' },
         { label: '支出', value: '2' }
-      ]
+      ],
+      currentIndex: -1
     };
   },
   created() {
@@ -364,10 +348,8 @@ export default {
           slot: 'feeType',
           minWidth: 150,
           showOverflowTooltip: true,
-
           show: !this.hideFeeType
         },
-
         {
           prop: 'name',
           label: '名称',
@@ -460,7 +442,6 @@ export default {
         }
       ];
     },
-    // 选择按钮显示
     chooseShow() {
       return (scope) => {
         if (this.source == '配件回收') {
@@ -473,8 +454,6 @@ export default {
         return flag;
       };
     },
-
-    // 添加 按钮显示权限
     buttonJud() {
       if (this.source == '派单进来') {
         return true;
@@ -482,7 +461,6 @@ export default {
       let flag = this.type != 'view' && this.source != '报工信息';
       return flag;
     },
-    // 方案列表删除权限
     schemeOperate() {
       return (row) => {
         if (this.source == '配件回收') {
@@ -493,14 +471,12 @@ export default {
         return flag;
       };
     },
-    // 方案表格操作权限
     schemeTableTool() {
       return (row) => {
         let flag = this.type == 'view' || row.isApply == 1;
         return flag;
       };
     },
-    // input输入权限
     inputOperate() {
       return (row) => {
         let flag = this.type == 'view' || row.isApply == 1;
@@ -555,7 +531,7 @@ export default {
       const defaultFeeType = row.typeId === '5' ? '2' : '1';
       let obj = {
         typeId: row.typeId,
-        feeType: defaultFeeType, // 这里根据typeId动态设置默认值
+        feeType: defaultFeeType,
         code: '',
         name: '',
         categoryModel: '',
@@ -572,7 +548,6 @@ export default {
       }
       this.$set(this.form.tableList, index, obj);
     },
-    // spareParts 组件的 getValidate 方法
     getValidate() {
       return new Promise((resolve, reject) => {
         this.$refs.form.validate((valid, obj) => {
@@ -600,9 +575,6 @@ export default {
       });
     },
     async addEquipment(row, index) {
-      // const res = await parameterGetByCode({
-      //   code: 'after_sales_accessory_source'
-      // });
       this.currentIndex = index;
       if (this.obtain == '仓库') {
         this.$refs.productListRef.open('', index, '0');
@@ -614,30 +586,34 @@ export default {
       return this.form.tableList;
     },
     async setTableValue(val) {
-  const tableList = JSON.parse(JSON.stringify(val));
-  for (let i = 0; i < tableList.length; i++) {
-    const item = tableList[i];
-    item.feeType = (item.feeType || '1').toString();
-    item.categoryCode = item.categoryCode || item.code;
-    item.categoryName = item.categoryName || item.name;
-    if (item.typeId == 2) {
-      const warehouseList = await getIdWarehouseList({ categoryId: item.categoryId });
-      item.warehouseList = warehouseList;
-      if (item.warehouseId) {
-        const matchedWarehouse = warehouseList.find(wh => wh.warehouseId === item.warehouseId);
-        if (matchedWarehouse) {
-          item.warehouseName = matchedWarehouse.warehouseName; // 同步仓库名
+      const tableList = JSON.parse(JSON.stringify(val));
+      for (let i = 0; i < tableList.length; i++) {
+        const item = tableList[i];
+        item.feeType = (item.feeType || '1').toString();
+        item.categoryCode = item.categoryCode || item.code;
+        item.categoryName = item.categoryName || item.name;
+        if (item.typeId == 2) {
+          const warehouseList = await getIdWarehouseList({
+            categoryId: item.categoryId
+          });
+          item.warehouseList = warehouseList;
+          if (item.warehouseId) {
+            const matchedWarehouse = warehouseList.find(
+              (wh) => wh.warehouseId === item.warehouseId
+            );
+            if (matchedWarehouse) {
+              item.warehouseName = matchedWarehouse.warehouseName;
+            }
+            item.warehouseNum = await getWarehouseOutStock({
+              warehouseId: item.warehouseId,
+              code: item.categoryCode
+            });
+          }
         }
-        item.warehouseNum = await getWarehouseOutStock({
-          warehouseId: item.warehouseId,
-          code: item.categoryCode
-        });
       }
-    }
-  }
-  this.$set(this.form, 'tableList', tableList);
-  this.calculatePrice();
-},
+      this.$set(this.form, 'tableList', tableList);
+      this.calculatePrice();
+    },
     totalCountChange(index, data, name) {
       data[name] = data[name].replace(/[^\d]/g, '').replace(/^0+/, '') || '0';
       let row = this.form.tableList[index];
@@ -656,7 +632,6 @@ export default {
     clearList() {
       this.form.tableList = [];
     },
-    // 计算汇总价格 ***
     calculatePrice() {
       let totlal = 0;
       this.form.tableList.map((el) => (totlal += el.settlementPrice));
@@ -676,7 +651,6 @@ export default {
         ...data[0],
         feeType: feeType
       };
-      // 用合并后的新对象更新行数据
       this.$set(this.form.tableList, this.currentIndex, newRow);
       this.$set(
         this.form.tableList[this.currentIndex],
@@ -712,13 +686,20 @@ export default {
       this.$set(this.form.tableList[this.currentIndex], 'typeId', '2');
       this.$forceUpdate();
     },
-    async warehouseChange(item, row, index) {
-      this.$set(
-        this.form.tableList[index],
-        'warehouseName',
-        item.warehouseName
+    // 处理仓库选择变更
+    async handleWarehouseChange(row, index, warehouseId) {
+      const selectedWarehouse = row.warehouseList.find(
+        item => item.warehouseId === warehouseId
       );
+      if (selectedWarehouse) {
+        await this.warehouseChange(selectedWarehouse, row, index);
+      }
+    },
+    // 仓库变更后更新库存
+    async warehouseChange(item, row, index) {
+      this.$set(this.form.tableList[index], 'warehouseName', item.warehouseName);
       this.$set(this.form.tableList[index], 'warehouseId', item.warehouseId);
+      // 重新调用库存查询接口
       this.$set(
         this.form.tableList[index],
         'warehouseNum',

+ 18 - 20
src/views/salesServiceManagement/demandList/components/addDialog.vue

@@ -11,7 +11,7 @@
     @close="handleClose"
   >
     <info ref="infoRef" :demandList="demandList" :type="type"></info>
-    <!-- <SubmitDialog ref="submitRef" @savExit="savExit" /> -->
+    <SubmitDialog ref="submitRef" @savExit="savExit" />
     <dispatchDialog ref="dispatchRef" @savExit="savExit" />
     <process-submit-dialog
       :isNotNeedProcess="false"
@@ -71,7 +71,7 @@ export default {
     modalTitle,
     customerDialog,
     info,
-    // SubmitDialog,
+    SubmitDialog,
     dispatchDialog,
 
     processSubmitDialog
@@ -170,34 +170,32 @@ export default {
         const pData = await this.handleParameter();
         if (!pData) return;
 
+        const currentAftertype =
+          this.$refs.infoRef?.form?.aftertype || this.form.aftertype;
         const submitParams = {
           ...pData,
           submitSource: this.type === 'add' ? 1 : 2
         };
 
-        const businessId = await demandSubmit(submitParams);
-        if (!businessId) {
-          console.log('未获取到id');
-          return;
-        }
-
-        const detailRes = await getSalesDemandById(businessId);
-        if (!detailRes) {
-          this.$message.error('获取详情失败');
-          return;
-        }
-
-        const currentAftertype =
-          this.$refs.infoRef?.form?.aftertype || this.form.aftertype;
         if (currentAftertype === '3') {
-          console.log(detailRes)
+          // 类型为3时,直接调用接口并打开流程对话框
+          const businessId = await demandSubmit(submitParams);
+          if (!businessId) {
+            console.log('未获取到id');
+            return;
+          }
+          const detailRes = await getSalesDemandById(businessId);
+          if (!detailRes) {
+            this.$message.error('获取详情失败');
+            return;
+          }
           const processParams = {
             businessId: businessId,
             businessKey: 'after_sale_quality_issues_feedback',
             formCreateUserId: getCurrentUser().id,
             variables: {
               businessCode: detailRes.code,
-              businessName: detailRes.name, 
+              businessName: detailRes.name,
               businessType: '质量问题反馈'
             }
           };
@@ -206,8 +204,8 @@ export default {
             this.$refs.processSubmitDialogRef.init(processParams);
           });
         } else {
-          this.$message.success('提交成功!');
-          this.savExit();
+          // 类型不为3时,仅打开弹框,由弹框内操作触发提交
+          this.$refs.submitRef.open(submitParams, this.type); // 传递完整参数
         }
       } catch (error) {
         this.$message.error('提交失败:' + (error.message || '未知错误'));