Procházet zdrojové kódy

2022.7.31 任务分组工时报表

ggooalice před 2 roky
rodič
revize
474d1c6f06

+ 56 - 49
fhKeeper/formulahousekeeper/timesheet/src/views/corpreport/list.vue

@@ -101,7 +101,7 @@
             <el-option v-for="(item, index) in selUserList" :key="index" :label="item.name" :value="item.id"></el-option>
           </el-select>
       </div>
-      <p style="float: right;margin-right: 25px;" ><el-button type="primary" @click="exportExcel" size="mini" v-if="ins != 12">报表导出</el-button></p>
+      <p style="float: right;margin-right: 25px;" ><el-button type="primary" @click="exportExcel" size="mini">报表导出</el-button></p>
     </div>
     <div ref="staff" style="margin: 5px 0px 0px 10px; width: 98%">
         <div class="staff" ref="tabless" :style="'width:'+(windowWidth - 410)+'px'">
@@ -350,7 +350,7 @@
             <el-table v-if="ins == 12" border :data="groupWorktimeList" key="12"
             highlight-current-row v-loading="listLoading" :height="tableHeight" 
              style="width: 100%;" ref="table">
-                <el-table-column :label="'按任务分组统计(共' + groupListTotal.left + '条)'" header-align="center">
+                <el-table-column label="按任务分组统计" header-align="center">
                   <el-table-column prop="leftgroupName" label="分组名称" min-width="100"></el-table-column>
                   <el-table-column prop="leftworkingTime" label="工时(h)" min-width="50" align="right" header-align="center">
                     <template slot-scope="scope">
@@ -359,9 +359,9 @@
                   </el-table-column>
                 </el-table-column>
                 <el-table-column width="2" class-name="dividingLine" label-class-name="dividingLine"></el-table-column>
-                <el-table-column :label="'按项目统计(共' + groupListTotal.right + '条)'" header-align="center">
-                  <el-table-column prop="rightprojectCode" label="项目编号" min-width="100"></el-table-column>
-                  <el-table-column prop="rightprojectName" label="项目名称" min-width="100"></el-table-column>
+                <el-table-column label="按项目统计" header-align="center">
+                  <el-table-column prop="rightprojectCode" label="项目编号" min-width="75"></el-table-column>
+                  <el-table-column prop="rightprojectName" label="项目名称" min-width="125"></el-table-column>
                   <el-table-column prop="rightgroupName" label="分组名称" min-width="100"></el-table-column>
                   <el-table-column prop="rightworkingTime" label="工时(h)" min-width="50" align="right" header-align="center">
                     <template slot-scope="scope">
@@ -515,6 +515,16 @@
 
         <!--工具条-->
         <el-col :span="24" class="toolbar" v-if="ins != 6">
+          <el-pagination
+                @size-change="handleSizeChange"
+                @current-change="groupPageChange"
+                :current-page="groupPage"
+                :page-sizes="[20 , 50 , 80 , 100]"
+                :page-size="size"
+                layout="total, sizes, prev, pager, next"
+                :total="groupTotal"
+                style="float:left;"
+            ></el-pagination>
             <el-pagination
                 @size-change="handleSizeChange"
                 @current-change="handleCurrentChange"
@@ -731,11 +741,8 @@ export default {
 
       personnelList: [], //'人员工时统计表'
       groupWorktimeList: [], //任务分组工时表
-      groupWorktimeAll: [],
-      groupListTotal:{
-        left: 0,
-        right: 0
-      }
+      groupPage: 1,
+      groupTotal: 0
     };
   },
   computed: {},
