Explorar o código

feat(对账单): 实现批量生成对账单功能并优化相关逻辑

liujt hai 5 meses
pai
achega
25c3be1869

+ 11 - 0
src/api/saleManage/accountstatement.js

@@ -181,3 +181,14 @@ export async function accountStatementExportAPI(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+/**
+ * 对账单 生成对账单
+ */
+export async function batchGenerateStatementAPI(data) {
+  const res = await request.post(`/wms/allotApply/batchGenerateStatement`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 35 - 76
src/views/warehouseManagement/inventoryAllocation/accountstatement/generateStatement.vue

@@ -28,22 +28,12 @@
             height="350"
             full-height="calc(100vh - 76px)"
         > 
-            <template v-slot:orderNo="scope">
-                <el-form-item :prop="'datasource.' + scope.$index + '.orderNo'">
-                    <el-input v-model="scope.row.orderNo" @click.native="openOrderDialog(scope.row, scope.$index)"></el-input>
-                <!-- <el-select
-                    v-model="scope.row.batchStockId" 
-                    placeholder="请选择"
-                    @change="batchNoChange(scope.$index, scope.row)"
+            <template v-slot:saleOrderNos="scope">
+                <el-form-item 
+                    :prop="'datasource.' + scope.$index + '.saleOrderNos'"
+                    :rules="[{ required: true, message: '请选择订单', trigger: ['blur'] }]"
                 >
-                    <el-option
-                    v-for="item in scope.row.batchNoList || []"
-                    :key="item.id"
-                    :label="item.batchNo"
-                    :value="item.id"
-                    >
-                    </el-option>
-                </el-select> -->
+                    <el-input v-model="scope.row.saleOrderNos" @click.native="openOrderDialog(scope.row, scope.$index)"></el-input>
                 </el-form-item>
             </template>
         </ele-pro-table>
@@ -72,11 +62,7 @@
 
   import saleForm from './saleForm.vue';
   import {
-    getStatementRecordListAPI,
-    infoAccountStatementAPI,
-    createAccountStatementAPI,
-    updateAccountStatementAPI,
-    accountstatementInfoAPI
+    batchGenerateStatementAPI
   } from '@/api/saleManage/accountstatement';
   import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
   import OrderListDialog from './orderListDialog.vue';
@@ -171,9 +157,9 @@
           },
           {
             minWidth: 140,
-            prop: 'orderNo',
+            prop: 'saleOrderNos',
             label: '销售订单号',
-            slot: 'orderNo',
+            slot: 'saleOrderNos',
             align: 'center',
             showOverflowTooltip: true
           }
@@ -185,17 +171,17 @@
       open(dialogType, row) {
         this.dialogType = dialogType;
         console.log('row~~~', row);
-        this.form.datasource = row || [];
+        this.form.datasource = JSON.parse(JSON.stringify(row)) || [];
       },
       //打开订单弹窗
       openOrderDialog(row, index) {
-        let item = { id: row.orderId };
-        this.$refs.orderListDialogRef.open(item, index);
+        // let item = { id: row.orderId };
+        this.$refs.orderListDialogRef.open(row, index);
       },
       //选择订单信息回调
       getOrderInfo(arr, index) {
         console.log('arr~~~', arr, index, this.form.datasource[index]);
-        this.form.datasource[index].orderNo = arr.map(item => item.orderNo).join(',');
+        this.form.datasource[index].saleOrderNos = arr.map(item => item.orderNo).join(',');
         // this.dataForm.sourceType = 3;
         // let params = Object.assign({}, this.dataForm, {
         //   orderId: obj.id,
@@ -211,6 +197,8 @@
 
       //关闭弹窗
       cancel() {
+        // this.form.datasource = [];
+        this.$set(this.form, 'datasource', []);
         this.$emit('update:generateStatementFlag', false);
       },
    
@@ -218,58 +206,29 @@
       async save(is) {
         if (!this.form.datasource.length)
           return this.$message.warning('暂无对账信息');
-        let api =
-          this.dialogType == 'add'
-            ? createAccountStatementAPI
-            : updateAccountStatementAPI;
-        let params = {
-          ...this.dataForm,
-          orderList: this.form.datasource,
-        };
-        console.log('params~~~', params);
-        this.saveLoading = true;
-        try {
-          let data = await api(params);
-          this.saveLoading = false;
-          if (is == 'sub') {
-            await this.submitApprove(data);
-            return;
-            // await submitAccountStatementApproveAPI({
-            //   businessId: data,
-            //   type: this.dataForm.type
-            // });
-          }
-          this.$message.success('操作成功');
-          this.reload();
-        } catch (error) {
-          this.saveLoading = false;
-        }
-        this.$message.success('操作成功');
-        this.reload();
-      },
-      async submitApprove(res) {
-        let data = await accountstatementInfoAPI(res);
-        this.processSubmitDialogFlag = true;
-        this.$nextTick(() => {
-          let params = {
-            businessId: res,
-            businessKey: 'sales_account_statement_approve',
-            formCreateUserId: data.createUserId,
-            variables: {
-              type: data.type,
-              businessCode: data.statementNo,
-              businessName: data.contactName,
-              businessType: '对账单'
+        
+        this.$refs.form.validate(async(valid, obj) => {
+          if (valid) {
+            let params = this.form.datasource.map(item => {
+                return {
+                    allotId: item.id,
+                    saleOrderNos: item.saleOrderNos,
+                }
+            });
+            console.log('params~~~', params);
+            this.saveLoading = true;
+            try {
+                await batchGenerateStatementAPI(params);
+                this.saveLoading = false;
+                this.$message.success('操作成功');
+                this.reload();
+            } catch (error) {
+                this.saveLoading = false;
             }
-            // callBackMethodType : '1',
-            // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
-            // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
-            // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
-            // miniHandle : '',
-            // miniView : '',
-          };
-          this.$refs.processSubmitDialogRef.init(params);
+          }
         });
+        // this.$message.success('操作成功');
+        // this.reload();
       },
       reload() {
         this.cancel();

+ 4 - 3
src/views/warehouseManagement/inventoryAllocation/accountstatement/orderListDialog.vue

@@ -183,9 +183,10 @@ export default {
   methods: {
     open(item, currentIndex) {
       this.currentIndex = currentIndex;
-      if (item && item.id) {
-        this.radio = item.id;
-      }
+      this.selection = [];
+      // if (item && item.id) {
+      //   this.radio = item.id;
+      // }
 
       this.visible = true;
     },

+ 22 - 2
src/views/warehouseManagement/inventoryAllocation/index.vue

@@ -22,9 +22,9 @@
           <el-button v-if="$hasPermission('wms:inventoryAllocation:print2')" :disabled="selection.length > 1" icon="el-icon-download" type="primary"  @click="printExl2"
             >打印送货单带车</el-button
           >
-          <!-- <el-button v-if="$hasPermission('wms:inventoryAllocation:statement')" :disabled="selection.length == 0" type="primary"  @click="handleGenerateStatement('add')"
+          <el-button v-if="$hasPermission('wms:inventoryAllocation:statement')" :disabled="selection.length == 0" type="primary"  @click="handleGenerateStatement('add')"
             >生成对账单</el-button
-          > -->
+          >
         </template>
         <!-- 单号链接 -->
         <template v-slot:allotCode="{ row }">
@@ -38,6 +38,7 @@
             type="primary"
             :underline="false"
             icon="el-icon-view"
+            :disabled="saveLoading"
             @click="submit(row)"
           >
             提交
@@ -114,6 +115,7 @@
         generateStatementFlag: false,
         allocationType,
         groupName: '',
+        saveLoading: false,
         stutusOptions: {
           0: '未提交',
           1: '审核中',
@@ -165,6 +167,20 @@
               )[0].label;
             }
           },
+          {
+            prop: 'saleOrderNos',
+            label: '销售订单号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'customerNames',
+            label: '客户',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
           {
             prop: 'categoryName',
             label: '物品名称',
@@ -298,6 +314,7 @@
       },
       // 提交
       submit(row) {
+        this.saveLoading = true;
         storageApi
           .submitAllot({
             id: row.id,
@@ -305,11 +322,14 @@
             outVerifyUserId: row.targetWarehouseUserId
           })
           .then(() => {
+            this.saveLoading = false;
             this.$message({
               type: 'success',
               message: '提交成功'
             });
             this.reload();
+          }).catch(() => {
+            this.saveLoading = false;
           });
       },
       // 修改