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'){
var url=process.env.NODE_ENV === 'development'?{
default:`http://59syiv.natappfree.cc` //陈
// default:`http://nys8cm.natappfree.cc` //马
// default:`http://59syiv.natappfree.cc` //陈
default:`http://sfhtpp.natappfree.cc` //马
// default:`http://4gg9xn.natappfree.cc` //何
// default:`http://192.168.0.116:8080` //孙
}:{

27
pages/home/index.vue

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

67
pages/massif/add_farming.vue

@ -124,23 +124,25 @@
<view class="card">
<view class="plant-dikuaimianji">{{massif.plotName}}</view>
<view class="plant-batch-add" @click="toCollectList"/>
<view class="info">
<text>化肥</text> <text>中量元素水溶肥</text> <text>200kg</text>
<view v-if="formData.inputList.length<=0" class="plant-batch-add" @click="toCollectList"/>
<view class="info" v-for="(v,k) in formData.inputList" :key="k">
<text>{{v.parentName}}</text> <text>{{v.name}}</text> <text>{{v.inputQuantity}}{{v.unit}}</text>
</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 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
v-for="(v,k) in fields"
:key="k"
v-bind="v"
:field="k"
:required="!!rules[k]"
:value="formData[k]"
@input="formData[k]=$event"/>
:value="/^select$/.test(v.type)?fields[k].value:formData[k]"
@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>
</view>
<u-popup :show="isShow" closeOnClickOverlay @close="isShow=false">
@ -168,6 +170,7 @@ export default {
farmingTime:"",
images:[],
farmingRemarks:"",
inputList:[],
plotId:"",
plantBaseInfoId: this.$store.state.plantBaseInfoId,
@ -183,9 +186,11 @@ export default {
massif:{},
tempType:"",
isShow:false,
eventChannel:null,
}
},
onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.formData.plotId=options.plotId
this.init()
this.getMassifDetail()
@ -207,7 +212,7 @@ export default {
params:{plotId: this.formData.plotId}
})
if(res.statu){
this.farmingPlanId.columns=[res.data.map(v=>({}))]
this.fields.farmingPlanId.columns=[res.data]
}else{
uni.showModal({
title:"提示",
@ -233,21 +238,45 @@ export default {
toCollectList(){
uni.navigateTo({
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(){
this.$refs.form.validoter().then(async valid=>{
if(valid){
var res=await request("/api/plantFarming/addOrUpdate",{
method:"post",
body:{
...this.formData,
if(this.check()){
this.$refs.form.validate().then(async valid=>{
if(valid){
var res=await request("/api/plantFarming/addOrUpdate",{
method:"post",
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(){
if(this.tempType){

256
pages/massif/agrSpecs.vue

@ -39,67 +39,79 @@
}
}
}
}
}
.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;
}
}
.company{
text{
font-size:24rpx;
&:first-child{
color:#FBA83C;
margin-right:16rpx;
}
&:nth-child(2){
color:#999;
}
}
}
}
}
// .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{
padding:0 30rpx;
display:flex;
@ -109,37 +121,37 @@
display:flex;
align-items: center;
text{
font-size:16rpx;
&:first-child{
flex-shrink: 0;
color:#fff;
font-size:20rpx;
border-radius: 0px 20rpx 0px 20rpx;
background:#10C176;
border-radius:0 20rpx 0 20rpx;
width:80rpx;
height:34rpx;
height:40rpx;
text-align: center;
line-height: 34rpx;
margin-right:16rpx;
line-height: 40rpx;
margin-right:10rpx;
}
&:nth-child(2){
flex-grow: 1;
display:flex;
align-items: center;
font-weight: bold;
font-size:20rpx;
}
&:nth-child(3){
color:#999;
margin-left:6rpx;
margin-right:20rpx;
}
}
}
.company{
font-size:16rpx;
&:before{
content:attr(data-name);
color:#FBA83C;
margin-right:20rpx;
}
&:after{
content:attr(data-company);
color:#999999;
text{
font-size:24rpx;
&:first-child{
color:#FBA83C;
margin-right:16rpx;
}
&:nth-child(2){
color:#999;
}
}
}
}
@ -148,32 +160,29 @@
<template>
<view class="container">
<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>
<view class="card info">
<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 style="color:#707070;font-size:20rpx;">云南云天化股份有限公司</view>
</view>
<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
v-for="(v,k) in fields"
:key="k"
v-bind="v"
: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>
</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>
</template>
<script>
@ -182,41 +191,76 @@ export default {
data(){
return{
fields:{
specs:{label:"规格",tip:"库存:2袋(200kg)",type:"select"},
num:{label:"投入数量",suffix:"kg"},
specificationId:{label:"规格",tip:"",type:"select",columns:[[]],value:[]},
inputQuantity:{label:"投入数量",type:"digit",suffix:""},
},
formData:{
specificationId:"",
inputQuantity:"",
inventoryId:"",
},
formData:{},
rules:{
specificationId:{required:true,message:"规格必选!"},
inputQuantity:{required:true,type:"number",message:"投入数量必填!"},
},
agrList:[],
agrDetail:{},
eventChannel:null,
}
},
onLoad(){
this.searchAgr()
computed:{
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:{
async searchAgr(){
var res=await request("/api/OutInManageApi/queryCollectingList",{
method:"post",
body:{
baseId: "1611250480973049857"||this.$store.state.plantBaseInfoId,
search:"",
pageNo:1,
pageSize:100,
}
async init(){
var res=await request("/api/plantFarming/getSpecification",{
params:{goodsId: this.agrDetail.goodsId}
})
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{
uni.showModal({
title:"提示",
content:res.msg||"获取已领用农资列表失败!",
content:res.msg||"获取规格选项失败!",
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>

148
pages/massif/collectList.vue

@ -1,51 +1,49 @@
<style lang="scss">
.container{
min-height:100%;
height:100%;
background:#f6f6f6;
// padding:30rpx 0;
.card{
.name{
display:flex;
align-items: center;
margin-bottom:20rpx;
text{
&:first-child{
flex-shrink: 0;
color:#fff;
font-size:20rpx;
border-radius: 0px 20rpx 0px 20rpx;
background:#10C176;
width:80rpx;
height:40rpx;
text-align: center;
line-height: 40rpx;
margin-right:10rpx;
}
&:nth-child(2){
flex-grow: 1;
display:flex;
align-items: center;
font-weight: bold;
margin-right:20rpx;
&:after{
content:"("attr(data-unit)")";
scroll-view{
flex-grow: 1;
height:1rpx;
.card{
margin-top:0;
.name{
display:flex;
align-items: center;
margin-bottom:20rpx;
text{
&:first-child{
flex-shrink: 0;
color:#fff;
font-size:20rpx;
border-radius: 0px 20rpx 0px 20rpx;
background:#10C176;
width:80rpx;
height:40rpx;
text-align: center;
line-height: 40rpx;
margin-right:10rpx;
}
&:nth-child(2){
flex-grow: 1;
display:flex;
align-items: center;
font-weight: bold;
color:#999;
font-size:24rpx;
margin-right:20rpx;
}
}
}
}
.company{
text{
font-size:24rpx;
&:first-child{
color:#FBA83C;
margin-right:16rpx;
}
&:nth-child(2){
color:#999;
.company{
text{
font-size:24rpx;
&:first-child{
color:#FBA83C;
margin-right:16rpx;
}
&:nth-child(2){
color:#999;
}
}
}
}
@ -53,25 +51,75 @@
}
</style>
<template>
<view class="container">
<d-search/>
<view class="container flex">
<d-search v-model="searchVal.search" @click="clean();search(0)"/>
<view class="card" @click="$u.route({url:'pages/massif/agrSpecs'})">
<view class="name">
<text>化肥</text> <text data-unit="">中量元素水溶肥</text> <text class="plant-youbian"/>
</view>
<view class="company">
<text>微量元素肥</text> <text>云南云天化股份有限公司</text>
<scroll-view scroll-y>
<view class="card" v-for="(v,k) in list" :key="k" @click="toSpecs(v)">
<view class="name">
<text>{{v.parentName}}</text> <text>{{v.name}}</text> <text class="plant-youbian"/>
</view>
<view class="company">
<text>{{v.typeOne}}</text> <text>{{v.supplier}}</text>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
import request from '@/common/request'
export default {
data(){
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>

10
pages/massif/mana/farmRecord.vue

@ -82,7 +82,7 @@
<scroll-view scroll-y @scrollotower="search">
<view class="card" v-for="(v,k) in list" :key="k">
<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 class="info">
<text>负责人{{v.principal}}</text> <text>记录时间{{v.time}}</text>
@ -121,7 +121,13 @@ export default {
methods:{
toAdd(){
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(){

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

@ -211,7 +211,7 @@
<view class="d-form">
<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">
<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>
</u-input>
<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:()=>[]
},
value:{
type:Number,
type:[Number],
default:0,
},
},

Loading…
Cancel
Save