yangan
2024-06-24 1777479d224819e835d3e05ec356c84e8b0f45c9
pages/driver-page/driver-index/bill-of-lading-details/weighDetail/weighDetail.vue
@@ -52,7 +52,7 @@
                     @input='v=>discountInputHandle(v,i,item.clean)'></u--input>
               </view>
               <view v-else-if='flag'
                  class="count">{{ item.cinderWeight }}
                  class="count">{{ item.cinderWeight ?  item.cinderWeight + '吨' :"" }}
               </view>
            </view>
            <!-- 净重div -->
@@ -60,13 +60,14 @@
               <view class="weigh-qualified">
               <view v-if="!unqualifiedArr(i).length">
                  
                  <view> 扣渣后净重:<text  class="count"> {{  cleanWeight(item) }}</text></view>
                  <view> 扣渣后净重:<text  class="count"> {{  cleanWeight(item) ?  cleanWeight(item)  + '吨' : ''}}</text></view>
               </view>
                <view v-else class='weigh-qualified-no'>
                  <view >   合格净重:  <text class="count">{{ item.clean  }}</text></view>
                  <view > 扣渣后净重:<text class="count">{{  cleanWeight(item) }}</text></view>
                <view v-else-if ='unqualifiedArr(i).length && item.clean' class='weigh-qualified-no'>
                  <view > 扣渣后净重:<text class="count">{{  cleanWeight(item) ?  cleanWeight(item)  + '吨' : '' }}</text></view>
                  <view >   合格净重:  <text class="count">{{ qualifiedWeight(item,i) ? qualifiedWeight(item,i) + '吨' : '' }}</text></view>
               </view>
               <view v-else-if ='unqualifiedArr(i).length && !item.clean' class='weigh-qualified-no'>
               </view>
      
            </view>
@@ -74,7 +75,7 @@
               <view>
                  不合格净重:
               </view>
               <view class="count">    {{el.unqualifiedWeight || ''}}</view>
               <view class="count">    {{el.unqualifiedWeight ? el.unqualifiedWeight  + '吨'   : ''}}</view>
            </view>
            </view>
            
@@ -91,7 +92,7 @@
            <view style="font-size: 35rpx;">{{ coalDetailsData.customerName || '' }}</view>
            </view>
            <!-- 物资明细 -->
            <view class="level">
            <view class="level" v-if="!flag">
            <view style="width: 180rpx;">
               <u--text text="物资明细"
                  size='32'></u--text>
@@ -123,6 +124,19 @@
            </view>
            <view class="tag-select"
               @click="productNamePopoverShow(i)">
               <!-- !flag?(globalShowWeigh[i].modifyProductName?globalShowWeigh[i].modifyProductName:item.modifygoodsName):(item.breed+'/'+item.spec) -->
               <text>
                  {{item.spec}}
               </text>
            </view>
         </view>
         <view class="level" v-if="flag">
            <view style="width: 180rpx;">
               <u--text text="规格"
                  size='32'></u--text>
            </view>
            <view class="tag-select">
               <!-- !flag?(globalShowWeigh[i].modifyProductName?globalShowWeigh[i].modifyProductName:item.modifygoodsName):(item.breed+'/'+item.spec) -->
               <text>
                  {{item.spec}}
@@ -259,6 +273,7 @@
         <!-- 超尺扣罚金额 -->
         <view class="notice-num koufaBox-item">   
               <view class="num-text"
               v-if="(roleType===4&&!flag) || (flag && item.oveForfeit)"
               style="margin-left: 10rpx;">
               <u--text text=" 超尺扣罚"
                  size='29'></u--text>
@@ -278,13 +293,14 @@
               </u-input>
            </view>
            <view class="num-show"
               v-else-if="flag" >
               {{item.oveForfeit  ? item.oveForfeit + '元' :""}}
               v-else-if="flag && item.oveForfeit" >
               {{ item.oveForfeit + '元'}}
            </view>
         </view>
         
         <view class="notice-num koufaBox-item" >   
               <view class="num-text"
               v-if="(roleType===4&&!flag) || (flag && item.thiForfeit)"
               style="margin-left: 10rpx;">
               <u--text text="厚度扣罚"
                  size='29'></u--text>
