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.
153 lines
3.4 KiB
153 lines
3.4 KiB
<style lang="scss">
|
|
.container{
|
|
min-height: 100%;
|
|
background:#f6f6f6;
|
|
padding:30rpx 0;
|
|
.card{
|
|
margin-top:0;
|
|
&.spec{
|
|
.data{
|
|
display:flex;
|
|
align-items: center;
|
|
.plant-youbian{
|
|
margin-left:20rpx;
|
|
background:#F7F7F7;
|
|
padding:20rpx;
|
|
border-radius: 24rpx;
|
|
display: flex;
|
|
flex-direction: row-reverse;
|
|
color:#999;
|
|
&:before{
|
|
transform: rotate(90deg);
|
|
}
|
|
}
|
|
}
|
|
&>.tip{
|
|
color:#999;
|
|
font-size:24rpx;
|
|
margin-top:18rpx;
|
|
}
|
|
}
|
|
.input{
|
|
margin-right:20rpx;
|
|
flex-grow: 1;
|
|
background:#F7F7F7;
|
|
border-radius: 24rpx;
|
|
display:flex;
|
|
justify-content: space-between;
|
|
padding:20rpx;
|
|
align-items: center;
|
|
input{
|
|
flex-grow: 1;
|
|
}
|
|
text{
|
|
margin-left:10rpx;
|
|
color:#999;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
<template>
|
|
<view class="container">
|
|
<view class="card spec">
|
|
<view class="title_mast">规格</view>
|
|
<view class="data">
|
|
<view class="input"><input placeholder="请输入" type="digit" v-model="formData.num"/><text>{{formData.massUnits}}</text></view>
|
|
/
|
|
<view class="plant-youbian" @click="show=true">{{formData.dressingUnit}}</view>
|
|
</view>
|
|
<view class="tip">例如:肥料一袋50kg,录入规格则为50kg/袋</view>
|
|
</view>
|
|
|
|
<!-- <view class="card warning">
|
|
<view class="title_mast">预警值</view>
|
|
<view class="input"><input placeholder="请输入预警值" type="digit" v-model="formData.earlyValue"/><text>{{formData.dressingUnit}}</text></view>
|
|
</view> -->
|
|
|
|
<button class="cu-btn round bg-green shadow submit" @click="submit">确定</button>
|
|
|
|
<u-picker
|
|
closeOnClickOverlay
|
|
:columns="units"
|
|
:show="show"
|
|
keyName="label"
|
|
@close="show=false"
|
|
@cancel="show=false"
|
|
@confirm="formData.dressingUnit=$event.value[0].value;show=false"/>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import request from '@/common/request'
|
|
export default {
|
|
data(){
|
|
return{
|
|
units:[],
|
|
show:false,
|
|
formData:{
|
|
dressingUnit: "",
|
|
earlyValue: "",
|
|
goodsId: "",
|
|
goodsName: "",
|
|
goodsSpecification: "",
|
|
goodsType: "1",
|
|
massUnits: "",
|
|
num: '',
|
|
sysOrgCode: "",
|
|
},
|
|
eventChannel:null,
|
|
}
|
|
},
|
|
onLoad(options){
|
|
this.eventChannel=this.getOpenerEventChannel()
|
|
this.formData.goodsId=options.goodsId
|
|
this.init()
|
|
},
|
|
methods:{
|
|
async init(){
|
|
var res=await request("/api/goods/unitsShow",{
|
|
params:{goodsId:this.formData.goodsId}
|
|
})
|
|
if(res.statu){
|
|
this.units=[res.data.list.map(v=>({label:v.text,value:v.value}))]
|
|
this.formData.massUnits=res.data.massUnits
|
|
this.formData.dressingUnit=this.units[0][0].value
|
|
}else{
|
|
uni.showModal({
|
|
title:"提示",
|
|
content:res.msg||"获取单位选项失败!",
|
|
showCancel:false,
|
|
})
|
|
}
|
|
},
|
|
check(){
|
|
if(!this.formData.num>0){
|
|
uni.showToast({title:"规格值必填!",icon:"none"})
|
|
return false
|
|
// }else if(!this.formData.earlyValue>0){
|
|
// uni.showToast({title:"预警值必填!",icon:"none"})
|
|
// return false
|
|
}
|
|
return true
|
|
},
|
|
async submit(){
|
|
if(this.check()){
|
|
var res=await request("/goods/goods/addPlantGoodsSpecification",{
|
|
method:"post",
|
|
body:this.formData
|
|
})
|
|
if(res.statu){
|
|
this.eventChannel.emit("addUnit",res.data)
|
|
uni.navigateBack()
|
|
}else{
|
|
uni.showModal({
|
|
title:"提示",
|
|
content:res.msg||"获取农资详情失败!",
|
|
showCancel:false,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
},
|
|
}
|
|
</script>
|