From bac08f72eb1ebf7f527ab985ac3220403518ad48 Mon Sep 17 00:00:00 2001 From: FCD <2453864257@qq.com> Date: Mon, 26 Jan 2026 15:08:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=99=E6=A0=B7=E6=A3=80=E9=AA=8C=EF=BC=8C?= =?UTF-8?q?=E8=B7=A8=E5=B9=B4=E6=9C=88=E4=BB=BD=E8=AE=A1=E7=AE=97=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/quality/SampleCheck/index.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pages/quality/SampleCheck/index.vue b/src/pages/quality/SampleCheck/index.vue index 39a186b..415c83d 100644 --- a/src/pages/quality/SampleCheck/index.vue +++ b/src/pages/quality/SampleCheck/index.vue @@ -164,8 +164,7 @@ import { getManagerList, getQcWaitCheckSampleTaskList, getWorkshopList, - submitCheckSampleTaskZl0030, - updateQcCheckSampleTask + submitCheckSampleTaskZl0030 } from './model'; import moment from 'moment'; import PageHead from '@/components/lanju/page-head/index.vue'; @@ -312,8 +311,17 @@ export default class SampleCheck extends BasePage { //计算时间差 timeDifference(time: any) { //留样时间戳 - const sampleTime = new Date(moment(time).format('YYYY-MM-DD')).getMonth(); - return new Date().getMonth() - sampleTime; + const targetDate = moment(time).toDate(); // 直接转Date对象更高效 + + // 2. 获取当前时间和目标时间的年、月 + const now = new Date(); + const currentYear = now.getFullYear(); + const currentMonth = now.getMonth(); + const targetYear = targetDate.getFullYear(); + const targetMonth = targetDate.getMonth(); + + // 3. 核心计算:结合年份和月份计算总差值 + return (currentYear - targetYear) * 12 + (currentMonth - targetMonth); } //时间转换