From 951b0558a6c3990e1c0ca792aed332914228508d Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期二, 13 十月 2026 17:45:08 +0800
Subject: [PATCH] 设备模块调整:档案修订新增保养、核查日期与周期并自动计算下次日期,列表新增核查、保养相关列且到期前一个月标红;设备校准的服务机构改为合格供应商下拉,使用授权的被授权人改为检测员下拉;设备树改为全部/设备/计量器具分类;保养计划明细新增计划保养时间;移除量值溯源计划页签

---
 src/views/CNAS/resourceDemand/device/component/management.vue |  217 +++++++++++++++++++++++++++++++++---------------------
 1 files changed, 133 insertions(+), 84 deletions(-)

diff --git a/src/views/CNAS/resourceDemand/device/component/management.vue b/src/views/CNAS/resourceDemand/device/component/management.vue
index e4b42a1..eb3cbd2 100644
--- a/src/views/CNAS/resourceDemand/device/component/management.vue
+++ b/src/views/CNAS/resourceDemand/device/component/management.vue
@@ -75,7 +75,9 @@
 				<el-col :span="7">
 					<el-form :label-position="labelPosition" :model="formData" label-width="116px">
 						<el-form-item label="鏍″噯鏈嶅姟鏈烘瀯:">
-							<el-input :disabled="isUp" v-model="formData.calibrationServices" size="small"></el-input>
+							<el-select :disabled="isUp" v-model="formData.calibrationServices" clearable filterable size="small" style="width: 100%">
+								<el-option v-for="name in calibrationServiceOptions" :key="name" :label="name" :value="name"></el-option>
+							</el-select>
 						</el-form-item>
 						<el-form-item label="璧勪骇缂栫爜:">
 							<el-input v-model="formData.assetCode" :disabled="isUp" size="small"></el-input>
@@ -119,27 +121,18 @@
 				<!-- 鍙宠竟甯冨眬 -->
 				<el-col :span="7">
 					<el-form :label-position="labelPosition" :model="formData" label-width="140px" ref="ruleForm">
-						<!-- 瀹為獙瀹ゅ垪琛� -->
-						<el-form-item label="鎵�灞為儴闂�:" required>
-							<el-select :disabled="isUp" v-model="formData.subordinateDepartmentsId" placeholder="璇烽�夋嫨" size="small"
-								style="width:100%">
-								<el-option v-for="item in subordinateDepartmentsList" :key="item.value" :label="item.label"
-									:value="item.value">
-								</el-option>
-							</el-select>
-						</el-form-item>
 						<el-form-item label="妫�娴嬮」鐩�:">
 							<el-cascader :disabled="isUp" v-model="formData.insProductIds" :options="options" :show-all-levels="false"
 								:props="props" placeholder="璇烽�夋嫨" size="small" style="width:100%;" :collapse-tags="!isUp" separator=","
 								filterable clearable></el-cascader>
 						</el-form-item>
 						<el-form-item label="鏈�杩戞牎鍑嗘棩鏈�:">
-							<el-date-picker :disabled="isUp" style="width:100%" v-model="formData.lastCalibrationDate"
+							<el-date-picker :disabled="isUp" style="width:100%" v-model="formData.lastCalibrationDate" @change="calcNextDate(formData)"
 								format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" type="date" size="small" placeholder="閫夋嫨鏃ユ湡">
 							</el-date-picker>
 						</el-form-item>
 						<el-form-item label="涓嬫鏍″噯鏃ユ湡:">
-							<el-date-picker :disabled="isUp" style="width:100%" v-model="formData.nextCalibrationDate"
+							<el-date-picker :disabled="true" style="width:100%" v-model="formData.nextCalibrationDate"
 								format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" type="date" size="small" placeholder="閫夋嫨鏃ユ湡">
 							</el-date-picker>
 						</el-form-item>
@@ -161,12 +154,38 @@
 							</el-select>
 						</el-form-item>
 						<el-form-item label="鏍″噯鍛ㄦ湡锛堟湀锛�:" required>
