瀏覽代碼

提交工单选项

Lijy 4 周之前
父節點
當前提交
1061e7d918
共有 1 個文件被更改,包括 53 次插入2 次删除
  1. 53 2
      fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

+ 53 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

@@ -33,6 +33,7 @@
                         <el-radio-button :label="$t('lable.department')"
                             v-if="(permissions.viewAllSummary || permissions.viewMagDeptSummary)"></el-radio-button>
                         <el-radio-button :label="$t('ren-yuan')" v-if="permissions.countPersonnel"></el-radio-button>
+                        <el-radio-button label="工单" v-if="user.companyId == 7536"></el-radio-button>
                         <el-radio-button :label="namess"
                             v-if="jichu.customDegreeActive == 1 && !jichu.customDegreeMultiple"></el-radio-button>
                         <el-radio-button v-for="item in theCustomList" :key="item.id"
@@ -57,8 +58,10 @@
                         @change="filterPersonnel"></select-personnel>
                 </el-col>
                 <el-col :span="2" style="display: flex;justify-content: flex-end;">
+                    <el-button @click="reportExportCustomization" size="small" :loading="reportExportLoading"
+                        v-if="user.companyId == 7536">报表导出</el-button>
                     <el-button @click="exportTheCustomListFlg" size="small" :loading="theCustomListFlgBtnLoading"
-                        v-if="theCustomListFlg">报表导</el-button>
+                        v-else-if="theCustomListFlg">报表导</el-button>
                     <el-button @click="showExportDialog" size="small" v-else>报表导出</el-button>
                 </el-col>
             </el-row>
@@ -215,6 +218,10 @@ export default {
                     url: '/device-log/getDeviceTimeCost',
                     extraParams: { projectId: this.chartProjectId }
                 },
+                ['工单']: {
+                    url: '/project/getTimeCostByWorkNum',
+                    extraParams: { }
+                },
                 [this.namess]: {
                     url: '/project/getDegreeCost',
                     extraParams: { projectId: this.chartProjectId }
@@ -347,11 +354,39 @@ export default {
                 this.pageTotal = this.allListData ? this.allListData.length : 0
                 list = this.allListData.slice(0 + 10 * (this.pageIndex - 1), 49 + 50 * (this.pageIndex - 1))
                 newBarChartOptions = this.namessChartData(list, totalMoneyCost, newBarChartOptions)
-            }
+            } else if (this.singleChoiceType == '工单') {
+                newBarChartOptions = this.workOrderChartData(list, totalMoneyCost, newBarChartOptions)
+            } 
 
             console.log({ ...newBarChartOptions }, '<==== 图表数据')
             this.echartsEcharData = { ...newBarChartOptions }
         },
+        workOrderChartData(list, totalMoneyCost = 0, chartData) { // 工单图表数据
+            let xList = [], yList = [], totalHours = 0;
+            const yAxisValue = this.chartYAxisVal[this.chartYAxis]
+            const { countCost, countHours } = this.permissions
+            for (let i in list) {
+                xList.push(this.nameNumber == '1' ? list[i].workNum : list[i].workNum);
+
+                let item = {
+                    "value": yAxisValue == 0 ? (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0) || list[i].costMoney : (list[i].cost ? list[i].cost.toFixed(1) : 0),
+                    "id": list[i].id || i,
+                }
+                if (countCost) {
+                    item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
+                }
+                if (countHours) {
+                    item.cost = list[i].cost
+                    totalHours += parseFloat(list[i].cost);
+                }
+                yList.push(item);
+            }
+
+            totalHours = this.totalHours.toFixed(1);
+            totalMoneyCost = totalMoneyCost.toFixed(2)
+
+            return { ...this.sameChartProcessing(xList, yList, totalHours, totalMoneyCost, chartData) }
+        },
         equipmentChartData(list, totalMoneyCost = 0, chartData) { // 设备图表数据
             let xList = [], yList = [], totalHours = 0;
             const yAxisValue = this.chartYAxisVal[this.chartYAxis]
@@ -1041,6 +1076,22 @@ export default {
         showExportDialog() { // 显示报表导出
             this.reportExportVisable = true
         },
+        reportExportCustomization() { // 报表导出
+            var url = '/project/exportTimeCostByWorkNum';
+            var fileName = this.chartDate.join('至') + '工单统计表.xlsx';
+            this.reportExportLoading = true;
+            this.postData(url, {
+                startDate: this.chartDate[0],
+                endDate: this.chartDate[1],
+            }).then((res) => {
+                const aTag = document.createElement('a');
+                aTag.download = fileName;
+                aTag.href = res.data;
+                aTag.click()
+            }).finally(() => {
+                this.reportExportLoading = false
+            })
+        },
         // 单独封装请求
         async postData(urls, param) {
             return new Promise((resolve, reject) => {