Browse Source

联调添加农事

master
邓宏 2 years ago
parent
commit
6862abdf76
  1. 4
      common/request.js
  2. 27
      pages/home/index.vue
  3. 67
      pages/massif/add_farming.vue
  4. 256
      pages/massif/agrSpecs.vue
  5. 148
      pages/massif/collectList.vue
  6. 10
      pages/massif/mana/farmRecord.vue
  7. 2
      uni_modules/d-form/components/d-form/d-form.vue
  8. 2
      uni_modules/d-picker/components/d-picker/d-picker.vue

4
common/request.js

@ -2,8 +2,8 @@ import store from "@/store"
export function host(host='default',suffix='/plant_manage'){ export function host(host='default',suffix='/plant_manage'){
var url=process.env.NODE_ENV === 'development'?{ var url=process.env.NODE_ENV === 'development'?{
default:`http://59syiv.natappfree.cc` //陈 // default:`http://59syiv.natappfree.cc` //陈
// default:`http://nys8cm.natappfree.cc` //马 default:`http://sfhtpp.natappfree.cc` //马
// default:`http://4gg9xn.natappfree.cc` //何 // default:`http://4gg9xn.natappfree.cc` //何
// default:`http://192.168.0.116:8080` //孙 // default:`http://192.168.0.116:8080` //孙
}:{ }:{

27
pages/home/index.vue

@ -12,7 +12,15 @@
border-radius: 0 0 80rpx 80rpx; border-radius: 0 0 80rpx 80rpx;
box-sizing:content-box; box-sizing:content-box;
} }
swiper{ swiper.headImg{
height:424rpx;
margin-bottom:-80rpx;
image{
width:100%;
height:100%;
}
}
swiper.data{
height:213rpx; height:213rpx;
swiper-item{ swiper-item{
&>view{ &>view{
@ -260,8 +268,13 @@
</style> </style>
<template> <template>
<view class="container"> <view class="container">
<image class="head" src="@/static/banner.png" mode="aspectFit"/> <!-- <image class="head" src="@/static/banner.png" mode="aspectFit"/> -->
<swiper :display-multiple-items="2" circular> <swiper class="headImg" circular>
<swiper-item>
<image src="@/static/banner.png" mode="aspectFill"/>
</swiper-item>
</swiper>
<swiper class="data" :display-multiple-items="2" circular>
<swiper-item> <swiper-item>
<view data-title="地块个数()" style="--c:16, 193, 118;"> <view data-title="地块个数()" style="--c:16, 193, 118;">
<text class="value">{{massif.plotNum}}</text> <text class="value">{{massif.plotNum}}</text>
@ -353,6 +366,7 @@ import request from '@/common/request.js'
export default { export default {
data() { data() {
return { return {
headImgs:[],
mapContext:null, mapContext:null,
show:false, show:false,
plantBase:[[]], plantBase:[[]],
@ -380,6 +394,7 @@ import request from '@/common/request.js'
} }
}, },
onLoad() { onLoad() {
this.getHeadImg()
if(this.isAdmin){ if(this.isAdmin){
this.getPlantBase() this.getPlantBase()
}else{ }else{
@ -387,6 +402,12 @@ import request from '@/common/request.js'
} }
}, },
methods: { methods: {
async getHeadImg(){
var res=await request("/base/api/plantCompany/picShow",{method:"post"})
if(res.statu){
}
},
// //
async getMassif(plantBaseId){ async getMassif(plantBaseId){
var res=await request("/api/plantIndex/queryPlot",{ var res=await request("/api/plantIndex/queryPlot",{

67
pages/massif/add_farming.vue

@ -124,23 +124,25 @@
<view class="card"> <view class="card">
<view class="plant-dikuaimianji">{{massif.plotName}}</view> <view class="plant-dikuaimianji">{{massif.plotName}}</view>
<view class="plant-batch-add" @click="toCollectList"/> <view v-if="formData.inputList.length<=0" class="plant-batch-add" @click="toCollectList"/>
<view class="info"> <view class="info" v-for="(v,k) in formData.inputList" :key="k">
<text>化肥</text> <text>中量元素水溶肥</text> <text>200kg</text> <text>{{v.parentName}}</text> <text>{{v.name}}</text> <text>{{v.inputQuantity}}{{v.unit}}</text>
</view> </view>
<button class="cu-btn round bg-green shadow submit" @click="toCollectList">+继续添加农资</button> <button class="cu-btn round bg-green shadow submit" v-if="formData.inputList.length>0" @click="toCollectList">+继续添加农资</button>
</view> </view>
<view class="card"> <view class="card">
<u-form class="inline" :model="formData" :rules="rules" ref="form" labelWidth="auto"> <u-form class="inline" errorType="toast" :model="formData" :rules="rules" ref="form" labelWidth="auto">
<d-form <d-form
v-for="(v,k) in fields" v-for="(v,k) in fields"
:key="k" :key="k"
v-bind="v" v-bind="v"
:field="k" :field="k"
:required="!!rules[k]" :required="!!rules[k]"
:value="formData[k]" :value="/^select$/.test(v.type)?fields[k].value:formData[k]"
@input="formData[k]=$event"/> @input="formData[k]=$event"
@select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value[0].value"
@imgs="fields[k].value=$event"/>
</u-form> </u-form>
</view> </view>
<u-popup :show="isShow" closeOnClickOverlay @close="isShow=false"> <u-popup :show="isShow" closeOnClickOverlay @close="isShow=false">
@ -168,6 +170,7 @@ export default {
farmingTime:"", farmingTime:"",
images:[], images:[],
farmingRemarks:"", farmingRemarks:"",
inputList:[],
plotId:"", plotId:"",
plantBaseInfoId: this.$store.state.plantBaseInfoId, plantBaseInfoId: this.$store.state.plantBaseInfoId,
@ -183,9 +186,11 @@ export default {
massif:{}, massif:{},
tempType:"", tempType:"",
isShow:false, isShow:false,
eventChannel:null,
} }
}, },
onLoad(options){ onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.formData.plotId=options.plotId this.formData.plotId=options.plotId
this.init() this.init()
this.getMassifDetail() this.getMassifDetail()
@ -207,7 +212,7 @@ export default {
params:{plotId: this.formData.plotId} params:{plotId: this.formData.plotId}
}) })
if(res.statu){ if(res.statu){
this.farmingPlanId.columns=[res.data.map(v=>({}))] this.fields.farmingPlanId.columns=[res.data]
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",
@ -233,21 +238,45 @@ export default {
toCollectList(){ toCollectList(){
uni.navigateTo({ uni.navigateTo({
url:"/pages/massif/collectList", url:"/pages/massif/collectList",
event:{ add:()=>{} } events:{ addSpecs: e=>{
this.formData.inputList.push(e)
} }
}) })
}, },
check(){
if(!this.formData.farmingType){
uni.showToast({title:"农资类型必选!",icon:"none"})
return false
}else if(this.formData.inputList.length<=0){
uni.showToast({title:"请添加农资!",icon:"none"})
return false
}
return true
},
submit(){ submit(){
this.$refs.form.validoter().then(async valid=>{ if(this.check()){
if(valid){ this.$refs.form.validate().then(async valid=>{
var res=await request("/api/plantFarming/addOrUpdate",{ if(valid){
method:"post", var res=await request("/api/plantFarming/addOrUpdate",{
body:{ method:"post",
...this.formData, body:{
...this.formData,
images: this.fields.images.value
}
})
if(res.statu){
uni.navigateBack()
this.eventChannel.emit("update")
}else{
uni.showModal({
title:"提示",
content:res.msg||"保存农事失败!",
showCancel:false,
})
} }
}) }
} })
}) }
}, },
async addType(){ async addType(){
if(this.tempType){ if(this.tempType){

256
pages/massif/agrSpecs.vue

@ -39,67 +39,79 @@
} }
} }
} }
} .company{
} text{
font-size:24rpx;
.u-popup{ &:first-child{
.u-popup__content{ color:#FBA83C;
&>.btns{ margin-right:16rpx;
display:flex; }
justify-content: space-between; &:nth-child(2){
padding:10rpx; color:#999;
}
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;
}
}
} }
} }
} }
} }
} }
// .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;
// }
// }
// }
// }
// }
// }
// }
.agr-picker{ .agr-picker{
padding:0 30rpx; padding:0 30rpx;
display:flex; display:flex;
@ -109,37 +121,37 @@
display:flex; display:flex;
align-items: center; align-items: center;
text{ text{
font-size:16rpx;
&:first-child{ &:first-child{
flex-shrink: 0;
color:#fff; color:#fff;
font-size:20rpx;
border-radius: 0px 20rpx 0px 20rpx;
background:#10C176; background:#10C176;
border-radius:0 20rpx 0 20rpx;
width:80rpx; width:80rpx;
height:34rpx; height:40rpx;
text-align: center; text-align: center;
line-height: 34rpx; line-height: 40rpx;
margin-right:16rpx; margin-right:10rpx;
} }
&:nth-child(2){ &:nth-child(2){
flex-grow: 1;
display:flex;
align-items: center;
font-weight: bold; font-weight: bold;
font-size:20rpx; margin-right:20rpx;
}
&:nth-child(3){
color:#999;
margin-left:6rpx;
} }
} }
} }
.company{ .company{
font-size:16rpx; text{
&:before{ font-size:24rpx;
content:attr(data-name); &:first-child{
color:#FBA83C; color:#FBA83C;
margin-right:20rpx; margin-right:16rpx;
} }
&:after{ &:nth-child(2){
content:attr(data-company); color:#999;
color:#999999; }
} }
} }
} }
@ -148,32 +160,29 @@
<template> <template>
<view class="container"> <view class="container">
<d-navbar style="--bg:#10C176;--c:#fff;" isBack text="农资规格"> <d-navbar style="--bg:#10C176;--c:#fff;" isBack text="农资规格">
<button slot="right" class="cu-btn round">确定</button> <button slot="right" class="cu-btn round" @click="submit">确定</button>
</d-navbar> </d-navbar>
<view class="card info"> <view class="card info">
<view class="name"> <view class="name">
<text>化肥</text> <text>中量元素水溶肥</text> <text @click="$refs.dPicker.show=true" class="plant-jiantou_zuoyouqiehuan"/> <text>{{agrDetail.parentName}}</text> <text>{{agrDetail.name}}</text> <text @click="$u.route({type:'navigateBack'})" class="plant-jiantou_zuoyouqiehuan"/>
</view>
<view class="company">
<text>{{agrDetail.typeOne}}</text> <text>{{agrDetail.supplier}}</text>
</view> </view>
<view style="color:#707070;font-size:20rpx;">云南云天化股份有限公司</view>
</view> </view>
<view class="card"> <view class="card">
<u-form class="inline" labelWidth="auto" :model="formData" :rules="rules"> <u-form class="inline" labelWidth="auto" ref="form" errorType="toast" :model="formData" :rules="rules">
<d-form <d-form
v-for="(v,k) in fields" v-for="(v,k) in fields"
:key="k" :key="k"
v-bind="v" v-bind="v"
:field="k" :field="k"
:required="!!rules[k]"/> :required="!!rules[k]"
@input="formData[k]=$event"
@select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value[0].value"/>
</u-form> </u-form>
</view> </view>
<d-picker :list="agrList" ref="dPicker">
<view slot-scope="{row}" class="agr-picker">
<view class="name"><text>{{row.agriculturalGoods}}</text><text>{{row.substanceName}}</text><text>({{row.specDescribe}})</text></view>
<view class="company" :data-name="row.detailType" :data-company="row.supplierName"/>
</view>
</d-picker>
</view> </view>
</template> </template>
<script> <script>
@ -182,41 +191,76 @@ export default {
data(){ data(){
return{ return{
fields:{ fields:{
specs:{label:"规格",tip:"库存:2袋(200kg)",type:"select"}, specificationId:{label:"规格",tip:"",type:"select",columns:[[]],value:[]},
num:{label:"投入数量",suffix:"kg"}, inputQuantity:{label:"投入数量",type:"digit",suffix:""},
},
formData:{
specificationId:"",
inputQuantity:"",
inventoryId:"",
}, },
formData:{},
rules:{ rules:{
specificationId:{required:true,message:"规格必选!"},
inputQuantity:{required:true,type:"number",message:"投入数量必填!"},
}, },
agrDetail:{},
agrList:[], eventChannel:null,
} }
}, },
onLoad(){ computed:{
this.searchAgr() specsVal(){
var specs=(this.fields.specificationId.columns[0]?.find?.(v=>v.value==this.formData.specificationId)||{}).label||""
return{
specs:(specs.match(/(\d+)(.+?)\/(.+?)/)||[]).slice(1,4),
num:this.formData.inputQuantity
}
},
},
watch:{
specsVal(n){
this.fields.inputQuantity.suffix=n.specs[2]
if(n.num>0 && n.specs[0]>0){
this.$set(this.fields.inputQuantity, "tip", `${parseFloat(n.num)*parseFloat(n.specs[0])}${n.specs[1]}`)
}else{
this.$set(this.fields.inputQuantity, "tip", "")
}
}
},
async onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.eventChannel.on("detail", e=>this.agrDetail=e)
this.formData.inventoryId=options.id
this.init()
}, },
methods:{ methods:{
async searchAgr(){ async init(){
var res=await request("/api/OutInManageApi/queryCollectingList",{ var res=await request("/api/plantFarming/getSpecification",{
method:"post", params:{goodsId: this.agrDetail.goodsId}
body:{
baseId: "1611250480973049857"||this.$store.state.plantBaseInfoId,
search:"",
pageNo:1,
pageSize:100,
}
}) })
if(res.statu){ if(res.statu){
this.agrList=res.data.list this.fields.specificationId.columns=[res.data.listSpec.map(v=>({label:v.goodsSpecification,value:v.id}))]
this.fields.specificationId.tip=res.data.inventory
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",
content:res.msg||"获取已领用农资列表失败!", content:res.msg||"获取规格选项失败!",
showCancel:false, showCancel:false,
}) })
} }
}, },
submit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
this.eventChannel.emit("update", {
...this.formData,
unit:this.specsVal.specs[1],
parentName: this.agrDetail.parentName,
name: this.agrDetail.name,
})
uni.navigateBack()
}
})
},
} }
} }
</script> </script>