-							<el-input :disabled="isUp" v-model="formData.calibrationDate" size="small"></el-input>
+							<el-input :disabled="isUp" v-model="formData.calibrationDate" size="small" @change="calcNextDate(formData)"></el-input>
+						</el-form-item>
+						<el-form-item label="鏈�杩戜繚鍏绘棩鏈�:">
+							<el-date-picker :disabled="isUp" style="width:100%" v-model="formData.lastMaintenanceDate" @change="calcNextDate(formData)"
+								format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" type="date" size="small" placeholder="閫夋嫨鏃ユ湡">
+							</el-date-picker>
+						</el-form-item>
+						<el-form-item label="涓嬫淇濆吇鏃ユ湡:">
+							<el-date-picker :disabled="true" style="width:100%" v-model="formData.nextMaintenanceDate"
+								format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" type="date" size="small" placeholder="閫夋嫨鏃ユ湡">
+							</el-date-picker>
+						</el-form-item>
+						<el-form-item label="淇濆吇鍛ㄦ湡锛堟湀锛�:">
+							<el-input :disabled="isUp" v-model="formData.maintenanceCycle" size="small" @change="calcNextDate(formData)"></el-input>
+						</el-form-item>
+						<el-form-item label="鏈�杩戞牳鏌ユ棩鏈�:">
+							<el-date-picker :disabled="isUp" style="width:100%" v-model="formData.lastExamineDate" @change="calcNextDate(formData)"
+								format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" type="date" size="small" placeholder="閫夋嫨鏃ユ湡">
+							</el-date-picker>
+						</el-form-item>
+						<el-form-item label="涓嬫鏍告煡鏃ユ湡:">
+							<el-date-picker :disabled="true" style="width:100%" v-model="formData.nextExamineDate"
+								format="YYYY-MM-DD" value-format="YYYY-MM-DD HH:mm:ss" type="date" size="small" placeholder="閫夋嫨鏃ユ湡">
+							</el-date-picker>
+						</el-form-item>
+						<el-form-item label="鏍告煡鍛ㄦ湡锛堟湀锛�:">
+							<el-input :disabled="isUp" v-model="formData.examineCycle" size="small" @change="calcNextDate(formData)"></el-input>
 						</el-form-item>
 						<el-form-item label="琚巿鏉冧汉:">
 							<el-select v-model="formData.authorizedPerson" multiple :disabled="isUp" placeholder="璇烽�夋嫨" size="small"
 								style="width:100%">
-								<el-option v-for="item in responsiblePersonList" :key="item.value" :label="item.label"
+								<el-option v-for="item in inspectorList" :key="item.value" :label="item.label"
 									:value="item.value">
 								</el-option>
 							</el-select>
@@ -186,7 +205,7 @@
 				</el-col>
 			</el-row>
 			<template #footer><span  class="dialog-footer">
-				<el-row v-if="!isUp">
+				<el-row v-if="!isUp" justify="end">
 					<el-button @click="handleClose">鍙� 娑�</el-button>
 					<el-button type="primary" @click="submitForm" :loading="upLoad">纭� 瀹�</el-button>
 				</el-row>
@@ -235,7 +254,9 @@
               <el-input v-model="formData2.factoryNo" size="small"></el-input>
             </el-form-item> -->
 						<el-form-item label="鏍″噯鏈嶅姟鏈烘瀯:">
-							<el-input v-model="formData2.calibrationServices" size="small"></el-input>
+							<el-select v-model="formData2.calibrationServices" clearable filterable size="small" style="width: 100%">
+								<el-option v-for="name in calibrationServiceOptions2" :key="name" :label="name" :value="name"></el-option>
+							</el-select>
 						</el-form-item>
 						<el-form-item label="璧勪骇缂栫爜:">
 							<el-input v-model="formData2.assetCode" size="small"></el-input>
@@ -277,26 +298,18 @@
 				<!-- 鍙宠竟甯冨眬 -->
 				<el-col :span="7">
 					<el-form :label-position="labelPosition" :model="formData2" label-width="120px" ref="ruleForm">
