ggooalice před 2 roky
rodič
revize
8bbf2e9644

binární
fhKeeper/formulahousekeeper/timesheet/src/assets/image/hanglie_corp.png


+ 68 - 14
fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

@@ -30,6 +30,7 @@
 
             <el-radio-group v-model="radio" @change="getEchart" style="margin-left:10px;">
                 <el-radio-button label="项目"></el-radio-button>
+                <el-radio-button label="项目分类"></el-radio-button>
                 <el-radio-button label="部门"></el-radio-button>
                 <el-radio-button label="人员"></el-radio-button>
                 <el-radio-button :label="namess" v-if="jichu.customDegreeActive == 1"></el-radio-button>
@@ -59,7 +60,7 @@
         <!--导出报表条件选择 -->
         <el-dialog title="工时报表导出" v-if="exportDialog" :visible.sync="exportDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
             <el-form ref="form3" :model="exportParam" >
-                <el-form-item prop="projectId" label="选择项目" v-if="radio != '人员'">
+                <el-form-item prop="projectId" label="选择项目" v-if="radio != '人员' && radio != '项目分类'">
                     <el-select v-model="exportParam.projectId" placeholder="全部项目"  clearable style="width:350px;" filterable="true">
                         <el-option v-for="item in projectList"  :key="item.id" :label="item.projectName + item.projectCode" :value="item.id">
                             <span style="float: left;color: #8492a6;">{{ item.projectCode }}</span>
@@ -67,6 +68,13 @@
                         </el-option>
                     </el-select>
                 </el-form-item>
+
+                <el-form-item prop="projectCategoryId" label="项目分类" v-if="radio == '项目分类'">
+                    <el-select v-model="exportParam.projectCategoryId" placeholder="全部项目分类"  clearable style="width:350px;" filterable="true">
+                        <el-option v-for="item in categoryList"  :key="item.id" :label="item.name" :value="item.id">
+                        </el-option>
+                    </el-select>
+                </el-form-item>
                 <el-form-item prop="userIds" label="选择人员" v-if="radio == '人员'">
                     <el-select v-model="exportParam.userIds" placeholder="全部人员" multiple="true"  clearable style="width:350px;" filterable="true">
                         <el-option v-for="item in hasReportUserList"  :key="item.id" :label="item.name" :value="item.id"></el-option>
@@ -93,26 +101,27 @@
                     ></el-date-picker>
                 </el-form-item>
                 
-                <el-form-item label="选择人员" v-if="radio == '项目' || radio == '部门'">
+                <el-form-item label="选择人员" v-if="radio == '项目' || radio == '部门' || radio == '项目分类'">
                     <el-select v-model="exportParam.userId"  placeholder="全部人员" style="width: 350px" filterable="true" clearable="true">
                         <span v-for="(item, index) in users" :key="index">
                         <el-option :label="item.name" :value="item.id"></el-option>
                         </span> 
                     </el-select>
                 </el-form-item>
-                <el-form-item prop="type" label="选择样式" v-if="radio == '项目' || radio == '部门'">
+                <el-form-item prop="type" label="选择样式" v-if="radio == '项目' || radio == '部门' || radio == '项目分类'">
                     <el-select v-model="exportParam.type" placeholder="选择样式" style="width:350px;" >
-                        <el-option label="项目在行上" value="0"></el-option>
-                        <el-option label="项目在列上" value="1"></el-option>
+                        <el-option :label="radio == '项目分类' ? '项目分类在行上' : '项目在行上'" value="0"></el-option>
+                        <el-option :label="radio == '项目分类' ? '项目分类在列上' : '项目在列上'" value="1"></el-option>
                     </el-select>
                     <div class="prompt">
                         <el-popover placement="top" width="1200" trigger="hover">
-                            <img src="../../assets/image/hanglie.png" alt="" width="100%">
+                            <img src="../../assets/image/hanglie.png" alt="" width="100%" v-if="this.radio != '项目分类'">
+                            <img src="../../assets/image/hanglie_corp.png" alt="" width="100%" v-else>
                             <i class="el-icon-question" slot="reference" />
                         </el-popover>
                     </div>
                 </el-form-item>
-                <el-form-item v-if="(radio == '项目' || radio == '部门') && exportParam.type == '0'">
+                <el-form-item v-if="(radio == '项目' || radio == '部门' || radio == '项目分类') && exportParam.type == '0'">
                     <el-checkbox v-model="exportParam.projectSum" >含单个项目数据汇总</el-checkbox>
                 </el-form-item>
             </el-form>
@@ -135,6 +144,7 @@
                 parentDeptId:null,
                 hasReportUserList:[],
                 projectList:[],
