qingyiay
2023-03-31 04f3f15c930c2b02187d0ce11d68978b65361d54
pages/public-page/forward/forward.vue
@@ -3,10 +3,10 @@
   <view class="forward">
      <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">
      <view class="forward-card" v-for="(val, index) in jhOrderPlanForwardList" :key="index">
         <u--form labelPosition="top" :model="forwardForm" ref="form1">
            <u-form-item label="转发对象" labelWidth="20%" ref="item1" @click="forwardObjectClick(index)">
               <u--input v-model="val.name" placeholder="点击选择转发对象"></u--input>
               <u--input v-model="val.name" placeholder="点击选择转发对象" :readonly="true"></u--input>
            </u-form-item>
            <u-form-item label="输入数量" labelWidth="20%" ref="item1">
               <view class="forward-card-amount">
@@ -59,22 +59,27 @@
      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;
         } else if (params.carNumSurplusHuodai != 0) {
            this.forwardSurplus = params.carNumSurplusHuodai;
         }
      }
      this.carNumSurplusHuodai = this.forwardSurplus = Number(params.carNumSurplusHuodai);
      this.orderPlanId = params.orderPlanId;
      this.$reqGet('forwardList', { OrderPlanId: params.orderPlanId }).then(res => {
         if (res.data.length !== 0) {
         if (res.data.length !== 0 && this.roleType == 1) {
            this.jhOrderPlanForwardList = res.data.map(item => {
               return {
                  id: item.id,
                  orderPlanId: item.orderPlanId,
                  name: item.xsUserName === null ? item.fleetName : item.xsUserName,
                  carNum: item.carNum,
                  xsUserId: item.xsUserId === null ? 0 : item.xsUserId,
                  fleetId: item.fleetId === null ? 0 : item.fleetId,
                  checkboxValue1: ''
               };
            });
         } 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,
@@ -167,6 +172,7 @@
      checkboxChange(value, index) {
         console.log('复选框变化', value, index);
         if (value.length != 0) {
            console.log(this.forwardSurplus, '货代转发全部数量');
            this.jhOrderPlanForwardList[index].carNum = this.forwardSurplus;
         } else {
            this.jhOrderPlanForwardList[index].carNum = null;
@@ -226,15 +232,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('删除成功');
         }
      },
      // 提交
@@ -245,22 +255,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);
               }
            });
         }