Browse Source

联调地块管理

master
邓宏 2 years ago
parent
commit
087fd85019
  1. 4
      common/request.js
  2. 28
      components/form.vue
  3. 45
      components/search.vue
  4. 2
      main.js
  5. 48
      pages/home/index.vue
  6. 4
      pages/massif/info.vue
  7. 34
      pages/massif/mana/plantPlan.vue
  8. 21
      pages/massif/mana/recovery.vue
  9. 90
      pages/massif/plant_plan.vue

4
common/request.js

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

28
components/form.vue

@ -146,7 +146,7 @@
</u-input>
<button v-if="btnText" @click="btnFun" class="cu-btn bg-green shadow">{{btnText}}</button>
</view>
<view v-if="type=='select'" class="plant-youbian" :class="{noData:!/^\d+$/.test(value)}" @click="show=true">{{/^\d+$/.test(value)&&columns[0][value].label||placeholder||`请选择${label}`}}</view>
<view v-if="type=='select'" class="plant-youbian" :class="{noData: !/^\d+$/.test(value[0])}" @click="show=true">{{pickerContent}}</view>
<u-upload v-if="type=='upImg'" :fileList="imgs" previewFullImage multiple :maxCount="num" @delete="delImg" @afterRead="afterRead">
<view class="album">
<text class="plant-paizhao">添加照片</text>
@ -182,7 +182,7 @@
closeOnClickOverlay
@close="show=false"
@cancel="show=false"
@confirm="$emit('select',$event.indexs[0]);show=false"
@confirm="$emit('select',$event);show=false"
@change="pickerChange"/>
<u-datetime-picker
v-if="type=='dateRange'"
@ -209,10 +209,11 @@
import request,{host} from '@/common/request'
function setPickerCol(columns, value, n){
if(columns.length<=0)return
var v=value[n-1]||0
if(columns[v].item){
this.setColumnValues(n,columns[v].item)
setPickerCol(columns[v].item, value, ++n)
if(columns[v].children){
this.setColumnValues(n,columns[v].children)
setPickerCol(columns[v].children, value, ++n)
}
}
@ -300,10 +301,21 @@ import request,{host} from '@/common/request'
imgs(){
if(this.type=='upImg')return this.value.map((v,index)=>({url:`${host(undefined,"/plant_manage/sys/common/static")}/${v}`,status:"success",index,type:'saved'})).concat(this.imgList.map((v,index)=>Object.assign(v,{index,type:'unsaved'})))
return []
},
pickerContent(){
if(/^\d+$/.test(this.value[0])){
if(/^\d+$/.test(this.value[1])){
return this.columns[0][this.value[0]].children[this.value[1]].label
}else{
this.columns[0][this.value[0]].label
}
}else{
return this.placeholder||`请选择${this.label}`
}
},
},
created(){
if(this.columns?.length>0){
if(this.type=='select' && this.columns?.length>0){
this.$nextTick(()=>{
setPickerCol.bind(this.$refs.picker)(this.columns[0]||[],this.value,1)
})
@ -348,8 +360,8 @@ import request,{host} from '@/common/request'
this.$emit('imgs',this.imgs.map(v=>({saved:v.url,unsaved:v.tempUrl})[v.type]).join(','))
},
pickerChange(e){
if(e.value[e.columnIndex].item){
this.$refs.picker.setColumnValues(e.columnIndex+1,e.value[0].item)
if(e.value[e.columnIndex]?.children?.length>0){
this.$refs.picker.setColumnValues(e.columnIndex+1,e.value[0].children)
}
},
},

45
components/search.vue

@ -1,45 +0,0 @@
<style lang="scss" scoped>
.d-search{
flex-shrink: 0;
display:flex;
align-items: center;
background:#fff;
margin:30rpx;
border-radius: 40rpx;
padding:6rpx;
height:60rpx;
.u-icon{
margin:0 14rpx;
flex-shrink: 0;
}
input{
flex-grow: 1;
}
.u-button{
flex-shrink: 0;
width:max-content;
}
}
</style>
<template>
<view class="d-search">
<u-icon name="search" color="#999999" size="20"/>
<input placeholder="请输入搜索内容" :value="value" @input="$emit('input',$event.detail.value)" @confirm="$emit('search')"/>
<u-button type="primary" shape="circle" color="#10C176" text="搜索" size="mini" @click="$emit('search')"/>
</view>
</template>
<script>
export default {
props:{
value:{
type:String,
default:""
}
},
data(){
return{
}
}
}
</script>

2
main.js

@ -3,13 +3,11 @@ import App from './App'
import store from './store'
import uView from 'uview-ui';
import cuNavbar from './components/cu-navbar.vue'
import dSearch from './components/search.vue'
import dForm from './components/form.vue'
import {defineObj} from 'black-knight/lib/config/custom'
Vue.use(uView)
Vue.component("cuNavbar", cuNavbar)
Vue.component("dSearch", dSearch)
Vue.component("dForm", dForm)
Vue.prototype.$store=store

48
pages/home/index.vue

@ -300,7 +300,7 @@
</view>
<view class="card base">
<view class="title">
基地管理 <text class="plant-jiantou_zuoyouqiehuan" @click="show=true">切换基地</text>
基地管理 <text class="plant-jiantou_zuoyouqiehuan" v-if="isAdmin" @click="show=true">切换基地</text>
</view>
<view class="matter">
<text class="plant-jilu" style="--c:16, 193, 118;margin-right:40px;">农事记录</text>
@ -318,7 +318,7 @@
</view>
</view>
<u-picker :show="show" :columns="baseList" closeOnClickOverlay @close="show=false" @cancel="show=false"/>
<u-picker v-if="isAdmin" :show="show" :columns="plantBase" keyName="baseName" closeOnClickOverlay @close="show=false" @cancel="show=false"/>
</view>
</template>
@ -329,22 +329,28 @@ import request from '@/common/request.js'
return {
mapContext:null,
show:false,
baseList:[['东方红壹号基地','东方红贰号基地','东方红叁号基地']],
massif:{}
plantBase:[[]],
massif:{},
}
},
computed:{
isAdmin(){
return this.$store.getters.userInfo.roleCode=='companyAdmin'
},
},
onLoad() {
this.getMassif()
this.getPurchase()
// this.getMassif()
// this.getPurchase()
this.isAdmin && this.getPlantBase()
},
onShow(){
},
methods: {
//
async getMassif(){
async getMassif(plantBaseId){
var res=await request("/api/plantIndex/queryPlot",{
params:{companyId: this.$store.getters.userInfo.companyId}
params:{plantBaseId}
})
if(res.statu){
this.massif=res.data
@ -356,11 +362,27 @@ import request from '@/common/request.js'
})
}
},
//
async getPurchase(){
var res=await request("/purchaseMain/purchaseMain/listPlantPurchaseSubByMainId")
console.log(res,'------------res----------')
},
// //
// async getPurchase(){
// var res=await request("/purchaseMain/purchaseMain/listPlantPurchaseSubByMainId")
// console.log(res,'------------res----------')
// },
//
async getPlantBase(){
var res=await request("/api/plantPlot/getAllPlantBaseInfo",{
params:{companyId:this.$store.getters.userInfo.companyId}
})
if(res.statu){
this.plantBase=[res.data]
this.getMassif(res.data[0].id)
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取基地列表失败!",
showCancel:false,
})
}
}
}
}
</script>

