From 025e46e11cb2962fd7692adfa401333758cc779b Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 02 九月 2025 14:00:34 +0800
Subject: [PATCH] 修改组件

---
 src/pages/equipmentManagement/repair/maintain.vue |  120 ++++++++++++++++++++++++++++--------------------------------
 1 files changed, 56 insertions(+), 64 deletions(-)

diff --git a/src/pages/equipmentManagement/repair/maintain.vue b/src/pages/equipmentManagement/repair/maintain.vue
index 9900220..12a39b7 100644
--- a/src/pages/equipmentManagement/repair/maintain.vue
+++ b/src/pages/equipmentManagement/repair/maintain.vue
@@ -1,55 +1,59 @@
 <template>
 	<view class="repair-maintain">
 		<!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
-		<PageHeader title="璁惧缁翠慨" @back="goBack" />
+		<PageHeader title="鏂板缁翠慨" @back="goBack" />
 		
 		<!-- 琛ㄥ崟鍐呭 -->
-		<u-form @submit="sendForm" ref="formRef" label-width="110" input-align="right" error-message-align="right">
-			<!-- 缁翠慨淇℃伅 -->
-			<u-cell-group title="缁翠慨淇℃伅">
-				<u-form-item label="瀹為檯缁翠慨浜�" prop="repairPerson" required border-bottom>
+		<u-form ref="formRef" :model="form" :rules="formRules" label-width="140rpx">
+			<!-- 鍩烘湰淇℃伅 -->
+			<u-cell-group title="缁翠慨淇℃伅" inset>
+				<u-form-item prop="maintenanceName" label="缁翠慨浜�" required>
 					<u-input
-						v-model="form.repairPerson"
-						placeholder="璇疯緭鍏ュ疄闄呯淮淇汉"
+						v-model="form.maintenanceName"
+						placeholder="璇疯緭鍏ョ淮淇汉"
 						clearable
 					/>
 				</u-form-item>
-				<u-form-item label="瀹為檯缁翠慨鏃ユ湡" prop="repairDate" required border-bottom>
+				<u-form-item prop="maintenanceResult" label="缁翠慨缁撴灉" required>
 					<u-input
-						v-model="form.repairDate"
-						placeholder="璇烽�夋嫨瀹為檯缁翠慨鏃ユ湡"
-						readonly
-						@click="showDatePicker"
-						clearable
-					/>
-				</u-form-item>
-				<u-form-item label="缁翠慨缁撴灉" prop="repairResult" required border-bottom>
-					<u-textarea
-						v-model="form.repairResult"
+						v-model="form.maintenanceResult"
+						type="textarea"
+						rows="3"
 						placeholder="璇疯緭鍏ョ淮淇粨鏋�"
-						:maxlength="200"
-						count
-						:autoHeight="true"
+						clearable
+						maxlength="200"
+						show-word-limit
 					/>
+				</u-form-item>
+				<u-form-item label="缁翠慨鏃ユ湡" prop="maintenanceTime" required border-bottom>
+					<u-input
+						v-model="form.maintenanceTime"
+						placeholder="璇烽�夋嫨缁翠慨鏃ユ湡"
+						readonly
+						@click="showDatePicker = true"
+						clearable
+					/>
+					<template #right>
+						<u-icon name="arrow-right" @click="showDatePicker = true"></u-icon>
+					</template>
 				</u-form-item>
 			</u-cell-group>
 			
 			<!-- 鎻愪氦鎸夐挳 -->
 			<view class="footer-btns">
 				<u-button class="cancel-btn" @click="goBack">鍙栨秷</u-button>
-				<u-button class="save-btn" type="primary" @click="sendForm" :loading="loading">淇濆瓨</u-button>
+				<u-button class="save-btn" @click="submitForm" :loading="loading">淇濆瓨</u-button>
 			</view>
 		</u-form>
 
 		<!-- 鏃ユ湡閫夋嫨鍣� -->
-		<u-popup v-model="showDate" mode="bottom">
-			<u-datetime-picker
-				v-model="currentDate"
-				title="閫夋嫨鏃ユ湡"
-				@confirm="onDateConfirm"
-				@cancel="showDate = false"
-			/>
-		</u-popup>
+		<up-datetime-picker
+			:show="showDatePicker"
+			v-model="pickerDateValue"
+			mode="date"
+			title="閫夋嫨鏃ユ湡"
+			@confirm="onDateConfirm"
+		/>
 	</view>
 </template>
 
@@ -60,16 +64,7 @@
 import { addMaintain } from '@/api/equipmentManagement/repair';
 import useUserStore from "@/store/modules/user";
 import dayjs from "dayjs";
