yangan
2024-10-28 93c421bb25860b60aed6a1a75f2927f8ac4789af
subPages/addDailyPlan/addDailyPlan.vue
@@ -44,8 +44,28 @@
                     class="customer-name_block-input"
                     placeholder="请输入车数"
                     border="surround"
                     :disabled="isNumOk"
                     v-model="value"
                  ></u--input>
            </view>
         </view>
            <!-- 客户名称 -->
            <view class="customer-name">
            <view class="customer-name_label" style="display: flex; align-items: center;">
               合卡订单
               <view style="width: 50%;margin-left: 30rpx;"><u-button  text='选择需要合卡订单'     :disabled="!deptId" @click="todoUncoid"></u-button></view>
            </view>
            <view class="customer-name_block">
                    <u-input
                    @clear="clearInp"
                    clearable
                     class="customer-name_block-input"
                     placeholder="请选择订单"
                     border="surround"
                     v-model="activeName"
                     :disabled="!deptId"
                  ></u-input>
            </view>
         </view>
             <view class="table">
@@ -55,18 +75,24 @@
         emptyText="暂无更多数据">
               <uni-tr>
                   <uni-th align="center">产品名称</uni-th>
                  <uni-th align="center">类型</uni-th>
                   <uni-th align="center">仓库</uni-th>
                  <uni-th align="center">规格</uni-th>
                  <uni-th align="center" v-if="isNumOk">数量</uni-th>
                  <uni-th align="center">订单余量</uni-th>
               </uni-tr>
               <uni-tr v-for="(item, index) in subDataList" :key="index">
                  <uni-td align="center">
                     <view>{{   item.productName}}</view></uni-td>
               <uni-td>
                  <view class="name">{{ item.orderType }}</view>
               </uni-td>
                <uni-td align="center">
               <view>{{ item.bunkerName }}</view></uni-td>
                     <uni-td align="center">
                     <view>{{   item.productSpecs}}</view></uni-td>
                   <uni-td align="center" v-if="isNumOk">
                  <view>
                     <u--input
                     v-model="subDataList[index].nums"
                     border="surround"
                     placeholder="请输入数量" />
                        </view></uni-td>
                        <uni-td align="center">
                           <view>{{   item.surplusQuant}}</view></uni-td>
            </uni-tr>
            </uni-table>
       </view>
@@ -103,7 +129,7 @@
                     v-for="item in customerNameList"
                     @click="selectCustomer(item)">
                     <view class="item-image">
                        <image src="https://mx.jzeg.cn:9096/appimg/image/banner/address.png"
                        <image src="https://wrzs.czjlchem.com:9090/appimg/image/banner/address.png"
                           mode="widthFix"
                           style="width: 18px;"></image>
                     </view>