4
pages/massif/info.vue

@ -29,7 +29,7 @@ import request from '@/common/request'
data(){
return{
fields:{
plantBaseName:{label:"基地名称",type:"select",columns:[],value:[]},
plantBaseName:{label:"基地名称",type:"select",columns:[[]],value:[null]},
plotNumber:{label:"地块编号"},
plotName:{label:"地块名称"},
drawArea:{label:"地块面积(亩)",type:'digit'},
@ -129,7 +129,7 @@ import request from '@/common/request'
if(res.statu){
this.formData=res.data
this.fields.date.value=[res.data.beginTime, res.data.endTime]
this.fields.plantBaseName.value=this.fields.plantBaseName.columns[0].findIndex(v=>v.value==res.data.plantBaseName)
this.fields.plantBaseName.value=[this.fields.plantBaseName.columns[0].findIndex(v=>v.value==res.data.plantBaseName)]
this.fields.image.value=res.data.image.join(',')
}else{
uni.showModal({

34
pages/massif/mana/plantPlan.vue

@ -10,7 +10,7 @@
position:relative;
border-radius: 20rpx;
&:before{
content:"蔬菜";
content:attr(data-type);
position:absolute;
top:0;
left:0;
@ -89,9 +89,9 @@
</style>
<template>
<view class="plant_plan">
<view class="card" v-for="(v,k) in list" :key="k">
<view class="card" v-for="(v,k) in list" :key="k" @click="reDetail(v.id)">
<view class="info">
<image src="/static/logo.png"/>
<image :src="`${host}/${v.images}`" :data-type="v.plantType"/>
<view class="detail">
<view class="name">
<text>{{v.plantStandard}}</text> <text>{{v.varietyName}}</text> <text class="plant-youbian"/>
@ -104,15 +104,15 @@
<view class="date">
<text>本次预估采收时间{{v.harvestTime}}</text>
<button class="cu-btn" style="--c:255, 196, 87;">结束种植</button>
<button class="cu-btn" style="--c:153, 153, 153;" @click="$u.route({url:'pages/massif/plant_info'})">采收</button>
<button class="cu-btn" style="--c:153, 153, 153;" @click.stop="$u.route({url:'pages/massif/plant_info'})">采收</button>
</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="$u.route({url:'pages/massif/plant_plan'})">+新增种植计划</button>
<button class="cu-btn round bg-green shadow submit" @click="addPlant">+新增种植计划</button>
</view>
</template>
<script>
import request from '@/common/request'
import request,{host} from '@/common/request'
export default {
name:"plantPlan",
props:{
@ -128,13 +128,19 @@ export default {
pageSize:4
},
total:0,
list:[]
list:[],
host:host(undefined,"/plant_manage/sys/common/static"),
}
},
created(){
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/plantPlan/list',{
@ -154,7 +160,19 @@ export default {
})
}
}
}
},
addPlant(){
uni.navigateTo({
url:`/pages/massif/plant_plan?plotId=${this.id}`,
event:{update:()=> {this.clean();this.search()} }
})
},
reDetail(id){
uni.navigateTo({
url:`/pages/massif/plant_plan?id=${id}`,
event:{update:()=> {this.clean();this.search()} }
})
},
}
}
</script>

21
pages/massif/mana/recovery.vue

@ -87,12 +87,29 @@
</view>
</template>
<script>
import request from '@/common/request'
export default {
name:"recovery",
data(){
return{
}
searchVal:{
plantScheduleId:"",// id
pageNo:"",
pageSize:"",
startTime:"",
endTime:"",
}
}
},
created(){
this.search()
},
methods:{
async search(){
var res=await request("/api/plantHarvest/list",{
params:this.searchVal
})
},
}
}
</script>

