山水共长天一色 3 yıl önce
ebeveyn
işleme
8c329b1227

+ 50 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/corpreport/list.vue

@@ -94,7 +94,7 @@
             </el-table>
 
             <!-- 项目任务报表 -->
-            <el-table v-if="ins == 1" :key="ins" border :data="list1" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
+            <el-table v-if="ins == 1" :key="ins" border :data="list1" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;" :span-method="objectSpanMethod">
                 <el-table-column  prop="project_code" label="项目编号"  width="120"></el-table-column>
                 <el-table-column  prop="project_name" label="项目名称" width="200">
                   <template slot-scope="scope" >
@@ -548,6 +548,12 @@ export default {
       listLoading:false,
       tableHeight:0,
       list1:[],
+      listArr1:[],
+      listArr2:[],
+      listPosition1:0,
+      listPosition2:0,
+
+
       list2: [],
       list3: [],
       list4: [],
@@ -612,6 +618,43 @@ export default {
       }
   },
   methods: {
+    rowspan(spanArr,position,spanName){
+      this.list1.forEach((item,index) => {
+        if(index == 0){
+          spanArr.push(1)
+          position = 0
+        }else {
+          if(this.list1[index][spanName] == this.list1[index-1][spanName]){
+            spanArr[position] += 1
+            spanArr.push(0)
+          }else {
+            spanArr.push(1)
+            position = index
+          }
+        }
+      })
+    },
+    objectSpanMethod({ row, column, rowIndex, columnIndex }){
+      if(columnIndex == 0){
+        const _row = this.listArr1[rowIndex]
+        const _col = _row > 0 ? 1 : 0
+        return {
+          rowspan: _row,
+          colspan: _col
+        }
+      }
+      if(columnIndex == 1){
+        const _row = this.listArr2[rowIndex]
+        const _col = _row > 0 ? 1 : 0
+        return {
+          rowspan: _row,
+          colspan: _col
+        }
+      }
+    },
+
+
+
     getUserList() {
       this.http.post('/user/getEmployeeList', {
         departmentId: -1,
@@ -913,6 +956,12 @@ export default {
         res => {
             if (res.code == "ok") {
                 this.list1 = res.data.records;
+                this.listArr1 = []
+                this.listArr2 = []
+                this.listPosition1 = 0
+                this.listPosition2 = 0
+                this.rowspan(this.listArr1,this.listPosition1,'project_code')
+                this.rowspan(this.listArr2,this.listPosition2,'project_name')
                 this.total = res.data.total;
                 this.listLoading = false; 
             } else {