-
+
+
+
+
+
+
-
-
+
- 添加
- 删除
-
+
+
+
+
+
+
+
+
+ {{item.pValue}}/{{item.value}}
+
+
+
+
+
+
+
+
+
+
+
@@ -244,8 +280,10 @@ import { getResourcePage } from "@/api/farm/resource";
import { getProjectPage} from "@/api/farm/project";
import { getCropPage} from "@/api/farm/crop";
import { getResourceTypePage} from "@/api/farm/resourceType";
-import { getTaskCatePage} from "@/api/farm/taskCate"
-import { getCpUserPage} from "@/api/system/cpUser"
+import { getTaskCatePage} from "@/api/farm/taskCate";
+import { getCpUserPage} from "@/api/system/cpUser";
+import { getAreaPage} from "@/api/farm/area";
+
import { values } from 'min-dash';
export default {
@@ -308,23 +346,25 @@ export default {
cropList:[],
resourceTypeList:[],
- selectResourceTypeList:[],
+ resourceNumberList:[],
twoList:[],
props: { multiple: true },
- selectRList:[],
-
cpUserList:[],
- selectExecutorPerson:[],
executorPerson:[],
taskCateAllList:[], //未组装的
taskCateList:[], //组装好的
- selectTaskCateList: [],//选择的
cateOneList:[],
cateTwoList:[],
+ formR:{},
+
+ areasList:[],
+ assemAreaList:[],
+ areasParentList:[],
+ areasSonList:[],
};
},
@@ -335,8 +375,17 @@ export default {
this.getCpUserList();
this.getCropList();
this.getTaskCateList();
+ this.getAreasList();
},
methods: {
+ getAreasList(){
+ getAreaPage({
+ pageNo: 1,
+ pageSize: 100
+ }).then(res =>{
+ this.areasList = res.data.list;
+ })
+ },
getTaskCateList(){
getTaskCatePage({
pageNo: 1,
@@ -406,6 +455,7 @@ export default {
/** 查询任务列表 */
getList() {
this.loading = true;
+ // this.assemArea();
// 处理查询参数
let params = {...this.queryParams};
this.addBeginAndEndTime(params, this.dateRangePlanStartTime, 'planStartTime');
@@ -448,6 +498,16 @@ export default {
})
element.executorPerson = executorName;
+ if (element.areas != null) {
+ element.areas = JSON.parse(element.areas);
+ let areaName = "";
+ element.areas.forEach(item =>{
+ let p = this.areasList.filter(t => t.id == item[0])[0].name;
+ let s = this.areasList.filter(t => t.id == item[1])[0].name;
+ areaName += p +"/" + s +"、\n";
+ })
+ element.areas = areaName;
+ }
});
this.list = response.data.list;
this.total = response.data.total;
@@ -531,12 +591,18 @@ export default {
handleAdd() {
this.reset();
this.twoRescoure();
+ this.assemArea();
+
+ this.resourceNumberList = [];
+
+
this.open = true;
this.title = "添加农场任务";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
+ this.assemArea();
const id = row.id;
getTask(id).then(response => {
this.form = response.data;
@@ -551,9 +617,14 @@ export default {
this.form.images = imagesArr;
}
- let executorArr = JSON.parse(response.data.executorPerson);
- this.form.executorPerson = executorArr;
- this.executorPerson = executorArr;
+ let executorArr = JSON.parse(response.data.executorPerson);
+ this.form.executorPerson = executorArr;
+ this.executorPerson = executorArr;
+
+
+ let areasArray = JSON.parse(response.data.areas);
+ this.form.areas = areasArray;
+
this.open = true;
this.title = "修改农场任务";
});
@@ -568,6 +639,7 @@ export default {
//资源转json
this.form.resources = JSON.stringify(this.selectResourceList);
this.form.executorPerson = JSON.stringify(this.executorPerson);
+ this.form.areas = JSON.stringify(this.form.areas);
//图片转json
let im = this.form.images;
this.form.images = JSON.stringify("");
@@ -589,6 +661,7 @@ export default {
// 添加的提交
createTask(this.form).then(response => {
this.form.executorPerson = JSON.stringify(this.form.executorPerson);
+ this.form.members = JSON.stringify(this.form.members);
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
@@ -636,23 +709,68 @@ export default {
})
this.twoList = firstList;
},
- addR(row){
- console.log("添加", row);
+ changeCateOne(row){
+ this.cateTwoList = this.taskCateAllList.filter(t => t.parentId == row);
+ },
+
+ changeResources(row){
+ let selectROW = this.$refs['chooseR'].getCheckedNodes();
+ if (row.length == 0) {
+ this.resourceNumberList = [];
+ return ;
+ }
+ if (selectROW.filter(t=>t.hasChildren).length == 0) {
+ //节点数量为0 清除待填数据
+ this.resourceNumberList = [];
+ }
+
+ selectROW.forEach(item =>{
+ if(!item.hasChildren){
+ //没有腹肌才算
+ let obj = {
+ pId: item.parent.data.value,
+ pValue: item.parent.data.label,
+ id:item.data.value,
+ value: item.data.label
+ };
+ var index = this.resourceNumberList.findIndex(item => item.id === obj.id);
+ if(index == -1){
+ this.resourceNumberList.push(obj);
+ }
+ }
+ })
},
- delR(row){
- console.log("删除", row);
+ assemArea(){
+ let parentLsit = this.areasList.filter(t => t.parentId == 0);
+ let sonList = this.areasList.filter(s => s.parentId != 0);
+
+ let firstList = [];
+ parentLsit.forEach(p => {
+ this.areasParentList.push(p);
+ let secondList = [];
+ sonList.forEach(s => {
+ if (p.id == s.parentId) {
+ this.areasSonList.push(s);
+ secondList.push({value:s.id, label:s.name});
+ }
+ })
+ firstList.push({value: p.id, label:p.name, children: secondList})
+ })
+ this.assemAreaList = firstList;
},
- changeTaskCate(row){
- let selectArr = row;
- this.taskCateAllList.forEach(item =>{
- selectArr.forEach(id =>{
- if(item.value == id){
+ changeProject(row){
+ this.form.areas = null;
+ this.assemArea();
+ let projectArea = JSON.parse(this.projectList.filter(project => project.id == row)[0].areas);
+ let filterArr = [];
+ this.assemAreaList.forEach(t=>{
+ projectArea.forEach(a=>{
+ if (a == t.value) {
+ filterArr.push(t);
}
})
})
- },
- changeCateOne(row){
- this.cateTwoList = this.taskCateAllList.filter(t => t.parentId == row);
+ this.assemAreaList = filterArr;
}
}
};