@@ -964,7 +971,16 @@ export default {
             handleSizeChange(val) {
                 this.size = val;
                 this.page = 1
+                if(this.ins == 12){
+                  this.groupPage = 1
+
+                }
                 this.getList();
+                
+            },
+            groupPageChange(val){
+                this.groupPage = val;
+                this.getGroupWorktimeAll()
             },
             getList() {
                 if (this.ins == 0) {
@@ -994,6 +1010,17 @@ export default {
                 } else if(this.ins == 11) {
                     this.getPersonnelList()
                 }else if(this.ins == 12){
+                  this.groupWorktimeList = []
+                  for(let i=0; i<this.size; i++){
+                    this.groupWorktimeList.push({
+                      leftgroupName:null,
+                      leftworkingTime:null,
+                      rightgroupName:null,
+                      rightworkingTime:null,
+                      rightprojectCode:null,
+                      rightprojectName:null
+                    })
+                  }
                     this.getGroupWorktimeList()
                     this.getGroupWorktimeAll()
                 }
@@ -1062,6 +1089,11 @@ export default {
           if(this.departmentIdArray.length != 0){
             sl.departmentId = this.departmentIdArray[this.departmentIdArray.length - 1]
           }
+        }else if(this.ins == 12){
+          fName = "任务分组工时统计.xls"
+          url += "/exportGroupWithProjectTimeCost"
+          sl.startDate = this.rangeDatas[0]
+          sl.endDate = this.rangeDatas[1]
         }
           this.http.post(url, sl,
             res => {
@@ -1475,34 +1507,19 @@ export default {
       if(this.proJuctId){
         parameter.projectId = this.proJuctId
       }
-      this.groupListTotal.right = 0
       this.listLoading = true
-      this.http.post('/project/getTimeCostByGroup',parameter,
+      this.http.post('/project/getTimeCostByGroupProject',parameter,
         res => {
           this.listLoading = false
           if(res.code == 'ok'){
-            this.groupWorktimeList = []
+            this.total = res.data.total
             let list = res.data.records
-            this.groupListTotal.right = res.code.total
-            this.groupWorktimeAll.length > res.data.total ? this.total = this.groupWorktimeAll.length : this.total = res.data.total
-            let forlength = 0
-            if(this.groupWorktimeAll.length - this.size*(this.page-1) < list.length){
-              forlength = list.length
-            }else{
-              forlength = this.groupWorktimeAll.length - this.size*(this.page-1) > this.size ? this.size : this.groupWorktimeAll.length - this.size*(this.page-1)
+            for(let i=0; i<this.size; i++){
+              this.groupWorktimeList[i].rightgroupName = list[i] ? list[i].groupName : null
+              this.groupWorktimeList[i].rightworkingTime = list[i] ? list[i].workingTime : null
+              this.groupWorktimeList[i].rightprojectCode = list[i] ? list[i].projectCode : null
+              this.groupWorktimeList[i].rightprojectName = list[i] ? list[i].projectName : null
             }
-            for(let i=0; i<forlength; i++){
-              let item = {
-                leftgroupName: this.groupWorktimeAll[i + this.size*(this.page - 1)] ? this.groupWorktimeAll[i + this.size*(this.page - 1)].groupName : null,
-                leftworkingTime: this.groupWorktimeAll[i + this.size*(this.page - 1)] ? this.groupWorktimeAll[i + this.size*(this.page - 1)].workingTime : null,
-                rightprojectCode: list[i] ? list[i].projectCode : null,
-                rightprojectName: list[i] ? list[i].projectName : null,
-                rightgroupName: list[i] ? list[i].groupName : null,
-                rightworkingTime: list[i] ? list[i].workingTime : null
-              }
-              this.groupWorktimeList.push(item)
-            }
-            console.log('groupWorktimeList',this.groupWorktimeList);
           }else {
             this.$message({
               message: res.msg,
@@ -1521,28 +1538,18 @@ export default {
       let parameter = {
         startDate: this.rangeDatas[0],
         endDate: this.rangeDatas[1],
-        pageIndex: 1,
-        pageSize: 9999
+        pageIndex: this.groupPage,
+        pageSize: this.size
       }
-      this.groupListTotal.left = 0
       this.http.post('/project/getTimeCostByGroup',parameter,
         res => {
           if(res.code == 'ok'){
-              this.groupWorktimeAll = []
-              let allList = JSON.parse(JSON.stringify(res.data.records))
-              for(let m in allList){
-                let isin = false
-                for(let n in this.groupWorktimeAll){
-                  if(this.groupWorktimeAll[n].groupName == allList[m].groupName){
-                    isin = true
-                    this.groupWorktimeAll[n].workingTime = this.groupWorktimeAll[n].workingTime + allList[m].workingTime
-                  }
-                }
-                if(!isin){
-                  this.groupWorktimeAll.push(allList[m])
-                }
+            let list = res.data.records
+              this.groupTotal = res.data.total
+              for(let i=0; i<this.size; i++){
+                this.groupWorktimeList[i].leftgroupName = list[i] ? list[i].groupName : null
+                this.groupWorktimeList[i].leftworkingTime = list[i] ? list[i].workingTime : null
               }
-              this.groupListTotal.left = this.groupWorktimeAll.length
           }else {
             this.$message({
               message: res.msg,