yangan
2024-11-12 09451cd55edf531e51c6e38fc54b4dbc58712d7f
pages/loadUnload-page/historyOrder/index.vue
@@ -46,7 +46,7 @@
                  v-if="filterList[index].tmTaskCoalList.length"
                  :key="index">
                  <view class="card-top">
                     <view class="left"><combined-title :title="filterList[index].sendDate"></combined-title></view>
                     <view class="left"><combined-title :title="item.sendDate"></combined-title></view>
                     <view class="card-top_num">
                        {{ item.tmTaskCoalList.length }}车
                        {{Number(item.tmTaskCoalList
@@ -99,26 +99,26 @@
                        <!-- <view class="black-block"><view class="black-bar"></view></view>
                        <view class="coal-type">{{ value.orderType }}</view> -->
                     </view>
                     <view class="five-line">
                     <view class="second-line">
                        <view class="coal-name">
                           <view class="productName">
                              <text>产品等级:{{ value.productGrade  ? value.productGrade : '暂无' }}</text>
                              </view>
                              <view class="productName">
                              <text>包装类型:{{ proType[value.packingType]}}</text>
                              <text>{{ proType[value.packingType]}}</text>
                              </view>
                           
                        </view>
                        <!-- <view class="black-block"><view class="black-bar"></view></view>
                        <view class="coal-type">{{ value.orderType }}</view> -->
                     </view>
                     <view class="five-line">
                     <view class="second-line">
                           <view class="coal-name">
                        <view class="productName">
                              <text>计划量:{{ value.planMeasure  ?value.planMeasure  :'暂无'}}</text>
                              </view>
                              <view class="productName">
                              <text>实际量:{{value.realityMeasure ? value.realityMeasure  : '暂无'}}</text>
                              <text>实际量:{{value.productQuantity ? value.productQuantity  : '暂无'}}</text>
                              </view>
                           </view>
                     </view>
@@ -248,11 +248,12 @@
         return {
            conditionList: [],
            coalList: [],
            proType:['散装','液氣瓶装','罐装','PVC25','PVC80','PVC1150','PVc1200'],
            proType:['散装','液氯瓶装','罐装','PVC25','PVC80','PVC1150','PVc1200'],
            bunnkerList:[],
            typeList: [],
            customerList: [],
            forwarderList: [],
            totalLength :0,totalTon:0,tmNum:0,
            fleetList: [],
            filedList: [],
            carNoList: [],
@@ -265,13 +266,18 @@
            },
            first: '',
            last: '',
            dateParams:{
               startTime:'',
               endTime:"",
            },
            firstFilter: '',
            lastFilter: '',
            taskList: [],
            tmNum:0,
            // tmNum:0,
            filterList: [],
            totalLength: 0,
            totalTon: 0,
            // totalLength: 0,
            // totalTon: 0,
            // 筛选弹出层
            conditinonShow: false,
            // 超过两行自动隐藏
@@ -304,24 +310,38 @@
         this.getTmTaskCoalData();
      },
      onLoad() {
         this.firstDate();
         this.lastDate();
         
      },
      onPullDownRefresh () {
         //调用获取数据方法
         this.getTmTaskCoalData();
         //结束下拉刷新
         this.$nextTick(()=>{
            uni.stopPullDownRefresh();
         })
      },
      methods: {
         firstDate() {
            let y = new Date().getFullYear(); //获取年份
            let m = new Date().getMonth() + 1; //获取月份
            let d = '01';
            m = m < 10 ? '0' + m : m; //月份补 0
            this.first = [y, m, d].join('-');
            this.firstFilter = [y, m, d].join('-');
            let d = new Date().getDate(); //获取当天日期
             m = m < 10 ? '0' + m : m; //月份补 0
            this.first = [y, m, d].join('-')  + ' ' + '00:00:00';
            this.dateParams.startTime = [y, m, d].join('-') ;
            this.firstFilter = [y, m, d].join('-')
         },
         lastDate() {
            let y = new Date().getFullYear(); //获取年份
            let m = new Date().getMonth() + 1; //获取月份
            let d = new Date(y, m, 0).getDate(); //获取当月最后一日
            let d = new Date().getDate();  //获取当月最后一日
            m = m < 10 ? '0' + m : m; //月份补 0
            d = d < 10 ? '0' + d : d; //日数补 0
            this.last = [y, m, d].join('-');
            this.last = [y, m, d].join('-') +' ' +  '23:59:59';
            this.dateParams.endTime = [y, m, d].join('-') ;
            this.lastFilter = [y, m, d].join('-');
         },
         // 筛选条件
@@ -391,15 +411,30 @@
            uni.showLoading({
               title: '加载中'
            });
            this.$reqGet('getHistoryTaskCoalList', { startTime: this.first, endTime: this.last,bunkerIds:this.bunkerIds,userId:this.userId }).then(res => {
            this.$reqGet('getHistoryTaskCoalList', { startTime: this.first , endTime:this.last ,bunkerIds:this.bunkerIds,productIds:uni.getStorageSync('productIds') }).then(res => {
               console.log(res.data,'res.data');
               this.filterList = this.taskList = res.data.tmTaskCoalList;
               this.totalLength = res.data.carNum;
               this.totalTon = res.data.weight;
               this.tmNum =  res.data.number;
               this.filterList = this.taskList = res.data.map(item=>{
                  if(!item.carNum){
                     item.carNum = 0;
                  }
                  if(!item.weight){
                     item.weight = 0;
                  }
                  if(!item.number){
                     item.number = 0;
                  }
                  return item;
               });
               // this.totalLength = res.data.carNum;
               // this.totalTon = res.data.weight;
               // this.tmNum =  res.data.number;
               if (this.filterList.length != 0) {
                  console.log(this.filterList,'fis')
                  this.totalLength =    this.filterList.reduce((x, y) => x + y.carNum,0);
                  this.totalTon = this.filterList.reduce((x, y) => new BigNumber(x).plus( y.weight),0).toFixed(2);
                  this.tmNum = this.filterList.reduce((x, y) => x + y.number,0);
                  let coalTemp,customerTemp,bunnkerTemp = [];
                  coalTemp = res.data.tmTaskCoalList.map(item=>item.tmTaskCoalList.map(val=>{
                  coalTemp = res.data.map(item=>item.tmTaskCoalList.map(val=>{
                     return {
                        name:val.productName,
                        active:false
@@ -412,7 +447,7 @@
                     return item
                  }, [])
                  }
                  customerTemp = res.data.tmTaskCoalList.map(item=>item.tmTaskCoalList.map(val=>{
                  customerTemp = res.data.map(item=>item.tmTaskCoalList.map(val=>{
                     return {
                        name:val.customerName,
                        active:false
@@ -425,7 +460,7 @@
                     return item
                  }, [])
                  }
                  bunnkerTemp=  res.data.tmTaskCoalList.map(item=>item.tmTaskCoalList.map(val=>{
                  bunnkerTemp=  res.data.map(item=>item.tmTaskCoalList.map(val=>{
                     return {
                        name:val.bunkerName,
                        active:false
@@ -454,6 +489,7 @@
               } else {
                  this.totalLength = 0;
                  this.totalTon = 0;
               }
               uni.hideLoading();
            });
@@ -525,17 +561,29 @@
            };
            this.filterList = this.taskList.map((val,i) => {
               return {
                  condition: val.condition,
                  conditionId: val.conditionId,
                  carNum:val.carNum,
                  number:val.number,
                  weight:val.weight,
                  sendDate:this.taskList[i].sendDate,
                  conditionType: val.conditionType,
                  tmTaskCoalList: val.tmTaskCoalList.filter(v => Reflect.ownKeys(conditionMapping).every(key =>
                     mapping[key](v, conditionMapping[key])))
               };
            });
            console.log(this.filterList,'filterList')
            if (this.filterList.length != 0) {
               this.totalLength = this.filterList.map(v => v.tmTaskCoalList.length).reduce((x, y) => x + y); // 车数
               const tempArr =  this.filterList.map((item,i)=>{
                  if(!item.tmTaskCoalList.length){
                      item.carNum = 0;
                     item.number = 0;
                     item.weight = 0;
                  }
                  return item;
               })
               console.log(tempArr,'temp')
                  this.totalLength =    tempArr.reduce((x, y) => x + y.carNum,0);
                  this.totalTon = tempArr.reduce((x, y) => new BigNumber(x).plus( y.weight),0).toFixed(2);
                  this.tmNum = tempArr.reduce((x, y) => x + y.number,0);
               // this.totalTon = this.filterList.map(v => 
               //    v.taskCoalList.reduce((prev, cur) => {
               //       const cleanvalue = cur.clean || 0
@@ -544,20 +592,16 @@
               // );
               // this.totalTon = this.filterList.map(item=>)
               // this.totalTon = this.filterList.map(v=>v.tmTaskCoalList.filter(item=>item.isWeight === 1).reduce((x,y)=>x.weight + y.weight));
               const tonList = this.filterList.map(item=>item.tmTaskCoalList.filter(item=>item.isWeight === 1)).flat(1);
                const tmNumList = this.filterList.map(item=>item.tmTaskCoalList.filter(item=>item.isWeight !== 1)).flat(1);
               this.totalTon = tonList.reduce((x,y)=>new BigNumber(x).plus(new BigNumber(y.clean)).toFixed(2),0)
               this.tmNum = tmNumList.reduce((x,y)=>new BigNumber(x).plus(new BigNumber(y.productQuantity)),0)
   console.log(tonList,this.totalTon,'tonLisy')
               // this.totalTon = this.totalTon.reduce((x, y) => { //总质量数
               //    let xx = new BigNumber(x)
               //    let yy = new BigNumber(y)
               //    return xx.plus(yy).toNumber().toFixed(2)
               // }, new BigNumber(0));
            } else {
               this.totalLength = 0;
               this.totalTon = 0;
               this.tmNum = 0;
               // this.totalLength = 0;
               // this.totalTon = 0;
               // this.tmNum = 0;
            }
         },
         // 确定筛选
@@ -591,8 +635,11 @@
         },
         confirm(e) {
            console.log(e, '日期选择');
            this.first = e.range.before;
            this.last = e.range.after;
            this.first = e.range.before + ' ' + '00:00:00';
            this.dateParams.startTime = e.range.before;
            this.last = e.range.after + ' ' + '23:59:59' ;
            this.dateParams.endTime = e.range.after;
            this.getTmTaskCoalData();
        this.$nextTick(() => {
          this.$refs.calendar.close()
        })
@@ -693,8 +740,8 @@
         // 关闭筛选条件弹窗
         conditinonclose() {
            this.conditinonShow = false;
         }
      },
         },
               },
      computed: {
         roleType() {
            return uni.getStorageSync('roleType');
@@ -703,7 +750,7 @@
            return `${this.firstFilter}至${this.lastFilter}`;
         },
         dateselect() {
            return `${this.first}至${this.last}`;
            return `${this.dateParams.startTime}至${this.dateParams.endTime}`;
         },
         coalTotal() {
            return this.coalList.length;
@@ -731,17 +778,40 @@
         },
         bunkerIds(){
            return uni.getStorageSync('bunkerIds')
         }
         },
         // totalLength(){
         //    console.log(this.filterList,'filterList')
         //    if(this.filterList.length){
          //       return   this.filterList.reduce((x, y) => x + y.carNum,0); // 车数
         //    }else{
         //       return 0
         //    }
         // },
         // totalTon(){
         //       if(this.filterList.length){
          //       return   this.filterList.reduce((x, y) => new BigNumber(x).plus(new BigNumber(y.weight)) ,0).toFixed(2); // 车数
         //    }else{
         //       return 0
         //    }
         // },
         // tmNum(){
         //       if(this.filterList.length){
          //       return   this.filterList.reduce((x, y) => new BigNumber(x).plus(new BigNumber(y.number)) ,0); // 车数
         //    }else{
         //       return 0
         //    }
         // }
      },
      watch: {
         dateselect(newV, old) {
            let tempDate = `${this.first}至${this.last}`;
            if (newV != old && old != '至') {
               this.first = newV.slice(0, 10);
               this.last = newV.slice(11);
               this.getTmTaskCoalData();
            }
         }
         // dateselect(newV, old) {
         //    console.log(newV,'old')
         //    let tempDate = `${this.first}至${this.last}`;
         //    if (newV != old && old != '至') {
         //       this.first = newV.slice(0, 10);
         //       this.last = newV.slice(11);
         //       // this.getTmTaskCoalData();
         //    }
         // },
      }
   };
</script>
@@ -1068,6 +1138,7 @@
                     width: 100%;
                     height: vww(15);
                     display: flex;
                     margin-bottom: 10rpx;
                     justify-content: space-between;
                     align-items: center;
@@ -1138,6 +1209,7 @@
                     display: flex;
                     justify-content: flex-start;
                     align-items: center;
                     margin-top: 10rpx;
                     color: #515151;
                     .time-icon {