@@ -302,13 +318,14 @@
               </u-input>
            </view>
            <view class="num-show"
               v-else-if="flag">
               {{item.thiForfeit ? item.thiForfeit+ '元' :"" }}
               v-else-if="flag  && item.thiForfeit">
               {{ item.thiForfeit+ '元' }}
            </view>
         </view>
      
         <view class="notice-num koufaBox-item" >   
               <view class="num-text"
               v-if="(roleType===4&&!flag) || (flag && item.obtForfeit)"
               style="margin-left: 10rpx;">
               <u--text text="密闭器"
                  size='29'></u--text>
@@ -325,13 +342,14 @@
               </template></u-input>
            </view>
            <view class="num-show"
               v-else-if="flag">
               {{item.obtForfeit ? item.obtForfeit+ '元' :"" }}
               v-else-if="flag && item.obtForfeit">
               {{ item.obtForfeit+ '元' }}
            </view>
         </view>
         <view class="notice-num koufaBox-item">   
               <view class="num-text"
               v-if="(roleType===4&&!flag) || (flag && item.othForfeit)"
               style="margin-left: 10rpx;">
               <u--text text="其他扣罚"
                  size='29'></u--text>
@@ -348,8 +366,8 @@
               </template></u-input>
            </view>
            <view class="num-show"
               v-else-if="flag">
               {{item.othForfeit ? item.othForfeit+ '元' :"" }}
               v-else-if="flag && item.othForfeit">
               {{ item.othForfeit+ '元'}}
            </view>
         </view>
         </view>
@@ -403,7 +421,9 @@
               <u--image :showLoading="true"
                  :src="`${BaseUrl}${val}`"
                  width="80px"
                  height="80px">
                  height="80px"
                  @click="imageClick(val)"
                  >
                  <view slot="error"
                     style="font-size: 24rpx;">加载失败</view>
               </u--image>
@@ -422,7 +442,7 @@
               height="150"
               :previewFullImage="true">
            </u-upload>
         </view>
                  </view>
         <u--list
         :height="0"
         style="   margin-left: 50rpx;margin-top: 30rpx;"
@@ -451,7 +471,19 @@
            <view class="tag-select">
               <text>
                  <!-- {{!flag?(globalShowWeigh[i].unqualifiedBreed?globalShowWeigh[i].unqualifiedBreed:item.unqualifiedBreed):(item.unqualifiedBreed||"请选择")}} -->
                  {{  el.unqualifiedBreed  }}
                  {{  el.unsecondClass  }}
               </text>
            </view>
         </view>
         <view class="unqualifiedBreed">
            <view style="width: 180rpx;">
               <u--text text="不合格规格"
                  size='32'></u--text>
            </view>
            <view class="tag-select">
               <text>
                  <!-- {{!flag?(globalShowWeigh[i].unqualifiedBreed?globalShowWeigh[i].unqualifiedBreed:item.unqualifiedBreed):(item.unqualifiedBreed||"请选择")}} -->
                  {{  el.unSpecifications  }}
               </text>
            </view>
         </view>
@@ -551,6 +583,19 @@
               :closeOnClickOverlay='true'
               @close='unqualifiedClose'
               @select="selectUnqualifiedClick"></u-action-sheet>
         </view>
      </view>
      <!-- 原发出场时间 -->
      <view v-if="roleType!==3">
         <view>
            <text>货物发货地出场时间或发货磅单时间:</text>
         </view>
         <view>
            <uni-datetime-picker
            v-model="outDate"
            type="datetime"
            @change="datechange"
         />
         </view>
      </view>
      <!-- 新增 验质备注。验质说明 -->
@@ -693,22 +738,40 @@
               @close='unqualifiedClose'
               @select="selectUnqualifiedClick"></u-action-sheet>
         </view>
      </view>
      </view>
         <!-- 图片预览弹出框 -->
         <view class="previewImage-container">
         <u-popup :show="previewImageShow"
            mode="center"
            @close="previewImageClose"
            @open="previewImageOpen">
            <u--image :src="previewImageSrc != null ? BaseUrl + previewImageSrc : ''"
               width="400px"
               height="400px"></u--image>
         </u-popup>
      </view>
   </view>
