From fb814a1ea0062a8ac3b1c60d0d22e20e3fa3ee11 Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期四, 04 六月 2026 09:50:36 +0800
Subject: [PATCH] 1.app生产报工新增   本季度  上一季度的时间过滤

---
 pages/scgl/scbg.vue |  103 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 98 insertions(+), 5 deletions(-)

diff --git a/pages/scgl/scbg.vue b/pages/scgl/scbg.vue
index f97185d..237490a 100644
--- a/pages/scgl/scbg.vue
+++ b/pages/scgl/scbg.vue
@@ -173,6 +173,17 @@
 						<u-button :plain='custom' style="width: 70px;height: 25px;" @click="dateChange('custom')"
 							type="primary" shape="circle" text="鑷畾涔�"></u-button>
 					</view>
+
+					<view class="head_block" style="height: 80rpx; display: flex;justify-content: space-around;">
+						<u-button :plain='currentQuarter' style="width: 70px;height: 25px;"
+							@click="dateChange('currentQuarter')" type="primary" shape="circle" text="鏈搴�">
+						</u-button>
+						<u-button :plain='lastQuarter' style="width: 70px;height: 25px;"
+							@click="dateChange('lastQuarter')" type="primary" shape="circle" text="涓婁竴瀛e害">
+						</u-button>
+
+					</view>
+
 				</view>
 
 				<view v-if="!custom" class="flex_column"
@@ -256,12 +267,14 @@
 				today: true,
 				month: false,
 				custom: true,
+				currentQuarter: true,
+				lastQuarter: true,
 
 				// calendarRange: new Date().toISOString().slice(0, 10) + '~' + new Date().toISOString().slice(0,
 				// 10), //绯荤粺褰撳墠鏃ユ湡
-				calendarRange: new Date().getFullYear() + '-' + (new Date().getMonth() + 1).toString().padStart(
-					2, '0') + '-01' + '~' + new Date().toISOString().slice(0, 10), //褰撴湀鏃ユ湡
-
+				// calendarRange: new Date().getFullYear() + '-' + (new Date().getMonth() + 1).toString().padStart(
+				// 	2, '0') + '-01' + '~' + new Date().toISOString().slice(0, 10), //褰撴湀鏃ユ湡
+				calendarRange: '',
 
 
 				tagArr: [
@@ -292,7 +305,7 @@
 			}
 		},
 		created() {
-
+			this.dateChange('currentQuarter')
 		},
 		mounted() {
 			this.init()
@@ -495,13 +508,16 @@
 					this.today = false
 					this.month = true
 					this.custom = true
+					this.currentQuarter = true
+					this.lastQuarter = true
 					this.calendarRange = new Date().toISOString().slice(0, 10) + '~' + new Date().toISOString().slice(0,
 						10)
 				} else if (val === 'month') {
 					this.today = true
 					this.month = false
 					this.custom = true
-
+					this.currentQuarter = true
+					this.lastQuarter = true
 					this.calendarRange = new Date().getFullYear() + '-' + (new Date().getMonth() + 1).toString().padStart(
 						2, '0') + '-01' + '~' + new Date().toISOString().slice(0, 10)
 
@@ -509,11 +525,88 @@
 					this.today = true
 					this.month = true
 					this.custom = false
+					this.currentQuarter = true
+					this.lastQuarter = true
 					this.calendarRange = new Date().getFullYear() + '-' + (new Date().getMonth() + 1).toString().padStart(
 						2, '0') + '-01' + '~' + new Date().toISOString().slice(0, 10)
+				} else if (val === 'currentQuarter') {
+					this.today = true
+					this.month = true
+					this.custom = true
+					this.currentQuarter = false
+					this.lastQuarter = true
+
+					this.calendarRange = this.getCurrentQuarter().start + '~' + this.getCurrentQuarter().end
+				} else if (val === 'lastQuarter') {
+					this.today = true
+					this.month = true
+					this.custom = true
+					this.currentQuarter = true
+					this.lastQuarter = false
+					this.calendarRange = this.getLastQuarter().start + '~' + this.getLastQuarter().end
+
 				}
 			},
 
+
+
+			// 鑾峰彇 鏈搴� 寮�濮嬨�佺粨鏉熸棩鏈�
+			getCurrentQuarter() {
+				const now = new Date()
+				const year = now.getFullYear()
+				const month = now.getMonth() // 0-11
+
+				// 褰撳墠瀛e害
+				const quarter = Math.floor(month / 3)
+				const startMonth = quarter * 3
+				const endMonth = startMonth + 2
+
+				const start = new Date(year, startMonth, 1)
+				const end = new Date(year, endMonth + 1, 0) // 鍙栧綋鏈堟渶鍚庝竴澶�
+
+				return {
+					start: this.formatDate(start),
+					end: this.formatDate(end)
+				}
+			},
+
+			// 鑾峰彇 涓婁竴瀛e害 寮�濮嬨�佺粨鏉熸棩鏈�
+			getLastQuarter() {
+				const now = new Date()
+				const year = now.getFullYear()
+				const month = now.getMonth()
+
+				let quarter = Math.floor(month / 3)
+				let lastQuarter = quarter - 1
+				let lastYear = year
+
+				// 濡傛灉鏄涓�瀛e害锛屼笂瀛e害灏辨槸鍘诲勾绗洓瀛e害
+				if (lastQuarter < 0) {
+					lastQuarter = 3
+					lastYear = year - 1
+				}
+
+				const startMonth = lastQuarter * 3
+				const endMonth = startMonth + 2
+
+				const start = new Date(lastYear, startMonth, 1)
+				const end = new Date(lastYear, endMonth + 1, 0)
+
+				return {
+					start: this.formatDate(start),
+					end: this.formatDate(end)
+				}
+			},
+
+			// 鏃ユ湡鏍煎紡鍖栵細yyyy-MM-dd
+			formatDate(date) {
+				const y = date.getFullYear()
+				const m = (date.getMonth() + 1).toString().padStart(2, '0')
+				const d = date.getDate().toString().padStart(2, '0')
+				return `${y}-${m}-${d}`
+			},
+
+
 			// 鏃ュ巻鏃堕棿鐐瑰嚮
 			calendarClick() {
 				this.$refs.calendar.open();

--
Gitblit v1.9.3