Browse Source

联调接口

master
邓宏 2 years ago
parent
commit
726ac947e3
  1. 2
      common/request.js
  2. 1
      pages.js
  3. 8
      pages/home/index.vue
  4. 43
      pages/massif/add_farming.vue
  5. 2
      pages/massif/collectList.vue
  6. 15
      pages/massif/mana/farmRecord.vue
  7. 9
      pages/massif/mana/index.vue
  8. 44
      pages/massif/mana/plantPlan.vue
  9. 78
      pages/massif/mana/recovery.vue
  10. 9
      pages/massif/plant_info.vue
  11. 6
      pages/massif/plant_plan.vue
  12. 139
      pages/purchase/index.vue
  13. 13
      pages/purchase/newSpecs.vue
  14. 14
      pages/purchase/specs.vue
  15. 11
      router/purchase.js
  16. 9
      uni_modules/d-form/components/d-form/d-form.vue

2
common/request.js

@ -4,7 +4,7 @@ export function host(host='default',suffix='/plant_manage'){
return(
process.env.NODE_ENV === 'development'?{
default:`http://xvff42.natappfree.cc${suffix}` //陈
// default:`http://mq3s8b.natappfree.cc${suffix}` //马
// default:`http://6h8nxd.natappfree.cc${suffix}` //马
}:{
default:`http://qv6mj8.natappfree.cc${suffix}`
}

1
pages.js

@ -27,7 +27,6 @@ module.exports = hot((pagesJson)=>{
color:"#999",
selectedColor:"#10C176",
backgroundColor:"#fff",
// iconWidth:"35rpx",
list:[
{pagePath:"pages/home/index",text:"首页",iconPath: "/static/tab_home.png",selectedIconPath: "/static/tab_home_active.png"},
{pagePath:"pages/massif/index",text:"地块管理",iconPath: "/static/tab_massif.png",selectedIconPath: "/static/tab_massif_active.png"},

8
pages/home/index.vue

@ -291,7 +291,7 @@
<view class="item meansAgrProd">农资库存</view>
<view class="item agrProd">农产品库存</view>
</view>
<view class="card stock" style="--c:#ffc353;" @click="$u.route({url:'pages/purchase/apply'})">
<view class="card stock" style="--c:#ffc353;" @click="$u.route({url:'pages/purchase/index'})">
<view class="title">采购申请</view>
<view class="item warehousing">入库管理</view>
@ -340,7 +340,6 @@ import request from '@/common/request.js'
},
onLoad() {
// this.getMassif()
// this.getPurchase()
this.isAdmin && this.getPlantBase()
},
onShow(){
@ -362,11 +361,6 @@ import request from '@/common/request.js'
})
}
},
// //
// async getPurchase(){
// var res=await request("/purchaseMain/purchaseMain/listPlantPurchaseSubByMainId")
// console.log(res,'------------res----------')
// },
//
async getPlantBase(){
var res=await request("/api/plantPlot/getAllPlantBaseInfo",{

43
pages/massif/add_farming.vue

@ -93,8 +93,8 @@
</d-navbar>
<view class="card">
<view class="plant-dikuaimianji">阳光玫瑰种植1号地块</view>
<view class="plant-batch-add" @click="$u.route({url:'pages/massif/collectList'})"/>
<view class="plant-dikuaimianji">{{massif.plotName}}</view>
<view class="plant-batch-add" @click="toCollectList"/>
</view>
<view class="card">
@ -114,16 +114,20 @@
:key="k"
v-bind="v"
:field="k"
:required="!!rules[k]"/>
:required="!!rules[k]"
:value="[]"/>
</u-form>
</view>
</view>
</template>
<script>
import request from '@/common/request'
export default {
data(){
return{
fields:{
// people:{label:"",},
// date:{label:""},
imgs:{label:"农事图片",type:"upImg"},
intro:{label:"产品介绍",type:"textarea"},
},
@ -131,12 +135,35 @@ export default {
name:"",
},
rules:{
}
intro:{required:true},
},
massif:{}
}
},
onLoad(){
}
onLoad(options){
this.getMassifDetail(options.plotId)
},
methods:{
async getMassifDetail(id){
var res=await request("/api/plantPlot/queryById",{
params:{id}
})
if(res.statu){
this.massif=res.data
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取地块信息失败!",
showCancel:false,
})
}
},
toCollectList(){
uni.navigateTo({
url:"/pages/massif/collectList",
event:{ add:()=>{} }
})
},
},
}
</script>

2
pages/massif/collectList.vue

@ -2,7 +2,7 @@
.container{
min-height:100%;
background:#f6f6f6;
padding:30rpx 0;
// padding:30rpx 0;
.card{
.name{

15
pages/massif/mana/farmRecord.vue

@ -68,7 +68,7 @@
<view class="head">
<image mode="aspectFit" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAXhJREFUOE+dk7FLw1AQxr+LbSyInQuODiIW+hc4iZP/QCfBpXmmUHR26eRopdT0ZRLX7k7FybmgKAUJjrZriTqY2Jy80IQ0aik5eMO7++7H4953hFRYlrWlaZoAcEBEG6rMzG8AboMgkKZpviRbKLo0m81cqVQ6B3BKRLk0eAb6JqIWgDPDMHyVCwHtdnu1UCj0mXn3r8Z0jpnvPc/bbzQaXyHAtm0JwFimOdIwsxRCHFOn09nJ5/OPAFaiYrVaxWAwgOM4i5hT3/crJKVsEdFJUlmr1UKAOouCmS/Jtu0hgO2MgKECfABYywIA8KkALoD1jIB3BXgCUE4DRqMRxuPx3Ahc150bLDM/K8CFMk9SqX6hWCz+mt9kMkGv14vzQRC0qNvtljVNe0h+45J+mBJRJTSSlPKKiMwlG0MZM1tCiHpsZV3X+0SUzcrRPui6rl5yBED75zUBM197nldXexAvU1I8s/YhgD0Am7PaK4A7Zr4RQijjxfEDDjS1T8RMzc4AAAAASUVORK5CYII="/>
<text class="title">农资使用情况</text>
<text class="add" @click="$u.route({url:'pages/massif/add_farming'})">+添加农事</text>
<text class="add" @click="toAdd">+添加农事</text>
</view>
<view class="card">
<view class="name">
@ -83,10 +83,23 @@
<script>
export default {
name:"farmRecord",
props:{
plotId:{
type:String,
default:""
}
},
data(){
return{
}
},
methods:{
toAdd(){
uni.navigateTo({
url:`/pages/massif/add_farming?plotId=${this.plotId}`
})
}
}
}
</script>

9
pages/massif/mana/index.vue

@ -20,9 +20,9 @@
<u-tabs :list="tabs" :current="tabIndex" activeStyle="color:#10C176;" lineColor="#10C176" lineWidth="50" :scrollable="false" @change="tabIndex=$event.index"/>
<plant-plan v-if="tabIndex==0" :id="plantId"/>
<farmRecord v-else-if="tabIndex==1" />
<recovery v-else />
<plant-plan v-if="tabIndex==0" :plotId="plotId" @trigger="tabIndex=$event.tabIndex;plantId=$event.plantId"/>
<farmRecord v-else-if="tabIndex==1" :plotId="plotId"/>
<recovery v-else :plotId="plotId"/>
</view>
</template>
<script>
@ -39,11 +39,12 @@ export default {
{name:"农事记录",},
{name:"采收记录",},
],
plotId:"",
plantId:"",
}
},
onLoad(options){
this.plantId=options.id
this.plotId=options.id
},
onReady(){
/* #ifdef APP-PLUS */

44
pages/massif/mana/plantPlan.vue

@ -19,10 +19,6 @@
min-width:80rpx;
text-align: center;
}
&/deep/ image{
color:red;
border-radius: 20rpx!important;
}
}
&>.detail{
flex-grow: 1;
@ -75,6 +71,14 @@
color:#999;
font-size:24rpx;
margin-right:auto;
&.over{
background:#F7F7F7;
border-radius: 8rpx;
height:48rpx;
line-height: 48rpx;
padding:0 20rpx;
margin:0 0 0 auto;
}
}
button{
margin:0 0 0 20rpx;
@ -93,7 +97,7 @@
<view class="plant_plan">
<view class="card" v-for="(v,k) in list" :key="k">
<view class="info" @click="reDetail(v.id)">
<u-image :data-type="v.plantType" width="170rpx" height="140rpx" mode="aspectFill" src="https://cdn.uviewui.com/uview/album/1.jpg">
<u-image :data-type="v.plantType" radius="20rpx" width="170rpx" height="140rpx" mode="aspectFill" src="https://cdn.uviewui.com/uview/album/1.jpg">
<view slot="error" style="font-size: 24rpx;">加载失败</view>
</u-image>
<view class="detail">
@ -107,11 +111,15 @@
</view>
<view class="date">
<text>本次预估采收时间{{v.harvestTime}}</text>
<button class="cu-btn" style="--c:255, 196, 87;" @click.stop="finishPlant(v.id)">结束种植</button>
<button class="cu-btn" style="--c:153, 153, 153;" @click.stop="$u.route({url:'pages/massif/plant_info',params:{plantId:v.id,plotId:id}})">采收</button>
<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>
</view>
</template>
@ -120,7 +128,7 @@ import request,{host} from '@/common/request'
export default {
name:"plantPlan",
props:{
id:{
plotId:{
type:String,
default:""
}
@ -150,7 +158,7 @@ export default {
var res=await request('/api/plantPlan/list',{
params: {
...this.searchVal,
plotId: this.id
plotId: this.plotId
}
})
if(res.statu){
@ -167,8 +175,8 @@ export default {
},
addPlant(){
uni.navigateTo({
url:`/pages/massif/plant_plan?plotId=${this.id}`,
event:{update:()=> {this.clean();this.search()} }
url:`/pages/massif/plant_plan?plotId=${this.plotId}`,
event:{ update:()=> {this.clean();this.search()} }
})
},
reDetail(id){
@ -178,12 +186,13 @@ export default {
})
},
//
async finishPlant(plantPlanId){
async finishPlant(index){
var res=await request("/api/plantPlan/finishPlant",{
params:{plantPlanId}
params:{plantPlanId:this.list[index].id}
})
if(res.statu){
uni.showToast({title:"结束成功!",duration:1500})
this.list[index].status=2
}else{
uni.showModal({
title:"提示",
@ -192,6 +201,13 @@ export default {
})
}
},
//
toAdd(plantId){
uni.navigateTo({
url:`/pages/massif/plant_info?plantId=${plantId}&plotId=${this.plotId}`,
event:{ toRecovery:()=> {this.$emit("trigger",{tabIndex:2,plantId})} }
})
}
}
}
</script>

78
pages/massif/mana/recovery.vue

@ -13,7 +13,7 @@
background:#fff;
height:48rpx;
font-size:24rpx;
color:#999;
color:#333;
border-radius: 8rpx;
padding:0 10rpx;
min-width:226rpx;
@ -21,6 +21,9 @@
&:before{
transform: rotate(90deg);
}
&.noDate{
color:#999;
}
}
&:nth-child(2){
color:#999;
@ -30,10 +33,8 @@
}
.card{
display:flex;
image{
.u-transition{
flex-shrink: 0;
width:90rpx;
height:90rpx;
margin-right:20rpx;
}
.detail{
@ -59,6 +60,9 @@
.info{
font-size: 24rpx;
color:#999;
text:nth-child(2){
margin-left:20rpx;
}
}
}
}
@ -67,27 +71,37 @@
<template>
<view class="recovery">
<view class="dateRange">
<text class="plant-youbian">请选择开始时间</text>
<text class="plant-youbian" :class="{noDate:!searchVal.startTime}" @click="dateType='startTime';show=true">{{searchVal.startTime||"请选择开始时间"}}</text>
<text>~</text>
<text class="plant-youbian">请选择结束时间</text>
<text class="plant-youbian" :class="{noDate:!searchVal.endTime}" @click="dateType='endTime';show=true">{{searchVal.endTime||"请选择结束时间"}}</text>
</view>
<view class="card">
<image mode="aspectFill" src="/static/logo.png"/>
<view class="card" v-for="(v,k) in list" :key="k">
<u-image width="90rpx" height="90rpx" radius="6rpx" mode="aspectFill" :src="`${host}/${v.images}`"/>
<view class="detail">
<view class="name">
<text>精品小黄瓜</text>
<text data-unit="kg">200</text></view>
<text>{{v.plantName}}</text>
<text data-unit="kg">{{v.harvestNum}}</text></view>
<view class="info">
<text>负责人张召忠</text>
<text>采收时间2022-12-12</text>
<text>负责人{{v.principal}}</text>
<text>采收时间{{v.harvestTime}}</text>
</view>
</view>
</view>
<u-empty v-if="list.length==0" icon="http://cdn.uviewui.com/uview/empty/data.png"/>
<u-datetime-picker
:show="show"
mode="date"
closeOnClickOverlay
@close="show=false"
@cancel="show=false"
:value="date"
@confirm="searchVal[dateType]=new Date($event.value).format('yyyy-MM-dd');show=false"/>
</view>
</template>
<script>
import request from '@/common/request'
import request,{host} from '@/common/request'
export default {
name:"recovery",
props:{
@ -98,14 +112,23 @@ export default {
},
data(){
return{
show:false,
dateType:"startTime",
host:host(undefined,"/plant_manage/sys/common/static"),
searchVal:{
plotId:"",
plantScheduleId:"",// id
pageNo:"",
pageSize:"",
pageNo:1,
pageSize:5,
startTime:"",
endTime:"",
}
},
list:[],
total:0,
}
},
computed:{
date(){
return new Date().format('yyyy-MM-dd')
}
},
created(){
@ -113,9 +136,24 @@ export default {
},
methods:{
async search(){
var res=await request("/api/plantHarvest/list",{
params:this.searchVal
})
if(this.total==0||this.list.length<this.total){
var res=await request("/api/plantHarvest/list",{
params:{
...this.searchVal,
plotId:this.plotId
}
})
if(res.statu){
this.list=this.list.concat(res.data.records)
this.total=res.data.total
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取采收记录列表失败!",
showCancel:false,
})
}
}
},
}
}

9
pages/massif/plant_info.vue

@ -19,7 +19,7 @@
:field="k"
:required="!!rules[k]"
:value="/^select$/.test(v.type)?fields[k].value:formData[k]"
@select="fields[k].value=$event.indexs;formData[k]=$event.value[0].value"
@select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value[0].value"
@input="formData[k]=$event"/>
</u-form>
</view>
@ -51,10 +51,12 @@ export default {
principal:{required:true, message:"负责人必填!", trigger:"blur"},
harvestTime:{required:true, message:"采收时间必填!", trigger:"blur"},
status:{required:true, message:"采收状态必填!", trigger:"blur"},
}
},
eventChannel:null,
}
},
onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.formData.plantSchedulId=options.plantId
this.formData.plotId=options.plotId
this.init()
@ -80,7 +82,8 @@ export default {
body: this.formData
})
if(res.statu){
this.eventChannel('toRecovery')
uni.navigateBack()
}else{
uni.showModal({
title:"提示",

6
pages/massif/plant_plan.vue

@ -75,7 +75,11 @@ export default {
plantStandard: {required:true, message:"种植标准必填!", trigger:"blur"},
plantBatch: {required:true, message:"种植批次号必填!", trigger:"blur"},
principal: {required:true, message:"负责人必填!", trigger:"blur"},
principalId: {required:true, message:"负责人身份证必填!", trigger:"blur"},
principalId: {required:true, validator(rule,val,call){
if(!val)call(new Error("负责人身份证必填!"));
else if(!/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(val))call(new Error("请输入正确身份证格式!"));
else call();
}, trigger:"blur"},
},
eventChannel:null,
}

139
pages/purchase/index.vue

@ -0,0 +1,139 @@
<style lang="scss">
.container{
min-height: 100%;
background:#f6f6f6;
// padding:30rpx 0;
scroll-view{
flex-grow: 1;
height:1rpx;
border:1rpx solid transparent;
.card{
margin-top:0;
&>.info{
display:flex;
align-items: center;
margin-bottom:20rpx;
text{
&:first-child{
font-size:20rpx;
color:#fff;
background:#10C176;
border-radius: 0 20rpx 0 20rpx;
height:40rpx;
width:80rpx;
line-height: 40rpx;
text-align: center;
margin-right:16rpx;
}
&:nth-child(2){
font-weight: bold;
}
&:nth-child(3){
color:#999;
font-size: 20rpx;
margin-left:6rpx;
}
}
}
&>.name{
text{
&:first-child{
color:#FBA83C;
}
&:nth-child(2){
color:#999;
margin-left:22rpx;
}
}
}
&>.data{
display:flex;
align-items: center;
justify-content: space-between;
border-top:2rpx solid #D8D8D8;
margin-top:20rpx;
padding-top:16rpx;
text{
&:first-child{
color:#999;
font-size:24rpx;
}
&:nth-child(2){
font-weight: bold;
&:after{
content:"("attr(data-unit)")";
font-weight: normal;
margin-left:5rpx;
}
}
}
}
}
}
}
</style>
<template>
<view class="container flex">
<d-search v-model="searchVal.baseName" @search="clean();search()"/>
<scroll-view scroll-y >
<view class="card" v-for="(v,k) in list" :key="k">
<view class="info">
<text>化肥</text> <text>中量元素水溶肥</text> <text>(100kg/)</text>
</view>
<view class="name">
<text>微量元素肥</text> <text>云南云天化股份有限公司</text>
</view>
<view class="data">
<text>采购时间{{v.applicantTime}}</text> <text data-unit="共200kg">2</text>
</view>
</view>
<u-empty v-if="list.length==0" icon="http://cdn.uviewui.com/uview/empty/data.png"/>
</scroll-view>
</view>
</template>
<script>
import request from '@/common/request'
export default {
data(){
return{
searchVal:{
pageNo:1,
pageSize:5,
companyId: this.$store.getters['userInfo'].companyId
},
list:[],
total:0,
}
},
onLoad(){
this.search()
},
methods:{
clean(){
this.list=[]
this.total=0
this.searchVal.pageNo=1
},
async search(){
if(this.total==0||this.list.length<this.total){
var res=await request("/api/purchase/purchaseList",{
methods:"post",
body: this.searchVal
})
if(res.statu){
this.list=this.list.concat(res.data.records)
this.total=res.data.total
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取采购列表失败!",
showCancel:false,
})
}
}
},
}
}
</script>

13
pages/purchase/newSpecs.vue

@ -64,10 +64,23 @@
<view class="title_mast">预警值</view>
<view class="input"><input placeholder="请输入预警值"/><text>kg</text></view>
</view>
<button class="cu-btn round bg-green shadow submit">确定</button>
</view>
</template>
<script>
import request from '@/common/request'
export default {
data(){
return{
}
},
onLoad(){},
methods:{
async init(){
var res=await request("")
}
},
}
</script>

14
pages/purchase/specs.vue

@ -155,6 +155,7 @@ export default{
data(){
return{
purchase:null,
specList:[],
}
},
onLoad(options){
@ -174,6 +175,19 @@ export default{
showCancel:false,
})
}
var res=await request("/api/goods/queryGoodsSpecification",{
params:{goodsName:this.purchase.goodsName}
})
if(res.statu){
this.specList=res.data.map(v=>({label:v.goodsSpecification,value:v.id}))
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取规格选项失败!",
showCancel:false,
})
}
},
}
}