90
pages/massif/plant_plan.vue

@ -12,7 +12,8 @@
</style>
<template>
<view class="container">
<u-form class="card inline" errorType="toast" :model="formData" :rules="rules" labelWidth="auto">
<!-- errorType="toast" -->
<u-form class="card inline" :model="{...formData,images:fields.images.value}" :rules="rules" ref="form" labelWidth="auto">
<d-form
v-for="(v,k) in fields"
:key="k"
@ -20,11 +21,11 @@
:field="k"
:required="!!rules[k]"
:value="/^select$/.test(v.type)?fields[k].value:formData[k]"
@select="select"
@select="$set(fields.plantType, 'value', $event.indexs);formData.plantType=$event.value[1].value"
@input="formData[k]=$event"
@imgs="fields[k].value=$event"/>
</u-form>
<button class="cu-btn round bg-green shadow submit">确认提交</button>
<button class="cu-btn round bg-green shadow submit" @click="submit">确认提交</button>
</view>
</template>
<script>
@ -34,7 +35,7 @@ export default {
return{
fields:{
varietyName:{label:"品种名称"},
plantType:{label:"作物类型",type:"select",columns:[],value:[]},
plantType:{label:"作物类型",type:"select",columns:[[]],value:[null,null]},
plantArea:{label:"种植面积(亩)",type:"digit"},
startTime:{label:"种植开始日期",type:"calendar"},
harvestTime:{label:"预估采收日期",type:"calendar"},
@ -63,36 +64,81 @@ export default {
principal:"",
principalId:"",
productIntroduce:"",
plotId: "", // id
},
rules:{
varietyName: {required:true, message:"必填!", trigger:"blur"},
plantType: {required:true, message:"必填!", trigger:"blur"},
plantArea: {required:true, message:"必填!", trigger:"blur"},
startTime: {required:true, message:"必填!", trigger:"blur"},
harvestTime: {required:true, message:"必填!", trigger:"blur"},
images: {required:true, message:"必填!", trigger:"blur"},
plantStandard: {required:true, message:"必填!", trigger:"blur"},
plantBatch: {required:true, message:"必填!", trigger:"blur"},
principal: {required:true, message:"必填!", trigger:"blur"},
principalId: {required:true, message:"必填!", trigger:"blur"},
varietyName: {required:true, message:"品种名称必填!", trigger:"blur"},
plantType: {required:true, message:"作物类型必选!", trigger:"blur"},
plantArea: {required:true, type:"number", message:"种植面积必填!", trigger:"blur"},
startTime: {required:true, message:"种植开始日期必选!", trigger:"blur"},
harvestTime: {required:true, message:"预估采收日期必选!", trigger:"blur"},
images: {required:true, message:"产品图片必选!", trigger:"blur"},
plantStandard: {required:true, message:"种植标准必填!", trigger:"blur"},
plantBatch: {required:true, message:"种植批次号必填!", trigger:"blur"},
principal: {required:true, message:"负责人必填!", trigger:"blur"},
principalId: {required:true, message:"负责人身份证必填!", trigger:"blur"},
},
eventChannel:null,
}
},
onLoad(){
onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.init()
setTimeout(() => {
this.fields.plantType.columns=[[{label:"1",value:1,item:[{label:'1-1',value:'1-1'}]},{label:2,value:2,item:[{label:'2-1',value:'2-1'}]}]]
}, 1000);
options.plotId && (this.formData.plotId=options.plotId)
options.id && this.getDetail(options.id)
},
methods:{
async init(){
var res=await request("/sys/category/loadTreeData",{
params:{pid:"",pcode:"B06",}
var res=await request("/api/plantPlan/getType")
if(res.statu){
this.fields.plantType.columns=[res.data]
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取作物类型下拉选项失败!",
showCancel:false,
})
}
},
submit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
var res=await request("/api/plantPlan/add",{
method:"post",
body:{
...this.formData,
images:this.fields.images.value
}
})
if(res.statu){
this.eventChannel.emit("update")
uni.navigateBack()
}else{
uni.showModal({
title:"提示",
content:res.msg||"保存失败!",
showCancel:false,
})
}
}
})
},
select(e){
console.log(e,'-------------e-----------------')
async getDetail(id){
var res=await request("/api/plantPlan/queryById",{
params:{id}
})
if(res.statu){
this.formData=res.data
this.fields.images.value=res.data.images.join(',')
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取种植计划详情失败!",
showCancel:false,
})
}
},
}
}
</script>
Loading…
Cancel
Save