148
pages/massif/collectList.vue

@ -1,51 +1,49 @@
<style lang="scss"> <style lang="scss">
.container{ .container{
min-height:100%; height:100%;
background:#f6f6f6; background:#f6f6f6;
// padding:30rpx 0;
.card{ scroll-view{
.name{ flex-grow: 1;
display:flex; height:1rpx;
align-items: center; .card{
margin-bottom:20rpx; margin-top:0;
text{ .name{
&:first-child{ display:flex;
flex-shrink: 0; align-items: center;
color:#fff; margin-bottom:20rpx;
font-size:20rpx; text{
border-radius: 0px 20rpx 0px 20rpx; &:first-child{
background:#10C176; flex-shrink: 0;
width:80rpx; color:#fff;
height:40rpx; font-size:20rpx;
text-align: center; border-radius: 0px 20rpx 0px 20rpx;
line-height: 40rpx; background:#10C176;
margin-right:10rpx; width:80rpx;
} height:40rpx;
&:nth-child(2){ text-align: center;
flex-grow: 1; line-height: 40rpx;
display:flex; margin-right:10rpx;
align-items: center; }
font-weight: bold; &:nth-child(2){
margin-right:20rpx; flex-grow: 1;
&:after{ display:flex;
content:"("attr(data-unit)")"; align-items: center;
font-weight: bold; font-weight: bold;
color:#999; margin-right:20rpx;
font-size:24rpx;
} }
} }
} }
} .company{
.company{ text{
text{ font-size:24rpx;
font-size:24rpx; &:first-child{
&:first-child{ color:#FBA83C;
color:#FBA83C; margin-right:16rpx;
margin-right:16rpx; }
} &:nth-child(2){
&:nth-child(2){ color:#999;
color:#999; }
} }
} }
} }
@ -53,25 +51,75 @@
} }
</style> </style>
<template> <template>
<view class="container"> <view class="container flex">
<d-search/> <d-search v-model="searchVal.search" @click="clean();search(0)"/>
<view class="card" @click="$u.route({url:'pages/massif/agrSpecs'})"> <scroll-view scroll-y>
<view class="name"> <view class="card" v-for="(v,k) in list" :key="k" @click="toSpecs(v)">
<text>化肥</text> <text data-unit="">中量元素水溶肥</text> <text class="plant-youbian"/> <view class="name">
</view> <text>{{v.parentName}}</text> <text>{{v.name}}</text> <text class="plant-youbian"/>
<view class="company"> </view>
<text>微量元素肥</text> <text>云南云天化股份有限公司</text> <view class="company">
<text>{{v.typeOne}}</text> <text>{{v.supplier}}</text>
</view>
</view> </view>
</view> </scroll-view>
</view> </view>
</template> </template>
<script> <script>
import request from '@/common/request'
export default { export default {
data(){ data(){
return{ return{
searchVal:{
pageNo:1,
pageSize:6,
search:"",
},
list:[],
total:0,
eventChannel:null,
} }
},
onLoad(){
this.eventChannel=this.getOpenerEventChannel()
this.search()
},
methods:{
clean(){
this.list=[]
this.total=0
this.searchVal.pageNo=1
},
async search(){
var res=await request("/api/plantFarming/listAgrMaterials",{
params: this.searchVal
})
if(res.statu){
this.list=this.list.concat(res.data.list)
this.total=res.data.total
this.searchVal.pageNo++
if(this.list.length==this.total)uni.showToast({title:"加载完成!",icon:"none"})
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取领用农资失败!",
showCancel:false,
})
}
},
toSpecs(e){
uni.navigateTo({
url:`/pages/massif/agrSpecs?id=${e.id}`,
events:{update: e=>{
this.eventChannel.emit("addSpecs", e)
uni.navigateBack()
}},
success(res){
res.eventChannel.emit('detail',e)
}
})
},
} }
} }
</script> </script>

10
pages/massif/mana/farmRecord.vue

@ -82,7 +82,7 @@
<scroll-view scroll-y @scrollotower="search"> <scroll-view scroll-y @scrollotower="search">
<view class="card" v-for="(v,k) in list" :key="k"> <view class="card" v-for="(v,k) in list" :key="k">
<view class="name"> <view class="name">
<text>{{v.type}}</text> <text>{{v.inputName}}</text> <text>{{v.inputTotal}}{{v.unit}}</text> <text>{{v.type}}</text> <text>{{v.inputName}}</text> <text>{{v.inputTotal||0}}{{v.unit}}</text>
</view> </view>
<view class="info"> <view class="info">
<text>负责人{{v.principal}}</text> <text>记录时间{{v.time}}</text> <text>负责人{{v.principal}}</text> <text>记录时间{{v.time}}</text>
@ -121,7 +121,13 @@ export default {
methods:{ methods:{
toAdd(){ toAdd(){
uni.navigateTo({ uni.navigateTo({
url:`/pages/massif/add_farming?plotId=${this.plotId}` url:`/pages/massif/add_farming?plotId=${this.plotId}`,
events:{update: e=>{
this.total=0
this.list=[]
this.searchVal.pageNo=1
this.search()
}}
}) })
}, },
async search(){ async search(){

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

@ -211,7 +211,7 @@
<view class="d-form"> <view class="d-form">
<u-form-item :class="{tip:!!tip, parallel:styleType=='parallel'}" :label="label" :prop="field" :required="required"> <u-form-item :class="{tip:!!tip, parallel:styleType=='parallel'}" :label="label" :prop="field" :required="required">
<view v-if="/^text$|^number$|^digit$|^password$/.test(type)" class="textinput"> <view v-if="/^text$|^number$|^digit$|^password$/.test(type)" class="textinput">
<u-input :placeholder="placeholder||`请输入${label}`" :type="type" :disabled="disabled" :value="value" @input="$emit('input',$event)" @blur="/^number$|^digit$/.test(type) && $emit('input',parseFloat(value)||'')"> <u-input :placeholder="placeholder||`请输入${label}`" :type="type" :disabled="disabled" :value="value" @input="$emit('input',$event)" @blur="/^number$|^digit$/.test(type) && $emit('input', parseFloat($event)||'')">
<text v-if="suffix" slot="suffix">{{suffix}}</text> <text v-if="suffix" slot="suffix">{{suffix}}</text>
</u-input> </u-input>
<button v-if="btnText" @click="btnFun" class="cu-btn bg-green shadow">{{btnText}}</button> <button v-if="btnText" @click="btnFun" class="cu-btn bg-green shadow">{{btnText}}</button>

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

@ -35,7 +35,7 @@ import {dataType} from 'black-knight/lib/config/tools'
default:()=>[] default:()=>[]
}, },
value:{ value:{
type:Number, type:[Number],
default:0, default:0,
}, },
}, },

Loading…
Cancel
Save