qingyiay
2023-05-09 01e96c8855927df67ac8a6831e345b6cb33140d1
pages/public-page/forward/forward.vue
@@ -11,7 +11,7 @@
            <u-form-item label="输入数量" labelWidth="20%" ref="item1">
               <view class="forward-card-amount">
                  <view class="forward-card-amount-input"><u--input v-model="val.carNum" placeholder="请输入转发数量"></u--input></view>
                  <u-checkbox-group v-model="val.checkboxValue1" placement="column" @change="v => checkboxChange(v, index)">
                  <u-checkbox-group v-model="val.checkboxValue1" placement="column" @change="v => checkboxChange(v, index, val)">
                     <u-checkbox :customStyle="{ marginBottom: '8px' }" size="30" labelSize="30" label="全部转发" name="全部转发" :disabled="val.ischecked"></u-checkbox>
                  </u-checkbox-group>
               </view>
@@ -125,20 +125,15 @@
         index: '',
         checkboxValue1: '',
         selectPopupShow: false,
         list1: [
            {
               name: '车队'
            },
            {
               name: '货代'
            }
         ],
         list1: [{ name: '车队' }, { name: '货代' }],
         tabHuoDai: false,
         carNumSurplus1: '',
         cars2: '',
         carNum: '',
         carNumSurplusHuodai: '',
         formNum: 1
         formNum: 1,
         // 个人转发数据
         personalForward: {}
      };
   },
   onShow() {
@@ -153,15 +148,14 @@
         return uni.getStorageSync('roleType');
      },
      text() {
         return `已领取${this.cars2}张日计划单,剩余${this.carNumSurplus1}张日计划单`;
         return `已领取${this.cars2}张提煤单,剩余${this.carNumSurplus1}张提煤单`;
      },
      text1() {
         return `已拥有${this.carNum}张日计划单,剩余${this.carNumSurplusHuodai}张日计划单`;
         return `已拥有${this.carNum}张提煤单,剩余${this.carNumSurplusHuodai}张提煤单`;
      }
   },
   methods: {
      init() {
         console.log('roleType', this.roleType);
         switch (this.roleType) {
            case 1:
               this.getAllHuoDaiByCustomerId();
@@ -177,22 +171,22 @@
      allrelay(x, y) {
         let a = 0;
         if (y != 0) {
            a = x + y;
            a = Number(x) + Number(y);
            return a;
         } else {
            return x;
            return Number(x);
         }
      },
      allrelayto(x, y) {
         let a = 0;
         if (y != 0) {
            a = x - y;
            a = Number(x) - Number(y);
            return a;
         } else {
            return x;
            return Number(x);
         }
      },
      checkboxChange(value, index) {
      checkboxChange(value, index, v) {
         uni.setStorageSync('allrelay', this.jhOrderPlanForwardList[index].carNum);
         this.jhOrderPlanForwardList = this.jhOrderPlanForwardList.map((v, i) => {
            return {
@@ -203,17 +197,36 @@
         if (value.length != 0) {
            let tempforwardSurplus = this.forwardSurplus;
            let tempcarNumSurplus1 = this.carNumSurplus1;
            // 计算全部转发数
            // 客户
            if (this.roleType == 1) {
               this.jhOrderPlanForwardList[index].carNum = this.allrelay(this.jhOrderPlanForwardList[index].carNum, tempcarNumSurplus1);
            if (v.id) {
               this.$reqGet('jhorderplanforward', { forwardId: v.id }).then(res => {
                  this.personalForward = res.data;
                  // 计算全部转发数
                  // 客户
                  if (this.roleType == 1) {
                     this.jhOrderPlanForwardList[index].carNum = this.allrelay(this.personalForward.carNum, tempcarNumSurplus1);
                     if (this.jhOrderPlanForwardList[index].carNum == 0) {
                        this.jhOrderPlanForwardList[index].carNum == tempcarNumSurplus1;
                     }
                  }
                  tempcarNumSurplus1 = 0;
                  // 货代
                  if (this.roleType == 2) {
                     this.jhOrderPlanForwardList[index].carNum = this.allrelay(this.personalForward.carNum, tempforwardSurplus);
                  }
                  tempforwardSurplus = 0;
               });
            } else {
               if (this.roleType == 1) {
                  this.jhOrderPlanForwardList[index].carNum = this.carNumSurplus1;
                  // this.allrelay(this.jhOrderPlanForwardList[index].carNum, this.carNumSurplus1);
               }
               tempcarNumSurplus1 = 0;
               if (this.roleType == 2) {
                  this.jhOrderPlanForwardList[index].carNum = this.forwardSurplus;
                  // this.allrelay(this.jhOrderPlanForwardList[index].carNum, this.forwardSurplus);
               }
               tempforwardSurplus = 0;
            }
            tempcarNumSurplus1 = 0;
            // 货代
            if (this.roleType == 2) {
               this.jhOrderPlanForwardList[index].carNum = this.allrelay(this.jhOrderPlanForwardList[index].carNum, tempforwardSurplus);
            }
            tempforwardSurplus = 0;
            // 选择一个后其余禁止复选
            this.jhOrderPlanForwardList.forEach((v, i) => {
               if (i !== index) {
@@ -225,11 +238,17 @@
            let tempcarNumSurplus1 = this.carNumSurplus1;
            // 货代
            if (this.roleType == 2) {
               this.jhOrderPlanForwardList[index].carNum = this.allrelayto(this.jhOrderPlanForwardList[index].carNum, this.forwardSurplus);
               this.jhOrderPlanForwardList[index].carNum = 0;
               if (this.jhOrderPlanForwardList[index].carNum <= 0) {
                  this.jhOrderPlanForwardList[index].carNum = 0;
               }
            }
            // 客户
            if (this.roleType == 1) {
               this.jhOrderPlanForwardList[index].carNum = this.allrelayto(this.jhOrderPlanForwardList[index].carNum, this.carNumSurplus1);
               this.jhOrderPlanForwardList[index].carNum = 0;
               if (this.jhOrderPlanForwardList[index].carNum <= 0) {
                  this.jhOrderPlanForwardList[index].carNum = 0;
               }
            }
         }
      },
@@ -333,8 +352,9 @@
         if (this.jhOrderPlanForwardList.length === 0) {
            this.$u.toast('请至少选择一组转发对象');
         }
         let reg = /^[1-9]\d*$/;
         this.jhOrderPlanForwardList.forEach(v => {
            if (isNaN(Number(v.carNum)) || Number(v.carNum) <= 0) {
            if (!reg.test(v.carNum) || Number(v.carNum) <= 0) {
               this.$u.toast('请输入合法数字');
               isPass = false;
               return isPass;