Browse Source

联调修改接口

master
邓宏 2 years ago
parent
commit
22998ccaea
  1. 2
      common/request.js
  2. 5
      components/form.vue
  3. 2
      pages/home/login.vue
  4. 18
      pages/massif/index.vue
  5. 33
      pages/massif/info.vue

2
common/request.js

@ -3,7 +3,7 @@ import store from "@/store"
export function host(host='default',suffix='/plant_manage'){ export function host(host='default',suffix='/plant_manage'){
return( return(
process.env.NODE_ENV === 'development'?{ process.env.NODE_ENV === 'development'?{
default:`http://m3df6f.natappfree.cc${suffix}` default:`http://jtsfcq.natappfree.cc${suffix}`
}:{ }:{
default:`http://qv6mj8.natappfree.cc${suffix}` default:`http://qv6mj8.natappfree.cc${suffix}`
} }

5
components/form.vue

@ -194,6 +194,7 @@
:insert="false" :insert="false"
lunar lunar
@confirm="$emit('input',$event.fulldate)"/> @confirm="$emit('input',$event.fulldate)"/>
</view> </view>
</template> </template>
@ -301,7 +302,7 @@ import request,{host} from '@/common/request'
this.imgList=this.imgList.filter(v=>!v==e.file[i]) this.imgList=this.imgList.filter(v=>!v==e.file[i])
} }
} }
this.$emit('imgs',this.imgs.map(v=>({saved:v.url,unsaved:v.tempUrl})[v.type])) this.$emit('imgs',this.imgs.map(v=>({saved:v.url,unsaved:v.tempUrl})[v.type]).join(','))
}, },
delImg({file}){ delImg({file}){
if(file.type=='unsaved'){ if(file.type=='unsaved'){
@ -309,7 +310,7 @@ import request,{host} from '@/common/request'
}else{ }else{
this.$emit("input",this.value.filter(v=>v.index!=file.index).map(v=>v.url)) this.$emit("input",this.value.filter(v=>v.index!=file.index).map(v=>v.url))
} }
this.$emit('imgs',this.imgs.map(v=>({saved:v.url,unsaved:v.tempUrl})[v.type])) this.$emit('imgs',this.imgs.map(v=>({saved:v.url,unsaved:v.tempUrl})[v.type]).join(','))
}, },
}, },
} }

2
pages/home/login.vue

@ -85,7 +85,7 @@ export default {
}) })
if(res.statu){ if(res.statu){
this.$store.commit("setUserInfo",res.data) this.$store.commit("setUserInfo",res.data)
this.$u.route({type:'switchTab',url:'pages/home/index'}) uni.switchTab({url:'/pages/home/index'})
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",

18
pages/massif/index.vue

@ -77,7 +77,7 @@
<template> <template>
<view class="container flex"> <view class="container flex">
<cu-navbar style="--bg:#10C176;--c:#fff;" text="地块管理"> <cu-navbar style="--bg:#10C176;--c:#fff;" text="地块管理">
<text class="plant-xinjian" slot="right" @click="$u.route({url:'pages/massif/info'})"/> <text class="plant-xinjian" slot="right" @click="toInfo"/>
</cu-navbar> </cu-navbar>
<d-search v-model="searchVal.search" @search="clean();search()"/> <d-search v-model="searchVal.search" @search="clean();search()"/>
@ -93,7 +93,7 @@
<text>{{v.usedArea}}</text> <text>(在用面积)</text> <text>{{v.usedArea}}</text> <text>(在用面积)</text>
</view> </view>
<view class="btns"> <view class="btns">
<text class="plant-xiugai">修改</text> <text class="plant-xiugai" @click.stop="$u.route({url:'/pages/massif/info',params:{id:v.id}})">修改</text>
<text class="plant-shanchu" @click.stop="del(k)">删除</text> <text class="plant-shanchu" @click.stop="del(k)">删除</text>
<text class="plant-xinzeng" @click.stop="$u.route({url:'pages/massif/mana/index'})">地块管理</text> <text class="plant-xinzeng" @click.stop="$u.route({url:'pages/massif/mana/index'})">地块管理</text>
</view> </view>
@ -122,6 +122,17 @@ import request from '@/common/request'
this.search() this.search()
}, },
methods:{ methods:{
toInfo(){
uni.navigateTo({
url:"/pages/massif/info",
events:{
update:()=>{
this.clean()
this.search()
}
},
})
},
clean(){ clean(){
this.searchVal.pageNo=1 this.searchVal.pageNo=1
this.total=0 this.total=0
@ -133,7 +144,7 @@ import request from '@/common/request'
params: this.searchVal params: this.searchVal
}) })
if(res.statu){ if(res.statu){
this.list=res.data.records this.list=this.list.concat(res.data.records)
this.total=res.data.total this.total=res.data.total
}else{ }else{
uni.showModal({ uni.showModal({
@ -155,6 +166,7 @@ import request from '@/common/request'
this.list.splice(index,1) this.list.splice(index,1)
this.total-- this.total--
}else{ }else{
this.clean()
this.search() this.search()
} }
}else{ }else{

33
pages/massif/info.vue

@ -70,10 +70,13 @@ import dForm from '@/components/form.vue'
else call() else call()
}, trigger:"change"} }, trigger:"change"}
}, },
eventChannel:null,
} }
}, },
onLoad(){ onLoad(options){
this.init() this.init()
if(options.id)this.getDetail(options.id);
this.eventChannel=this.getOpenerEventChannel()
}, },
methods:{ methods:{
async init(){ async init(){
@ -108,10 +111,34 @@ import dForm from '@/components/form.vue'
endTime:this.fields.date.value[1], endTime:this.fields.date.value[1],
} }
}) })
console.log(res,'----------res------------') if(res.statu){
this.eventChannel.emit("update")
uni.navigateBack()
}else{
uni.showModal({
title:"提示",
content:res.msg||"地块基地信息保存失败!",
showCancel:false,
})
}
} }
}) })
} },
async getDetail(id){
var res=await request('/api/plantPlot/queryById',{
params:{id}
})
if(res.statu){
this.formData=res.data
this.fields.date.value=[res.data.beginTime, res.data.endTime]
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取详情失败!",
showCancel:false,
})
}
},
}, },
} }
</script> </script>
Loading…
Cancel
Save