yangan
2024-02-02 4d8e61ec448b4c5246478e75d5e8763a14bc5b5e
pages/public-page/selectSpecifications/selectSpecifications.vue
@@ -7,9 +7,10 @@
         :errorType="'border-bottom'" 
         :model="dataForm"
         ref="uForm">
         <u-form-item
         <!-- <u-form-item
         borderBottom=true
         label="一级品类"
         v-if="!pageFlag"
            prop="firstClass"
            :borderBottom="false">
            <u-cell-group>
@@ -20,19 +21,27 @@
                     slot="right-icon"
                     size="30"></u-icon></u-cell>
            </u-cell-group>
         </u-form-item>
         </u-form-item> -->
         <u-form-item
         borderBottom=true
         label="二级品名"
            prop="secondClass"
            :borderBottom="false">
            <u-cell-group>
               <u-cell :title="dataForm.secondClass"
               <!-- <u-cell :title="dataForm.secondClass"
                  value="请选择"
                  @click="secondClassSelect">
                  <u-icon name="arrow-right"
                     slot="right-icon"
                     size="30"></u-icon></u-cell>
                     size="30"></u-icon></u-cell> -->
                     <!-- <niceui-data-select-input
                     v-model="dataForm.secondClass"
                     :localdata="secondClassActionsList"
                     @change="change"
                     :value="dataForm.secondClass"
                     class="uni-px-5 uni-pb-5"
                     ></niceui-data-select-input> -->
                     <uni-combox  :candidates="secondClassActionsList" placeholder="请选择二级品名" v-model="dataForm.secondClass"></uni-combox>
            </u-cell-group>
         </u-form-item>
         <u-form-item 
