Browse Source

联调接口

master
邓宏 2 years ago
parent
commit
4413242ae9
  1. 22
      common/request.js
  2. 5
      pages/massif/mana/index.vue
  3. 222
      pages/massif/mana/plantPlan.vue
  4. 24
      pages/massif/mana/recovery.vue
  5. 2
      pages/massif/plant_info.vue
  6. 13
      pages/purchase/agrProdList.vue
  7. 67
      pages/purchase/apply.vue
  8. 81
      pages/purchase/newSpecs.vue
  9. 148
      pages/purchase/specs.vue
  10. 0
      uni_modules/d-picker/changelog.md
  11. 106
      uni_modules/d-picker/components/d-picker/d-picker.vue
  12. 81
      uni_modules/d-picker/package.json
  13. 1
      uni_modules/d-picker/readme.md

22
common/request.js

@ -1,14 +1,24 @@
import store from "@/store" import store from "@/store"
export function host(host='default',suffix='/plant_manage'){ export function host(host='default',suffix='/plant_manage'){
return( var url=process.env.NODE_ENV === 'development'?{
process.env.NODE_ENV === 'development'?{ default:`http://2uktvr.natappfree.cc` //陈
default:`http://xvff42.natappfree.cc${suffix}` //陈 // default:`http://6h8nxd.natappfree.cc` //马
// default:`http://6h8nxd.natappfree.cc${suffix}` //马
}:{ }:{
default:`http://qv6mj8.natappfree.cc${suffix}` default:`http://qv6mj8.natappfree.cc`
} }
)[host] return ({
default:`${url.default}${suffix}`,
imgUrl:`${url.default}/plant_manage/sys/common/static`
})[host]
// return(
// process.env.NODE_ENV === 'development'?{
// default:`http://10.0.0.217${suffix}` //陈
// // default:`http://6h8nxd.natappfree.cc${suffix}` //马
// }:{
// default:`http://qv6mj8.natappfree.cc${suffix}`
// }
// )[host]
} }

5
pages/massif/mana/index.vue