@@ -135,27 +161,53 @@
         this.sendDate = this.sendDateStart = dayjs().format('YYYY-MM-DD')
         this.sendDateEnd = dayjs().add(7, 'day').format('YYYY-MM-DD')
      },
      onShow(){
         uni.$on('updateData',(data)=>{
            console.log('监听到事件来自 updateData ,携带参数为:' + JSON.parse( JSON.stringify(data)) , JSON.parse(data) .id );
            const params = JSON.parse(data);
            // this.checkList2 = params.map(item=>{
            //    item.text = item.orderCode + '/' + item.customerName;
            //    return item;
            // });
            // let temp = this.checkList2;
            // this.closeOrderIds = temp.map(item=>item.id).join(',')
            this.activeName = params.orderCode  +'/' + params.customerName;
            this.closeOrderId = params.id;
         })
      },
      data() {
         return {
            selfDeliverShow: false,
            deptId: '',
            checkList:[],
            deptName: '',
            mapProductNum:'',
            activeName:'',
            isNumOk:false,
            isNumData:[],
            checkList2:[],
            deptList: [],
            uncoidCard:'',
            productName: '',
            productNameList: [],
            filedId: '',
            filedName: '',
            unionParams:{},
            filedNameList: [],
            sendDate: '',
            sendDateStart: '',
            sendDateEnd: '',
            customerId: '',
            closeOrderIds:'',
            value:'',
            customerName: '',
            customerNameList: [],
            buildLoading: false,
            subDataList:[],
            isWeighing:'',
            orderType:'',
         }
      },
      computed: {
@@ -202,16 +254,64 @@
                        this.deptId = this.customerNameList[0].value; //选择当前 
                        // if(this.deptId){
                        //    this.deptChange(this.deptId);
                        // }
                        // }
                        this.unionParams = {
                           orderId:this.customerNameList[0].id,
                           deptId:this.customerNameList[0].deptId,
                           customerId:this.customerNameList[0].customerId,
                           productId:this.customerNameList[0].productId
                        }
                     }else{
                        this.deptId = '';
                     }
            
                     if(this.deptId){
                  this.subDataList = this.customerNameList.filter(item=>item.id === e).length ? 
                     this.customerNameList.filter(item=>item.id === e)[0].tmOrderList  : []; 
                  this.subDataList.map(item=>{
                     item.nums = item.surplusQuant
                     return item
                  })
                  console.log(this.subDataList,'subDataList')
                  const tempArr = this.customerNameList.filter(item=>item.id === e);
                  if(tempArr.length){
                     this.unionParams = {
                           orderId:tempArr[0].id,
                           deptId:tempArr[0].deptId,
                           customerId:tempArr[0].customerId,
                           productId:tempArr[0].productId
                        }
                  }else{
                     this.unionParams = {
                           orderId:'',
                           deptId:'',
                           customerId:'',
                           productId:'',
                        }
                  }
                     }else{
                        this.subDataList = [];
                     }
                     //查看是不是采购的计数
                     if(this.subDataList.find(item=>item.isWeight === 0)){
                        this.isNumOk = true;
                        this.value = 1;
                     } else{
                        this.isNumOk = false;
                     }
                     if(this.isNumOk){
                        let tempArr = [];
                        this.subDataList.forEach(item=>{
                        tempArr.push(item.productId + ':' + item.surplusQuant);
                        this.isWeighing = item.isWeight;
                        this.orderType = item.orderType;
                        })
                        this.mapProductNum = tempArr.join(",")
                     }else{
                        this.mapProductNum = '';
                     }
                  }
               })
@@ -219,12 +319,33 @@
            
         },
         confirmBuild() {
            let tempArr = [];
               this.subDataList.forEach(item=>{
                  this.checkList.forEach(val=>{
                     if(item.id === val){
                        tempArr.push(item.productId + ':' + item.nums);
                     }
                  })
                  })
               this.mapProductNum = tempArr.join(",");
               if(   this.subDataList.find(item=>Number(item.nums) > Number(item.surplusQuant))){
                  this.$u.toast('请检查所选择的产品输入的数量是否小于订单余量')
                  return;
               }
            ;
            let form = {
              orderId:this.deptId,
              carNum:this.value,
              sendDate:this.sendDate,
              sendSign:0,
              itemIds:this.checkList.join(",") + ','
              itemIds:this.checkList.join(",") + ',',
              closeOrderId:this.closeOrderId,
              mapProductNum:this.mapProductNum,
              orderType:this.orderType,
              isWeighing:this.isWeighing
            }
            this.buildLoading = true
            this.$reqPost('addDeliveryPlan', form, 'json').then(res => {
@@ -253,7 +374,18 @@
              })
               console.log(this.checkList,'checkList')
             }
         }
         },
         todoUncoid(){
            console.log('todoUncoid');
            uni.navigateTo({
            url: `/subPages/unionCard/unionCard?unionParams=${JSON.stringify(this.unionParams)}&checkArray=${JSON.stringify(this.checkList2) }`
            });
         },
         clearInp(){
            this.closeOrderId = '';
            this.activeName = '';
         },
      },
   }
</script>