yangan
2024-01-10 9cb5cd3735f58bd62c3ad0d20b89646801bc05bf
pages/public-page/selectSpecifications/selectSpecifications.vue
@@ -1,7 +1,7 @@
<template>
   <view class="main">
      <u--form labelPosition="top"
         labelWidth="25%"
         labelWidth="30%"
         :borderBottom="false"
         :rules="rules"
         :errorType="'border-bottom'" 
@@ -49,8 +49,27 @@
            prop="unqualifiedWeight"
            borderBottom>
            <u-input v-model="dataForm.unqualifiedWeight"
               placeholder="请输称重"
               placeholder="请输入重量"
               type="digit"
               border="bottom"
               @change="v=>checkNum(v,'unqualifiedWeight')"
               @input="$u.debounce(specInputHandle, 500)"></u-input>
         </u-form-item>
         <!-- <u-form-item label="不合格判定" prop="unqualifiedType">
            <u-radio-group  size='32' v-model="dataForm.unqualifiedType">
            <u-radio  :label-size="25" :name="'1'"  :label="'超尺扣罚'" :disabled="disabled">长度扣罚</u-radio>
            <u-radio  :label-size="25" :name="'2'" :label="'厚度扣罚'" :disabled="disabled">厚度扣罚</u-radio>
            <u-radio  :label-size="25" :name="'3'" :label="'密闭器'" :disabled="disabled">密闭器</u-radio>
            </u-radio-group>
         </u-form-item> -->
         <u-form-item label="单价"
            prop="penaltyUnitPrice"
            borderBottom>
            <u-input v-model="dataForm.penaltyUnitPrice"
               placeholder="请输入不合格单价"
               type="digit"
               border="bottom"
               @change="v=>checkNum(v,'penaltyUnitPrice')"
               @input="$u.debounce(specInputHandle, 500)"></u-input>
         </u-form-item>
      </u--form>
@@ -100,6 +119,8 @@
               secondClass: "",
               specifications: "",
               unqualifiedWeight:'',
               // unqualifiedType:'',
               penaltyUnitPrice:''
            },
            index: '',
            takeCoalId: "",
@@ -140,6 +161,16 @@
               message: '请选择值',
               trigger: ['blur', 'change']
            },
            // 'unqualifiedType':{
            //    required: true,
            //    message: '请选择值',
            //    trigger: ['blur', 'change']
            // },
            'penaltyUnitPrice':{
               required: true,
               message: '请选择值',
               trigger: ['blur', 'change']
            }
         },
            // 
            showWeighCopyStorge: []