</template>
<script>
   import BigNumber from "bignumber.js"
   import formatDate from  '@/utils/date'
   import { BaseUrl } from '@/api/publicInterface.js';
   import { onlineurl } from '@/api/request.js'
   import { mapState, mapMutations } from "vuex"
   export default {
      data() {
         return {
            dateInpShow:false,
            outDate:'',
            dateValue:'',
            previewImageShow:false,
            qualityInstructions:"",
            previewImageSrc: '',
            penaltyType:[],
             indexFlag:0, // 下标标志位
            remarks:'',
@@ -862,7 +925,11 @@
                  // }
                 
                   let result =  arr.length && arr.map((el,index)=>{
                  let obj = {unqualifiedBreed:el,unqualifiedWeight:temp[index],unqualifiedType:noPin[index],penaltyUnitPrice:noPrice[index]}
                  const pinming = el.split("/")[0];
                  const guige = el.split("/")[1];
                  let obj = {unqualifiedBreed:el,unqualifiedWeight:temp[index],unqualifiedType:noPin[index],penaltyUnitPrice:noPrice[index],
                  unsecondClass:pinming,unSpecifications:guige
                  }
                  return obj
                  })
                  console.log(result,temp,'arr')
@@ -878,17 +945,44 @@
         },
         cleanWeight(){
            return function(item){
               if(!item.weight){
                  return ''
               }else if(item.weight && !item.unqualifiedWeight){
               // if(!item.weight){
               //    return ''
               // }else if(item.weight && !item.unqualifiedWeight){
               //    return item.weight
               // }else if(item.weight && item.unqualifiedWeight){
               //    return item.weight
               // }
               if(item.weight){
                  return item.weight
               }else if(item.weight && item.unqualifiedWeight){
                  return (item.weight - (item.unqualifiedWeight - 0)).toFixed(2)
               }else{
               }else if(!item.clean){
                  return ''
               } else if(item.clean && !item.unqualifiedWeight){
                  return item.clean
               }else if(item.clean && item.cinderWeight){
                  return  new BigNumber(item.clean - 0).minus(item.cinderWeight - 0);
               }
               console.log(item,'clearnWeight')
            }
         },
         //合格净重
         qualifiedWeight(){
            return function(item,i){
               console.log(item,'itemnsssajdakdj');
               let znums;
               if(this.globalShowWeigh[i].unqualifiedWeights){
               znums = this.globalShowWeigh[i].unqualifiedWeights.split(',')
               }else{
                  znums = []
               }
               let z =  new BigNumber(znums.reduce((p,n)=>{
                  return (p - 0) + (n - 0)
               },0))
               let y = new BigNumber(item.cinderWeight)
            return new BigNumber(item.clean - 0).minus(z).minus(y);
            }
         }
      },
@@ -934,20 +1028,20 @@
            // let y = new BigNumber(value - 0) // 因为value 是 0 所以需要循环 取减
            let z = new BigNumber(this.showWeigh[index].cinderWeight -  0);
            let y;
            if(value.filter(Boolean) .length){
                y = value.reduce((p,n)=>{
            return (p - 0) + (n - 0);
             },0);
            // if(value.filter(Boolean) .length){
            //     y = value.reduce((p,n)=>{
            // return (p - 0) + (n - 0);
             // },0);
            
            }else{
                y = 0;
            }
            // }else{
            //     y = 0;
            // }
            if(clean){
               if(x.minus(y).minus(z).toFixed(2)  <= 0){
                  this.showWeigh[index].weight = '0';
                  this.$u.toast('当前净重不合格,请检查皮重,毛重是否准确')
               }else{
                  this.showWeigh[index].weight = x.minus(y).minus(z).toFixed(2) ;
                  this.showWeigh[index].weight = x.minus(z).toFixed(4);
               }
            }
            
@@ -978,6 +1072,8 @@
                  uni.hideLoading()
                  this.coalDetailsData = res.data;
                  this.remarks  = res.data.remarks;
                  this.dateValue = res.data.startTime;
                  this.outDate = res.data.startTime;
                  this.qualityInstructions = res.data.qualityInstructions
                  this.orderCode = res.data.orderCode
                  this.showWeigh = this.coalDetailsData.tmTaskCoalItems ? this.coalDetailsData
@@ -1032,6 +1128,13 @@
               })
            })
         },
         previewImageClose() {
            this.previewImageShow = false;
         },
         previewImageOpen() {
            this.previewImageShow = true;
            console.log('preview open');
         },
         GetOrderPlan() {
            uni.showLoading({ title: '加载中...' });
            this.$reqGet('GetOrderPlan').then(res => {
@@ -1059,19 +1162,30 @@
               }
            })
         },
         imageClick(imgStr){
            console.log(imgStr,'触发')
               this.previewImageSrc = imgStr;
            this.$nextTick(() => {
               this.previewImageShow = true;
            });
         },
         // 点击确认
         confirmInput() {
            let flag = true;
            let params = {},unqualifiedWeightAll;
            params.qualityInstructions = this.qualityInstructions;
            params.remarks = this.remarks;
            params.startTime = this.dateValue;
            console.log( this.showWeigh,' this.showWeigh')
            this.showWeigh = this.showWeigh.map((v, i) => {
            console.log(this.penaltyType,this.$refs.checkbox,'123')
            // let tempArr = v.penaltyType.split(',');
             v.unqualifiedType = '';
               if(this.globalShowWeigh[i].unqualifiedWeights){
               unqualifiedWeightAll = this.globalShowWeigh[i].unqualifiedWeights.split(",").reduce((p,n)=>{return (p - 0) + (n - 0)},0).toFixed(2)  || ''
               unqualifiedWeightAll = this.globalShowWeigh[i].unqualifiedWeights.split(",").reduce((p,n)=>{return (p - 0) + (n - 0)},0).toFixed(4)  || ''
               }else{
                  unqualifiedWeightAll = 0;
               }
@@ -1187,7 +1301,7 @@
            value = parseFloat(value);
            value = value + ""; // 变回为字符串
         }else{
            value =  value.replace(/^(-)*(\d+)\.(\d\d).*$/,"$1$2.$3");
            value =  value.replace(/^(-)*(\d+)\.(\d\d\d\d).*$/,"$1$2.$3");
            this.$nextTick(()=>{
               this.showWeigh[index].cinderWeight  = value.replace(/[^\d.]/g, "");
            });
@@ -1206,7 +1320,8 @@
                  this.showWeigh[index].weight = '0';
                  this.$u.toast('当前净重不合格,请检查皮重,毛重是否准确')
               }else{
                  this.showWeigh[index].weight = x.minus(y).minus(z);
                  console.log(znums.length)
                   this.showWeigh[index].weight = x.minus(y);
               }
            }else{
               this.$u.toast('当前无净重')
@@ -1242,7 +1357,7 @@
                  this.showWeigh[index].weight = '0';
                  this.$u.toast('当前净重不合格,请检查皮重,毛重是否准确')
               }else{
                  this.showWeigh[index].weight = x.minus(y).minus(z).toFixed(2) ;
                  this.showWeigh[index].weight = x.minus(y).minus(z).toFixed(4) ;
               }
            
         
@@ -1408,6 +1523,16 @@
            // }
            console.log(event,'event')
         },
         dateInpFoucs(){
            console.log('聚焦');
            this.dateInpShow = true;
         },
         datechange(value){
            console.log('dateChange',value,formatDate.formatDate(new Date(value)) );
            this.dateValue = (formatDate.formatDate(new Date(value)) + ':' + '00');
         }
      },
   }
@@ -1422,15 +1547,13 @@
   }
   .weigh-qualified{
      display: flex;
      width: 300rpx;
      width: 340rpx;
      flex-direction: row;
      justify-content: space-around;
      height:auto;
   }
   .weight-box{
      display: flex;
      height: 160rpx;
      margin-bottom: 20rpx;
      flex-direction: column;
      overflow-y: scroll;