From a8ebfcbec49fb628fa2fa1a66bc1950125bc0786 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 18 五月 2026 14:51:14 +0800
Subject: [PATCH] 优化设备保养表单:新增保养人选择器,确保保养人必填,加载保养人列表

---
 src/pages/equipmentManagement/upkeep/add.vue |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/src/pages/equipmentManagement/upkeep/add.vue b/src/pages/equipmentManagement/upkeep/add.vue
index ff5339b..bc8cae0 100644
--- a/src/pages/equipmentManagement/upkeep/add.vue
+++ b/src/pages/equipmentManagement/upkeep/add.vue
@@ -41,12 +41,17 @@
 				</template>
 			</u-form-item>
 
-			<u-form-item label="淇濆吇浜�" prop="maintenancePerson" border-bottom>
+			<u-form-item label="淇濆吇浜�" prop="maintenancePerson" required border-bottom>
 				<u-input
 					v-model="form.maintenancePerson"
-					placeholder="璇疯緭鍏ヤ繚鍏讳汉"
+					placeholder="璇烽�夋嫨淇濆吇浜�"
+					readonly
+					@click="showPersonPicker"
 					clearable
 				/>
+				<template #right>
+					<u-icon name="arrow-right" @click="showPersonPicker" />
+				</template>
 			</u-form-item>
 			
 			<u-form-item label="淇濆吇椤圭洰" prop="maintenanceItems" border-bottom>
@@ -72,6 +77,14 @@
 			@select="onDeviceConfirm"
 			@close="showDevice = false"
 		/>
+		<!-- 淇濆吇浜洪�夋嫨鍣� -->
+		<up-action-sheet
+			:show="showPerson"
+			:actions="personActions"
+			title="閫夋嫨淇濆吇浜�"
+			@select="onPersonConfirm"
+			@close="showPerson = false"
+		/>
 <up-datetime-picker
 			:show="showDate"
 			v-model="pickerDateValue"
@@ -89,6 +102,7 @@
 import PageHeader from '@/components/PageHeader.vue';
 import { getDeviceLedger } from '@/api/equipmentManagement/ledger';
 import { addUpkeep, editUpkeep, getUpkeepById } from '@/api/equipmentManagement/upkeep';
+import { userListNoPageByTenantId } from '@/api/system/user';
 import useUserStore from '@/store/modules/user';
 import dayjs from "dayjs";
 import { formatDateToYMD } from '@/utils/ruoyi';
@@ -117,6 +131,7 @@
 const operationType = ref('add');
 const loading = ref(false);
 const showDevice = ref(false);
+const showPerson = ref(false);
 const showDate = ref(false);
 const pickerDateValue = ref(Date.now());
 const currentDate = ref([new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate()]);
@@ -124,12 +139,20 @@
 // 璁惧閫夐」
 const deviceOptions = ref([]);
 const deviceNameText = ref('');
+// 淇濆吇浜洪�夐」
+const userOptions = ref([]);
 // 杞崲涓� action-sheet 闇�瑕佺殑鏍煎紡
 const deviceActions = computed(() => {
 	return deviceOptions.value.map(item => ({
 		text: item.deviceName,
 		value: item.id,
 		data: item
+	}));
+});
+const personActions = computed(() => {
+	return userOptions.value.map(item => ({
+		name: item.nickName,
+		value: item.userId,
 	}));
 });
 
@@ -141,6 +164,7 @@
 const formRules = {
 	deviceLedgerId: [{ required: true, trigger: "change", message: "璇烽�夋嫨璁惧鍚嶇О" }],
 	maintenancePlanTime: [{ required: true, trigger: "change", message: "璇烽�夋嫨璁″垝淇濆吇鏃ユ湡" }],
+	maintenancePerson: [{ required: true, trigger: "change", message: "璇烽�夋嫨淇濆吇浜�" }],
 };
 
 // 浣跨敤 ref 澹版槑琛ㄥ崟鏁版嵁
@@ -159,6 +183,16 @@
 		deviceOptions.value = data || [];
 	} catch (e) {
 		showToast('鑾峰彇璁惧鍒楄〃澶辫触');
+	}
+};
+
+// 鍔犺浇淇濆吇浜哄垪琛�
+const loadUserOptions = async () => {
+	try {
+		const { data } = await userListNoPageByTenantId();
+		userOptions.value = data || [];
+	} catch (e) {
+		showToast('鑾峰彇淇濆吇浜哄垪琛ㄥけ璐�');
 	}
 };
 
@@ -254,6 +288,22 @@
 	showDevice.value = true;
 };
 
+// 鏄剧ず淇濆吇浜洪�夋嫨鍣�
+const showPersonPicker = () => {
+	if (!userOptions.value.length) {
+		showToast('鏆傛棤鍙�変繚鍏讳汉');
+		return;
+	}
+	showPerson.value = true;
+};
+
+// 纭淇濆吇浜洪�夋嫨
+const onPersonConfirm = (selected) => {
+	const user = userOptions.value.find(item => item.userId === selected.value);
+	form.value.maintenancePerson = user?.nickName || selected.name || '';
+	showPerson.value = false;
+};
+
 // 纭璁惧閫夋嫨
 const onDeviceConfirm = (selected) => {
 	// selected 杩斿洖鐨勬槸閫変腑椤�
@@ -283,8 +333,9 @@
 });
 
 onMounted(() => {
-	// 椤甸潰鍔犺浇鏃惰幏鍙栬澶囧垪琛ㄥ拰鍙傛暟
+	// 椤甸潰鍔犺浇鏃惰幏鍙栬澶囧垪琛ㄣ�佷繚鍏讳汉鍒楄〃鍜屽弬鏁�
 	loadDeviceName();
+	loadUserOptions();
 	getPageParams();
 });
 

--
Gitblit v1.9.3