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); } //时间转换