|
|
|
@ -13,8 +13,8 @@
|
|
|
|
|
<el-form-item label="项目名" prop="name"> |
|
|
|
|
<el-input v-model="queryParams.name" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="资源名" prop="resources"> |
|
|
|
|
<el-input v-model="queryParams.resources" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/> |
|
|
|
|
<el-form-item label="区域名" prop="areas"> |
|
|
|
|
<el-input v-model="queryParams.areas" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="优先级" prop="weight"> |
|
|
|
|
<el-input v-model="queryParams.weight" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/> |
|
|
|
@ -55,7 +55,12 @@
|
|
|
|
|
<el-table-column label="ID" align="center" prop="id" /> |
|
|
|
|
<el-table-column label="项目名" align="center" prop="name" /> |
|
|
|
|
<el-table-column label="项目内容" align="center" prop="content" /> |
|
|
|
|
<el-table-column label="资源名" align="center" prop="resources"/> |
|
|
|
|
<el-table-column label="区域名" align="center" prop="areas"/> |
|
|
|
|
<el-table-column label="作物名" align="center" prop="cropId" > |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<span> {{cropList.find(t=>t.id == scope.row.cropId ).name}} </span> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column label="图片" align="center" prop="images"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-image style="" :src="scope.row.images.split(',')[0]" |
|
|
|
@ -101,10 +106,10 @@
|
|
|
|
|
<el-form-item label="项目内容"> |
|
|
|
|
<editor v-model="form.content" :min-height="192"/> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="资源选择"> |
|
|
|
|
<el-select v-model="selectResourceList" multiple placeholder="请选择"> |
|
|
|
|
<el-form-item label="区域选择"> |
|
|
|
|
<el-select v-model="selectAreasList" multiple placeholder="请选择"> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in resourceList" |
|
|
|
|
v-for="item in areasList" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.name" |
|
|
|
|
:value="item.id"> |
|
|
|
@ -112,6 +117,12 @@
|
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="作物选择"> |
|
|
|
|
<el-select v-model="form.cropId" placeholder="请选择" @change="selectCrop"> |
|
|
|
|
<el-option v-for="item in cropList" :key="item.id" :label="item.name" :value="item.id"> {{item.name}} |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="项目图片"> |
|
|
|
|
<imageUpload v-model="form.images"/> |
|
|
|
|
</el-form-item> |
|
|
|
@ -137,7 +148,10 @@
|
|
|
|
|
import { createProject, updateProject, deleteProject, getProject, getProjectPage, exportProjectExcel, getProjectSearchPage } from "@/api/farm/project"; |
|
|
|
|
import ImageUpload from '@/components/ImageUpload'; |
|
|
|
|
import Editor from '@/components/Editor'; |
|
|
|
|
import { getResourcePage } from "@/api/farm/resource"; |
|
|
|
|
// import { getResourcePage } from "@/api/farm/resource"; |
|
|
|
|
import { getAreaPage} from "@/api/farm/area"; |
|
|
|
|
import { getCropPage} from "@/api/farm/crop"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
name: "Project", |
|
|
|
@ -173,31 +187,40 @@ export default {
|
|
|
|
|
resources: null, |
|
|
|
|
images: null, |
|
|
|
|
weight: null, |
|
|
|
|
areas: null, |
|
|
|
|
cropId: null |
|
|
|
|
}, |
|
|
|
|
// 表单参数 |
|
|
|
|
form: {}, |
|
|
|
|
// 表单校验 |
|
|
|
|
rules: { |
|
|
|
|
}, |
|
|
|
|
resourceList:[], |
|
|
|
|
//下拉多选框 默认为null |
|
|
|
|
selectResourceList:[], |
|
|
|
|
areasList:[], |
|
|
|
|
selectAreasList:[], |
|
|
|
|
cropList:[] |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
this.getResource(); |
|
|
|
|
this.getAreasList(); |
|
|
|
|
this.getCropList(); |
|
|
|
|
this.getList(); |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
/**查询资源*/ |
|
|
|
|
getResource(){ |
|
|
|
|
getResourcePage({ |
|
|
|
|
getCropList(){ |
|
|
|
|
getCropPage({ |
|
|
|
|
pageNo: 1, |
|
|
|
|
pageSize: 10, |
|
|
|
|
name: null, |
|
|
|
|
}).then(res=>{ |
|
|
|
|
this.resourceList = res.data.list; |
|
|
|
|
pageSize: 100 |
|
|
|
|
}).then(res =>{ |
|
|
|
|
this.cropList = res.data.list; |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
getAreasList(){ |
|
|
|
|
getAreaPage({ |
|
|
|
|
pageNo: 1, |
|
|
|
|
pageSize: 100 |
|
|
|
|
}).then(res =>{ |
|
|
|
|
this.areasList = res.data.list; |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
/** 查询项目列表 */ |
|
|
|
@ -210,21 +233,18 @@ export default {
|
|
|
|
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); |
|
|
|
|
// 执行查询 |
|
|
|
|
getProjectPage(params).then(response => { |
|
|
|
|
//1 循环list |
|
|
|
|
response.data.list.forEach(element => { |
|
|
|
|
element.resources = JSON.parse(element.resources); |
|
|
|
|
//2 循环每个list对象的resource |
|
|
|
|
let resourceName = ''; |
|
|
|
|
element.resources.forEach((inn) =>{ |
|
|
|
|
//3 每个resouce循环比较 resourceList,取得名字 |
|
|
|
|
this.resourceList.forEach((resource) =>{ |
|
|
|
|
if(inn == resource.id){ |
|
|
|
|
resourceName += (resource.name + "、\n"); |
|
|
|
|
element.areas = JSON.parse(element.areas); |
|
|
|
|
let areasName = ''; |
|
|
|
|
element.areas.forEach((inn) =>{ |
|
|
|
|
this.areasList.forEach((ar) =>{ |
|
|
|
|
if(inn == ar.id){ |
|
|
|
|
areasName += (ar.name + "、\n"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
}) |
|
|
|
|
element.resources = resourceName; |
|
|
|
|
element.areas = areasName; |
|
|
|
|
}); |
|
|
|
|
this.list = response.data.list; |
|
|
|
|
this.total = response.data.total; |
|
|
|
@ -242,17 +262,14 @@ export default {
|
|
|
|
|
//执行查询 |
|
|
|
|
getProjectSearchPage(params).then(response =>{ |
|
|
|
|
response.data.list.forEach(element => { |
|
|
|
|
element.resources = JSON.parse(element.resources); |
|
|
|
|
let resourceName = ''; |
|
|
|
|
element.resources.forEach((inn) =>{ |
|
|
|
|
this.resourceList.forEach((resource) =>{ |
|
|
|
|
if(inn == resource.id){ |
|
|
|
|
resourceName += (resource.name + "、\n"); |
|
|
|
|
} |
|
|
|
|
element.areas = JSON.parse(element.areas); |
|
|
|
|
element.areas.forEach(inn => { |
|
|
|
|
this.areasList.forEach((area) =>{ |
|
|
|
|
if(inn = area.id){ |
|
|
|
|
element.name = area.name; |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
}) |
|
|
|
|
element.resources = resourceName; |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
this.list = response.data.list; |
|
|
|
|
this.total = response.data.total; |
|
|
|
@ -276,6 +293,8 @@ export default {
|
|
|
|
|
planStartTime: undefined, |
|
|
|
|
planEndTime: undefined, |
|
|
|
|
weight: undefined, |
|
|
|
|
areas: undefined, |
|
|
|
|
cropId:undefined |
|
|
|
|
}; |
|
|
|
|
this.resetForm("form"); |
|
|
|
|
}, |
|
|
|
@ -283,7 +302,6 @@ export default {
|
|
|
|
|
handleQuery() { |
|
|
|
|
this.queryParams.pageNo = 1; |
|
|
|
|
this.getSearchList(); |
|
|
|
|
// this.getList(); |
|
|
|
|
}, |
|
|
|
|
/** 重置按钮操作 */ |
|
|
|
|
resetQuery() { |
|
|
|
@ -291,7 +309,6 @@ export default {
|
|
|
|
|
this.dateRangePlanEndTime = []; |
|
|
|
|
this.dateRangeCreateTime = []; |
|
|
|
|
this.resetForm("queryForm"); |
|
|
|
|
// this.handleQuery(); |
|
|
|
|
this.queryParams.pageNo = 1; |
|
|
|
|
this.getList(); |
|
|
|
|
}, |
|
|
|
@ -307,9 +324,9 @@ export default {
|
|
|
|
|
const id = row.id; |
|
|
|
|
getProject(id).then(response => { |
|
|
|
|
this.form = response.data; |
|
|
|
|
let array = JSON.parse(response.data.resources); |
|
|
|
|
this.form.resources = array; |
|
|
|
|
this.selectResourceList = array; |
|
|
|
|
let areasArray = JSON.parse(response.data.areas); |
|
|
|
|
this.form.areas = areasArray; |
|
|
|
|
this.selectAreasList = areasArray; |
|
|
|
|
this.open = true; |
|
|
|
|
this.title = "修改农场项目"; |
|
|
|
|
}); |
|
|
|
@ -320,7 +337,7 @@ export default {
|
|
|
|
|
if (!valid) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.form.resources = JSON.stringify(this.selectResourceList); |
|
|
|
|
this.form.areas = JSON.stringify(this.selectAreasList); |
|
|
|
|
// 修改的提交 |
|
|
|
|
if (this.form.id != null) { |
|
|
|
|
updateProject(this.form).then(response => { |
|
|
|
@ -332,7 +349,7 @@ export default {
|
|
|
|
|
} |
|
|
|
|
// 添加的提交 |
|
|
|
|
createProject(this.form).then(response => { |
|
|
|
|
this.form.resources = JSON.stringify(this.form.resources); |
|
|
|
|
this.form.areas = JSON.stringify(this.form.areas); |
|
|
|
|
this.$modal.msgSuccess("新增成功"); |
|
|
|
|
this.open = false; |
|
|
|
|
this.getList(); |
|
|
|
@ -368,8 +385,6 @@ export default {
|
|
|
|
|
}).catch(() => {}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|