You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

268 lines
6.1 KiB

2 years ago
<style lang="scss">
.container{
background:#f6f6f6;
min-height: 100%;
padding:30rpx 0;
.card{
margin-top:0;
&.info{
.name{
display: flex;
align-items: center;
margin-bottom: 14rpx;
text{
&:first-child{
flex-shrink: 0;
color:#fff;
background:#10C176;
font-size:20rpx;
height:40rpx;
width:80rpx;
border-radius: 4rpx;
text-align: center;
line-height: 40rpx;
margin-right:16rpx;
}
&:nth-child(2){
flex-grow: 1;
}
&:nth-child(3){
flex-shrink: 0;
color:#fff;
background:#10C176;
border-radius: 50%;
width:34rpx;
height:34rpx;
text-align: center;
line-height: 34rpx;
}
}
}
.company{
text{
font-size:24rpx;
&:first-child{
color:#FBA83C;
margin-right:16rpx;
}
&:nth-child(2){
color:#999;
2 years ago
}
}
}
}
}
// .u-popup{
// .u-popup__content{
// &>.btns{
// display:flex;
// justify-content: space-between;
// padding:10rpx;
// }
// picker-view{
// height:500rpx;
// picker-view-column{
// view.item{
// padding:0 30rpx;
// display:flex;
// flex-direction: column;
// justify-content: space-evenly;
// .name{
// display:flex;
// align-items: center;
// text{
// font-size:16rpx;
// &:first-child{
// color:#fff;
// background:#10C176;
// border-radius:0 20rpx 0 20rpx;
// width:80rpx;
// height:34rpx;
// text-align: center;
// line-height: 34rpx;
// margin-right:16rpx;
// }
// &:nth-child(2){
// font-weight: bold;
// font-size:20rpx;
// }
// &:nth-child(3){
// color:#999;
// margin-left:6rpx;
// }
// }
// }
// .company{
// font-size:16rpx;
// &:before{
// content:attr(data-name);
// color:#FBA83C;
// margin-right:20rpx;
// }
// &:after{
// content:attr(data-company);
// color:#999999;
// }
// }
// }
// }
// }
// }
// }
2 years ago
.agr-picker{
padding:0 30rpx;
display:flex;
flex-direction: column;
justify-content: space-evenly;
.name{
display:flex;
align-items: center;
text{
&:first-child{
flex-shrink: 0;
2 years ago
color:#fff;
font-size:20rpx;
border-radius: 0px 20rpx 0px 20rpx;
2 years ago
background:#10C176;
width:80rpx;
height:40rpx;
2 years ago
text-align: center;
line-height: 40rpx;
margin-right:10rpx;
2 years ago
}
&:nth-child(2){
flex-grow: 1;
display:flex;
align-items: center;
2 years ago
font-weight: bold;
margin-right:20rpx;
2 years ago
}
}
}
.company{
text{
font-size:24rpx;
&:first-child{
color:#FBA83C;
margin-right:16rpx;
}
&:nth-child(2){
color:#999;
}
2 years ago
}
}
}
2 years ago
}
</style>
<template>
<view class="container">
<d-navbar style="--bg:#10C176;--c:#fff;" isBack text="农资规格">
<button slot="right" class="cu-btn round" @click="submit">确定</button>
2 years ago
</d-navbar>
2 years ago
<view class="card info">
<view class="name">
<text>{{agrDetail.parentName}}</text> <text>{{agrDetail.name}}</text> <text @click="$u.route({type:'navigateBack'})" class="plant-jiantou_zuoyouqiehuan"/>
</view>
<view class="company">
<text>{{agrDetail.typeOne}}</text> <text>{{agrDetail.supplier}}</text>
2 years ago
</view>
</view>
<view class="card">
<u-form class="inline" labelWidth="auto" ref="form" errorType="toast" :model="formData" :rules="rules">
2 years ago
<d-form
v-for="(v,k) in fields"
:key="k"
v-bind="v"
:field="k"
:required="!!rules[k]"
@input="formData[k]=$event"
@select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value[0].value"/>
2 years ago
</u-form>
</view>
</view>
</template>
<script>
2 years ago
import request from '@/common/request.js'
2 years ago
export default {
data(){
return{
fields:{
specificationId:{label:"规格",tip:"",type:"select",columns:[[]],value:[]},
inputQuantity:{label:"投入数量",type:"digit",suffix:""},
},
formData:{
specificationId:"",
inputQuantity:"",
inventoryId:"",
2 years ago
},
rules:{
specificationId:{required:true,message:"规格必选!"},
inputQuantity:{required:true,type:"number",message:"投入数量必填!"},
2 years ago
},
agrDetail:{},
eventChannel:null,
2 years ago
}
2 years ago
},
computed:{
specsVal(){
var specs=(this.fields.specificationId.columns[0]?.find?.(v=>v.value==this.formData.specificationId)||{}).label||""
return{
specs:(specs.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4),
num:this.formData.inputQuantity
}
},
},
watch:{
specsVal(n){
this.fields.inputQuantity.suffix=n.specs[2]
if(n.num>0 && n.specs[0]>0){
this.$set(this.fields.inputQuantity, "tip", `${parseFloat(n.num)*parseFloat(n.specs[0])}${n.specs[1]}`)
}else{
this.$set(this.fields.inputQuantity, "tip", "")
}
}
},
async onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.eventChannel.on("detail", e=>{
this.agrDetail=e
this.init()
})
this.formData.inventoryId=options.id
2 years ago
},
methods:{
async init(){
var res=await request("/api/plantFarming/getSpecification",{
params:{goodsId: this.agrDetail.goodsId}
2 years ago
})
if(res.statu){
this.fields.specificationId.columns=[res.data.listSpec.map(v=>({label:v.goodsSpecification,value:v.id}))]
this.fields.specificationId.tip=res.data.inventory
2 years ago
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取规格选项失败!",
2 years ago
showCancel:false,
})
}
},
submit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
this.eventChannel.emit("update", {
...this.formData,
total: `${parseFloat(this.specsVal.num)*parseFloat(this.specsVal.specs[0])}${this.specsVal.specs[1]}`,
parentName: this.agrDetail.parentName,
name: this.agrDetail.name,
})
uni.navigateBack()
}
})
},
2 years ago
}
}
</script>