819527061@qq.com
2024-07-05 c3db9f5a903f7213f14d9eaafc804ecdb3bdf2a0
pages/driver-page/driver-index/bill-of-lading-details/weighDetail/weighDetail.vue
@@ -59,14 +59,17 @@
            <view class="weight-box">
               <view class="weigh-qualified">
               <view v-if="!unqualifiedArr(i).length">
                  <view> 扣渣后净重:<text  class="count"> {{  cleanWeight(item) ?  cleanWeight(item)  + '吨' : ''}}</text></view>
               </view>
                <view v-else class='weigh-qualified-no'>
                <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">{{ item.clean  ? item.clean + '吨' : '' }}</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>
            <view class="weigh-qualified" v-for="el,index in unqualifiedArr(i)">
               <view>
@@ -75,7 +78,7 @@
               <view class="count">    {{el.unqualifiedWeight ? el.unqualifiedWeight  + '吨'   : ''}}</view>
            </view>
            </view>
         </view>
      </view>
         <!-- 判断是否检验质量 -->
@@ -84,17 +87,17 @@
               <view style="width: 180rpx;">
               <u--text text="供应商"
                  size='32'></u--text>
            </view>
            <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>
            </view>
            <view class="tag-select"
               @click="goodsPopoverShow(i,'goods')"
               v-if='roleType===4'>
@@ -107,12 +110,12 @@
               <view style="width: 180rpx;">
               <u--text text="品名"
                  size='32'></u--text>
            </view>
            <!-- (coalDetailsData.coalName ? coalDetailsData.coalName: '') -->
            <view class="tag-select"   @click="productNamePopoverShow(i)">{{ item.breed }}</view>
            <view class="tag-select"   @click="productNamePopoverShow(i)">{{ item.breed }}</view>
            </view>
         <view class="level"
            v-if='item.modifygoodsName ||globalShowWeigh[i].modifyProductName'>
            <view style="width: 180rpx;">
@@ -126,7 +129,7 @@
                  {{item.spec}}
               </text>
            </view>
         </view>
         <view class="level" v-if="flag">
            <view style="width: 180rpx;">
@@ -139,7 +142,7 @@
                  {{item.spec}}
               </text>
            </view>
         </view>
         <!-- <view class="unqualifiedBreed">
            <view style="width: 180rpx;">
@@ -196,7 +199,7 @@
               {{item.num + item.numUnit}}
            </view>
         </view>
         <view class="notice-num">
         <view class="notice-num">
               <view class="num-text"
               style="margin-left: 10rpx;">
               <u--text text="通知重量"
@@ -222,7 +225,7 @@
            </view>
         </view>
         <!-- 新增扣罚种类、 扣罚金额,不合格判定种类-->
         <!-- <view class="notice-num">
         <!-- <view class="notice-num">
               <view class="num-text"
               style="margin-left: 10rpx;">
               <u--text text="扣罚种类"
@@ -242,7 +245,7 @@
            </view>
         </view> -->
         <!-- 单价 -->
         <view class="notice-num">
         <view class="notice-num">
               <view class="num-text"
               style="margin-left: 10rpx;">
               <u--text text="单价"
@@ -268,7 +271,7 @@
         <!-- 扣罚容器 -->
         <view class="kouFa-box">
         <!-- 超尺扣罚金额 -->
         <view class="notice-num koufaBox-item">
         <view class="notice-num koufaBox-item">
               <view class="num-text"
               v-if="(roleType===4&&!flag) || (flag && item.oveForfeit)"
               style="margin-left: 10rpx;">
@@ -278,7 +281,7 @@
            <view class="num-input"
            v-if='roleType===4&&!flag'
            >
            <u-input
            <u-input
            v-model="item.oveForfeit"
            placeholder="请输入"
                  border="bottom"
@@ -294,8 +297,8 @@
               {{ item.oveForfeit + '元'}}
            </view>
         </view>
         <view class="notice-num koufaBox-item" >
         <view class="notice-num koufaBox-item" >
               <view class="num-text"
               v-if="(roleType===4&&!flag) || (flag && item.thiForfeit)"
               style="margin-left: 10rpx;">
@@ -319,8 +322,8 @@
               {{ item.thiForfeit+ '元' }}
            </view>
         </view>
         <view class="notice-num koufaBox-item" >
         <view class="notice-num koufaBox-item" >
               <view class="num-text"
               v-if="(roleType===4&&!flag) || (flag && item.obtForfeit)"
               style="margin-left: 10rpx;">
@@ -344,7 +347,7 @@
            </view>
         </view>
         <view class="notice-num koufaBox-item">
         <view class="notice-num koufaBox-item">
               <view class="num-text"
               v-if="(roleType===4&&!flag) || (flag && item.othForfeit)"
               style="margin-left: 10rpx;">
