Browse Source

联调 巡园记录接口

master
邓宏 11 months ago
parent
commit
ae78df79d0
  1. 32
      pages/patrolGarden/abnoReport.vue
  2. 83
      pages/patrolGarden/info.vue
  3. 71
      pages/patrolGarden/record.vue
  4. 24
      uni_modules/d-form/components/d-form/d-form.vue

32
pages/patrolGarden/abnoReport.vue

@ -7,11 +7,11 @@
</style>
<template>
<view class="container">
<u-form class="card inline" errorType="toast" :model="formData" ref="form" labelWidth="auto">
<u-form class="card inline" errorType="toast" :model="formData" ref="form" :rules="rules" labelWidth="auto">
<d-form label="当前位置" type="map" @position="formData.lat=$event.latitude;formData.lng=$event.longitude"/>
<d-form label="凭证" required field="pic" :value="formData.pic" type="upImg"/>
<d-form label="描述" type="textarea" v-model="formData.dec"/>
<d-form label="是否处理" type="radio" :columns="[{label:'是',value:1},{label:'否',value:0}]"/>
<d-form label="凭证" required field="pic" :value="imgs" type="upImg" @imgs="formData.pic=$event"/>
<d-form label="描述" type="textarea" v-model="formData.remark"/>
<d-form label="是否处理" type="radio" :columns="[{label:'是',value:1},{label:'否',value:0}]" v-model="formData.flagDeal"/>
</u-form>
<button class="cu-btn round bg-green shadow submit" @click="sumbit">保存</button>
</view>
@ -21,13 +21,31 @@ export default {
data(){
return{
formData:{
pic:[],
dec:"",
lng:"",
lat:"",
remark:"",
pic:'',
flagDeal:0,
},
imgs:[],
rules:{
pic:{required:true,message:"请上传凭证!",trigger:'blur'}
},
eventChannel:null,
}
},
onLoad(){
this.eventChannel=this.getOpenerEventChannel()
},
methods:{
sumbit(){},
sumbit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
this.eventChannel.emit('update',this.formData)
uni.navigateBack()
}
})
},
}
}
</script>

83
pages/patrolGarden/info.vue