@ -27,13 +27,13 @@
<swiper :current="tabIndex" @change="tabIndex=$event.detail.current"> <swiper :current="tabIndex" @change="tabIndex=$event.detail.current">
<swiper-item> <swiper-item>
<plant-plan :plotId="plotId" @trigger="tabIndex=$event.tabIndex;plantId=$event.plantId"/> <plant-plan :plotId="plotId" @trigger="$refs.recovery.reSearch($event.plantId);tabIndex=$event.tabIndex"/>
</swiper-item> </swiper-item>
<swiper-item> <swiper-item>
<farmRecord :plotId="plotId"/> <farmRecord :plotId="plotId"/>
</swiper-item> </swiper-item>
<swiper-item> <swiper-item>
<recovery :plotId="plotId" :plantId="plantId"/> <recovery :plotId="plotId" ref="recovery"/>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
@ -53,7 +53,6 @@ export default {
{name:"采收记录",}, {name:"采收记录",},
], ],
plotId:"", plotId:"",
plantId:"",
} }
}, },
onLoad(options){ onLoad(options){

222
pages/massif/mana/plantPlan.vue

@ -1,124 +1,137 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.plant_plan{ .plant_plan{
.card{ height:100%;
&>.info{ display:flex;
display:flex; flex-direction: column;
&>.u-transition{ scroll-view{
position:relative; flex-grow: 1;
margin-right:20rpx; height:1rpx;
&:before{ .card{
content:attr(data-type); &>.info{
position:absolute; display:flex;
z-index: 30; &>.u-transition{
top:0; position:relative;
left:0; margin-right:20rpx;
border-radius: 20rpx 20rpx 20rpx 0; &:before{
background:rgba(60, 84, 44, 0.5); content:attr(data-type);
color:#fff; position:absolute;
padding:6rpx 2rpx; z-index: 30;
min-width:80rpx; top:0;
text-align: center; left:0;
border-radius: 20rpx 20rpx 20rpx 0;
background:rgba(60, 84, 44, 0.5);
color:#fff;
padding:6rpx 2rpx;
min-width:80rpx;
text-align: center;
}
} }
} &>.detail{
&>.detail{ flex-grow: 1;
flex-grow: 1; width:1rpx;
width:1rpx; .name{
.name{ display:flex;
display:flex; margin-bottom: 6rpx;
margin-bottom: 6rpx; text{
text{ &:first-child{
&:first-child{ flex-shrink: 0;
flex-shrink: 0; font-size:20rpx;
font-size:20rpx; color:#fff;
color:#fff; background:#10C176;
background:#10C176; height:40rpx;
height:40rpx; width:80rpx;
width:80rpx; line-height: 40rpx;
line-height: 40rpx; text-align: center;
text-align: center; border-radius: 6rpx;
border-radius: 6rpx; margin-right:12rpx;
margin-right:12rpx; }
&:nth-child(2){
font-weight: bold;
flex-grow: 1;
}
} }
&:nth-child(2){ }
font-weight: bold; .batch,.recovery{
flex-grow: 1; font-size:24rpx;
color:var(--c);
margin-bottom:6rpx;
}
.mu{
color:#10C176;
font-size:32rpx;
font-weight: bold;
&:after{
content:"亩";
} }
} }
} }
.batch,.recovery{ }
&>.date{
border-top:2rpx solid rgba(216, 216, 216, 0.5);
margin-top:6rpx;
padding-top:12rpx;
display:flex;
align-items: center;
text{
flex-shrink: 0;
color:#999;
font-size:24rpx; font-size:24rpx;
color:var(--c); margin-right:auto;
margin-bottom:6rpx; &.over{
} background:#F7F7F7;
.mu{ border-radius: 8rpx;
color:#10C176; height:48rpx;
font-size:32rpx; line-height: 48rpx;
font-weight: bold; padding:0 20rpx;
&:after{ margin:0 0 0 auto;
content:"亩";
} }
} }
} button{
} margin:0 0 0 20rpx;
&>.date{ color:rgba(var(--c),1);
border-top:2rpx solid rgba(216, 216, 216, 0.5); background:rgba(var(--c),0.15);
margin-top:6rpx;
padding-top:12rpx;
display:flex;
align-items: center;
text{
flex-shrink: 0;
color:#999;
font-size:24rpx;
margin-right:auto;
&.over{
background:#F7F7F7;
border-radius: 8rpx;
height:48rpx; height:48rpx;
line-height: 48rpx; font-size:24rpx;
padding:0 20rpx; padding:0 16rpx;
margin:0 0 0 auto; min-width:100rpx;
} }
} }
button{
margin:0 0 0 20rpx;
color:rgba(var(--c),1);
background:rgba(var(--c),0.15);
height:48rpx;
font-size:24rpx;
padding:0 16rpx;
min-width:100rpx;
}
} }
} }
button{
flex-shrink: 0;
margin:20rpx auto!important;
}
} }
</style> </style>
<template> <template>
<view class="plant_plan"> <view class="plant_plan">
<view class="card" v-for="(v,k) in list" :key="k"> <scroll-view scroll-y @scrolltolower="search">
<view class="info" @click="reDetail(v.id)"> <view class="card" v-for="(v,k) in list" :key="k">
<u-image :data-type="v.plantType" radius="20rpx" width="170rpx" height="140rpx" mode="aspectFill" src="https://cdn.uviewui.com/uview/album/1.jpg"> <view class="info" @click="reDetail(v.id)">
<view slot="error" style="font-size: 24rpx;">加载失败</view> <u-image :data-type="v.plantType" radius="20rpx" width="170rpx" height="140rpx" mode="aspectFill" src="https://cdn.uviewui.com/uview/album/1.jpg">
</u-image> <view slot="error" style="font-size: 24rpx;">加载失败</view>
<view class="detail"> </u-image>
<view class="name"> <view class="detail">
<text>{{v.plantStandard}}</text> <text class="over">{{v.varietyName}}</text> <text class="plant-youbian"/> <view class="name">
<text>{{v.plantStandard}}</text> <text class="over">{{v.varietyName}}</text> <text class="plant-youbian"/>
</view>
<view class="batch" style="--c:#999;">种植批次号{{v.plantBatch}}</view>
<view class="recovery" style="--c:#FFC760;">已采收{{v.harvested}}kg</view>
<view class="mu">{{v.plantArea}}</view>
</view> </view>
<view class="batch" style="--c:#999;">种植批次号{{v.plantBatch}}</view> </view>
<view class="recovery" style="--c:#FFC760;">已采收{{v.harvested}}kg</view> <view class="date">
<view class="mu">{{v.plantArea}}</view> <text>本次预估采收时间{{v.harvestTime}}</text>
<template v-if="v.status==1">
<button class="cu-btn" style="--c:255, 196, 87;" @click.stop="finishPlant(k)">结束种植</button>
<button class="cu-btn" style="--c:153, 153, 153;" @click.stop="toAdd(v.id)">采收</button>
</template>
<text v-if="v.status==2" class="over">已结束</text>
</view> </view>
</view> </view>
<view class="date"> <u-empty v-if="list.length==0" icon="http://cdn.uviewui.com/uview/empty/data.png"/>
<text>本次预估采收时间{{v.harvestTime}}</text> </scroll-view>
<template v-if="v.status==1">
<button class="cu-btn" style="--c:255, 196, 87;" @click.stop="finishPlant(k)">结束种植</button>
<button class="cu-btn" style="--c:153, 153, 153;" @click.stop="toAdd(v.id)">采收</button>
</template>
<text v-if="v.status==2" class="over">已结束</text>
</view>
</view>
<u-empty v-if="list.length==0" icon="http://cdn.uviewui.com/uview/empty/data.png"/>
<button class="cu-btn round bg-green shadow submit" @click="addPlant">+新增种植计划</button> <button class="cu-btn round bg-green shadow submit" @click="addPlant">+新增种植计划</button>
</view> </view>
@ -162,6 +175,8 @@ export default {
} }
}) })
if(res.statu){ if(res.statu){
this.list=this.list.concat(res.data.records)
this.list=this.list.concat(res.data.records)
this.list=this.list.concat(res.data.records) this.list=this.list.concat(res.data.records)
this.total=res.data.total this.total=res.data.total
}else{ }else{
@ -176,7 +191,7 @@ export default {
addPlant(){ addPlant(){
uni.navigateTo({ uni.navigateTo({
url:`/pages/massif/plant_plan?plotId=${this.plotId}`, url:`/pages/massif/plant_plan?plotId=${this.plotId}`,
event:{ update:()=> {this.clean();this.search()} } events:{ update:()=> {this.clean();this.search()} }
}) })
}, },
reDetail(id){ reDetail(id){
@ -203,14 +218,9 @@ export default {
}, },
// //
toAdd(plantId){ toAdd(plantId){
this.$emit("trigger",{tabIndex:2,plantId})
uni.navigateTo({ uni.navigateTo({
url:`/pages/massif/plant_info?plantId=${plantId}&plotId=${this.plotId}`, url:`/pages/massif/plant_info?plantId=${plantId}&plotId=${this.plotId}`,
event:{ toRecovery:()=>{ events:{ toRecovery:()=> this.$emit("trigger",{tabIndex:2,plantId}) }
// this.$nextTick(()=>{
this.$emit("trigger",{tabIndex:2,plantId})
// })
} }
}) })
} }
} }

24
pages/massif/mana/recovery.vue

@ -109,10 +109,6 @@ export default {
type:String, type:String,
defaylt:"" defaylt:""
}, },
plantId:{
type:String,
default:'',
},
}, },
data(){ data(){
return{ return{
@ -134,25 +130,25 @@ export default {
return this.searchVal[this.dateType] || new Date().format('yyyy-MM-dd') return this.searchVal[this.dateType] || new Date().format('yyyy-MM-dd')
} }
}, },
watch:{
plantId(){
this.list=[]
this.total=0
this.searchVal.pageNo=1
this.search()
},
},
created(){ created(){
this.search() this.search()
}, },
methods:{ methods:{
async search(){ reSearch(plantId){
this.$nextTick(()=>{
this.list=[]
this.total=0
this.searchVal.pageNo=1
this.search(plantId)
})
},
async search(plantId=''){
if(this.total==0||this.list.length<this.total){ if(this.total==0||this.list.length<this.total){
var res=await request("/api/plantHarvest/list",{ var res=await request("/api/plantHarvest/list",{
params:{ params:{
...this.searchVal, ...this.searchVal,
plotId:this.plotId, plotId:this.plotId,
plantScheduleId:this.plantId, plantScheduleId: plantId,
} }
}) })
if(res.statu){ if(res.statu){

2
pages/massif/plant_info.vue

@ -82,8 +82,8 @@ export default {
body: this.formData body: this.formData
}) })
if(res.statu){ if(res.statu){
this.eventChannel.emit('toRecovery')
uni.navigateBack() uni.navigateBack()
this.eventChannel.emit('toRecovery')
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",

13
pages/purchase/agrProdList.vue

@ -56,7 +56,7 @@
<d-search v-model="searchVal.goodsName" @search="clean();search()"/> <d-search v-model="searchVal.goodsName" @search="clean();search()"/>
<scroll-view scroll-y @scrolltolower="search"> <scroll-view scroll-y @scrolltolower="search">
<view class="card" v-for="(v,k) in list" :key="k" @click="$u.route({url:'pages/purchase/specs',params:{id:v.id}})"> <view class="card" v-for="(v,k) in list" :key="k" @click="toAddSepc(v.id)">
<view class="name"> <view class="name">
<text>{{v.goodsName}}</text> {{v.detailedType}} <text class="plant-youbian"/> <text>{{v.goodsName}}</text> {{v.detailedType}} <text class="plant-youbian"/>
</view> </view>
@ -80,9 +80,11 @@ export default {
}, },
list:[], list:[],
total:0, total:0,
eventChannel:null,
} }
}, },
onLoad(){ onLoad(){
this.eventChannel=this.getOpenerEventChannel()
this.search() this.search()
}, },
methods:{ methods:{
@ -114,6 +116,15 @@ export default {
events:{update:()=>{ this.clean();this.search() }} events:{update:()=>{ this.clean();this.search() }}
}) })
}, },
toAddSepc(id){
uni.navigateTo({
url:`/pages/purchase/specs?id=${id}`,
events:{submit: e=>{
uni.navigateBack()
this.eventChannel.emit("submit",e)
}}
})
},
} }
} }
</script> </script>

