| | |
| | | <template> |
| | | <view class="main"> |
| | | <u--form labelPosition="top" |
| | | labelWidth="20%" |
| | | labelWidth="30%" |
| | | :borderBottom="false" |
| | | :rules="pageFlag ? rules : rulesGe" |
| | | :errorType="'border-bottom'" |
| | | :model="dataForm" |
| | | ref="uForm"> |
| | | <u-form-item label="一级品类" |
| | | <!-- <u-form-item |
| | | borderBottom=true |
| | | label="一级品类" |
| | | v-if="!pageFlag" |
| | | prop="firstClass" |
| | | :borderBottom="false"> |
| | | <u-cell-group> |
| | |
| | | slot="right-icon" |
| | | size="30"></u-icon></u-cell> |
| | | </u-cell-group> |
| | | </u-form-item> |
| | | <u-form-item label="二级品名" |
| | | </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 label="规格" |
| | | <u-form-item |
| | | label="规格" |
| | | prop="specifications" |
| | | borderBottom> |
| | | <u-input v-model="dataForm.specifications" |
| | | placeholder="请输入规格" |
| | | border="bottom" |
| | | @input="$u.debounce(specInputHandle, 500)"></u-input> |
| | | </u-form-item> |
| | | <!-- 新增不合格称重 --> |
| | | <u-form-item label="不合格重量" |
| | | v-if="pageFlag" |
| | | prop="unqualifiedWeight" |
| | | borderBottom> |
| | | <u-input v-model="dataForm.unqualifiedWeight" |
| | | 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" |
| | | v-if="pageFlag" |
| | | 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> |
| | |
| | | export default { |
| | | data() { |
| | | return { |
| | | pageFlag:false, // false:'不合格' true :'合格的' |
| | | |
| | | dataForm: { |
| | | firstClass: "", |
| | | secondClass: "", |
| | | specifications: "" |
| | | specifications: "", |
| | | unqualifiedWeight:'', |
| | | // unqualifiedType:'', |
| | | penaltyUnitPrice:'' |
| | | }, |
| | | index: '', |
| | | takeCoalId: "", |
| | | params:{}, |
| | | // 一级品类操作菜单 |
| | | firstClassActionsList: [], |
| | | firstClassShow: false, |
| | |
| | | // 判断是修改品名与规格还是不合格品名 |
| | | productName: false, |
| | | unqualified: false, |
| | | rules: { |
| | | 'firstClass': { |
| | | type: 'string', |
| | | required: true, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | }, |
| | | 'secondClass': { |
| | | type: 'string', |
| | | required: true, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | }, |
| | | 'specifications': { |
| | | type: 'string', |
| | | required: false, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | }, |
| | | 'unqualifiedWeight': { |
| | | required: true, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | }, |
| | | // 'unqualifiedType':{ |
| | | // required: true, |
| | | // message: '请选择值', |
| | | // trigger: ['blur', 'change'] |
| | | // }, |
| | | 'penaltyUnitPrice':{ |
| | | required: false, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | } |
| | | }, |
| | | rulesGe:{ |
| | | 'firstClass': { |
| | | type: 'string', |
| | | required: true, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | }, |
| | | 'secondClass': { |
| | | type: 'string', |
| | | required: true, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | }, |
| | | 'specifications': { |
| | | type: 'string', |
| | | required: false, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | }, |
| | | 'unqualifiedWeight': { |
| | | required: false, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | }, |
| | | // 'unqualifiedType':{ |
| | | // required: true, |
| | | // message: '请选择值', |
| | | // trigger: ['blur', 'change'] |
| | | // }, |
| | | 'penaltyUnitPrice':{ |
| | | required: false, |
| | | message: '请选择值', |
| | | trigger: ['blur', 'change'] |
| | | } |
| | | }, |
| | | // |
| | | showWeighCopyStorge: [] |
| | | } |
| | |
| | | computed: { |
| | | ...mapState(["globalShowWeigh"]), |
| | | }, |
| | | onReady() { |
| | | //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。 |
| | | this.$refs.uForm.setRules(this.rules) |
| | | }, |
| | | onLoad(params) { |
| | | this.index = params.index || "" |
| | | this.takeCoalId = params.takeCoalId || '' |
| | | this.getFirstCategoryName() |
| | | this.getFirstCategoryName(params) |
| | | this.params = params; |
| | | this.productName = params.productName === "true" || false |
| | | this.unqualified = params.unqualified === "true" || false |
| | | this.showWeighCopyStorge = JSON.parse(JSON.stringify(uni.getStorageSync('showWeighCopyStorge'))) |
| | | params.pageFlag ? this.pageFlag = false : this.pageFlag = true; |
| | | this.showWeighCopyStorge = JSON.parse(JSON.stringify(uni.getStorageSync('showWeighCopyStorgeOther'))) |
| | | console.log(params, 'paramsparamsparams'); |
| | | |
| | | if(params.type == 'edit'){ |
| | | this.init(params) |
| | | } |
| | | }, |
| | | methods: { |
| | | ...mapMutations(['changeglobalShowWeigh']), |
| | | getFirstCategoryName() { |
| | | getFirstCategoryName(params) { |
| | | uni.showLoading({ |
| | | title: "加载中" |
| | | }) |
| | | this.$reqGet("getFirstCategoryName").then(res => { |
| | | if (res.code === 0) { |
| | | uni.hideLoading() |
| | | this.firstClassActionsList = res.data.map(v => { |
| | | return { |
| | | ...v, |
| | | name: 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') |
| | | } |
| | | }) |
| | | 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]; |
| | | console.log(this.showWeighCopyStorge,'arr') |
| | | let {firstClass,secondClass,specifications} = arr.tempArr[params.indexTo]; |
| | | Object.assign(this.dataForm,{firstClass,secondClass,specifications}); |
| | | 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() { |
| | |
| | | }, |
| | | firstClassSelectClick(val) { |
| | | this.dataForm.firstClass = val.name |
| | | this.secondClassSelect(); |
| | | }, |
| | | // 二级品类选择 |
| | | getSecondCategoryName() { |
| | |
| | | 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('加载失败') |
| | |
| | | //二级品类菜单 |
| | | async secondClassSelect() { |
| | | await this.getSecondCategoryName() |
| | | this.secondClassShow = true |
| | | // this.secondClassShow = true |
| | | }, |
| | | secondClassClose() { |
| | | this.secondClassShow = false |
| | |
| | | this.haveSelectd = false |
| | | }, |
| | | formHandle() { |
| | | this.showWeighCopyStorge = this.globalShowWeigh |
| | | if (this.productName) { |
| | | console.log(this.globalShowWeigh, this.$refs.uForm,'this.globalShowWeigh'); |
| | | this.$refs.uForm.validate().then(res => { |
| | | // 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 |
| | | .dataForm.specifications |
| | | this.showWeighCopyStorge[this.index].breed = this.dataForm.secondClass |
| | | this.showWeighCopyStorge[this.index].spec = this.dataForm.specifications |
| | | } |
| | | if (this.unqualified) { |
| | | this.showWeighCopyStorge[this.index].unqualifiedBreed = this.dataForm.secondClass + '/' + this.dataForm |
| | | .specifications |
| | | let str = this.dataForm.secondClass + '/' + this.dataForm |
| | | .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 || '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].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 |
| | | .dataForm.specifications |
| | | this.showWeighCopyStorge[this.index].breed = this.dataForm.secondClass |
| | | this.showWeighCopyStorge[this.index].spec = this.dataForm.specifications |
| | | } |
| | | if (this.unqualified) { |
| | | let str = this.dataForm.secondClass + '/' + this.dataForm |
| | | .specifications; |
| | | 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(","); |
| | | }else{ |
| | | noPrice = [] |
| | | } |
| | | |
| | | tempWeightArr.push(this.dataForm.unqualifiedWeight); |
| | | tempArr.push(str); |
| | | // noPin.push(this.dataForm.unqualifiedType) |
| | | 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(',') |
| | | 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; |
| | | |
| | | if(!this.showWeighCopyStorge[this.index].tempArr){ |
| | | this.showWeighCopyStorge[this.index].tempArr = []; |
| | | } |
| | | this.showWeighCopyStorge[this.index].tempArr.push({ |
| | | firstClass: this.dataForm.firstClass, |
| | | secondClass:this.dataForm.secondClass, |
| | | specifications:this.dataForm.specifications |
| | | }) |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | this.changeglobalShowWeigh(this.showWeighCopyStorge) |
| | | uni.setStorageSync('showWeighCopyStorgeOther', this.globalShowWeigh) |
| | | uni.redirectTo({ |
| | | 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,pageFlag:this.pageFlag}); |
| | | }).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\d\d).*$/,"$1$2.$3"); |
| | | |
| | | } // 如果没有小数点,首位不能为类似于 01、02的值 |
| | | this.$nextTick(()=>{ |
| | | this.dataForm[name] = value.replace(/[^\d.]/g, ""); |
| | | }); |
| | | |
| | | }, |
| | | change(e) { |
| | | this.dataForm.secondClass =e; |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | |
| | | margin: 10px; |
| | | position: relative; |
| | | } |
| | | /deep/ .uni-combox { |
| | | z-index: 99999!important |
| | | } |
| | | |
| | | |
| | | .slide-fade-enter-active { |
| | | transition: all 0.3s ease-out; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | </style> |