Преглед изворни кода

调整赛元微电子导出员工填报工时占比年月错误的问题

Lijy пре 1 година
родитељ
комит
daaea5b2b4
1 измењених фајлова са 19 додато и 4 уклоњено
  1. 19 4
      fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

+ 19 - 4
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -2954,10 +2954,25 @@
             //下载填报工时占比报表
             downloadProjectRatio() {
                 this.exportUserRatio = true;
-                let now = new Date();
-                let month = now.getMonth();//默认看上个月的
-                let monthStr = month<10? ('0'+month): month;
-                this.ratioYmonth = now.getFullYear()+''+monthStr;
+                // let now = new Date();
+                // let month = now.getMonth();//默认看上个月的
+                // let monthStr = month<10? ('0'+month): month;
+                // this.ratioYmonth = now.getFullYear()+''+monthStr;
+                const today = new Date();
+                const year = today.getFullYear();
+                const month = today.getMonth() + 1; 
+
+                let lastMonthYear, lastMonth;
+
+                if (month === 1) {
+                    lastMonthYear = year - 1;
+                    lastMonth = 12;
+                } else {
+                    lastMonthYear = year;
+                    lastMonth = month - 1;
+                }
+                this.ratioYmonth = lastMonthYear+''+(lastMonth < 10 ? '0' + lastMonth : lastMonth)
+                console.log('赋值 ==>', this.ratioYmonth)
             },
             confirmDownloadRatio() {
                 this.startRatioExporting = true;