Sfoglia il codice sorgente

优化月度工时导出

seyason 9 mesi fa
parent
commit
28dd1b27aa

+ 49 - 12
fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

@@ -59,6 +59,7 @@
         </el-col>
         <el-col :span="3">
             <el-button @click="exportProjectData" v-if="theCustomListFlg"  size="small">{{ $t('reporderived') }}</el-button>
+            <el-button @click="showExportMonthlyDataDialog" v-else-if="user.companyId == 10 && radio==$t('other.project')"  size="small">{{ $t('reporderived') }}</el-button>
             <el-button @click="showExportDialog" v-else  size="small">{{ $t('reporderived') }}</el-button>
         </el-col>
         </el-row>
@@ -90,14 +91,24 @@
             </div>
         </div>
 
-        <!--导出报表条件选择 -->
-        <el-dialog :title="$t('timeReportExport')" v-if="exportDialog" :visible.sync="exportDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
-            <el-form ref="form4"  v-if="user.companyId == 10">
+        <!--导出月度工时统计表-->
+        <el-dialog :title="$t('timeReportExport')" v-if="selectMonthExportDialog" :visible.sync="selectMonthExportDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
+            <el-form ref="form4" :model="exportParam" >
                 <el-form-item :label="this.$t('Selectmonth')" >
                     <el-date-picker size="small" v-model="exportParam.date" :editable="false" format="yyyy-MM" value-format="yyyy-MM" :clearable="false" type="month" :placeholder="$t('Selectmonth')" style="margin-right: 20px"></el-date-picker>
                 </el-form-item>
             </el-form>
-            <el-form ref="form3" :model="exportParam" v-else>
+            <div slot="footer" class="dialog-footer">
+                <el-button type="primary" @click="exportMonthlyProjectData" style="width:100%;" :loading="exporting">{{ $t('export.export') }}</el-button>
+            </div>
+        </el-dialog>
+        <!--导出报表条件选择 -->
+        <el-dialog :title="$t('timeReportExport')" v-if="exportDialog" :visible.sync="exportDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
+            
+            <el-form ref="form3" :model="exportParam" >
+                <el-form-item :label="this.$t('Selectmonth')" v-if="user.companyId == 10 && radio==$t('other.project')">
+                    <el-date-picker size="small" v-model="exportParam.date" :editable="false" format="yyyy-MM" value-format="yyyy-MM" :clearable="false" type="month" :placeholder="$t('Selectmonth')" style="margin-right: 20px"></el-date-picker>
+                </el-form-item>
                 <el-form-item prop="projectCategoryId" :label="$t('projectclassification')" v-if="radio == $t('projectclassification')||radio==$t('other.project')">
                     <el-select v-model="exportParam.projectCategoryId" :placeholder="$t('classificationitems')"  clearable style="width:350px;" filterable="true" @change="filterCategory">
                         <el-option v-for="item in categoryList"  :key="item.id" :label="item.name" :value="item.id">
@@ -216,6 +227,7 @@
         },
         data() {
             return {
+                selectMonthExportDialog: false,
                 exporting: false,
                 totalTime111: 0,
                 allListData: [],
@@ -340,9 +352,6 @@
 
                 this.exportDialog = true;
                 this.exportParam.dateRange = this.dateRange;
-                var array = this.exportParam.dateRange[0].split('-');
-                this.exportParam.date = array[0] + '-' + array[1];
-                console.log(this.exportParam.date)
                 this.$forceUpdate();
                 if (this.radio == this.$t('ren-yuan')) {
                     // this.exportParam.userIds = [];
@@ -388,6 +397,39 @@
                     });
                 });
             },
+            showExportMonthlyDataDialog() {
+                this.selectMonthExportDialog = true;
+                var array = this.exportParam.dateRange[0].split('-');
+                this.exportParam.date = array[0] + '-' + array[1];
+            },
+            exportMonthlyProjectData() {
+                var url = '/project/exportTimeByProjectAndEmployee';
+                var fileName = this.exportParam.date + '月度工时成本统计表.xlsx';
+                this.exporting = true;
+                this.http.post(url, this.exportParam,
+                    res => {
+                        this.exporting = false;
+                        if (res.code == "ok") {
+                            this.exportDialog = false;
+                            var aTag = document.createElement('a');
+                            aTag.download = fileName;
+                            aTag.href = res.data;
+                            aTag.click();
+                        } else {
+                            this.$message({
+                                message: res.msg,
+                                type: "error"
+                            });
+                        }
+                    },
+                    error => {
+                        this.$message({
+                            message: error,
+                            type: "error"
+                        });
+                        this.exporting = false;
+                    });
+            },
             exportProjectData() {
                  var param = {stateKey: 1};
                  if (this.exportParam.dateRange != null) {
@@ -413,11 +455,6 @@
                      if (this.exportParam.withPercent) {
                         param.withPercent = 1;
                      }
-                     if (this.user.companyId == 10) {
-                        param.date = this.exportParam.date;
-                        url = '/project/exportTimeByProjectAndEmployee';
-                        fileName = param.date + '月度工时成本统计表.xlsx';
-                     }
                  }
                  if (this.radio == this.$t('ren-yuan') ) {
                     //  console.log(this.exportParam.userIds);