-// 鏇挎崲 Vant 鐨� toast
-// import { showToast } from 'vant';
-
-// 鏇挎崲 toast 鏂规硶
-const showToast = (message) => {
-  uni.showToast({
-    title: message,
-    icon: 'none'
-  })
-}
+import { formatDateToYMD } from '@/utils/ruoyi'
 
 defineOptions({
 	name: "璁惧缁翠慨琛ㄥ崟",
@@ -80,8 +75,8 @@
 // 琛ㄥ崟寮曠敤
 const formRef = ref(null);
 const loading = ref(false);
-const showDate = ref(false);
-const currentDate = ref([new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate()]);
+const showDatePicker = ref(false);
+const pickerDateValue = ref(Date.now());; // 浣跨敤鏃堕棿鎴�
 
 // 琛ㄥ崟楠岃瘉瑙勫垯
 const formRules = {
@@ -97,10 +92,17 @@
 	maintenanceTime: dayjs().format("YYYY-MM-DD"), // 缁翠慨鏃ユ湡锛堝彧鏄剧ず鏃ユ湡锛�
 });
 
+// 鑷畾涔塻howToast鍑芥暟
+const showToast = (message) => {
+  uni.showToast({
+    title: message,
+    icon: 'none'
+  })
+};
+
 // 娓呴櫎琛ㄥ崟鏍¢獙鐘舵��
 const clearValidate = () => {
-	// Vant4涓笉闇�瑕佹墜鍔ㄦ竻闄ら獙璇佺姸鎬侊紝閲嶇疆琛ㄥ崟鏃朵細鑷姩娓呴櫎
-	// formRef.value?.clearValidate(); // 鍒犻櫎杩欒
+	// uview-plus涓嶉渶瑕佹墜鍔ㄦ竻闄ら獙璇佺姸鎬侊紝閲嶇疆琛ㄥ崟鏃朵細鑷姩娓呴櫎
 };
 
 // 閲嶇疆琛ㄥ崟鏁版嵁鍜屾牎楠岀姸鎬�
@@ -114,20 +116,16 @@
 
 const resetFormAndValidate = () => {
 	resetForm();
-	// clearValidate(); // 鍒犻櫎杩欒锛孷ant4浼氳嚜鍔ㄥ鐞�
 };
 
 // 鎻愪氦琛ㄥ崟
-const sendForm = async () => {
+const submitForm = async () => {
 	try {
-		// 浣跨敤Vant4鐨勬纭獙璇佹柟寮�
-		formRef.value?.validate().then(() => {
-			// 楠岃瘉閫氳繃
+		// 浣跨敤uview-plus鐨勮〃鍗曢獙璇佹柟寮�
+		const valid = await formRef.value.validate();
+		if (valid) {
 			submitFormData();
-		}).catch((errors) => {
-			// 楠岃瘉澶辫触
-			showToast('璇峰~鍐欏畬鏁翠俊鎭�');
-		});
+		}
 	} catch (e) {
 		showToast('琛ㄥ崟楠岃瘉澶辫触');
 	}
@@ -182,17 +180,11 @@
 	return options.id;
 };
 
-// 鏄剧ず鏃ユ湡閫夋嫨鍣�
-const showDatePicker = () => {
-	showDate.value = true;
-};
-
 // 纭鏃ユ湡閫夋嫨
-const onDateConfirm = ({ selectedValues }) => {
-	// 鍙繚瀛樺勾鏈堟棩锛屼笉鍖呭惈鏃跺垎绉�
-	form.value.maintenanceTime = selectedValues.join('-');
-	currentDate.value = selectedValues;
-	showDate.value = false;
+const onDateConfirm = (e) => {
+	form.value.maintenanceTime = formatDateToYMD(e.value)
+	pickerDateValue.value = formatDateToYMD(e.value)
+	showDatePicker.value = false;
 };
 
 // 鍒濆鍖栬〃鍗曟暟鎹�
@@ -201,7 +193,6 @@
 	form.value.maintenanceName = userStore.nickName || '';
 	// 璁剧疆褰撳墠鏃ユ湡锛堝彧鍖呭惈骞存湀鏃ワ級
 	form.value.maintenanceTime = dayjs().format('YYYY-MM-DD');
-	currentDate.value = [new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate()];
 };
 
 onShow(() => {
@@ -216,6 +207,7 @@
 </script>
 
 <style scoped lang="scss">
+@import '@/static/scss/form-common.scss';
 .repair-maintain {
 	min-height: 100vh;
 	background: #f8f9fa;

--
Gitblit v1.9.3