-						<!-- 瀹為獙瀹ゅ垪琛� -->
-						<el-form-item label="鎵�灞為儴闂�:" required>
-							<el-select v-model="formData2.subordinateDepartmentsId" placeholder="璇烽�夋嫨" size="small" style="width:100%">
-								<el-option v-for="item in subordinateDepartmentsList" :key="item.value" :label="item.label"
-									:value="item.value">
-								</el-option>
-							</el-select>
-						</el-form-item>
 						<el-form-item label="妫�娴嬮」鐩�:">
 							<el-cascader v-model="formData2.insProductIds" :options="options" :show-all-levels="false" :props="props"
 								placeholder="璇烽�夋嫨" size="small" style="width:100%" collapse-tags separator="," filterable
 								clearable></el-cascader>
 						</el-form-item>
 						<el-form-item label="鏈�杩戞牎鍑嗘棩鏈�:">
-							<el-date-picker style="width:100%" v-model="formData2.lastCalibrationDate" format="YYYY-MM-DD"
+							<el-date-picker style="width:100%" v-model="formData2.lastCalibrationDate" format="YYYY-MM-DD" @change="calcNextDate(formData2)"
 								value-format="YYYY-MM-DD HH:mm:ss" type="date" size="small" placeholder="閫夋嫨鏃ユ湡">
 							</el-date-picker>
 						</el-form-item>
 						<el-form-item label="涓嬫鏍″噯鏃ユ湡:">
-							<el-date-picker style="width:100%" v-model="formData2.nextCalibrationDate" format="YYYY-MM-DD"
+							<el-date-picker :disabled="true" style="width:100%" v-model="formData2.nextCalibrationDate" format="YYYY-MM-DD"
 								value-format="YYYY-MM-DD HH:mm:ss" type="date" size="small" placeholder="閫夋嫨鏃ユ湡">
 							</el-date-picker>
 						</el-form-item>
@@ -316,12 +329,12 @@
 							</el-select>
 						</el-form-item>
 						<el-form-item label="鏍″噯鍛ㄦ湡锛堟湀锛�:" required>
-							<el-input v-model="formData2.calibrationDate" size="small"></el-input>
+							<el-input v-model="formData2.calibrationDate" size="small" @change="calcNextDate(formData2)"></el-input>
 						</el-form-item>
 						<el-form-item label="琚巿鏉冧汉:">
 							<el-select v-model="formData2.authorizedPerson" multiple placeholder="璇烽�夋嫨" size="small"
 								style="width:100%">
-								<el-option v-for="item in responsiblePersonList" :key="item.value" :label="item.label"
+								<el-option v-for="item in inspectorList" :key="item.value" :label="item.label"
 									:value="item.value">
 								</el-option>
 							</el-select>
@@ -341,7 +354,7 @@
 				</el-col>
 			</el-row>
 			<template #footer><span  class="dialog-footer">
-				<el-row>
+				<el-row justify="end">
 					<el-button @click="handleClose2">鍙� 娑�</el-button>
 					<el-button type="primary" @click="submitForm2" :loading="upLoad2">纭� 瀹�</el-button>
 				</el-row>
@@ -377,7 +390,7 @@
 				<el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="configForm.formula"></el-input>
 			</div>
 			<template #footer><span  class="dialog-footer">
-				<el-row>
+				<el-row justify="end">
 					<el-button @click="dialogVisible3 = false">鍙� 娑�</el-button>
 					<el-button type="primary" @click="submitForm3" :loading="upLoad3">纭� 瀹�</el-button>
 				</el-row>
@@ -399,8 +412,9 @@
 	getDeviceParameter,
 	delDeviceParameter,
 } from '@/api/cnas/resourceDemand/device.js'
-import { listDept } from '@/api/system/dept'
 import { selectUserCondition } from "@/api/business/inspectionTask";