@ -61,59 +61,90 @@
<template>
<view class="container">
<u-form class="card inline" errorType="toast" :model="formData" :rules="rules" ref="form" labelWidth="auto">
<d-form label="基地名称" required/>
<d-form label="记录人" required/>
<d-form label="巡园日期" required type="calendar"/>
<d-form label="是否异常" required type="radio" :columns="[{label:'是',value:1},{label:'否',value:0}]" v-model="formData.abnormal"/>
<view class="handle">
<image src="https://alipic.lanhuapp.com/XDSlicePNGMAX194db53bfba98d0b8dd7897e8aa3b92427509704376c5621dac3520f49ce3d9a.png"/>
<view class="content">
<view class="doubleLine" style="--n:3;">柑橘黄斑病是子囊菌亚门球腔菌属的柑橘球腔菌侵染所致病菌以菌丝体在病叶和落叶中越冬柑橘黄斑病是子囊菌亚门球腔菌属的柑橘球腔菌侵染所致病菌以菌丝体在病叶和落叶中越冬</view>
<d-form label="基地名称" disabled :value="formData.baseName"/>
<d-form label="记录人" disabled v-model="formData.userName"/>
<d-form label="巡园日期" required field="operateDate" type="calendar" v-model="formData.operateDate"/>
<d-form label="是否异常" required type="radio" :columns="[{label:'是',value:1},{label:'否',value:0}]" v-model="formData.flagAbnormal"/>
<view class="handle" :class="{un:v.flagDeal==0}" v-for="(v,k) in formData.detailList" :key="k">
<image :src="`${host}/${(v.pic||'').split(',').filter(v=>v)[0]}`"/>
<view class="content" v-if="v.flagDeal==1">
<view class="doubleLine" style="--n:3;">{{v.remark}}</view>
</view>
</view>
<view class="handle un">
<image src="https://alipic.lanhuapp.com/XDSlicePNGMAX194db53bfba98d0b8dd7897e8aa3b92427509704376c5621dac3520f49ce3d9a.png"/>
<view class="content">
<view class="doubleLine">柑橘黄斑病是子囊菌亚门球腔菌属的柑橘球腔菌侵染所致病菌以菌丝体在病叶和落叶中越冬柑橘黄斑病是子囊菌亚门球腔菌属的柑橘球腔菌侵染所致病菌以菌丝体在病叶和落叶中越冬</view>
<view class="content" v-else>
<view class="doubleLine">{{v.remark}}</view>
<button class="cu-btn shadow">立即处理</button>
</view>
</view>
<button class="cu-btn round bg-green shadow add">+继续添加异常</button>
<button class="cu-btn round bg-green shadow add" v-if="formData.flagAbnormal==1" @click="toAbnormal">+{{formData.detailList.length>0?'继续':''}}添加异常</button>
<d-form label="凭证" type="upImg" :value="formData.pic"/>
<d-form label="备注" type="textarea" v-model="remark"/>
<d-form label="凭证" :required="formData.flagAbnormal==0" field="pic" type="upImg" :value="imgs" @imgs="formData.pic=$event" :num="3"/>
<d-form label="备注" type="textarea" v-model="formData.remark"/>
</u-form>
<button class="cu-btn round bg-green shadow submit" @click="sumbit">保存</button>
</view>
</template>
<script>
import request,{host} from '@/common/request'
export default {
data(){
return{
formData:{
pic:[],
abnormal:0,
baseId: this.$store.state.baseInfo.id,
baseName: this.$store.state.baseInfo.name,
userName: this.$store.getters['userInfo'].realname,
operateDate:"",
detailList:[],
flagAbnormal:0,
pic:'',
remark:"",
},
imgs:[],
rules:{
pic:{required:true,message:"请上传凭证!",trigger:'blur'},
operateDate:{required:true,message:"请选择巡园日期!",trigger:'blur'}
},
host:host('imgUrl'),
eventChannel:null,
}
},
watch:{
"formData.abnormal"(n){
"formData.flagAbnormal"(n){
if(n==1){
uni.navigateTo({
url:"/pages/patrolGarden/abnoReport"
})
this.toAbnormal()
}else{
this.formData.detailList=[]
}
}
},
onLoad(){
this.eventChannel=this.getOpenerEventChannel()
},
methods:{
demo(e){
console.log(e,'----e-------')
toAbnormal(){
uni.navigateTo({
url:"/pages/patrolGarden/abnoReport",
events:{update:e=>this.formData.detailList.push(e)}
})
},
sumbit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
var res=await request("/api/basetour/addBaseTourInfo",{
method:"post",
body:this.formData
})
if(res.statu){
this.eventChannel.emit('update')
uni.navigateBack()
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取保持失败!",
showCancel:false,
})
}
}
})
},
}
}

71
pages/patrolGarden/record.vue