@@ -368,10 +371,10 @@
            </view>
         </view>
         </view>
         <!--不合格判定种类  -->
         <!-- <view class="notice-num">
         <!-- <view class="notice-num">
               <view class="num-text"
               style="margin-left: 10rpx;">
               <u--text text="扣罚类型"
@@ -393,14 +396,14 @@
            <u-checkbox  :label-size="25" :name="'2'" :label="'厚度扣罚'"  :value="item.thickPenaltyAmount"   :checked="item.thickPenaltyAmount" :disabled="disabled">厚度扣罚</u-checkbox>
            <u-checkbox :label-size="25" :name="'3'" :label="'密闭器'"  :value="item.obturatorPenaltyAmount"   :checked="item.obturatorPenaltyAmount"  :disabled="disabled">密闭器</u-checkbox>
            <u-checkbox :label-size="25" :name="'4'" :label="'其他扣罚'" :value="item.qita"   :checked="item.qita" :disabled="disabled">其他扣罚</u-checkbox>
        </u-checkbox-group>
        </u-checkbox-group>
            </view>
            <view class="num-show"
               v-else-if="flag">
               <view>
                  <text> {{item.penaltyType == 1 ? '超尺扣罚' : item.penaltyType == 2 ? '厚度扣罚' :item.penaltyType == 3 ? '密闭器' : null }} </text>
               </view>
            </view>
         </view> -->
         </view>
@@ -418,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>
@@ -437,13 +442,13 @@
               height="150"
               :previewFullImage="true">
            </u-upload>
         </view>
                  </view>
         <u--list
         :height="0"
         style="   margin-left: 50rpx;margin-top: 30rpx;"
         >
            <u--list-item
                v-for="(el,index) in unqualifiedArr(i) "
                style=" box-shadow: 0px 0 0 0px #ccc;"
               :key="index"
@@ -456,7 +461,7 @@
               >
               <text slot="value" @click.stop="deleteItem(i,index)" style="color: red;">删除</text>
            </u-cell>
         <view>
            <view class="unqualifiedBreed">
            <view style="width: 180rpx;">
@@ -466,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>
@@ -493,7 +510,7 @@
               v-else-if="flag">
               {{el.unqualifiedWeight ? el.unqualifiedWeight + '吨':   ''}}
            </view>
         </view>
         <!-- <view class="notice-num">
            <view class="num-text">
@@ -510,7 +527,7 @@
               v-else-if="flag">
               {{selectlist.find(item=>item.value ==el.unqualifiedType ) ? selectlist.find(item=>item.value ==el.unqualifiedType ).name : ''  }}
            </view>
         </view> -->
         <view class="notice-num">
            <view class="num-text">
@@ -533,9 +550,9 @@
               v-else-if="flag">
               {{el.penaltyUnitPrice ?  el.penaltyUnitPrice + '元' : ''}}
            </view>
         </view>
         </view>
         </u--list-item>
      </u--list>
@@ -566,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>
      <!-- 新增 验质备注。验质说明 -->
@@ -621,7 +651,7 @@
            loading-text="确认"></u-button>
      </view></view>
      </view>
      <!-- 物料明细 -->
      <view v-if="!current">
         <view class="main-block"
@@ -708,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:'',
@@ -771,10 +819,10 @@
            list: [
               {
                  name: '物资明细'
               },
               },
               {
                  name: '称重明细'
               },
               },
            ],
            current: 1,
            showWeigh: [],