@@ -159,7 +190,7 @@
         this.params = params;
         this.productName = params.productName === "true" || false
         this.unqualified = params.unqualified === "true" || false
         this.showWeighCopyStorge = JSON.parse(JSON.stringify(uni.getStorageSync('showWeighCopyStorge')))
         this.showWeighCopyStorge = JSON.parse(JSON.stringify(uni.getStorageSync('showWeighCopyStorgeOther')))
         console.log(params,'paramsparamsparams');
         if(params.type == 'edit'){
            this.init(params)
@@ -188,10 +219,15 @@
            })
         },
         init(params){
          let arr =  this.globalShowWeigh[params.index];
          let arr =  this.showWeighCopyStorge[params.index];
          console.log(this.showWeighCopyStorge,'arr')
          let {firstClass,secondClass,specifications} = arr.tempArr[params.indexTo];
          Object.assign(this.dataForm,{firstClass,secondClass,specifications});
          this.dataForm.unqualifiedWeight = this.globalShowWeigh[params.index].unqualifiedWeights.split(',')[params.indexTo]
          this.dataForm.unqualifiedWeight = this.showWeighCopyStorge[params.index].unqualifiedWeights.split(',')[params.indexTo];
          //不合格类判定
         //  this.dataForm.unqualifiedType = this.showWeighCopyStorge[params.index].unqualifiedType.split(',')[params.indexTo];
          //单价
         this.dataForm.penaltyUnitPrice = this.showWeighCopyStorge[params.index].penaltyUnitPrice.split(',')[params.indexTo];
         },
         //一级品类菜单
         firstClassSelect() {
@@ -259,8 +295,10 @@
         formHandle() {
            console.log(this.globalShowWeigh,   this.$refs.uForm,'this.globalShowWeigh');
            this.$refs.uForm.validate().then(res => {
                  uni.$u.toast('校验通过')
                  // uni.$u.toast('校验通过')
                  this.showWeighCopyStorge = this.globalShowWeigh;
                  console.log(this.showWeighCopyStorge,this.index,'this.showWeighCopyStorge[this.index]');
            if(this.params.type == 'edit'){
               if (this.productName) {
               this.showWeighCopyStorge[this.index].modifyProductName = this.dataForm.secondClass + '/' + this
@@ -273,19 +311,29 @@
                  .specifications;
                let tempArr =    this.showWeighCopyStorge[this.index].unqualifiedBreed.split(",")
                let tempWeightArr =    this.showWeighCopyStorge[this.index].unqualifiedWeights.split(",")
                let noPinArr =this.showWeighCopyStorge[this.index].unqualifiedType.split(",")
                let noPriceArr = this.showWeighCopyStorge[this.index].penaltyUnitPrice.split(",");
                tempArr[this.params.indexTo] = str;
               tempWeightArr[this.params.indexTo] = this.dataForm.unqualifiedWeight;
               // noPinArr[this.params.indexTo] = this.dataForm.unqualifiedType;
               noPriceArr[this.params.indexTo] = this.dataForm.penaltyUnitPrice;
               this.showWeighCopyStorge[this.index].unqualifiedBreed = tempArr.join(',');
               this.showWeighCopyStorge[this.index].unqualifiedWeights = tempWeightArr.join(',');
               this.showWeighCopyStorge[this.index].unqualifiedType = noPinArr.join(',');
               this.showWeighCopyStorge[this.index].penaltyUnitPrice = noPriceArr.join(',');
               this.showWeighCopyStorge[this.index].breed = this.dataForm.secondClass
               this.showWeighCopyStorge[this.index].spec = this.dataForm.specifications
               //如果这个  tempArr不为 空
               if(this.showWeighCopyStorge[this.index].tempArr){
               this.showWeighCopyStorge[this.index].tempArr[this.params.indexTo].firstClass = this.dataForm.firstClass;
               this.showWeighCopyStorge[this.index].tempArr[this.params.indexTo].secondClass = this.dataForm.secondClass;
               this.showWeighCopyStorge[this.index].tempArr[this.params.indexTo].specifications = this.dataForm.specifications;
               }else{
               }
            }
            }else{
               if (this.productName) {
               this.showWeighCopyStorge[this.index].modifyProductName = this.dataForm.secondClass + '/' + this
@@ -296,20 +344,50 @@
            if (this.unqualified) {
               let str = this.dataForm.secondClass + '/' + this.dataForm
                  .specifications;
                let tempArr =  this.showWeighCopyStorge[this.index].unqualifiedBreed.split(",").filter(Boolean);
               let tempWeightArr =    this.showWeighCopyStorge[this.index].unqualifiedWeights.split(",").filter(Boolean);
                let tempArr;
               if(   this.showWeighCopyStorge[this.index].unqualifiedBreed){
                  tempArr =    this.showWeighCopyStorge[this.index].unqualifiedBreed.split(",").filter(Boolean);
               }else{
                  tempArr =  []
               }
               let tempWeightArr;
               if(this.showWeighCopyStorge[this.index].unqualifiedWeights){
                  tempWeightArr =    this.showWeighCopyStorge[this.index].unqualifiedWeights.split(",").filter(Boolean)
               }else{
                  tempWeightArr =  [];
               }
               // 添加不合格品类判定
                // let noPin;
               // if(this.showWeighCopyStorge[this.index].unqualifiedType){
               //    noPin = this.showWeighCopyStorge[this.index].unqualifiedType.split(",").filter(Boolean)
               // }else{
               //    noPin = []
               // }
               //添加不合格单价
               let noPrice;
               if(this.showWeighCopyStorge[this.index].penaltyUnitPrice){
                  noPrice = this.showWeighCopyStorge[this.index].penaltyUnitPrice.split(",").filter(Boolean)
               }else{
                  noPrice = []
               }
               tempWeightArr.push(this.dataForm.unqualifiedWeight);
               tempArr.push(str);
               // noPin.push(this.dataForm.unqualifiedType)
               noPrice.push(this.dataForm.penaltyUnitPrice)
               this.showWeighCopyStorge[this.index].unqualifiedBreed = tempArr.join(',')
               this.showWeighCopyStorge[this.index].unqualifiedWeights = tempWeightArr.join(',')
               // this.showWeighCopyStorge[this.index].unqualifiedType = noPin.join(',')
               this.showWeighCopyStorge[this.index].penaltyUnitPrice = noPrice.join(',')
               this.showWeighCopyStorge[this.index].breed = this.dataForm.secondClass
               this.showWeighCopyStorge[this.index].spec = this.dataForm.specifications
               // this.showWeighCopyStorge[this.index].firstClass = this.dataForm.firstClass;
                // this.showWeighCopyStorge[this.index].secondClass = this.dataForm.secondClass;
                // this.showWeighCopyStorge[this.index].specifications = this.dataForm.specifications;
               this.showWeighCopyStorge[this.index].firstClass = this.dataForm.firstClass;
                this.showWeighCopyStorge[this.index].secondClass = this.dataForm.secondClass;
                this.showWeighCopyStorge[this.index].specifications = this.dataForm.specifications;
               if(!this.showWeighCopyStorge[this.index].tempArr){
                  this.showWeighCopyStorge[this.index].tempArr = [];
@@ -332,10 +410,29 @@
            uni.navigateBack({
               url: `/pages/driver-page/driver-index/bill-of-lading-details/weighDetail/weighDetail?dataForm=${JSON.stringify(this.dataForm)}&orderPlanId=${this.takeCoalId}&index=${this.index}&havedSubmit=${true}`
            })
            uni.$emit("handClick",{data:this.dataForm,tempArr:this.showWeighCopyStorge[this.index].tempArr,index:this.index});
               }).catch(errors => {
                  console.log(errors,'errors')
                  uni.$u.toast('校验失败')
               })
   
         },
         checkNum(value,name){
            if (
               value &&
               value.indexOf(".") < 0 &&
               value != ""
               ) {
                  value = parseFloat(value);
                  value = value + ""; // 变回为字符串
               }else{
                  value =  value.replace(/^(-)*(\d+)\.(\d\d).*$/,"$1$2.$3");
               } // 如果没有小数点,首位不能为类似于 01、02的值
               this.$nextTick(()=>{
                     this.dataForm[name]  = value.replace(/[^\d.]/g, "");
                  });
         }
      }
   }