From 7b818cacf47927b0d09be976ab08d848de6caf59 Mon Sep 17 00:00:00 2001
From: fengyuan_yang <1976974459@qq.com>
Date: Wed, 10 Jun 2026 15:13:26 +0800
Subject: [PATCH] =?UTF-8?q?2026-06-10=20RoHs=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/modules/rohs/rohsRecord.vue | 137 ++++++++++++++++++++++++--
1 file changed, 131 insertions(+), 6 deletions(-)
diff --git a/src/views/modules/rohs/rohsRecord.vue b/src/views/modules/rohs/rohsRecord.vue
index 01e2a1d..14bdc24 100644
--- a/src/views/modules/rohs/rohsRecord.vue
+++ b/src/views/modules/rohs/rohsRecord.vue
@@ -378,10 +378,18 @@
-
+
+
+
+
+
+
+
+
+
-
+
+ style="width: 190px">
-
+
+
+
+
-
+
是
否
@@ -411,7 +422,7 @@
true-label="Y"
false-label="N"
:disabled="isRohsFieldDisabled('isAhGrade')"
- style="width: 200px">材料属性是否是AH/Is AH Grade
+ style="width: 190px">材料属性是否是AH/Is AH Grade
@@ -919,6 +930,11 @@
+
+
+
+
+
@@ -928,6 +944,9 @@
+
+
+
@@ -1301,7 +1320,9 @@ export default {
remark: '',
status: '',
sgsReportNumber: '',
+ rohsStatus: 'Active',
expiredDate: '',
+ expiryDate: '',
fiberInformation: '',
hsfStandard: '',
hsfApprover: '',
@@ -1365,6 +1386,15 @@ export default {
})
}
},
+ 'modalData.expiredDate' () {
+ this.syncExpiryDateByRule()
+ },
+ 'modalData.validUntilValue' () {
+ this.syncExpiryDateByRule()
+ },
+ 'modalData.validUntil' () {
+ this.syncExpiryDateByRule()
+ },
'modalData.endCustomer' () {
this.applyHsfStandardDefaultByCustomer(this.modalData)
}
@@ -1494,6 +1524,92 @@ export default {
}
return text.length >= 10 ? text.substring(0, 10) : text
},
+ parseDateOnly (value) {
+ const text = this.normalizeDateOnly(value)
+ if (!text) {
+ return null
+ }
+ const parts = text.split('-')
+ if (parts.length !== 3) {
+ return null
+ }
+ const year = Number.parseInt(parts[0], 10)
+ const month = Number.parseInt(parts[1], 10)
+ const day = Number.parseInt(parts[2], 10)
+ if (Number.isNaN(year) || Number.isNaN(month) || Number.isNaN(day)) {
+ return null
+ }
+ const date = new Date(year, month - 1, day)
+ if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
+ return null
+ }
+ return date
+ },
+ normalizeValidUntilUnitType (unitValue) {
+ const text = String(unitValue || '').trim().toLowerCase()
+ if (!text) {
+ return ''
+ }
+ if (text === 'd' || text === 'day' || text === 'days' || text.includes('日')) {
+ return 'day'
+ }
+ if (text === 'w' || text === 'week' || text === 'weeks' || text.includes('周')) {
+ return 'week'
+ }
+ if (text === 'm' || text === 'month' || text === 'months' || text.includes('月')) {
+ return 'month'
+ }
+ if (text === 'y' || text === 'year' || text === 'years' || text.includes('年')) {
+ return 'year'
+ }
+ return ''
+ },
+ addMonthsKeepDay (baseDate, monthDelta) {
+ const year = baseDate.getFullYear()
+ const month = baseDate.getMonth()
+ const day = baseDate.getDate()
+ const targetFirstDay = new Date(year, month + monthDelta, 1)
+ const targetYear = targetFirstDay.getFullYear()
+ const targetMonth = targetFirstDay.getMonth()
+ const lastDay = new Date(targetYear, targetMonth + 1, 0).getDate()
+ return new Date(targetYear, targetMonth, Math.min(day, lastDay))
+ },
+ addYearsKeepDay (baseDate, yearDelta) {
+ const targetYear = baseDate.getFullYear() + yearDelta
+ const month = baseDate.getMonth()
+ const day = baseDate.getDate()
+ const lastDay = new Date(targetYear, month + 1, 0).getDate()
+ return new Date(targetYear, month, Math.min(day, lastDay))
+ },
+ calculateExpiryDateByRule (reportDate, validUntilValue, validUntilUnit) {
+ const baseDate = this.parseDateOnly(reportDate)
+ const durationValue = this.normalizeValidUntilValue(validUntilValue)
+ const unitType = this.normalizeValidUntilUnitType(validUntilUnit)
+ if (!baseDate || !durationValue || !unitType) {
+ return ''
+ }
+ let resultDate = new Date(baseDate.getTime())
+ if (unitType === 'day') {
+ resultDate.setDate(resultDate.getDate() + durationValue)
+ } else if (unitType === 'week') {
+ resultDate.setDate(resultDate.getDate() + durationValue * 7)
+ } else if (unitType === 'month') {
+ resultDate = this.addMonthsKeepDay(baseDate, durationValue)
+ } else if (unitType === 'year') {
+ resultDate = this.addYearsKeepDay(baseDate, durationValue)
+ } else {
+ return ''
+ }
+ return this.normalizeDateOnly(resultDate)
+ },
+ syncExpiryDateByRule () {
+ if (!this.modalData) {
+ return ''
+ }
+ const expiryDate = this.calculateExpiryDateByRule(this.modalData.expiredDate, this.modalData.validUntilValue, this.modalData.validUntil)
+ this.$set(this.modalData, 'expiryDate', expiryDate)
+ return expiryDate
+ },
getCurrentDateString () {
return this.normalizeDateOnly(new Date())
},
@@ -2154,8 +2270,12 @@ export default {
this.$set(target, 'validUntilValue', this.normalizeValidUntilValue(validUntilValue))
const applicationDate = target.applicationDate || fallbackData.applicationDate || ''
const plannedMassProductionDate = target.plannedMassProductionDate || fallbackData.plannedMassProductionDate || ''
+ const expiredDate = target.expiredDate || fallbackData.expiredDate || ''
+ const normalizedExpiredDate = this.normalizeDateOnly(expiredDate)
this.$set(target, 'applicationDate', this.normalizeDateOnly(applicationDate))
this.$set(target, 'plannedMassProductionDate', this.normalizeDateOnly(plannedMassProductionDate))
+ this.$set(target, 'expiredDate', normalizedExpiredDate)
+ this.$set(target, 'expiryDate', this.calculateExpiryDateByRule(normalizedExpiredDate, target.validUntilValue, target.validUntil))
},
refreshCurrentTabTable () {
if (this.activeTable === 'approvalInformation') {
@@ -2300,6 +2420,7 @@ export default {
row.plannedMassProductionDate = this.normalizeDateOnly(row.plannedMassProductionDate)
row.expectReportTime = this.normalizeDateOnly(row.expectReportTime)
row.expiredDate = this.normalizeDateOnly(row.expiredDate)
+ row.expiryDate = this.normalizeDateOnly(row.expiryDate)
row.validUntilDisplay = this.getValidUntilDisplay(row.validUntilValue, row.validUntil)
return row
})
@@ -2482,7 +2603,9 @@ export default {
remark: '',
status: '草稿',
sgsReportNumber: '',
+ rohsStatus: 'Active',
expiredDate: '',
+ expiryDate: '',
fiberInformation: '',
hsfStandard: '',
hsfApprover: '',
@@ -2522,6 +2645,7 @@ export default {
if (!this.validateValidUntilPair()) {
return
}
+ this.syncExpiryDateByRule()
this.modalData.qualificationDocumentsNeeded = this.modalData.qualificationDocumentsNeededList.join(';')
this.modalData.testReportIncludingItems = this.modalData.testReportIncludingItemsList.join(';')
this.modalData.materialClassify = this.modalData.materialClassifyList.join(';')
@@ -2593,6 +2717,7 @@ export default {
if (!this.validateValidUntilPair()) {
return
}
+ this.syncExpiryDateByRule()
if (!this.nodeAuthorityLoaded) {
this.$message.warning('节点权限加载中,请稍后重试')
return