@@ -837,7 +885,7 @@
         //判断需不需要验质
         isYanz(){
            return function(item){
            // return     ( this.coalDetailsData.orderType !=='外购' ||   this.coalDetailsData.weighingType !=='回磅') ? false : true;
            // return     ( this.coalDetailsData.orderType !=='外购' ||   this.coalDetailsData.weighingType !=='回磅') ? false : true;
            if(this.coalDetailsData.orderType =='外购'){
               if(this.coalDetailsData.weighingType == '回磅'){
                  return true
@@ -875,41 +923,72 @@
                  //  if(item.penaltyType){
                  //    noPin = item.penaltyType.toString().split(',');
                  // }
                   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')
                  return result;
               }else{
                  return []
               }
               }
            }
         },
         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);
            }
         }
      },
      mounted() {
         this.roleType === 1 ? this.GetOrderPlan() : this.getTakeCoal();
      },
      onLoad(params) {
         console.log(params,this.showWeighCopyStorge,this.globalShowWeigh,'params路由')
@@ -931,8 +1010,8 @@
               this.showWeigh[res.index].spec = res.data.specifications;
               this.showWeigh[res.index].firstClass = res.data.firstClass;
            }
         })
      },
      onShow(){
@@ -949,23 +1028,23 @@
            // 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);
            }else{
                y = 0;
            }
            // if(value.filter(Boolean) .length){
            //     y = value.reduce((p,n)=>{
            // return (p - 0) + (n - 0);
             // },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);
               }
            }
         },
         checkboxChange(n,item) {
@@ -981,7 +1060,7 @@
               if(!n.includes('4')){
                  item.qita = ''
               }
            },
         getTakeCoal() {
@@ -993,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
@@ -1028,7 +1109,7 @@
                      this.changeglobalShowWeigh(uni.getStorageSync('showWeighCopyStorgeOther'))
                  //称重明细无数据时显示物资明细
                  if(!this.coalDetailsData.tmTaskCoalItems.length){
                     this.current = 0;
                     this.current = 0;
                  }
                  this.isWeighingType = res.data.weighingType //当前磅单是否回磅
               } else {
@@ -1046,6 +1127,13 @@
                  uni.hideLoading()
               })
            })
         },
         previewImageClose() {
            this.previewImageShow = false;
         },
         previewImageOpen() {
            this.previewImageShow = true;
            console.log('preview open');
         },
         GetOrderPlan() {
            uni.showLoading({ title: '加载中...' });
@@ -1074,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;
               }
@@ -1100,14 +1199,14 @@
                  unqualifiedWeight :unqualifiedWeightAll ,
                  tempArr:this.globalShowWeigh[i].tempArr ? JSON.stringify(this.globalShowWeigh[i].tempArr) : '',
                  penaltyUnitPrice:this.globalShowWeigh[i].penaltyUnitPrice,
               }
            });
            // if(flag){
            this.loading = true;
            params.tmTaskCoalItems = this.showWeigh;
            console.log(params,'params')
            this.$reqPost('updateTmTaskCoalItem', params, 'json').then(
               res => {
                  if (res.code == 0) {
@@ -1125,11 +1224,11 @@
               })
            // }else{
            //    this.$u.toast('请输入单价')
            //    return
            //    return
            // }
         },
         // 校验数据是否合格
         // 校验数据是否合格
         checkValue(data,target){
            if(!data.length){
               return
@@ -1137,7 +1236,7 @@
            let flag = data.find(item=>item[target] <=0);
            console.log(flag,'flag');
             if(flag){
               return false
               return false
            }else{
               return true;
            }
@@ -1202,12 +1301,12 @@
            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, "");
            });
         } // 如果没有小数点,首位不能为类似于 01、02的值
            // 如果没有净重 ,则不进行计算
            if(clean){
               this.showWeigh[index].cinderWeight = (value - 0)
@@ -1221,14 +1320,15 @@
                  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('当前无净重')
            }
         },
         // 选择不合格品名
         selectunqualifiedBreed(index) {
@@ -1257,10 +1357,10 @@
                  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) ;
               }
         },
         // 删除图片
         deletePic(event) {
@@ -1371,7 +1471,7 @@
            }
             this.globalShowWeigh[i].unqualifiedBreed = unqualifiedBreed;
             this.globalShowWeigh[i].unqualifiedWeights = unqualifiedWeights;
            //  this.globalShowWeigh[i].unqualifiedType = unqualifiedType;
            //  this.globalShowWeigh[i].unqualifiedType = unqualifiedType;
             this.globalShowWeigh[i].penaltyUnitPrice = penaltyUnitPrice;
             this.globalShowWeigh[i].tempArr.splice(index,1)
             console.log(this.globalShowWeigh[i].unqualifiedBreed,'unqualifiedBreed')
@@ -1381,7 +1481,7 @@
             this.numAll(this.globalShowWeigh[this.indexFlag].unqualifiedWeights.split(","),this.indexFlag,this.showWeigh[this.indexFlag].clean)
             console.log(this.globalShowWeigh[i],'deleteItem');
           }
         },
         editItem(i,index){
            this.indexFlag  = i; // 记录标识位
@@ -1394,7 +1494,7 @@
            }
         },
         amountChange(value,event){
            // //超尺扣罚
            // if(event.penaltyAmount){
            //    console.log("触发1")
@@ -1422,6 +1522,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');
         }
      },
@@ -1625,17 +1735,17 @@
   .tabs{
      font-size: 20rpx!important;
   }
   .u-card-wrap {
   .u-card-wrap {
      background-color: $u-bg-color;
      padding: 1px;
   }
   .u-body-item {
      font-size: 32rpx;
      color: #333;
      padding: 20rpx 10rpx;
   }
   .u-body-item image {
      width: 120rpx;
      flex: 0 0 120rpx;
@@ -1656,4 +1766,4 @@
      }
   }
</style>
</style>