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

受托收货单界面自动带入本销售订单的销售数量到收货数量

hezhanp 9 месяцев назад
Родитель
Сommit
bd751197f3
1 измененных файлов с 328 добавлено и 329 удалено
  1. 328 329
      src/views/saleManage/saleOrder/entrustedReceive/components/addOrEditDialog.vue

+ 328 - 329
src/views/saleManage/saleOrder/entrustedReceive/components/addOrEditDialog.vue

@@ -120,362 +120,361 @@
 </template>
 </template>
 
 
 <script>
 <script>
-  import fileUpload from '@/components/upload/fileUpload';
-  import dictMixins from '@/mixins/dictMixins';
-  import {
-    saveSaleEntrustedReceiveAPI,
-    updateSaleEntrustedReceiveAPI,
-    getPSaleEntrustedReceiveDetailAPI,
-    submit,
-    getReceiveCountAPI
-  } from '@/api/saleManage/entrustedReceive';
-  import { getcontactlink } from '@/api/saleManage/businessFollow';
-  import inventoryTable from './inventoryTable.vue';
-  import orderListDialog from '../../invoice/components/orderListDialog.vue';
-  import { getSaleOrderDetail } from '@/api/saleManage/saleorder';
-  import { getInventoryTotalAPI } from '@/api/wms';
-  // import fileMain from '@/components/addDoc/index.vue';
-  import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
-  import { getCode } from '@/api/login/index';
-  import { contactDetail } from '@/api/saleManage/contact';
-  import { getWarehouseListByIds } from '@/api/purchasingManage/returnGoods';
+import fileUpload from '@/components/upload/fileUpload';
+import dictMixins from '@/mixins/dictMixins';
+import {
+  saveSaleEntrustedReceiveAPI,
+  updateSaleEntrustedReceiveAPI,
+  getPSaleEntrustedReceiveDetailAPI,
+  submit,
+  getReceiveCountAPI
+} from '@/api/saleManage/entrustedReceive';
+import { getcontactlink } from '@/api/saleManage/businessFollow';
+import inventoryTable from './inventoryTable.vue';
+import orderListDialog from '../../invoice/components/orderListDialog.vue';
+import { getSaleOrderDetail } from '@/api/saleManage/saleorder';
+import { getInventoryTotalAPI } from '@/api/wms';
+// import fileMain from '@/components/addDoc/index.vue';
+import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
+import { getCode } from '@/api/login/index';
+import { contactDetail } from '@/api/saleManage/contact';
+import { getWarehouseListByIds } from '@/api/purchasingManage/returnGoods';
 
 
-  export default {
-    props: {
-      addOrEditDialogFlag: Boolean
-    },
-    mixins: [dictMixins],
-    components: {
-      processSubmitDialog,
-      // fileMain,
-      fileUpload,
-      inventoryTable,
-      orderListDialog
-    },
-    data() {
-      return {
-        orderSearchParams: {
-          saleType: '5'
-        },
-        detailData: {},
-        payWayOptions: [],
-        delDetailIds: [],
-        linkNameOptions: [],
+export default {
+  props: {
+    addOrEditDialogFlag: Boolean
+  },
+  mixins: [dictMixins],
+  components: {
+    processSubmitDialog,
+    // fileMain,
+    fileUpload,
+    inventoryTable,
+    orderListDialog
+  },
+  data() {
+    return {
+      orderSearchParams: {
+        saleType: '5'
+      },
+      detailData: {},
+      payWayOptions: [],
+      delDetailIds: [],
+      linkNameOptions: [],
+
+      title: '',
+      row: {},
+      form: {
+        id: '',
+        receiveDate: '',
+        carNo: '',
+        files: [],
+        linkName: '',
+        linkPhone: '',
+        orderId: '',
+        orderNo: '',
+        pricingWay: '',
+        productList: [],
+        sendNoteNo: '',
+        contactId: '',
+        contactName: ''
+      },
+      rules: {
+        contactName: [
+          { required: true, message: '请选择客户名称', trigger: 'change' }
+        ],
+        linkName: [
+          { required: true, message: '请输入', trigger: ['blur', 'change'] }
+        ],
+        linkPhone: [
+          { required: true, message: '请输入', trigger: ['blur', 'change'] }
+        ],
+        orderNo: [{ required: true, message: '请选择', trigger: 'change' }],
+        receiveAddress: [
+          { required: true, message: '请输入', trigger: 'change' }
+        ]
+      },
+      customerMark: '',
+      // 提交状态
+      loading: false,
+      // 是否是修改
+      isUpdate: false,
+      processSubmitDialogFlag: false,
+      businessId: '',
+      batchNo: ''
+    };
+  },
 
 
-        title: '',
-        row: {},
-        form: {
-          id: '',
-          receiveDate: '',
-          carNo: '',
-          files: [],
+  methods: {
+    //打开新增编辑弹框
+    async open(type, row, orderId) {
+      this.batchNo = await getCode('lot_number_code');
+      this.title = type === 'add' ? '新增受托收货单' : '修改';
+      this.row = row;
+      if (orderId) {
+        await this.getOrderDetail(orderId);
+      }
+      if (row && row?.id) {
+        await this.getSendSaleOrderDetail(row?.id);
+      }
+
+      this.isUpdate = type !== 'add';
+      if (!this.isUpdate) {
+        this.form.receiveDate = new Date();
+      }
+    },
+    //选择订单弹框
+    handleOrderBtn(e) {
+      if (e.target.nodeName == 'I') {
+        this.form = Object.assign({}, this.form, {
+          contactId: '',
+          contactName: '',
           linkName: '',
           linkName: '',
           linkPhone: '',
           linkPhone: '',
-          orderId: '',
           orderNo: '',
           orderNo: '',
-          pricingWay: '',
+          orderId: '',
           productList: [],
           productList: [],
-          sendNoteNo: '',
-          contactId: '',
-          contactName: ''
-        },
-        rules: {
-          contactName: [
-            { required: true, message: '请选择客户名称', trigger: 'change' }
-          ],
-          linkName: [
-            { required: true, message: '请输入', trigger: ['blur', 'change'] }
-          ],
-          linkPhone: [
-            { required: true, message: '请输入', trigger: ['blur', 'change'] }
-          ],
-          orderNo: [{ required: true, message: '请选择', trigger: 'change' }],
-          receiveAddress: [
-            { required: true, message: '请输入', trigger: 'change' }
-          ]
-        },
-        customerMark: '',
-        // 提交状态
-        loading: false,
-        // 是否是修改
-        isUpdate: false,
-        processSubmitDialogFlag: false,
-        businessId: '',
-        batchNo:''
-      };
+          pricingWay: ''
+        });
+        this.$refs.inventoryTableref &&
+          this.$refs.inventoryTableref.putTableValue([]);
+        return;
+      }
+      this.$refs.orderListDialogRef.open();
+    },
+    //选择订单回调
+    changeOrder(obj) {
+      this.getOrderDetail(obj.id);
+    },
+    async getContactDetail(id) {
+      if (id) {
+        const { base } = await contactDetail(id);
+        this.customerMark = base.serialNo;
+      }
     },
     },
 
 
-    methods: {
-      //打开新增编辑弹框
-      async open(type, row, orderId) {
-        this.batchNo = await getCode('lot_number_code');
-        this.title = type === 'add' ? '新增受托收货单' : '修改';
-        this.row = row;
-        if (orderId) {
-          await this.getOrderDetail(orderId);
-        }
-        if (row && row?.id) {
-          await this.getSendSaleOrderDetail(row?.id);
-        }
+    //获取订单详情
+    async getOrderDetail(id) {
+      this.loading = true;
+      let data = await getSaleOrderDetail(id);
+      this.getContactDetail(data.partaId);
 
 
-        this.isUpdate = type !== 'add';
-        if (!this.isUpdate) {
-          this.form.receiveDate = new Date();
-        }
-      },
-      //选择订单弹框
-      handleOrderBtn(e) {
-        if (e.target.nodeName == 'I') {
+      this.loading = false;
+      if (data) {
+        this.$nextTick(async () => {
+          let {
+            partaId,
+            partaName,
+            partaTel,
+            orderNo,
+            id,
+            partaLinkName,
+            productList,
+            pricingWay
+          } = data;
+          let mbomCategoryList = [];
+          if (productList && productList.length > 0) {
+            productList.forEach((v) => {
+              let arr = v.saleOrderProductBomList.map((item) => {
+                item.categoryRootLevelId = item.categoryLevelPathIdParent;
+                item.productCode = item.categoryCode;
+                item.productId = item.categoryId;
+                item.productName = item.categoryName;
+                item.bomCode = item.bomCode;
+                item.discountSinglePrice = 0;
+                item.singlePrice = 0;
+                item['batchNo'] = this.batchNo;
+                item.totalCount = item.dosage * productList[0].totalCount;
+                return item;
+              });
+              mbomCategoryList.push(...arr);
+            });
+          }
           this.form = Object.assign({}, this.form, {
           this.form = Object.assign({}, this.form, {
-            contactId: '',
-            contactName: '',
-            linkName: '',
-            linkPhone: '',
-            orderNo: '',
-            orderId: '',
-            productList: [],
-            pricingWay: ''
+            contactId: partaId,
+            contactName: partaName,
+            linkName: partaLinkName,
+            linkPhone: partaTel,
+            orderNo,
+            orderId: id,
+            productList: mbomCategoryList,
+            pricingWay
           });
           });
           this.$refs.inventoryTableref &&
           this.$refs.inventoryTableref &&
-            this.$refs.inventoryTableref.putTableValue([]);
-          return;
-        }
-        this.$refs.orderListDialogRef.open();
-      },
-      //选择订单回调
-      changeOrder(obj) {
-        this.getOrderDetail(obj.id);
-      },
-      async getContactDetail(id) {
-        if (id) {
-          const { base } = await contactDetail(id);
-          this.customerMark = base.serialNo;
-        }
-      },
-
-      //获取订单详情
-      async getOrderDetail(id) {
-        this.loading = true;
-        let data = await getSaleOrderDetail(id);
-        this.getContactDetail(data.partaId);
+            this.$refs.inventoryTableref.putTableValue(this.form.productList);
+        });
+      }
+    },
+    // getBatchNo(arr) {
+    //   let promiseAll = [];
+    //   arr.forEach((item) => {
+    //     promiseAll.push(
+    //       new Promise((resolve, reject) => {
+    //         getCode('lot_number_code').then((res) => {
+    //           resolve(res);
+    //         });
+    //       })
+    //     );
+    //   });
+    //   return Promise.all(promiseAll);
+    // },
+    //发货单详情
+    async getSendSaleOrderDetail(id) {
+      this.businessId = id;
 
 
-        this.loading = false;
-        if (data) {
-          this.$nextTick(async () => {
-            let {
-              partaId,
-              partaName,
-              partaTel,
-              orderNo,
-              id,
-              partaLinkName,
-              productList,
-              pricingWay
-            } = data;
-            let mbomCategoryList = [];
-            if (productList && productList.length > 0) {
-              productList.forEach((v) => {
-                let arr = v.saleOrderProductBomList.map((item) => {
-                  item.categoryRootLevelId = item.categoryLevelPathIdParent;
-                  item.productCode = item.categoryCode;
-                  item.productId = item.categoryId;
-                  item.productName = item.categoryName;
-                  item.bomCode = item.bomCode;
-                  item.discountSinglePrice = 0;
-                  item.singlePrice = 0;
-                  item['batchNo'] = this.batchNo;
+      this.loading = true;
+      let data = await getPSaleEntrustedReceiveDetailAPI(id);
+      this.getContactDetail(data.contactId);
 
 
-                  return item;
-                });
-                mbomCategoryList.push(...arr);
-              });
+      this.loading = false;
+      if (data) {
+        this.$nextTick(() => {
+          this.form = data;
+          this.form.pricingWay = data?.saleOrder?.pricingWay;
+          this.$refs.inventoryTableref &&
+            this.$refs.inventoryTableref.putTableValue(data.productList);
+        });
+      }
+    },
+    //获取产品已发货数总量
+    async getTotalCountHistory(data) {
+      let list = await getReceiveCountAPI({
+        orderId: data.orderId,
+        entrustedReceiveId: this.form.id
+      });
+      data.productList.forEach((item) => {
+        let find =
+          list.find((key) => key.productCode == item.productCode) || {};
+        item.receiveTotalCount = find.receiveTotalCount || 0;
+        item.orderTotalCount = item.totalCount || 0;
+        item.totalCount =
+          item.orderTotalCount - item.receiveTotalCount >= 0
+            ? item.orderTotalCount - item.receiveTotalCount
+            : 0;
+      });
+      return data;
+    },
+    getValidate() {
+      return Promise.all([
+        new Promise((resolve, reject) => {
+          this.$refs.form.validate((valid) => {
+            if (!valid) {
+              reject(false);
+            } else {
+              resolve(true);
             }
             }
-            console.log(mbomCategoryList, 'mbomCategoryList');
-            this.form = Object.assign({}, this.form, {
-              contactId: partaId,
-              contactName: partaName,
-              linkName: partaLinkName,
-              linkPhone: partaTel,
-              orderNo,
-              orderId: id,
-              productList: mbomCategoryList,
-              pricingWay
-            });
-            this.$refs.inventoryTableref &&
-              this.$refs.inventoryTableref.putTableValue(this.form.productList);
           });
           });
-        }
-      },
-      // getBatchNo(arr) {
-      //   let promiseAll = [];
-      //   arr.forEach((item) => {
-      //     promiseAll.push(
-      //       new Promise((resolve, reject) => {
-      //         getCode('lot_number_code').then((res) => {
-      //           resolve(res);
-      //         });
-      //       })
-      //     );
-      //   });
-      //   return Promise.all(promiseAll);
-      // },
-      //发货单详情
-      async getSendSaleOrderDetail(id) {
-        this.businessId = id;
-
-        this.loading = true;
-        let data = await getPSaleEntrustedReceiveDetailAPI(id);
-        this.getContactDetail(data.contactId);
-
-        this.loading = false;
-        if (data) {
-          this.$nextTick(() => {
-            this.form = data;
-            this.form.pricingWay = data?.saleOrder?.pricingWay;
-            this.$refs.inventoryTableref &&
-              this.$refs.inventoryTableref.putTableValue(data.productList);
+        }),
+        new Promise((resolve, reject) => {
+          this.$refs.inventoryTableref.validateForm((valid) => {
+            if (!valid) {
+              reject(false);
+            } else {
+              resolve(true);
+            }
           });
           });
+        })
+      ]);
+    },
+    async save(type) {
+      try {
+        await this.getValidate();
+        // 表单验证通过,执行保存操作
+        this.loading = true;
+        if (!this.isUpdate) {
+          delete this.form.id;
         }
         }
-      },
-      //获取产品已发货数总量
-      async getTotalCountHistory(data) {
-        let list = await getReceiveCountAPI({
-          orderId: data.orderId,
-          entrustedReceiveId: this.form.id
-        });
-        data.productList.forEach((item) => {
-          let find =
-            list.find((key) => key.productCode == item.productCode) || {};
-          item.receiveTotalCount = find.receiveTotalCount || 0;
-          item.orderTotalCount = item.totalCount || 0;
-          item.totalCount =
-            item.orderTotalCount - item.receiveTotalCount >= 0
-              ? item.orderTotalCount - item.receiveTotalCount
-              : 0;
+        this.form.files = this.form.files || [];
+        // this.form.replied = this.form.repliedFiles.length > 0 ? 1 : 0;
+        let commitData = Object.assign({}, this.form, {
+          productList: this.$refs.inventoryTableref.getTableValue()
         });
         });
-        return data;
-      },
-      getValidate() {
-        return Promise.all([
-          new Promise((resolve, reject) => {
-            this.$refs.form.validate((valid) => {
-              if (!valid) {
-                reject(false);
-              } else {
-                resolve(true);
-              }
-            });
-          }),
-          new Promise((resolve, reject) => {
-            this.$refs.inventoryTableref.validateForm((valid) => {
-              if (!valid) {
-                reject(false);
-              } else {
-                resolve(true);
-              }
-            });
+        const API = this.isUpdate
+          ? updateSaleEntrustedReceiveAPI
+          : saveSaleEntrustedReceiveAPI;
+        API(commitData)
+          .then((res) => {
+            this.loading = false;
+            this.$message.success('操作成功');
+            if (type === 'sub') {
+              this.sendSubmit(res);
+              return;
+            }
+            this.cancel();
+            this.$emit('done');
           })
           })
-        ]);
-      },
-      async save(type) {
-        try {
-          await this.getValidate();
-          // 表单验证通过,执行保存操作
-          this.loading = true;
-          if (!this.isUpdate) {
-            delete this.form.id;
-          }
-          this.form.files = this.form.files || [];
-          // this.form.replied = this.form.repliedFiles.length > 0 ? 1 : 0;
-          let commitData = Object.assign({}, this.form, {
-            productList: this.$refs.inventoryTableref.getTableValue()
+          .catch((e) => {
+            this.loading = false;
           });
           });
-          const API = this.isUpdate
-            ? updateSaleEntrustedReceiveAPI
-            : saveSaleEntrustedReceiveAPI;
-          API(commitData)
-            .then((res) => {
-              this.loading = false;
-              this.$message.success('操作成功');
-              if (type === 'sub') {
-                this.sendSubmit(res);
-                return;
-              }
-              this.cancel();
-              this.$emit('done');
-            })
-            .catch((e) => {
-              this.loading = false;
-            });
-        } catch (error) {
-          console.log(error);
-          // 表单验证未通过,不执行保存操作
-        }
-      },
-      async sendSubmit(res) {
-        let data = await getPSaleEntrustedReceiveDetailAPI(
-          this.businessId || res
-        );
-        this.processSubmitDialogFlag = true;
-        let storemanIds = '';
-        let ids = data.productList.map((item) => item.warehouseId);
-        let warehouseList = await getWarehouseListByIds(ids || []);
-        storemanIds = warehouseList.map((item) => item.ownerId);
+      } catch (error) {
+        console.log(error);
+        // 表单验证未通过,不执行保存操作
+      }
+    },
+    async sendSubmit(res) {
+      let data = await getPSaleEntrustedReceiveDetailAPI(
+        this.businessId || res
+      );
+      this.processSubmitDialogFlag = true;
+      let storemanIds = '';
+      let ids = data.productList.map((item) => item.warehouseId);
+      let warehouseList = await getWarehouseListByIds(ids || []);
+      storemanIds = warehouseList.map((item) => item.ownerId);
 
 
-        this.$nextTick(() => {
-          let params = {
-            businessId: this.businessId || res,
-            businessKey: 'sale_entrusted_receive_approve',
-            formCreateUserId: data.createUserId,
-            variables: {
-              businessCode: data.code,
-              businessType: '受托收货',
-              storemanIds: storemanIds.toString(),
-              businessName: data.productNames
-            }
-            // 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.$nextTick(() => {
+        let params = {
+          businessId: this.businessId || res,
+          businessKey: 'sale_entrusted_receive_approve',
+          formCreateUserId: data.createUserId,
+          variables: {
+            businessCode: data.code,
+            businessType: '受托收货',
+            storemanIds: storemanIds.toString(),
+            businessName: data.productNames
+          }
+          // 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);
-        });
-        // submit({
-        //   businessId: this.businessId || res,
-        //   // productionSupervisorId
-        // }).then((res) => {
-        //   this.cancel();
-        //   this.$emit('done');
-        // });
-      },
-      reload() {
-        this.cancel();
-        this.$emit('done');
-      },
-      cancel() {
-        this.$emit('update:addOrEditDialogFlag', false);
-      }
+        this.$refs.processSubmitDialogRef.init(params);
+      });
+      // submit({
+      //   businessId: this.businessId || res,
+      //   // productionSupervisorId
+      // }).then((res) => {
+      //   this.cancel();
+      //   this.$emit('done');
+      // });
+    },
+    reload() {
+      this.cancel();
+      this.$emit('done');
+    },
+    cancel() {
+      this.$emit('update:addOrEditDialogFlag', false);
     }
     }
-  };
+  }
+};
 </script>
 </script>
 <style scoped lang="scss">
 <style scoped lang="scss">
-  .TotalAmount {
-    font-size: 16px;
-    padding-right: 30px;
-  }
+.TotalAmount {
+  font-size: 16px;
+  padding-right: 30px;
+}
 
 
-  .headbox {
-    display: flex;
-    justify-content: flex-start;
-    align-items: center;
+.headbox {
+  display: flex;
+  justify-content: flex-start;
+  align-items: center;
 
 
-    .amount {
-      font-size: 14px;
-      font-weight: bold;
-      margin-right: 20px;
-    }
+  .amount {
+    font-size: 14px;
+    font-weight: bold;
+    margin-right: 20px;
   }
   }
+}
 </style>
 </style>