qingyiay
2023-03-29 82af85eae92790fc125ca42d1a800046fe0bd916
pages/public-page/forward/forward.vue
@@ -1,7 +1,8 @@
<template>
   <!-- 转发 -->
   <view class="forward">
      <view><u-notice-bar :text="text" :fontSize="30" mode="link"></u-notice-bar></view>
      <view v-if="roleType == 1"><u-notice-bar :text="text" :fontSize="30" mode="link"></u-notice-bar></view>
      <view v-else-if="roleType == 2"><u-notice-bar :text="text1" :fontSize="30" mode="link"></u-notice-bar></view>
      <view class="forward-card" v-for="(val, index) in jhOrderPlanForwardList">
         <u--form labelPosition="top" :model="forwardForm" ref="form1">
            <u-form-item label="转发对象" labelWidth="20%" ref="item1" @click="forwardObjectClick(index)">
@@ -53,8 +54,12 @@
export default {
   onLoad(params) {
      // 客户
      this.cars2 = Number(params.cars2);
      this.carNumSurplus1 = Number(params.carNumSurplus1);
      // 货代
      this.carNum = Number(params.carNum);
      this.carNumSurplusHuodai = Number(params.carNumSurplusHuodai);
      if (params.carNumSurplus1 || params.carNumSurplusHuodai) {
         if (params.carNumSurplus1 != 0) {
            this.forwardSurplus = params.carNumSurplus1;
@@ -64,7 +69,7 @@
      }
      this.orderPlanId = params.orderPlanId;
      this.$reqGet('forwardList', { OrderPlanId: params.orderPlanId }).then(res => {
         if (res.data) {
         if (res.data.length !== 0 && this.roleType == 1) {
            this.jhOrderPlanForwardList = res.data.map(item => {
               return {
                  id: item.id,
@@ -76,7 +81,18 @@
                  checkboxValue1: ''
               };
            });
            console.log(this.jhOrderPlanForwardList, '列表');
         } else if (res.data.length !== 0 && this.roleType == 2) {
            this.jhOrderPlanForwardList = res.data.map(item => {
               return {
                  id: item.id,
                  orderPlanId: item.orderPlanId,
                  name: item.fleetName,
                  carNum: item.carNum,
                  xsUserId: item.xsUserId === null ? 0 : item.xsUserId,
                  fleetId: item.fleetId === null ? 0 : item.fleetId,
                  checkboxValue1: ''
               };
            });
         } else {
            this.jhOrderPlanForwardList = this.jhOrderPlanForwardList.map(v => {
               if (!v.orderPlanId) {
@@ -122,6 +138,8 @@
         tabHuoDai: false,
         carNumSurplus1: '',
         cars2: '',
         carNum: '',
         carNumSurplusHuodai: '',
         formNum: 1
      };
   },
@@ -138,6 +156,9 @@
      },
      text() {
         return `已领取${this.cars2}张日计划单,剩余${this.carNumSurplus1}张日计划单`;
      },
      text1() {
         return `已拥有${this.carNum}张日计划单,剩余${this.carNumSurplusHuodai}张日计划单`;
      }
   },
   methods: {
@@ -217,15 +238,19 @@
      },
      // 删除一组表单
      deleteGroup(index, v) {
         if (v.id) {
         let tempcarNum = v.carNum;
         if (v.id && this.jhOrderPlanForwardList[index].carNum !== tempcarNum) {
            this.$reqPost('deleteForward', { id: v.id }, 'params').then(res => {
               if (res.code === 0) {
                  this.jhOrderPlanForwardList.splice(index, 1);
                  this.$u.toast('删除成功');
               } else if (res.code === 1) {
                  this.$u.toast(res.msg);
               }
            });
         } else {
            this.jhOrderPlanForwardList.splice(index, 1);
            this.$u.toast('删除成功');
         }
      },
      // 提交
@@ -236,22 +261,27 @@
               this.$u.toast('请输入合法数字');
               isPass = false;
               return isPass;
            } else if (Number(v.carNum) > Number(this.forwardSurplus)) {
               this.$u.toast('超过最大订单剩余量');
               isPass = false;
               return isPass;
            } else {
            }
            // else if (Number(v.carNum) > Number(this.forwardSurplus)) {
            //    this.$u.toast('超过最大订单剩余量');
            //    isPass = false;
            //    return isPass;
            // }
            else {
               isPass = true;
               return isPass;
            }
         });
         if (isPass) {
            this.$reqPost('forward', this.jhOrderPlanForwardList, 'json').then(res => {
               console.log(res, 'zh');
               if (res.code == 0) {
                  this.$u.toast('提交成功');
                  setTimeout(() => {
                     uni.navigateBack({ delta: 1 });
                  }, 1000);
               } else {
                  this.$u.toast(res.msg);
               }
            });
         }