67
pages/purchase/apply.vue

@ -93,32 +93,33 @@
<view class="container"> <view class="container">
<view class="card info"> <view class="card info">
<view> <view>
<text>申请人</text> <text>{{info.name}}</text> <text>申请人</text> <text>{{formData.applicantName}}</text>
</view> </view>
<view> <view>
<text>所在基地</text> <text>{{info.baseName}}</text> <text>所在基地</text> <text>{{formData.baseName}}</text>
</view> </view>
<view> <view>
<text>申请时间</text> <text>{{new Date().format('yyyy-MM-dd')}}</text> <text>申请时间</text> <text>{{formData.applicantTime}}</text>
</view> </view>
</view> </view>
<view class="card detail"> <view class="card detail">
<view class="title_mast">采购详情</view> <view class="title_mast">采购详情</view>
<view class="item" v-for="i in 3"> <view class="item" v-for="(v,k) in formData.plantPurchaseSubList" :key="k">
<view class="info"> <view class="info">
<text>化肥</text> <text>{{v.goodsName}}</text>
<text data-unit="100kg/">中量元素水溶肥</text> <text :data-unit="v.goodsSpecification">{{v.detailedType}}</text>
<text class="plant-shanchu">删除</text> <text class="plant-shanchu" @click="formData.plantPurchaseSubList.splice(k,1)">删除</text>
</view> </view>
<view class="company"> <view class="company">
<text style="--c:#707070;flex-shrink: 0;">云南云天化股份有限公司</text> <text style="--c:#707070;flex-shrink: 0;">{{v.supplier}}</text>
<text style="--c:#FBA83C;flex-grow:1;text-align:center;">微量元素肥</text> <text style="--c:#FBA83C;flex-grow:1;text-align:center;">{{v.detailedParentName}}</text>
</view> </view>
</view> </view>
<u-empty v-if="formData.plantPurchaseSubList.length==0" text=' ' icon="http://cdn.uviewui.com/uview/empty/data.png"/>
<view class="plant-xinzeng" @click="$u.route({url:'pages/purchase/agrProdList'})">添加物品</view> <view class="plant-xinzeng" @click="toAddGoods">添加物品</view>
</view> </view>
<view class="card type"> <view class="card type">
@ -133,7 +134,15 @@ import request from '@/common/request'
export default { export default {
data(){ data(){
return{ return{
info:{}, formData:{
applicantId: "",
applicantName: "",
applicantTime: "",
baseName: "",
companyId: "",
plantPurchaseSubList: [],
// sysOrgCode: "",
},
} }
}, },
onLoad(){ onLoad(){
@ -141,10 +150,13 @@ export default {
}, },
methods:{ methods:{
async init(){ async init(){
//
var res=await request("/api/purchase/purchaseUserShow") var res=await request("/api/purchase/purchaseUserShow")
if(res.statu){ if(res.statu){
this.info=res.data this.formData.applicantId=res.data.userId
this.formData.applicantName=res.data.name
this.formData.applicantTime=new Date().format('yyyy-MM-dd')
this.formData.baseName=res.data.baseName
this.formData.companyId=this.$store.getters['userInfo'].companyId
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",
@ -154,11 +166,30 @@ export default {
} }
}, },
async submit(){ async submit(){
var res=await request("/api/purchase/applicantStatus",{ if(this.formData.plantPurchaseSubList.length<=0){
params:{ uni.showToast({title:"请选择采购详情!",icon:"none"})
status:2, return false
purchaseId:"", }
} var res=await request("/purchaseMain/purchaseMain/addPlantPurchaseSub",{
method:"post",
body: this.formData
})
if(res.statu){
}else{
uni.showModal({
title:"提示",
content:res.msg||"保存失败!",
showCancel:false,
})
}
},
toAddGoods(){
uni.navigateTo({
url:`/pages/purchase/agrProdList`,
events:{submit: e=>{
this.formData.plantPurchaseSubList.push(e)
}}
}) })
}, },
} }

81
pages/purchase/newSpecs.vue

@ -53,19 +53,28 @@
<view class="card spec"> <view class="card spec">
<view class="title_mast">规格</view> <view class="title_mast">规格</view>
<view class="data"> <view class="data">
<view class="input"><input placeholder="请输入"/><text>kg</text></view> <view class="input"><input placeholder="请输入" type="digit" v-model="formData.num"/><text>{{formData.massUnits}}</text></view>
/ /
<view class="plant-youbian"></view> <view class="plant-youbian" @click="show=true">{{formData.dressingUnit}}</view>
</view> </view>
<view class="tip">例如肥料一袋50kg录入规格则为50kg/</view> <view class="tip">例如肥料一袋50kg录入规格则为50kg/</view>
</view> </view>
<view class="card warning"> <view class="card warning">
<view class="title_mast">预警值</view> <view class="title_mast">预警值</view>
<view class="input"><input placeholder="请输入预警值"/><text>kg</text></view> <view class="input"><input placeholder="请输入预警值" type="digit" v-model="formData.earlyValue"/><text>{{formData.massUnits}}</text></view>
</view> </view>
<button class="cu-btn round bg-green shadow submit">确定</button> <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;show=false"/>
</view> </view>
</template> </template>
<script> <script>
@ -73,13 +82,71 @@ import request from '@/common/request'
export default { export default {
data(){ data(){
return{ return{
units:[],
show:false,
formData:{
dressingUnit: "",
earlyValue: "",
goodsId: "",
goodsName: "",
goodsSpecification: "",
goodsType: "1",
massUnits: "",
num: '',
sysOrgCode: "",
},
eventChannel:null,
} }
}, },
onLoad(){}, onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.formData.goodsId=options.goodsId
this.init()
},
methods:{ methods:{
async init(){ async init(){
var res=await request("") 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,
})
}
}
} }
}, },
} }