+import dayjs from 'dayjs'
+import { selectQualifiedSupplierManagementPage } from '@/api/cnas/externalService/supplierManage/supplierManage'
 export default {
 	props: {
 		clickNodeVal: {
@@ -418,6 +432,7 @@
 		return {
 			dateFormat: 'yyyy-MM-dd',
 			deviceId: '',
+			qualifiedSupplierNames: [],
 			fileTypeOptions: [
 				{ label: 'csv', value: '.csv' },
 				{ label: 'db', value: '.db' },
@@ -453,16 +468,15 @@
 			responsiblePersonList: [],
 			// 鎺堟潈浜哄垪琛�
 			authorizerList: [],
+			// 妫�娴嬪憳鍒楄〃锛堣鎺堟潈浜轰笅鎷夛級
+			inspectorList: [],
 			// 褰撳墠鐘舵�佸垪琛�
 			deviceStatusList: [],
-			// 鎵�灞為儴闂�
-			subordinateDepartmentsList: [],
 			upLoad: false,
 			upLoad2: false,
 			dialogVisible3: false,
 			upLoad3: false,
 			configForm: {},
-			laboratoryNameIsNull: false,
 			queryParams: {},
 			tableData: [],
 			column: [
@@ -480,13 +494,14 @@
 				{ label: "鏍″噯鏈夋晥鏈�", prop: "activationDate" },
 				{ label: "绠$悊浜�", prop: "equipmentManagerUser" },
 				{ label: "瀛樻斁鐐�", prop: "storagePoint" },
-				{ label: "鎵�灞為儴闂�", prop: "laboratoryName" },
 				{ label: "妫�楠岄」鐩�", prop: "insProductItem" },
 				{ label: "鏍″噯鏈嶅姟鏈烘瀯", prop: "calibrationServices" },
 				{ label: "鏈�杩戞牎鍑嗘棩鏈�", prop: "lastCalibrationDateTwo" },
-				{ label: "鏈�杩戞牳鏌ユ棩鏈�", prop: "lastCalibrationDate" },
+				{ label: "鏈�杩戞牳鏌ユ棩鏈�", prop: "lastExamineDate" },
 				{ label: "涓嬫鏍″噯鏃ユ湡", prop: "nextCalibrationDateTwo" },
-				{ label: "涓嬫鏍告煡鏃ユ湡", prop: "nextCalibrationDate" },
+				{ label: "涓嬫鏍告煡鏃ユ湡", prop: "nextExamineDate" },
+				{ label: "鏈�杩戜繚鍏绘棩鏈�", prop: "lastMaintenanceDate" },
+				{ label: "涓嬫淇濆吇鏃ユ湡", prop: "nextMaintenanceDate" },
 				{
 					label: "璁惧鍒嗙被", prop: "largeCategory", dataType: "tag",
 					formatData: (params) => {
@@ -515,6 +530,8 @@
 					}
 				},
 				{ label: "鏍″噯鍛ㄦ湡(鏈�)", prop: "calibrationDate" },
+				{ label: "鏍告煡鍛ㄦ湡(鏈�)", prop: "examineCycle" },
+				{ label: "淇濆吇鍛ㄦ湡(鏈�)", prop: "maintenanceCycle" },
 				{
 					dataType: "action",
 					fixed: "right",
@@ -556,6 +573,20 @@
 		}
 	},
 	computed: {
+		// 鏍″噯鏈嶅姟鏈烘瀯涓嬫媺閫夐」锛堝悎鏍间緵搴斿晢 + 褰撳墠鍊煎厹搴曪級
+		calibrationServiceOptions() {
+			const list = this.qualifiedSupplierNames.slice();
+			const value = this.formData.calibrationServices;
+			if (value && list.indexOf(value) === -1) list.push(value);
+			return list;
+		},
+		// 鏂板璁惧寮圭獥鐨勬牎鍑嗘湇鍔℃満鏋勪笅鎷夐�夐」
+		calibrationServiceOptions2() {
+			const list = this.qualifiedSupplierNames.slice();
+			const value = this.formData2.calibrationServices;
+			if (value && list.indexOf(value) === -1) list.push(value);
+			return list;
+		},
 		action() {
 			return this.javaApi + '/deviceScope/uploadFile'
 		}
@@ -563,31 +594,28 @@
 	mounted() {
 		this.selectEnumByCategory()
 		this.selectDevicePrincipal()
-		this.obtainDepartmentList()
 		this.getInsProductIds()
+		this.obtainQualifiedSupplierList()
 		// 鍒濆鍖�
 		this.clickSidebar(this.clickNodeVal)
 	},
 	methods: {
+		// 鎷夊彇鍚堟牸渚涘簲鍟嗗垪琛紙鏍″噯鏈嶅姟鏈烘瀯涓嬫媺閫夐」锛�
+		obtainQualifiedSupplierList() {
+			selectQualifiedSupplierManagementPage({ current: 1, size: 999 }).then(res => {
+				if (res.code === 200) {
+					const rows = (res.data && res.data.records) || [];
+					this.qualifiedSupplierNames = [...new Set(rows.map(r => r.supplierName).filter(Boolean))];
+				}
+			});
+		},
 		//鍒嗙被
 		handleNotification(cate) {
 			this.queryParams.largeCategory = cate
 		},
-		obtainDepartmentList() {
-			listDept({ status: '0' }).then(res => {
-				let data = []
-				res.data.forEach(a => {
-					data.push({
-						label: a.deptName,
-						value: a.deptId
-					})
-				})
-				this.subordinateDepartmentsList = data
-			})
-		},
 		getList() {
 			this.tableLoading = true;
-			let param = { laboratoryNameIsNull: this.laboratoryNameIsNull, ...this.queryParams, ...this.page };
+			let param = { ...this.queryParams, ...this.page };
 			delete param.total;
 			getDeviceParameter({ ...param })
 				.then((res) => {
@@ -607,13 +635,22 @@
 			this.getList();
 		},
     tableRowClassName({ row }) {
-      const today = new Date();
-      const targetDate = new Date(row.activationDate);
-      const fiveDaysBeforeTarget = new Date(targetDate);
-      // 璁$畻鍓嶄簲澶╃殑鏃ユ湡
-      fiveDaysBeforeTarget.setDate(targetDate.getDate() - 5);
-      // 姣旇緝鏃堕渶瑕佺‘淇濇瘮杈冪殑鏄畬鏁寸殑鏃ユ湡鏃堕棿锛屽寘鍚椂鍒嗙
-      if (today > fiveDaysBeforeTarget) {
+      // 鏍″噯鏈夋晥鏈熷埌鏈熷墠涓�涓湀锛堝惈宸茶繃鏈燂級鏍囩孩鎻愰啋
+      const activationDate = row.activationDate ? dayjs(String(row.activationDate).replace(' ', 'T')) : null;
+      if (activationDate && activationDate.isValid() && !dayjs().isBefore(activationDate.subtract(1, 'month'))) {
+        return 'red-row';
+      }
+      // 涓嬫鏍″噯/鏍告煡/淇濆吇鏃ユ湡鎻愬墠涓�涓湀锛堝惈宸茶繃鏈燂級鏍囩孩鎻愰啋
+      const nextCalibration = row.nextCalibrationDate ? dayjs(String(row.nextCalibrationDate).replace(' ', 'T')) : null;
+      if (nextCalibration && nextCalibration.isValid() && !nextCalibration.isAfter(dayjs().add(1, 'month'))) {
+        return 'red-row';
+      }
+      const nextExamine = row.nextExamineDate ? dayjs(String(row.nextExamineDate).replace(' ', 'T')) : null;
+      if (nextExamine && nextExamine.isValid() && !nextExamine.isAfter(dayjs().add(1, 'month'))) {
+        return 'red-row';
+      }
+      const nextMaintenance = row.nextMaintenanceDate ? dayjs(String(row.nextMaintenanceDate).replace(' ', 'T')) : null;
+      if (nextMaintenance && nextMaintenance.isValid() && !nextMaintenance.isAfter(dayjs().add(1, 'month'))) {
         return 'red-row';
       }
       return '';
@@ -659,6 +696,17 @@
 				});
 				this.responsiblePersonList = data
 				this.authorizerList = data
+			})
+			// 琚巿鏉冧汉涓嬫媺鍙彇妫�娴嬪憳瑙掕壊浜哄憳
+			selectUserCondition({ type: 3 }).then(res => {
+				let data = [];
+				res.data.forEach((a) => {
+					data.push({
+						label: a.name,
+						value: a.id,
+					});
+				});
+				this.inspectorList = data
 			})
 		},
 		getInsProductIds() {
@@ -776,6 +824,30 @@
 				})
 			}
 		},
+		// 涓嬫鏃ユ湡 = 鏈�杩戞棩鏈� + 鍛ㄦ湡锛堟湀锛夛紝鑷姩璁$畻
+		calcNextDate(data) {
+			const calc = (lastDate, cycle) => {
+				const period = parseInt(cycle)
+				if (!lastDate || !period || period <= 0) {
+					return null
+				}
+				return dayjs(String(lastDate).replace(' ', 'T'))
+					.add(period, 'month')
+					.format('YYYY-MM-DD HH:mm:ss')
+			}
+			const nextCalibrationDate = calc(data.lastCalibrationDate, data.calibrationDate)
+			if (nextCalibrationDate) {
+				data.nextCalibrationDate = nextCalibrationDate
+			}
+			const nextMaintenanceDate = calc(data.lastMaintenanceDate, data.maintenanceCycle)
+			if (nextMaintenanceDate) {
+				data.nextMaintenanceDate = nextMaintenanceDate
+			}
+			const nextExamineDate = calc(data.lastExamineDate, data.examineCycle)
+			if (nextExamineDate) {
+				data.nextExamineDate = nextExamineDate
+			}
+		},
 		submitForm() {
 			if (!this.formData.deviceName) {
 				this.$message.error('鏈緭鍏ヤ华鍣ㄥ悕绉�')
@@ -791,10 +863,6 @@
 			}
 			if (!this.formData.activationDate) {
 				this.$message.error('鏈緭鍏ユ牎鍑嗘湁鏁堟湡')
-				return
-			}
-			if (!this.formData.subordinateDepartmentsId) {
-				this.$message.error('鏈�夋嫨鎵�灞為儴闂�')
 				return
 			}
 			if (this.formData.deviceStatus === '' || this.formData.deviceStatus === null) {
@@ -941,30 +1009,11 @@
 		},
 		// 鐐瑰嚮渚ц竟鏍忓埛鏂�
 		clickSidebar(clickNodeVal) {
-			this.laboratoryNameIsNull = false
-			// 鏄惁瀛樺湪value锛屽瓨鍦╲alue浠h〃涓轰笁绾�
+			// 瀛樺湪value浠h〃閫変腑浜嗚澶囷紝鐢辫澶囪鎯呭睍绀哄鐞�
 			if (!clickNodeVal.value) {
 				this.list = [];
-				this.queryParams.laboratoryName = null
-				this.queryParams.storagePoint = null
-				// 绛変簬1浠h〃涓烘爲鐨勪竴绾э紝label涓洪儴闂�
-				if (clickNodeVal.label == '鍏朵粬') {
-					this.laboratoryNameIsNull = true
-					this.refreshTable('page')
-					return
-				}
-				if (clickNodeVal.level == 1) {
-					this.queryParams.laboratoryName = clickNodeVal.label
-					// 绛変簬浜岀骇銆俵abel涓哄瓨鍌ㄥ湴鐐�
-				} else if (clickNodeVal.level == 2) {
-					// 鍏朵粬琛ㄧず娌℃湁閰嶇疆瀹為獙瀹わ紝鍙厤缃簡鍦扮偣
-					if (clickNodeVal.parent.label == '鍏朵粬') {
-						this.laboratoryNameIsNull = true
-					} else {
-						this.queryParams.laboratoryName = clickNodeVal.parent.label
-					}
-					this.queryParams.storagePoint = clickNodeVal.label
-				}
+				// 鏍戠殑涓�绾т负鍒嗙被锛氬叏閮�/璁惧/璁¢噺鍣ㄥ叿
+				this.queryParams.largeCategory = clickNodeVal.label === '鍏ㄩ儴' ? null : clickNodeVal.label
 				this.refreshTable('page')
 			}
 		},

--
Gitblit v1.9.3