yangan
2024-10-28 3a0823db9324207eb54b1747dfe3d2c6d52a9962
pages/public-page/forward/forward.vue
@@ -15,7 +15,7 @@
         <u-notice-bar :text="text"
            :fontSize="30"></u-notice-bar>
         <view class="notice-icon"
            style="background: url('https://mx.jzeg.cn:9096/appimg/image/banner/notice.png') no-repeat;background-size: cover; width: 42rpx;height: 42rpx;">
            style="background: url('https://wrzs.czjlchem.com:9090/appimg/image/banner/notice.png') no-repeat;background-size: cover; width: 42rpx;height: 42rpx;">
         </view>
      </view>
      <view v-else-if="roleType == 2"
@@ -73,7 +73,9 @@
                                    </u-checkbox-group>
                                 </view>
                              </u-form-item>
                           </u--form>
                           <view><u-button v-if="fenpeiFlag " text="分配日计划吨数" type="primary" :plain="true" @click="todoFenPei(val)"></u-button></view>
                        </view>
                     </view>
                  </view>
@@ -90,7 +92,7 @@
               :disabled="whetherClick"></u-button></view>
         <!--分享日计划  -->
         <view 
         class="AdddBtn"><u-button text="分享日计划"
         class="AdddBtn" v-if="isshow && roleType!== 2 "><u-button text="分享日计划"
               :hairline="false"
               open-type="share"
               :loading='loading'></u-button></view>
@@ -106,7 +108,7 @@
      </view>
      <!-- 增加按钮 -->
      <!-- 选择货代或车队弹出框 -->
      <!-- 选择承运商或车队弹出框 -->
      <view class="selectHuoDaiOrFleet-container">
         <u-popup :show="selectPopupShow"
            mode="bottom"
