<template>
|
<view class="main">
|
<u--form labelPosition="top"
|
labelWidth="30%"
|
:borderBottom="false"
|
:rules="rules"
|
:errorType="'border-bottom'"
|
:model="dataForm"
|
ref="uForm">
|
<u-form-item
|
borderBottom=true
|
label="品名"
|
prop="breeds"
|
:borderBottom="false">
|
<u-input v-model="dataForm.breeds"
|
placeholder="请输入拆分品名"
|
border="bottom"></u-input>
|
</u-form-item>
|
<u-form-item
|
label="规格"
|
prop="specs"
|
borderBottom>
|
<u-input v-model="dataForm. specs"
|
placeholder="请输入规格"
|
border="bottom"></u-input>
|
</u-form-item>
|
<!-- 新增不合格称重 -->
|
<u-form-item label="净重"
|
prop="weights"
|
borderBottom>
|
<u-input v-model="dataForm.weights"
|
placeholder="请输入拆分称重"
|
type="digit"
|
border="bottom"
|
@change="v=>checkNum(v)"></u-input>
|
</u-form-item>
|
</u--form>
|
<view style="margin-top: 20rpx;">
|
<u-button type="primary"
|
shape="circle"
|
text="提交"
|
@click.stop="formHandle"></u-button>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import { mapState, mapMutations } from "vuex"
|
export default {
|
data() {
|
return {
|
dataForm: {
|
breeds: "",
|
specs: "",
|
weights: "",
|
},
|
index: '',
|
takeCoalId: "",
|
params:{},
|
// 一级品类操作菜单
|
// 规格选择
|
specList: [],
|
haveSelectd: true,
|
// 判断是修改品名与规格还是不合格品名
|
productName: false,
|
unqualified: false,
|
rules: {
|
'breeds': {
|
type: 'string',
|
required: true,
|
message: '请选择值',
|
trigger: ['blur', 'change']
|
},
|
'specs': {
|
type: 'string',
|
required: true,
|
message: '请选择值',
|
trigger: ['blur', 'change']
|
},
|
'weights': {
|
type: 'string',
|
required: true,
|
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.params = params;
|
this.productName = params.productName === "true" || false
|
this.unqualified = params.unqualified === "true" || false
|
this.showWeighCopyStorge = JSON.parse(JSON.stringify(uni.getStorageSync('showWeighCopyStorgeOther')))
|
console.log(params,'paramsparamsparams');
|
if(params.type == 'edit'){
|
this.init(params)
|
}
|
},
|
methods: {
|
...mapMutations(['changeglobalShowWeigh']),
|
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];
|
},
|
|
// // 选择规格
|
// specInputHandle() {
|
// if (!this.dataForm.secondClass) return this.$u.toast('请先选择上方品名')
|
// this.$reqGet('getSpec', {
|
// firstCategoryName: this.dataForm.firstClass,
|
// secondCategoryName: this.dataForm
|
// .secondClass,
|
// specText: this.dataForm.specifications
|
// }).then(res => {
|
// if (res.code === 0) {
|
// this.specList = res.data
|
// } else {
|
// uni.hideLoading()
|
// this.$u.toast('加载失败')
|
// }
|
// })
|
// },
|
specSelectHandle(val) {
|
this.dataForm.specifications = val
|
this.haveSelectd = false
|
},
|
formHandle() {
|
console.log(this.globalShowWeigh, this.$refs.uForm,'this.globalShowWeigh');
|
this.$refs.uForm.validate().then(res => {
|
// uni.$u.toast('校验通过')
|
this.showWeighCopyStorge = this.globalShowWeigh;
|
if(this.params.type == 'edit'){
|
let breedsArr=this.showWeighCopyStorge[this.index].breeds.split(",")
|
,specsArr =this.showWeighCopyStorge[this.index].spec.split(",")
|
,weightsArr = this.showWeighCopyStorge[this.index].weights.split(",") ;
|
breedsArr[this.params.indexTo] = this.dataForm.breeds;
|
specsArr[this.params.indexTo] = this.dataForm.specs;
|
weightsArr[this.params.indexTo] = this.dataForm.weights;
|
//修改对应的 属性
|
this.showWeighCopyStorge[this.index].breeds = breedsArr.join(',');
|
this.showWeighCopyStorge[this.index].spec = specsArr.join(',');
|
this.showWeighCopyStorge[this.index].weights = weightsArr.join(',');
|
|
}else{
|
let breedsArr;
|
if( this.showWeighCopyStorge[this.index].breeds){
|
breedsArr = this.showWeighCopyStorge[this.index].breeds.split(",").filter(Boolean);
|
}else{
|
breedsArr = []
|
}
|
|
let specsArr;
|
if(this.showWeighCopyStorge[this.index].specs){
|
specsArr = this.showWeighCopyStorge[this.index].specs.split(",").filter(Boolean)
|
}else{
|
specsArr = [];
|
}
|
// 添加不合格品类判定
|
let weightsArr;
|
if(this.showWeighCopyStorge[this.index].weights){
|
weightsArr = this.showWeighCopyStorge[this.index].weights.split(",").filter(Boolean)
|
}else{
|
weightsArr = []
|
}
|
|
breedsArr.push(this.dataForm.breeds);
|
specsArr.push(this.dataForm.specs);
|
weightsArr.push(this.dataForm.weights)
|
this.showWeighCopyStorge[this.index].breeds = breedsArr.join(',')
|
this.showWeighCopyStorge[this.index].specs = specsArr.join(',')
|
this.showWeighCopyStorge[this.index].weights = weights.join(',')
|
|
// 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.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){
|
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.unqualifiedWeight = value.replace(/[^\d.]/g, "");
|
});
|
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss"
|
scoped>
|
.main {
|
width: 94%;
|
margin: 10px;
|
position: relative;
|
}
|
|
.slide-fade-enter-active {
|
transition: all 0.3s ease-out;
|
}
|
|
.spec-main {
|
width: 96%;
|
margin: auto;
|
height: 600rpx;
|
overflow: scroll;
|
background: #f0f0f0;
|
box-shadow: 4rpx 6rpx 51rpx 0rpx rgba(73, 120, 240, 0.11);
|
border-radius: 20rpx;
|
position: relative;
|
top: vww(5);
|
|
&_content {
|
width: 90%;
|
margin: auto;
|
padding-top: vww(10);
|
|
.spec-main_item {
|
padding: vww(5);
|
color: #515151;
|
border-bottom: 1px solid #e3e3e3;
|
font-size: 40rpx;
|
}
|
}
|
}
|
</style>
|