148
pages/purchase/specs.vue

@ -16,8 +16,8 @@
font-size:20rpx; font-size:20rpx;
color:#fff; color:#fff;
background:#10C176; background:#10C176;
border-radius: 4rpx; border-radius: 4rpx 30rpx 4rpx 30rpx;
padding: 0 4rpx; padding: 0 6rpx;
min-width:80rpx; min-width:80rpx;
text-align: center; text-align: center;
height:40rpx; height:40rpx;
@ -63,11 +63,15 @@
padding:0 28rpx; padding:0 28rpx;
display:flex; display:flex;
text{ text{
color:#999;
&:first-child{ &:first-child{
flex-grow: 1; flex-grow: 1;
color:#333;
&.noData{
color:#999;
}
} }
&:nth-child(2){ &:nth-child(2){
color:#999;
flex-shrink: 0; flex-shrink: 0;
transform: rotate(90deg); transform: rotate(90deg);
} }
@ -112,41 +116,47 @@
<view class="container"> <view class="container">
<view class="card fertilizer"> <view class="card fertilizer">
<view class="name"> <view class="name">
<text>{{purchase.goodsName}}</text> <text>{{formData.goodsName}}</text>
<text>{{purchase.detailedType}}</text> <text>{{formData.detailedType}}</text>
<text class="plant-jiantou_zuoyouqiehuan"/> <text class="plant-jiantou_zuoyouqiehuan" @click="$refs.dPicker.show=true"/>
</view> </view>
<view class="company"> <view class="company">
<text>{{purchase.detailedParentName}}</text> <text>{{formData.detailedParentName}}</text>
<text>{{purchase.supplier}}</text> <text>{{formData.supplier}}</text>
</view> </view>
</view> </view>
<view class="card specs"> <view class="card specs">
<view class="title_mast">规格</view> <view class="title_mast">规格</view>
<view class="select" style="margin-bottom:20rpx;">
<text>请添加规格</text>
<text class="plant-youbian"/>
</view>
<view style="display:flex;"> <view style="display:flex;">
<view class="select"> <view class="select">
<text>请添加规格</text> <text @click="show=true" :class="{noData:!formData.goodsSpecification}">{{formData.goodsSpecification||"请添加规格"}}</text>
<text class="plant-youbian"/> <text class="plant-youbian"/>
</view> </view>
<text class="plant-xinjian" @click="$u.route({url:'pages/purchase/newSpecs'})">新建</text> <text class="plant-xinjian" @click="toAdd">新建</text>
</view> </view>
<view class="tip">库存2(200kg)</view> <view class="tip" v-if="specStr">库存{{specStr}}</view>
</view> </view>
<view class="card purchase"> <view class="card purchase">
<view class="title_mast">采购数量</view> <view class="title_mast">采购数量</view>
<view class="input"> <view class="input">
<input placeholder="请输入采购数量"/> <input placeholder="请输入采购数量" type="digit" v-model="formData.num"/>
<text>kg</text>
</view> </view>
</view> </view>
<button class="cu-btn round bg-green shadow submit">确定</button> <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"
@confirm="searchStock($event.value[0].id);formData.goodsSpecification=$event.value[0].value;show=false"/>
<d-picker :list="goodsList" ref="dPicker" :value="pickerValue" @select="setGoodsVal"/>
</view> </view>
</template> </template>
<script> <script>
@ -154,12 +164,37 @@ import request from '@/common/request'
export default{ export default{
data(){ data(){
return{ return{
purchase:null, purchaseId:'',
specList:[], specList:[[]],
specStr:"",
show:false,
formData:{
goodsName:"",
goodsSpecification:"",
num:"",
purchaseId:"",
specificationId:"",
detailedType:"",
detailedParentName:"",
supplier:"",
},
goodsList:[],
eventChannel:null,
} }
}, },
computed:{
pickerValue(){
return this.goodsList.findIndex(v=>v.id==this.purchaseId)
},
},
onLoad(options){ onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.formData.specificationId=options.id
this.init(options.id) this.init(options.id)
this.searchGoods()
}, },
methods:{ methods:{
async init(id){ async init(id){
@ -167,7 +202,7 @@ export default{
params:{id} params:{id}
}) })
if(res.statu && res.data.records[0]){ if(res.statu && res.data.records[0]){
this.purchase=res.data.records[0] this.setGoodsVal(res.data.records[0])
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",
@ -175,12 +210,21 @@ export default{
showCancel:false, showCancel:false,
}) })
} }
},
async setGoodsVal(val){
this.purchaseId=val.id
this.formData.goodsName=val.goodsName
this.formData.detailedType=val.detailedType
this.formData.detailedParentName=val.detailedParentName
this.formData.supplier=val.supplier
var res=await request("/api/goods/queryGoodsSpecification",{ var res=await request("/api/goods/queryGoodsSpecification",{
params:{goodsName:this.purchase.goodsName} params:{goodsName:this.formData.goodsName}
}) })
if(res.statu){ if(res.statu){
this.specList=res.data.map(v=>({label:v.goodsSpecification,value:v.id})) this.specList=[res.data.map(v=>({label:v.goodsSpecification,value:v.goodsSpecification,id:v.id}))]
this.formData.goodsSpecification=''
this.specStr=''
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",
@ -189,6 +233,64 @@ export default{
}) })
} }
}, },
async searchStock(id){
var res=await request("/api/goods/stockShow?goodsSpecificationId",{
params:{goodsSpecificationId:id}
})
if(res.statu&&res.data){
this.specStr=`${res.data.packing}(${res.data.heft})`
}
},
toAdd(){
uni.navigateTo({
url:`/pages/purchase/newSpecs?goodsId=${this.purchaseId}`,
events:{addUnit:e=>{
this.specList[0].push({label:e.goodsSpecification,value:e.goodsSpecification,id:e.goodsSpecificationId})
}}
})
},
check(){
if(!this.formData.goodsSpecification){
uni.showToast({title:"规格必选!",icon:"none"})
return false
}else if(!this.formData.num>0){
uni.showToast({title:"采购数量必填!",icon:"none"})
return false
}
return true
},
async submit(){
if(this.check()){
var res=await request("/purchaseMain/purchaseMain/addPlantPurchaseSub",{
method:"post",
body: this.formData
})
if(res.statu){
uni.navigateBack()
this.eventChannel.emit("submit", this.formData)
}else{
uni.showModal({
title:"提示",
content:res.msg||"保存失败!",
showCancel:false,
})
}
}
},
async searchGoods(){
var res=await request("/api/goods/goodsList",{
params: { goodsName:"",pageNo:1,pageSize:30 }
})
if(res.statu){
this.goodsList=res.data.records
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取农资列表失败!",
showCancel:false,
})
}
},
} }
} }
</script> </script>