@@ -117,6 +126,7 @@
      data() {
         return {
            pageFlag:false, // false:'不合格'  true :'合格的'
            dataForm: {
               firstClass: "",
               secondClass: "",
@@ -155,7 +165,7 @@
            },
            'specifications': {
               type: 'string',
               required: true,
               required: false,
               message: '请选择值',
               trigger: ['blur', 'change']
            },
@@ -170,7 +180,7 @@
            //    trigger: ['blur', 'change']
            // },
            'penaltyUnitPrice':{
               required: true,
               required: false,
               message: '请选择值',
               trigger: ['blur', 'change']
            }
@@ -190,7 +200,7 @@
            },
            'specifications': {
               type: 'string',
               required: true,
               required: false,
               message: '请选择值',
               trigger: ['blur', 'change']
            },
@@ -230,7 +240,8 @@
         this.unqualified = params.unqualified === "true" || false
         params.pageFlag  ? this.pageFlag = false : this.pageFlag = true;
         this.showWeighCopyStorge = JSON.parse(JSON.stringify(uni.getStorageSync('showWeighCopyStorgeOther')))
         console.log(params,'paramsparamsparams');
         console.log(params, 'paramsparamsparams');
         if(params.type == 'edit'){
            this.init(params)
         }
@@ -241,21 +252,52 @@
            uni.showLoading({
               title: "加载中"
            })
            this.$reqGet("getFirstCategoryName").then(res => {
               if (res.code === 0) {
                  uni.hideLoading()
                  this.firstClassActionsList = res.data.filter(Boolean).map(v => {
                     return {
                        ...v,
                        name: v &&  v.firstCategoryName
            // this.$reqGet("getFirstCategoryName").then(res => {
            //    if (res.code === 0) {
            //       uni.hideLoading()
            //       this.firstClassActionsList = res.data.filter(Boolean).map(v => {
            //          return {
            //             ...v,
            //             name: v &&  v.firstCategoryName
            //          }
            //       })
            //       if(params.type !== 'edit')   this.dataForm.firstClass = this.firstClassActionsList[0].firstCategoryName
            //       //如果是合格的需要回显品名规格
            //
            //    } else {
            //       uni.hideLoading()
            //       this.$u.toast('加载失败')
            //    }
               // // 回显二级品名
               this.$reqGet('getSecondCategoryName').then(
               res => {
                  if (res.code === 0) {
                     uni.hideLoading();
                     console.log(res.data,'result')
                     this.secondClassActionsList = res.data.map(v => {
                        return v.secondCategoryName
                     })
                     // if(this.secondClassActionsList .length){
                     //    this.dataForm.secondClass = this.secondClassActionsList[0].value;
                     // }
            //
            //       }
                     if(params.actionObj){
                        let {breed,spec} = JSON.parse(params.actionObj);
                         this.secondClassActionsList.unshift(breed)
                     this.dataForm.specifications= spec;;
                     this.dataForm.secondClass= breed;
                     this.dataForm.firstClass= JSON.parse(params.actionObj).firstClass || '';
                     console.log(this.secondClassActionsList,'secondClass')
                     }
                  })
                  if(params.type !== 'edit')   this.dataForm.firstClass = this.firstClassActionsList[0].firstCategoryName
               } else {
                  uni.hideLoading()
                  this.$u.toast('加载失败')
               }
            })
                  } else {
                     uni.hideLoading()
                     this.$u.toast('加载失败')
                  }
               })
            // })
         },
         init(params){
          let arr =  this.showWeighCopyStorge[params.index];
@@ -277,6 +319,7 @@
         },
         firstClassSelectClick(val) {
            this.dataForm.firstClass = val.name
            this.secondClassSelect();
         },
         // 二级品类选择
         getSecondCategoryName() {
@@ -290,9 +333,11 @@
                     this.secondClassActionsList = res.data.map(v => {
                        return {
                           ...v,
                           name: v.secondCategoryName
                           value: v.secondCategoryName,
                           text:v.secondCategoryName
                        }
                     })
                     this.dataForm.secondClass = this.secondClassActionsList[0].value;
                  } else {
                     uni.hideLoading()
                     this.$u.toast('加载失败')
@@ -302,7 +347,7 @@
         //二级品类菜单
         async secondClassSelect() {
            await this.getSecondCategoryName()
            this.secondClassShow = true
            // this.secondClassShow = true
         },
         secondClassClose() {
            this.secondClassShow = false
@@ -350,15 +395,15 @@
                  .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 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;
               noPriceArr[this.params.indexTo] = this.dataForm.penaltyUnitPrice || '0';
               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].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
@@ -406,7 +451,7 @@
               //添加不合格单价
               let noPrice;
               if(this.showWeighCopyStorge[this.index].penaltyUnitPrice){
                  noPrice = this.showWeighCopyStorge[this.index].penaltyUnitPrice.split(",").filter(Boolean)
                  noPrice = this.showWeighCopyStorge[this.index].penaltyUnitPrice.split(",");
               }else{
                  noPrice = []
               }
@@ -414,7 +459,7 @@
               tempWeightArr.push(this.dataForm.unqualifiedWeight);
               tempArr.push(str);
               // noPin.push(this.dataForm.unqualifiedType)
               noPrice.push(this.dataForm.penaltyUnitPrice)
               noPrice.push(this.dataForm.penaltyUnitPrice ? this.dataForm.penaltyUnitPrice : '0')
               this.showWeighCopyStorge[this.index].unqualifiedBreed = tempArr.join(',')
               this.showWeighCopyStorge[this.index].unqualifiedWeights = tempWeightArr.join(',')
               // this.showWeighCopyStorge[this.index].unqualifiedType = noPin.join(',') 
@@ -449,7 +494,7 @@
            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});
            uni.$emit("handClick",{data:this.dataForm,tempArr:this.showWeighCopyStorge[this.index].tempArr,index:this.index,pageFlag:this.pageFlag});
               }).catch(errors => {
                  console.log(errors,'errors')
                  uni.$u.toast('校验失败')
@@ -472,7 +517,10 @@
                     this.dataForm[name]  = value.replace(/[^\d.]/g, "");
                  });
            
         }
         },
         change(e) {
            this.dataForm.secondClass =e;
      },
      }
   }
</script>
@@ -484,6 +532,10 @@
      margin: 10px;
      position: relative;
   }
   /deep/   .uni-combox  {
         z-index: 99999!important
   }
   .slide-fade-enter-active {
      transition: all 0.3s ease-out;
@@ -513,4 +565,5 @@
         }
      }
   }
</style>