diff --git a/src/views/farm/project/index.vue b/src/views/farm/project/index.vue
index 1f5f180..91acbb9 100644
--- a/src/views/farm/project/index.vue
+++ b/src/views/farm/project/index.vue
@@ -13,8 +13,8 @@
-
-
+
+
@@ -55,7 +55,12 @@
-
+
+
+
+ {{cropList.find(t=>t.id == scope.row.cropId ).name}}
+
+
-
-
+
+
@@ -112,6 +117,12 @@
+
+
+ {{item.name}}
+
+
+
@@ -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(() => {});
}
-
-
}
};