@ -47,9 +47,10 @@
}
&>.imgs{
display: flex;
margin-right:-20rpx;
image{
border-radius: 8rpx;
width:calc((100% - 20rpx*3)/4);
width:calc(100%/4 - 20rpx);
height:140rpx;
position:relative;
&+image{
@ -57,7 +58,7 @@
}
&:nth-child(4){
&:before{
content:"+32";
content:var(--c);
position:absolute;
top:0;
left:0;
@ -89,26 +90,25 @@
<d-navbar text="巡园记录" isBack style="--bg:#10C176;--c:#fff;">
<text slot="right" class="plant-xinjian" @click="toAddPage"/>
</d-navbar>
<d-search v-model="searchVal.name" @search="clean();search()"/>
<d-search v-model="searchVal.search" @search="search('pageOne')"/>
<scroll-view scroll-y>
<view class="card" @click="$u.route({url:'/pages/patrolGarden/detail'})">
<view class="card" v-for="(v,k) in list" :key="k" @click="$u.route({url:'/pages/patrolGarden/detail'})">
<view class="title">
<text class="icon"/>
<text class="name over">一号基地</text>
<text class="statu no">无异常</text>
<text class="name over">{{v.baseName}}</text>
<text v-if="v.flagAbnormal==0" class="statu no">无异常</text>
<text v-else class="statu unusual">异常</text>
</view>
<view class="imgs">
<image v-for="i in 4" :key="i" mode="aspectFill" src="https://alipic.lanhuapp.com/XDSlicePNGMAX3347bbbb56235edbfb4639fd8039bce3d3d9b375b7ead4bc95a9a6f3d4156935.png"/>
<image v-for="(v1,k1) in v.pic.slice(0,4)" :style="{'--c':v.pic.length-4>0?`'+${v.pic.length-4}'`:''}" :key="k1" mode="aspectFill" :src="`${host}/${v1}`"/>
</view>
<u-read-more toggle closetext="展开" showHeight="80rpx">
柑橘黄斑病是子囊菌亚门球腔菌属的柑橘球腔菌侵染所致病菌以菌丝体在病叶和落叶中越冬柑橘黄斑病是子囊菌亚门球腔菌属的柑橘球腔菌侵染所致病菌以菌丝体在病叶和落叶中越冬柑橘黄斑病是子囊菌亚门球
</u-read-more>
<u-read-more toggle closetext="展开" showHeight="80rpx">{{v.remark}}</u-read-more>
<view class="foot">
<text>巡园日期2020-09-09</text>
<text>张召忠</text>
<text>巡园日期{{v.operateDate}}</text>
<text>{{v.userName}}</text>
</view>
</view>
<view class="card" @click="$u.route({url:'/pages/patrolGarden/app'})">
<!-- <view class="card" @click="$u.route({url:'/pages/patrolGarden/app'})">
<view class="title">
<text class="icon"/>
<text class="name over">一号基地</text>
@ -118,27 +118,60 @@
<view class="imgs">
<image v-for="i in 4" :key="i" mode="aspectFit" src="https://alipic.lanhuapp.com/XDSlicePNGMAX3347bbbb56235edbfb4639fd8039bce3d3d9b375b7ead4bc95a9a6f3d4156935.png"/>
</view>
</view>
</view> -->
</scroll-view>
</view>
</template>
<script>
import request,{host} from '@/common/request'
export default {
data(){
return{
searchVal:{
name:"",
search:"",
baseId: this.$store.state.baseInfo.id,
pageNo:1,
pageSize:5,
},
total:0,
list:[],
host:host('imgUrl'),
}
},
onLoad(){
this.search()
},
methods:{
clean(){},
async search(){
async search(type){
if(type=='pageOne'){
this.searchVal.pageNo=1
this.list=[]
this.total=0
}
if(this.total==0||this.list.length<this.total){
var res=await request("/api/basetour/queryTourListByBaseId",{
method:"post",
body:this.searchVal,
})
if(res.statu){
this.list=this.list.concat(res.data.record.map(v=>({
...v,
pic: v.pic?(v.pic||'').split(',').filter(v=>v):v.detailVos.reduce((a,b)=>a.concat((b.pic||'').split(',').filter(v=>v)),[])
})))
this.total=res.data.total
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取巡园记录失败!",
showCancel:false,
})
}
}
},
toAddPage(){
uni.navigateTo({
url:"/pages/patrolGarden/info"
url:"/pages/patrolGarden/info",
events:{update:()=>this.search('pageOne')},
})
},
}

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

@ -283,7 +283,7 @@
</style>
<template>
<view class="d-form" :class="{parallel:styleType=='parallel'}">
<u-form-item :class="{tip:!!tip}" :label="labelName" :prop="field" :required="required">
<u-form-item :class="{tip:!!tip}" :label="labelName" :prop="required?field:''" :required="required">
<slot name="label" slot="label"/>
<slot v-if="!!$slots.default"/>
@ -589,7 +589,24 @@ import {computeArea} from '@/common/utils'
},
mounted(){
if(this.type=='map'){
/* #ifdef APP-PLUS */
this.amap=uni.createMapContext("amap",this).$getAppMap()
uni.getLocation({
altitude:true,
success:res=>{
this.amap.setCenter(new plus.maps.Point(res.longitude, res.latitude))
this.points=[{
id:1,
title:"sss",
latitude: res.latitude,
longitude: res.longitude,
iconPath:"/static/patrolGarden/point.png",
width:7,
height:7,
}]
this.$emit('position',res)
}
})
this.amap.onclick=e=>{
this.points=[{
id:1,
@ -597,11 +614,12 @@ import {computeArea} from '@/common/utils'
latitude: e.latitude,
longitude:e.longitude,
iconPath:"/static/patrolGarden/point.png",
width:10,
height:10,
width:7,
height:7,
}]
this.$emit('position',e)
}
/* #endif */
}
},
methods:{

Loading…
Cancel
Save