Browse Source

农场项目

master
小久哥 3 years ago
parent
commit
f184bd6473
  1. 109
      src/views/farm/project/index.vue

109
src/views/farm/project/index.vue

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

Loading…
Cancel
Save