Browse Source

联调接口

master
邓宏 2 years ago
parent
commit
4413242ae9
  1. 22
      common/request.js
  2. 5
      pages/massif/mana/index.vue
  3. 24
      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. 65
      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"
export function host(host='default',suffix='/plant_manage'){
return(
process.env.NODE_ENV === 'development'?{
default:`http://xvff42.natappfree.cc${suffix}` //陈
// default:`http://6h8nxd.natappfree.cc${suffix}` //马
var url=process.env.NODE_ENV === 'development'?{
default:`http://2uktvr.natappfree.cc` //陈
// default:`http://6h8nxd.natappfree.cc` //马
}:{
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-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>
<farmRecord :plotId="plotId"/>
</swiper-item>
<swiper-item>
<recovery :plotId="plotId" :plantId="plantId"/>
<recovery :plotId="plotId" ref="recovery"/>
</swiper-item>
</swiper>
</view>
@ -53,7 +53,6 @@ export default {
{name:"采收记录",},
],
plotId:"",
plantId:"",
}
},
onLoad(options){

24
pages/massif/mana/plantPlan.vue

@ -1,5 +1,11 @@
<style lang="scss" scoped>
.plant_plan{
height:100%;
display:flex;
flex-direction: column;
scroll-view{
flex-grow: 1;
height:1rpx;
.card{
&>.info{
display:flex;
@ -92,9 +98,15 @@
}
}
}
button{
flex-shrink: 0;
margin:20rpx auto!important;
}
}
</style>
<template>
<view class="plant_plan">
<scroll-view scroll-y @scrolltolower="search">
<view class="card" v-for="(v,k) in list" :key="k">
<view class="info" @click="reDetail(v.id)">
<u-image :data-type="v.plantType" radius="20rpx" width="170rpx" height="140rpx" mode="aspectFill" src="https://cdn.uviewui.com/uview/album/1.jpg">
@ -119,6 +131,7 @@
</view>
</view>
<u-empty v-if="list.length==0" icon="http://cdn.uviewui.com/uview/empty/data.png"/>
</scroll-view>
<button class="cu-btn round bg-green shadow submit" @click="addPlant">+新增种植计划</button>
</view>
@ -162,6 +175,8 @@ export default {
}
})
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.total=res.data.total
}else{
@ -176,7 +191,7 @@ export default {
addPlant(){
uni.navigateTo({
url:`/pages/massif/plant_plan?plotId=${this.plotId}`,
event:{ update:()=> {this.clean();this.search()} }
events:{ update:()=> {this.clean();this.search()} }
})
},
reDetail(id){
@ -203,14 +218,9 @@ export default {
},
//
toAdd(plantId){
this.$emit("trigger",{tabIndex:2,plantId})
uni.navigateTo({
url:`/pages/massif/plant_info?plantId=${plantId}&plotId=${this.plotId}`,
event:{ toRecovery:()=>{
// this.$nextTick(()=>{
this.$emit("trigger",{tabIndex:2,plantId})
// })
} }
events:{ toRecovery:()=> this.$emit("trigger",{tabIndex:2,plantId}) }
})
}
}

24
pages/massif/mana/recovery.vue

@ -109,10 +109,6 @@ export default {
type:String,
defaylt:""
},
plantId:{
type:String,
default:'',
},
},
data(){
return{
@ -134,25 +130,25 @@ export default {
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(){
this.search()
},
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){
var res=await request("/api/plantHarvest/list",{
params:{
...this.searchVal,
plotId:this.plotId,
plantScheduleId:this.plantId,
plantScheduleId: plantId,
}
})
if(res.statu){

2
pages/massif/plant_info.vue

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

13
pages/purchase/agrProdList.vue

@ -56,7 +56,7 @@
<d-search v-model="searchVal.goodsName" @search="clean();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">
<text>{{v.goodsName}}</text> {{v.detailedType}} <text class="plant-youbian"/>
</view>
@ -80,9 +80,11 @@ export default {
},
list:[],
total:0,
eventChannel:null,
}
},
onLoad(){
this.eventChannel=this.getOpenerEventChannel()
this.search()
},
methods:{
@ -114,6 +116,15 @@ export default {
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>

65
pages/purchase/apply.vue

@ -93,32 +93,33 @@
<view class="container">
<view class="card info">
<view>
<text>申请人</text> <text>{{info.name}}</text>
<text>申请人</text> <text>{{formData.applicantName}}</text>
</view>
<view>
<text>所在基地</text> <text>{{info.baseName}}</text>
<text>所在基地</text> <text>{{formData.baseName}}</text>
</view>
<view>
<text>申请时间</text> <text>{{new Date().format('yyyy-MM-dd')}}</text>
<text>申请时间</text> <text>{{formData.applicantTime}}</text>
</view>
</view>
<view class="card detail">
<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">
<text>化肥</text>
<text data-unit="100kg/">中量元素水溶肥</text>
<text class="plant-shanchu">删除</text>
<text>{{v.goodsName}}</text>
<text :data-unit="v.goodsSpecification">{{v.detailedType}}</text>
<text class="plant-shanchu" @click="formData.plantPurchaseSubList.splice(k,1)">删除</text>
</view>
<view class="company">
<text style="--c:#707070;flex-shrink: 0;">云南云天化股份有限公司</text>
<text style="--c:#FBA83C;flex-grow:1;text-align:center;">微量元素肥</text>
<text style="--c:#707070;flex-shrink: 0;">{{v.supplier}}</text>
<text style="--c:#FBA83C;flex-grow:1;text-align:center;">{{v.detailedParentName}}</text>
</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 class="card type">
@ -133,7 +134,15 @@ import request from '@/common/request'
export default {
data(){
return{
info:{},
formData:{
applicantId: "",
applicantName: "",
applicantTime: "",
baseName: "",
companyId: "",
plantPurchaseSubList: [],
// sysOrgCode: "",
},
}
},
onLoad(){
@ -141,10 +150,13 @@ export default {
},
methods:{
async init(){
//
var res=await request("/api/purchase/purchaseUserShow")
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{
uni.showModal({
title:"提示",
@ -154,11 +166,30 @@ export default {
}
},
async submit(){
var res=await request("/api/purchase/applicantStatus",{
params:{
status:2,
purchaseId:"",
if(this.formData.plantPurchaseSubList.length<=0){
uni.showToast({title:"请选择采购详情!",icon:"none"})
return false
}
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="title_mast">规格</view>
<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 class="tip">例如肥料一袋50kg录入规格则为50kg/</view>
</view>
<view class="card warning">
<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>
<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>
</template>
<script>
@ -73,13 +82,71 @@ 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(){},
onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.formData.goodsId=options.goodsId
this.init()
},
methods:{
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;
color:#fff;
background:#10C176;
border-radius: 4rpx;
padding: 0 4rpx;
border-radius: 4rpx 30rpx 4rpx 30rpx;
padding: 0 6rpx;
min-width:80rpx;
text-align: center;
height:40rpx;
@ -63,11 +63,15 @@
padding:0 28rpx;
display:flex;
text{
color:#999;
&:first-child{
flex-grow: 1;
color:#333;
&.noData{
color:#999;
}
}
&:nth-child(2){
color:#999;
flex-shrink: 0;
transform: rotate(90deg);
}
@ -112,41 +116,47 @@
<view class="container">
<view class="card fertilizer">
<view class="name">
<text>{{purchase.goodsName}}</text>
<text>{{purchase.detailedType}}</text>
<text class="plant-jiantou_zuoyouqiehuan"/>
<text>{{formData.goodsName}}</text>
<text>{{formData.detailedType}}</text>
<text class="plant-jiantou_zuoyouqiehuan" @click="$refs.dPicker.show=true"/>
</view>
<view class="company">
<text>{{purchase.detailedParentName}}</text>
<text>{{purchase.supplier}}</text>
<text>{{formData.detailedParentName}}</text>
<text>{{formData.supplier}}</text>
</view>
</view>
<view class="card specs">
<view class="title_mast">规格</view>
<view class="select" style="margin-bottom:20rpx;">
<text>请添加规格</text>
<text class="plant-youbian"/>
</view>
<view style="display:flex;">
<view class="select">
<text>请添加规格</text>
<text @click="show=true" :class="{noData:!formData.goodsSpecification}">{{formData.goodsSpecification||"请添加规格"}}</text>
<text class="plant-youbian"/>
</view>
<text class="plant-xinjian" @click="$u.route({url:'pages/purchase/newSpecs'})">新建</text>
<text class="plant-xinjian" @click="toAdd">新建</text>
</view>
<view class="tip">库存2(200kg)</view>
<view class="tip" v-if="specStr">库存{{specStr}}</view>
</view>
<view class="card purchase">
<view class="title_mast">采购数量</view>
<view class="input">
<input placeholder="请输入采购数量"/>
<text>kg</text>
<input placeholder="请输入采购数量" type="digit" v-model="formData.num"/>
</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>
</template>
<script>
@ -154,12 +164,37 @@ import request from '@/common/request'
export default{
data(){
return{
purchase:null,
specList:[],
purchaseId:'',
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){
this.eventChannel=this.getOpenerEventChannel()
this.formData.specificationId=options.id
this.init(options.id)
this.searchGoods()
},
methods:{
async init(id){
@ -167,7 +202,7 @@ export default{
params:{id}
})
if(res.statu && res.data.records[0]){
this.purchase=res.data.records[0]
this.setGoodsVal(res.data.records[0])
}else{
uni.showModal({
title:"提示",
@ -175,12 +210,21 @@ export default{
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",{
params:{goodsName:this.purchase.goodsName}
params:{goodsName:this.formData.goodsName}
})
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{
uni.showModal({
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>

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