11
router/purchase.js

@ -1,4 +1,15 @@
module.exports=[
{
path:"pages/purchase/index",
style:{
navigationBarTitleText:"采购管理",
navigationBarBackgroundColor:"#10C176",
navigationBarTextStyle:"white",
"app-plus":{
titleNView:true
}
}
},
{
path:"pages/purchase/apply",
style:{

9
uni_modules/d-form/components/d-form/d-form.vue

@ -133,7 +133,10 @@
}
&/deep/ {
.u-form-item__body__left__content{
margin-left:20rpx;
.u-form-item__body__left__content__required{
position:initial;
margin-right:4rpx;
}
}
.u-form-item__body__right__message{
margin-left:0!important;
@ -377,8 +380,8 @@ import {dataType} from 'black-knight/lib/config/tools'
this.$emit('imgs',this.imgs.map(v=>({saved:v.url,unsaved:v.tempUrl})[v.type]).join(','))
},
pickerChange(e){
if(e.value[e.columnIndex].hasOwnProperty('children')){
this.$refs.picker.setColumnValues(e.columnIndex+1,e.value[0].children||[])
if(dataType(e.value[e.columnIndex].children, 'array')){
this.$refs.picker.setColumnValues(e.columnIndex+1,e.value[0].children)
}
},
},

Loading…
Cancel
Save