@@ -160,17 +162,23 @@
   export default {
      onLoad(params) {
         console.log(params, '转发页面的参数');
         let reg=RegExp(/销/)
         this.isshow=!reg.test(params.orderType)
         this.productName = params.productName;
         this.customerId = params.customerId;
         this.packingType = params.packingType;
         this.pvcPlanMeasure = params.pvcPlanMeasure;
         // 客户
         this.cars2 = Number(params.cars2);
         this.tempcarNumSurplus1 = this.carNumSurplus1 = Number(params.carNumSurplus1 || 0);
         // 货代
         // 承运商
         this.carNum = Number(params.carNum);
         this.carNumSurplusHuodai = this.forwardSurplus = Number(params.carNumSurplusHuodai || 0);
         this.orderPlanId = params.orderPlanId;
         // 判断是否转发完成 完成则不可再添加
         if (this.roleType === 1) {  //roleType 1客户
            this.whetherClick = this.carNumSurplus1 === 0
         } else if (this.roleType === 2) {  //roleType 2货代
         } else if (this.roleType === 2) {  //roleType 2承运商
            this.whetherClick = this.forwardSurplus === 0
         }
         this.getOrderPlan()
@@ -189,8 +197,13 @@
      data() {
         return {
            isshow:false,
            pvcPlanMeasure:'',
            forwardSurplus: 0,
            paramsName: {},
            packingType:'',
            productName:'',
            customerId:'',
            huoDaiData: [],
            isClickFlag:true,// true 可以 or false for forward and back to the direction of the car direction (default       
            fleetData: [],
@@ -198,9 +211,9 @@
            orderPlanId: '',
            jhOrderPlanForwardList: [{  //转发对象
               orderPlanId: '',  //日计划Id
               name: '',  //车队或货代名称
               name: '',  //车队或承运商名称
               carNum: null,  //转发数量
               xsUserId: 0,  //货代Id
               xsUserId: 0,  //承运商Id
               fleetId: 0,  //车队Id
               checkboxValue1: '',  //全部转发
               isSelected: false
@@ -209,9 +222,9 @@
            index: '',
            checkboxValue1: '',
            selectPopupShow: false,
            list1: [{ name: '车队' }, { name: '货代' }],
            list1: [{ name: '车队' }], //{ name: '承运商' }
            tabHuoDai: false,
            carNumSurplus1: '',  //剩余的提煤单数量(转发的数量 - 领取的数量)
            carNumSurplus1: '',  //剩余的收发单数量(转发的数量 - 领取的数量)
            tempcarNumSurplus1: '',
            cars2: '',  //已经领取的车数
            carNum: '',
@@ -230,6 +243,7 @@
            }],
            loading: false, //提交loading
            originForwardName: '', //原转发对象
            isShow:false,
            laterForwardName: '', //后转发对象
            errorDataList: [], // 错误数据
            isDirectAdd: false, // 是否是在原来有对象的item修改 是的为true
@@ -238,6 +252,8 @@
      },
      onShow() {
         this.init();
         this.getBuild();
         // this.getOrderPlan();
         if (this.roleType == 2) {
            this.list1.splice(1, 1);
            this.tabHuoDai = false;
@@ -248,10 +264,18 @@
            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}张收发单`;
         },
         fenpeiFlag(){
            console.log(this.productName,this.packingType,'122222222cumped',/聚氯乙烯树脂/.test(this.productName) || (this.packingType &&  this.packingType == '1'))
            if(/聚氯乙烯树脂/.test(this.productName) || (this.packingType &&  this.packingType == '1')){
               return true
            }else{
               return false
            }
         }
      },
      methods: {
@@ -261,6 +285,12 @@
            })
            this.$reqGet('forwardList', { OrderPlanId: this.orderPlanId }).then(res => {
               uni.hideLoading()
               if(res.data.length){
                  this.isShow = true;
               }else{
                  this.isShow =  false;
               }
               if (res.data.length !== 0 && this.roleType == 1) {
                  this.jhOrderPlanForwardList = res.data.map((item, index) => {
                     return {
@@ -302,6 +332,15 @@
            }).catch(e => {
               uni.hideLoading()
            })
         },
         getBuild(){
            console.log(this.productName,'opr')
            if(/聚氯乙烯树脂/.test(this.productName)){
               this.$reqGet('getBuildList',{orderPlanId:this.orderPlanId,customerId:this.customerId}).then(res=>{
               console.log(res,'resss')
            })
            }
         },
         // 返回上一页
         back() {
@@ -371,7 +410,7 @@
               this.calculate(this.jhOrderPlanForwardList);
            }
         },
         // 获取货代列表
         // 获取承运商列表
         getAllHuoDaiByCustomerId() {
            this.$reqGet('getAllHuoDaiByCustomerId').then(res => {
               this.huoDaiData = res.data;
@@ -400,7 +439,7 @@
            this.selectPopupShow = false;
         },
         selectPopupOpen() {},
         // 转发选择货代
         // 转发选择承运商
         forwardHuoDaiObjectSelect(item, index) {
            this.$nextTick(() => {
               // let isableAdd = this.jhOrderPlanForwardList.filter(v => item.name === v.name);
@@ -423,7 +462,7 @@
               // })
               //    this.selectPopupShow = false;
               // } else {
               //    this.$u.toast('提煤单剩余数为0或已添加');
               //    this.$u.toast('收发单剩余数为0或已添加');
               //    this.selectPopupShow = true;
               // }
               // } else {
@@ -436,7 +475,7 @@
                  this.jhOrderPlanForwardList[this.index].xsUserId = item.userId;
                  this.jhOrderPlanForwardList[this.index].name = item.name;
                  this.jhOrderPlanForwardList[this.index].fleetId = 0;
                  this.jhOrderPlanForwardList[this.index].forWardType = 1;  //forWardType 转发类型 货代1 车队2
                  this.jhOrderPlanForwardList[this.index].forWardType = 1;  //forWardType 转发类型 承运商1 车队2
               }
               // }
            });
@@ -464,10 +503,11 @@
               // })
               //    this.selectPopupShow = false;
               // } else {
               //    this.$u.toast('提煤单剩余数为0或已添加');
               //    this.$u.toast('收发单剩余数为0或已添加');
               //    this.selectPopupShow = true;
               // }
               // } else {
               console.log(this.jhOrderPlanForwardList,item,'jhOrderPlanForwardList')
               let isableAdd = this.jhOrderPlanForwardList.filter(v => item.name === v.name);
               if (isableAdd.length > 0) {
                  this.$u.toast('存在重复添加');
@@ -482,25 +522,25 @@
               // }
            });
         },
         // 计算提煤单数量,添加或删除时调用
         // 计算收发单数量,添加或删除时调用
         calculate(arr) {
            let total = arr.reduce((prev, cur) => {
               return cur.carNum + prev;
            }, 0);
            console.log(total, '提煤单一共的数据');
        //roleType 1客户 2 货代 3司机 5装卸员
            console.log(total, '收发单一共的数据');
        //roleType 1客户 2 承运商 3司机 5装卸员
            if (this.roleType == 1) {
               if (Number(this.cars2) > total) {
                  this.carNumSurplus1 = Number(this.cars2) - total;
                  this.whetherClick = false;
                  this.whetherClick1 = false;
               } else if (Number(this.cars2) == total) {  //剩余的提煤单为0(添加、提交按钮不能点击)
               } else if (Number(this.cars2) == total) {  //剩余的收发单为0(添加、提交按钮不能点击)
                  this.whetherClick = true;
                  this.whetherClick1 = false;
                  this.carNumSurplus1 = Number(this.cars2) - total;
               } else {
                  this.carNumSurplus1 = 0;
                  this.$u.toast('剩余提煤单数量不足');
                  this.$u.toast('剩余收发单数量不足');
                  this.whetherClick = true;
                  this.whetherClick1 = true;
               }
@@ -516,7 +556,7 @@
                  this.carNumSurplusHuodai = Number(this.carNum) - total;
               } else {
                  this.carNumSurplusHuodai = 0;
                  this.$u.toast('剩余提煤单数量不足');
                  this.$u.toast('剩余收发单数量不足');
                  this.whetherClick = true;
                  this.whetherClick1 = true;
               }
@@ -526,7 +566,7 @@
            let time;
            let that = this;
            that.$set(that.jhOrderPlanForwardList[index], 'carNum', Number(value));
        //forWardType 转发类型 1货代 2车队
        //forWardType 转发类型 1承运商 2车队
            that.$set(that.jhOrderPlanForwardList[index], 'forWardType', xsUserId ? 1 : 2);
            return (function() {
               if (!time) {
@@ -604,6 +644,7 @@
         },
         // 提交
         submitForm() {
            //车数 * 吨数 <  计划吨数
            let isPass = false;
            if (this.jhOrderPlanForwardList.length === 0) {
               this.$u.toast('请至少选择一组转发对象');
@@ -612,6 +653,10 @@
            this.jhOrderPlanForwardList.forEach(v => {
               if (!reg.test(v.carNum) || Number(v.carNum) <= 0) {
                  this.$u.toast('请输入合法数字');
                  isPass = false;
                  return isPass;
               } else if (!v.name){
                  this.$u.toast('请选择车队');
                  isPass = false;
                  return isPass;
               } else {
@@ -625,12 +670,22 @@
               this.$reqPost('forward', this.jhOrderPlanForwardList, 'json').then(res => {
                  console.log(res, 'zh');
                  // res.data.length == 0 提交成功 否则提交失败
                  if (res.data.length == 0) {
                  if (res.code === 0) {
                     this.loading = false
                     this.$u.toast('提交成功');
                     setTimeout(() => {
                     if(this.fenpeiFlag){
                        setTimeout(()=>{
                           uni
               .navigateTo({ url: `/subPages/allocaTetonnage/index?orderPlanId=${this.orderPlanId}&customerId=${this.customerId}&status=${1}&pvcPlanMeasure=${this.pvcPlanMeasure}`});
                        },500)
                     }else{
                        setTimeout(() => {
                        uni.navigateBack({ delta: 1 });
                     }, 1000);
                     }
                  } else {
                     this.loading = false
                     this.errorDataList = res.data
@@ -642,12 +697,16 @@
            }
         },
         tabClick(item) {
            if (item.name == '货代') {
            if (item.name == '承运商') {
               this.tabHuoDai = true;
            } else {
               this.tabHuoDai = false;
            }
         },
         todoFenPei(val){
            uni
               .navigateTo({ url: `/subPages/allocaTetonnage/index?orderPlanId=${this.orderPlanId}&customerId=${this.customerId}&fleetId=${val.fleetId}&pvcPlanMeasure=${this.pvcPlanMeasure}`});
         }
      }
   };
</script>
@@ -741,7 +800,7 @@
            .forward-card {
               margin-top: vww(10);
               width: 690rpx;
               height: 275rpx;
               height: 400rpx;
               background: #ffffff;
               box-shadow: 4rpx 6rpx 25rpx 0rpx rgba(73, 120, 240, 0.15);
               border-radius: 20rpx;