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.

309 lines
6.9 KiB

2 years ago
<style lang="scss">
2 years ago
.container{
2 years ago
min-height: 100%;
background:#F6F6F6;
padding:30rpx 0;
.card{
margin-top:0;
}
&>.fertilizer{
&>.name{
display:flex;
align-items: center;
margin-bottom:14rpx;
text{
&:first-child{
font-size:20rpx;
color:#fff;
background:#10C176;
2 years ago
border-radius: 4rpx 30rpx 4rpx 30rpx;
padding: 0 6rpx;
2 years ago
min-width:80rpx;
2 years ago
text-align: center;
height:40rpx;
line-height: 40rpx;
margin-right:16rpx;
}
&:nth-child(3){
border-radius: 50%;
background:#10C176;
color:#fff;
margin-left:auto;
width:35rpx;
height:35rpx;
text-align: center;
line-height: 35rpx;
}
}
}
&>.company{
display:flex;
align-items: center;
text{
&:first-child{
flex-shrink: 0;
font-size:20rpx;
color:#707070;
}
&:nth-child(2){
2 years ago
margin-left:20rpx;
2 years ago
font-size:20rpx;
color:#FBA83C;
}
}
}
}
&>.specs{
.select{
flex-grow: 1;
height:80rpx;
line-height: 80rpx;
background:#F7F7F7;
border-radius: 24rpx;
padding:0 28rpx;
display:flex;
text{
&:first-child{
flex-grow: 1;
2 years ago
color:#333;
&.noData{
color:#999;
}
2 years ago
}
&:nth-child(2){
2 years ago
color:#999;
2 years ago
flex-shrink: 0;
transform: rotate(90deg);
}
}
}
.plant-xinjian{
color:#10C176;
border-radius: 24rpx;
margin-left:24rpx;
background:#E7FCF3;
height:80rpx;
line-height: 80rpx;
width:120rpx;
text-align: center;
box-shadow: 6rpx 6rpx 8rpx rgba(16,193,118,0.1);
}
.tip{
color:#FBA83C;
font-size:24rpx;
margin-top:12rpx;
}
}
&>.purchase{
.input{
display:flex;
background:#F7F7F7;
border-radius: 24rpx;
padding:20rpx;
input{
flex-grow: 1;
}
text{
color:#999;
line-height: 40rpx;
margin-left:20rpx;
}
}
}
2 years ago
.purcahse-picker{
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
}
</style>
<template>
2 years ago
<view class="container">
2 years ago
<view class="card fertilizer">
<view class="name">
<text>{{formData.detailedParentName}}</text>
<text>{{formData.goodsName}}</text>
2 years ago
<text class="plant-jiantou_zuoyouqiehuan" @click="$u.route({type:'back'})"/>
2 years ago
</view>
<view class="company">
<text>{{formData.detailedType}}</text>
2 years ago
<text>{{formData.supplier}}</text>
2 years ago
</view>
</view>
<view class="card specs">
<view class="title_mast">规格</view>
<view style="display:flex;">
<view class="select">
2 years ago
<text @click="show=true" :class="{noData:!formData.goodsSpecification}">{{formData.goodsSpecification||"请添加规格"}}</text>
2 years ago
<text class="plant-youbian"/>
</view>
2 years ago
<text class="plant-xinjian" @click="toAdd">新建</text>
2 years ago
</view>
2 years ago
<view class="tip" v-if="specStr">库存{{specStr}}</view>
2 years ago
</view>
2 years ago
<view class="card purchase" v-if="intoPage=='purchase'">
2 years ago
<view class="title_mast">采购数量</view>
<view class="input">
2 years ago
<input placeholder="请输入采购数量" type="digit" v-model="formData.num"/>
<text>{{dressingUnit}}</text>
2 years ago
</view>
</view>
2 years ago
<button class="cu-btn round bg-green shadow submit" @click="submit">确定</button>
<u-picker
:show="show"
:columns="specList"
keyName="label"
closeOnClickOverlay
@close="show=false"
@cancel="show=false"
2 years ago
@confirm="searchStock($event.value[0].id);formData.goodsSpecification=$event.value[0].value;formData.specificationId=$event.value[0].id;show=false"/>
2 years ago
</view>
</template>
<script>
import request from '@/common/request'
2 years ago
export default{
data(){
return{
2 years ago
specList:[[]],
specStr:"",
dressingUnit:"",
2 years ago
show:false,
formData:{
2 years ago
goodsId:"",
2 years ago
goodsName:"",
goodsSpecification:"",
num:"",
specificationId:"",
detailedType:"",
detailedParentName:"",
supplier:"",
},
2 years ago
goodsDetail:{},
2 years ago
eventChannel:null,
2 years ago
intoPage:"",
}
},
2 years ago
async onLoad(options){
2 years ago
this.intoPage=options.intoPage
2 years ago
this.eventChannel=this.getOpenerEventChannel()
2 years ago
this.eventChannel.on("detail", detail=>{
this.formData.goodsName=detail.goodsName
this.formData.detailedType=detail.detailedType
this.formData.detailedParentName=detail.detailedParentName
this.formData.supplier=detail.supplier
2 years ago
})
2 years ago
this.formData.goodsId=options.goodsId
//从新增入库页面进入不需要搜索规格
2 years ago
if(this.intoPage=='purchase')this.setGoodsVal()
2 years ago
},
methods:{
2 years ago
async setGoodsVal(val){
2 years ago
var res=await request("/api/goods/queryGoodsSpecification",{
method:"post",
body:{
goodsId:this.formData.goodsId,
supplier:this.formData.supplier,
}
2 years ago
})
if(res.statu){
2 years ago
this.specList=[res.data.map(v=>({label:v.goodsSpecification,value:v.goodsSpecification,id:v.id}))]
this.formData.goodsSpecification=''
this.specStr=''
this.dressingUnit=''
2 years ago
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取规格选项失败!",
showCancel:false,
})
}
2 years ago
},
//选择规格 搜索库存
2 years ago
async searchStock(id){
var res=await request("/api/goods/stockShow",{
params:{
goodsSpecificationId:id,
plantBaseInfoId:this.$store.state.plantBaseInfoId,
}
2 years ago
})
if(res.data.packing&&res.data.heft){
2 years ago
this.specStr=`${res.data.packing}(${res.data.heft})`
}else{this.specStr=''}
this.dressingUnit=`${res.data.dressingUnit}`
2 years ago
},
toAdd(){
uni.navigateTo({
2 years ago
url:`/pages/purchase/newSpecs?goodsId=${this.formData.goodsId}`,
2 years ago
events:{addUnit:e=>{
this.specList[0].push({label:e.goodsSpecification,value:e.goodsSpecification,id:e.goodsSpecificationId})
2 years ago
this.searchStock(e.goodsSpecificationId)
this.formData.goodsSpecification=e.goodsSpecification
this.formData.specificationId=e.goodsSpecificationId
2 years ago
}}
})
},
check(){
if(!this.formData.goodsSpecification){
uni.showToast({title:"规格必选!",icon:"none"})
return false
2 years ago
}else if(!this.formData.num>0 && this.intoPage=="purchase"){
2 years ago
uni.showToast({title:"采购数量必填!",icon:"none"})
return false
}
return true
},
async submit(){
if(this.check()){
2 years ago
uni.navigateBack()
this.eventChannel.emit("submit", this.formData)
2 years ago
}
},
}
2 years ago
}
</script>