0
uni_modules/d-picker/changelog.md

106
uni_modules/d-picker/components/d-picker/d-picker.vue

@ -0,0 +1,106 @@
<style lang="scss" scoped>
.dPicker.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;
}
}
}
}
}
}
}
</style>
<template>
<u-popup class="dPicker" :show="show" @close="show=false">
<view class="btns">
<button class="cu-btn sm" @click="show=false">取消</button>
<button class="cu-btn sm bg-green" @click="$emit('select',list[changeVal||value]);show=false">确定</button>
</view>
<picker-view :value="[value]" indicator-style="height:90rpx;" @change="changeVal=$event.detail.value[0]">
<picker-view-column>
<view v-for="(v,k) in list" :key="k" class="item" style="height:90rpx;">
<view class="name"><text>{{v.goodsName}}</text><text>{{v.detailedType}}</text></view>
<view class="company" :data-name="v.detailedParentName" :data-company="v.supplier"/>
</view>
</picker-view-column>
</picker-view>
</u-popup>
</template>
<script>
export default{
props:{
list:{
type:Array,
default:()=>[]
},
value:{
type:Number,
default:0,
},
},
data(){
return{
show:false,
changeVal:null,
}
},
watch:{
show(n){
if(!n){
this.changeVal=null
}
},
},
methods:{
},
}
</script>

81
uni_modules/d-picker/package.json

@ -0,0 +1,81 @@
{
"id": "d-picker",
"displayName": "d-picker",
"version": "1.0.0",
"description": "d-picker",
"keywords": [
"d-picker"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-vue": "u",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}

1
uni_modules/d-picker/readme.md

@ -0,0 +1 @@
# d-picker
Loading…
Cancel
Save