+                categoryList: [],
                 exportParam:{projectId:null,dateRange:[],userId: null,type: '0'},
                 exportDialog:false,
                 dateRange:[],
@@ -255,21 +265,31 @@
                         param.userIds = ids;
                      }
                  } 
+                if(this.radio == '项目分类'){
+                    fileName = '项目分类工时成本统计.xls';
+                    url = '/project/exportTimeCostByCategory'
+                    if(this.exportParam.projectCategoryId){
+                        param.projectCategoryId = this.exportParam.projectCategoryId
+                    }
+                }
                 
-                if (this.exportParam.projectId) {
+                if (this.exportParam.projectId && this.radio != '人员' && this.radio != '项目分类') {
                     param.projectId = this.exportParam.projectId;
                 }
                 if (this.exportParam.userId) {
-                    if(this.radio == '项目' || this.radio == '部门' || this.radio == '人员'){
+                    if(this.radio == '项目' || this.radio == '部门' || this.radio == '人员' || this.radio == '项目分类'){
                         param.userId = this.exportParam.userId;
                     }
                 }
+                if (this.exportParam.type == 1) {
+                    this.exportParam.projectSum = null
+                }
                 if (this.exportParam.projectSum != null) {
-                    if(this.radio == '项目' || this.radio == '部门'){
+                    if(this.radio == '项目' || this.radio == '部门' || this.radio == '项目分类'){
                         param.projectSum = this.exportParam.projectSum;
                     }
                 }
-                param.type = this.exportParam.type
+                param.type = this.exportParam.type*1
                 this.http.post(url, param,
                     res => {
                         this.listLoading = false;
@@ -659,6 +679,27 @@
                     that.jieliu()
                 // },100);
                 // this.jieliu()
+                if(this.radio == '项目分类'){
+                    this.getCategoryList()
+                }
+            },
+            getCategoryList(){
+                this.http.post('/project-category/list',{},
+                res => {
+                    if(res.code == 'ok'){
+                        this.categoryList = res.data
+                    }else {
+                        this.$message({
+                            message: res.msg,
+                            type: 'error'
+                        })
+                    }
+                },err => {
+                    this.$message({
+                        message: err,
+                        type: 'error'
+                    })
+                })
             },
             backToParentDept() {
                 if (this.radio == '部门') {
@@ -686,6 +727,10 @@
                 var url = '';
                 if (this.radio=='项目') {
                     url = this.port.project.listCost;
+                } else if (this.radio=='项目分类') {
+                    url = '/project/getTimeCostByCategory';
+                    // param.parentDeptId = this.parentDeptId;
+                    // param.userId = this.user.id
                 } else if (this.radio=='部门') {
                     url = this.port.project.depCost;
                     param.parentDeptId = this.parentDeptId;
@@ -713,12 +758,12 @@
                         var list
                         var totalMoneyCost;
                         var totalHours = 0.0;
-                        if(this.radio == '项目' || this.radio=='部门') {
+                        if(this.radio == '项目' || this.radio == '项目分类' || this.radio=='部门') {
                             list = res.data.costList
                             totalMoneyCost = ((this.radio=='项目')?res.data.totalMoneyCost:res.data.totalCostMoney);
                             for(var i in list) {
                                 if(this.radio=='项目') {
-                                    xList.push(this.radio=='项目'?list[i].project:list[i].name);
+                                    xList.push(list[i].project);
                                     yList.push({
                                         "value": this.yAxisValue==0?list[i].costMoney.toFixed(2) || list[i].costMoney:list[i].cost.toFixed(1),
                                         "id": list[i].id || i,
@@ -726,7 +771,7 @@
                                         "money":list[i].costMoney.toFixed(2)
                                     });
                                     totalHours += parseFloat(list[i].cost);
-                                } else {
+                                } else if(this.radio == '部门'){
                                     xList.push(list[i].departmentName);
                                     yList.push({
                                         "value": this.yAxisValue==0? list[i].costMoney.toFixed(2) || list[i].costMoney: list[i].costTime.toFixed(1),
@@ -736,6 +781,15 @@
                                         "money":list[i].costMoney.toFixed(2)
                                     });
                                     totalHours += parseFloat(list[i].costTime);
+                                }else {
+                                    xList.push(list[i].categoryName);
+                                    yList.push({
+                                        "value": this.yAxisValue==0?list[i].costMoney.toFixed(2) || list[i].costMoney:list[i].cost.toFixed(1),
+                                        "id": list[i].id || i,
+                                        "cost": list[i].cost,
+                                        "money":list[i].costMoney.toFixed(2)
+                                    });
+                                    totalHours += parseFloat(list[i].cost);
                                 }
                             }
                         } else {