From 6d44b0cf419280b2525a2910e6b0a3bd624e838f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E4=B9=85=E5=93=A5?= <787952492@qq.com>
Date: Thu, 2 Jun 2022 10:24:08 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1UI=E4=BB=A3=E7=A0=81=E4=BC=98?=
 =?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
 src/views/farm/task/index.vue | 149 ++++++++++++----------------------
 1 file changed, 52 insertions(+), 97 deletions(-)
diff --git a/src/views/farm/task/index.vue b/src/views/farm/task/index.vue
index 87ff3b7..bb06036 100644
--- a/src/views/farm/task/index.vue
+++ b/src/views/farm/task/index.vue
@@ -57,9 +57,16 @@
            {{ cpUserList.find(t => t.id == scope.row.mainPerson).name }} 
         
       
-      
-      
-
+      
+        
+              {{executorPersonConvert(scope.row.executorPerson)}}
+        
+      
+      
+        
+              {{areaConvert(scope.row.areas)}}
+        
+      
       
         
            {{ cropList.find(t => t.id == scope.row.cropId).name }} 
@@ -76,13 +83,12 @@
            {{ cateTwoList.find(t => t.id == scope.row.taskCateName).name }} 
         
       
-      
+      
           
               {{resouceConvert(scope.row.resources)}}
           
       
       
-
       
         
           
     
       
-
         
           
             
@@ -130,7 +135,6 @@
             
           
         
-
         
           
             
@@ -138,20 +142,17 @@
             
           
         
-
         
-          
+          
             
               {{ item.name }}
             
           
         
-
         
           
           
         
-
         
           
             
@@ -159,11 +160,9 @@
             
           
         
-
         
           
         
-
         
           
             
@@ -171,7 +170,6 @@
             
           
         
-
         
           
             
@@ -179,18 +177,12 @@
             
           
         
-
         主要按钮
-
         
           ziyuanxuanze(item,index,obj)">
           
-
           
         
-
-    
-
         
           
         
@@ -324,21 +316,42 @@ export default {
     this.getAreasList();
   },
   methods: {
+    executorPersonConvert(executorPerson){
+      let executorPersonName = "";
+      executorPerson.forEach(person => {
+        this.cpUserList.forEach( user => {
+          if (person == user.id) {
+            executorPersonName += user.name + "\n";
+          }
+        })
+      })
+      return executorPersonName;
+    },
+    areaConvert(area){
+      if (area != null) {
+        let areaMsg = "";
+        let parentLsit = this.areasList.filter(t => t.parentId == 0);
+        let sonList = this.areasList.filter(s => s.parentId != 0);
+        area.forEach(item =>{
+          let parentName = parentLsit.filter(parent => parent.id == item[0])[0].name;
+          let sonName = sonList.filter(son => son.id == item[1])[0].name;
+          areaMsg += parentName +"/"+ sonName +"\n";
+        })
+        return areaMsg;
+      }
+     
+    },
     resouceConvert(resources){
-       let rnameArr = this.resourceList.filter(s=>{
-            if (resources.length > 0){
-                return resources[0].resourceId.indexOf(s.id)>= 0;
-            }
-          } );
-          let rname = "";
-          rnameArr.forEach(s=>{
-            rname +=  s.name + "-";
-          })
-          return rname;
+      let resouceMsg = "";
+      resources.forEach(item =>{
+          let typeName = this.resourceTypeList.filter(type => type.id == item.resourceId[0])[0].name;
+          let resouceName = this.resourceList.filter(type => type.id == item.resourceId[1])[0].name;
+          resouceMsg += typeName +"/" + resouceName +":" + item.num +"\n";
+      })
+      return resouceMsg;
     },
     ziyuanxuanze(item,index,obj){
       this.form.resource[index].reource = obj[1];
-      console.log(this.form.resource);
     },
     addResource(){
       let resourceTmp = {reource:0,num:1}
@@ -421,7 +434,7 @@ export default {
     /** 查询任务列表 */
     getList() {
       this.loading = true;
-      // this.assemArea();
+      this.assemArea();
       // 处理查询参数
       let params = { ...this.queryParams };
       this.addBeginAndEndTime(params, this.dateRangePlanStartTime, 'planStartTime');
@@ -429,7 +442,6 @@ export default {
       this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
       // 执行查询
       getTaskPage(params).then(response => {
-
         //1 循环list
         response.data.list.forEach(element => {
           if (element.images != null) {
@@ -439,29 +451,6 @@ export default {
             //无图片给个空
             element.images = [];
           }
-          
-        
-          element.executorPerson = JSON.parse(element.executorPerson);
-          let executorName = '';
-          element.executorPerson.forEach((exe) => {
-            this.cpUserList.forEach((cp) => {
-              if (exe == cp.id) {
-                executorName += (cp.name + "、\n");
-              }
-            })
-          })
-          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;
@@ -485,17 +474,6 @@ export default {
           } else {
             element.images = [];
           }
-          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.resources = resourceName;
         });
         this.list = response.data.list;
         this.total = response.data.total;
@@ -546,10 +524,7 @@ export default {
       this.reset();
       this.twoRescoure();
       this.assemArea();
-
       this.resourceNumberList = [];
-
-
       this.open = true;
       this.title = "添加农场任务";
     },
@@ -559,28 +534,13 @@ export default {
       this.assemArea();
       const id = row.id;
       getTask(id).then(response => {
-        this.form = response.data;
-        if (response.data.resources != null) {
-          let resourceArr = JSON.parse(response.data.resources);
-          this.form.resources = resourceArr;
-          this.selectResourceList = resourceArr;
-        }
-
-        if (response.data.images != null) {
-          let imagesArr = JSON.parse(response.data.images);
-          this.form.images = imagesArr;
-        }
-
-        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 = "修改农场任务";
+      this.form = response.data;
+      if (response.data.images != null) {
+        let imagesArr = JSON.parse(response.data.images);
+        this.form.images = imagesArr;
+      }
+      this.open = true;
+      this.title = "修改农场任务";
       });
     },
     /** 提交按钮 */
@@ -590,9 +550,6 @@ export default {
         if (!valid) {
           return;
         }
-        //资源转json
-        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("");
@@ -613,8 +570,6 @@ 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();