From a1a73e25593d2914ea58cd84ec2540bc56bd6934 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 26 一月 2026 17:43:25 +0800
Subject: [PATCH] 来票台账接口更改

---
 src/pages/equipmentManagement/repair/maintain.vue |  504 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 267 insertions(+), 237 deletions(-)

diff --git a/src/pages/equipmentManagement/repair/maintain.vue b/src/pages/equipmentManagement/repair/maintain.vue
index 64d08cb..46b45aa 100644
--- a/src/pages/equipmentManagement/repair/maintain.vue
+++ b/src/pages/equipmentManagement/repair/maintain.vue
@@ -1,267 +1,297 @@
 <template>
-	<view class="repair-maintain">
-		<!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
-		<PageHeader title="鏂板缁翠慨" @back="goBack" />
-		
-		<!-- 琛ㄥ崟鍐呭 -->
-		<van-form @submit="sendForm" ref="formRef" label-width="110px" input-align="right" error-message-align="right" scroll-to-error scroll-to-error-position="center">
-			<!-- 鍩烘湰淇℃伅 -->
-			<van-cell-group title="缁翠慨淇℃伅" inset>
-				<van-field
-					v-model="form.maintenanceName"
-					label="缁翠慨浜�"
-					placeholder="璇疯緭鍏ョ淮淇汉"
-					:rules="formRules.maintenanceName"
-					required
-					clearable
-				/>
-				<van-field
-					v-model="form.maintenanceResult"
-					label="缁翠慨缁撴灉"
-					type="textarea"
-					rows="3"
-					placeholder="璇疯緭鍏ョ淮淇粨鏋�"
-					:rules="formRules.maintenanceResult"
-					required
-					clearable
-					maxlength="200"
-					show-word-limit
-				/>
-				<van-field
-					v-model="form.maintenanceTime"
-					label="缁翠慨鏃ユ湡"
-					placeholder="璇烽�夋嫨缁翠慨鏃ユ湡"
-					:rules="formRules.maintenanceTime"
-					required
-					readonly
-					@click="showDatePicker"
-					clearable
-				/>
-			</van-cell-group>
-			
-			<!-- 鎻愪氦鎸夐挳 -->
-			<view class="footer-btns">
-				<van-button class="cancel-btn" @click="goBack">鍙栨秷</van-button>
-				<van-button class="save-btn" native-type="submit" form-type="submit" :loading="loading">淇濆瓨</van-button>
-			</view>
-		</van-form>
-
-		<!-- 鏃ユ湡閫夋嫨鍣� -->
-		<van-popup v-model:show="showDate" position="bottom">
-			<van-date-picker
-				v-model="currentDate"
-				title="閫夋嫨鏃ユ湡"
-				@confirm="onDateConfirm"
-				@cancel="showDate = false"
-			/>
-		</van-popup>
-	</view>
+  <view class="repair-maintain">
+    <!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
+    <PageHeader title="鏂板缁翠慨"
+                @back="goBack" />
+    <!-- 琛ㄥ崟鍐呭 -->
+    <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.maintenanceName"
+                   placeholder="璇疯緭鍏ョ淮淇汉"
+                   clearable />
+        </u-form-item>
+        <u-form-item prop="maintenanceResult"
+                     label="缁翠慨缁撴灉"
+                     required>
+          <u-input v-model="form.maintenanceResult"
+                   type="textarea"
+                   rows="3"
+                   placeholder="璇疯緭鍏ョ淮淇粨鏋�"
+                   clearable
+                   maxlength="200"
+                   show-word-limit />
+        </u-form-item>
+        <u-form-item label="缁翠慨鐘舵��"
+                     prop="repairTime"
+                     required
+                     border-bottom>
+          <u-input v-model="repairStatusText"
+                   placeholder="璇烽�夋嫨缁翠慨鐘舵��"
+                   readonly
+                   @click="openRepairStatusPicker"
+                   clearable />
+          <template #right>
+            <u-icon name="arrow-right"
+                    @click="openRepairStatusPicker"></u-icon>
+          </template>
+        </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"
+                  @click="submitForm"
+                  :loading="loading">淇濆瓨</u-button>
+      </view>
+    </u-form>
+    <!-- 鏃ユ湡閫夋嫨鍣� -->
+    <up-datetime-picker :show="showDatePicker"
+                        v-model="pickerDateValue"
+                        mode="datetime"
+                        title="閫夋嫨鏃ユ湡"
+                        format="YYYY-MM-DD HH:mm:ss"
+                        @confirm="onDateConfirm"
+                        @cancel="showDatePicker = false" />
+  </view>
 </template>
 
 <script setup>
-import { ref, onMounted } from 'vue';
-import { onShow } from '@dcloudio/uni-app';
-import PageHeader from '@/components/PageHeader.vue';
-import { addMaintain } from '@/api/equipmentManagement/repair';
-import useUserStore from "@/store/modules/user";
-import dayjs from "dayjs";
-import { showToast } from 'vant';
+  import { ref, onMounted } from "vue";
+  import { onShow } from "@dcloudio/uni-app";
+  import PageHeader from "@/components/PageHeader.vue";
+  import { addMaintain } from "@/api/equipmentManagement/repair";
+  import useUserStore from "@/store/modules/user";
+  import dayjs from "dayjs";
 
-defineOptions({
-	name: "璁惧缁翠慨琛ㄥ崟",
-});
+  defineOptions({
+    name: "璁惧缁翠慨琛ㄥ崟",
+  });
 
-const userStore = useUserStore();
+  const userStore = useUserStore();
 
-// 琛ㄥ崟寮曠敤
-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 formRef = ref(null);
+  const loading = ref(false);
+  const showDatePicker = ref(false);
+  const pickerDateValue = ref(Date.now()); // 浣跨敤鏃堕棿鎴�
 
-// 琛ㄥ崟楠岃瘉瑙勫垯
-const formRules = {
-	maintenanceName: [{ required: true, trigger: "blur", message: "璇疯緭鍏ョ淮淇汉" }],
-	maintenanceResult: [{ required: true, trigger: "blur", message: "璇疯緭鍏ョ淮淇粨鏋�" }],
-	maintenanceTime: [{ required: true, trigger: "change", message: "璇烽�夋嫨缁翠慨鏃ユ湡" }],
-};
+  // 琛ㄥ崟楠岃瘉瑙勫垯
+  const formRules = {
+    maintenanceName: [
+      { required: true, trigger: "blur", message: "璇疯緭鍏ョ淮淇汉" },
+    ],
+    maintenanceResult: [
+      { required: true, trigger: "blur", message: "璇疯緭鍏ョ淮淇粨鏋�" },
+    ],
+    maintenanceTime: [
+      { required: true, trigger: "change", message: "璇烽�夋嫨缁翠慨鏃ユ湡" },
+    ],
+  };
+  const repairStatusOptions = ref([
+    { name: "寰呯淮淇�", value: "0" },
+    { name: "瀹岀粨", value: "1" },
+    { name: "澶辫触", value: "2" },
+  ]);
+  const repairStatusText = ref("瀹岀粨");
+  // 鎵撳紑鎶ヤ慨鐘舵�侀�夋嫨鍣�
+  const openRepairStatusPicker = () => {
+    uni.showActionSheet({
+      itemList: repairStatusOptions.value.map(item => item.name),
+      success: res => {
+        form.value.status = repairStatusOptions.value[res.tapIndex].value;
+        repairStatusText.value = repairStatusOptions.value[res.tapIndex].name;
+      },
+    });
+  };
+  // 浣跨敤 ref 澹版槑琛ㄥ崟鏁版嵁
+  const form = ref({
+    maintenanceName: userStore.nickName || "", // 榛樿浣跨敤褰撳墠鐢ㄦ埛鏄电О
+    maintenanceResult: undefined, // 缁翠慨缁撴灉
+    maintenanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), // 缁翠慨鏃ユ湡锛堝彧鏄剧ず鏃ユ湡锛�
+  });
 
-// 浣跨敤 ref 澹版槑琛ㄥ崟鏁版嵁
-const form = ref({
-	maintenanceName: userStore.nickName || '', // 榛樿浣跨敤褰撳墠鐢ㄦ埛鏄电О
-	maintenanceResult: undefined, // 缁翠慨缁撴灉
-	maintenanceTime: dayjs().format("YYYY-MM-DD"), // 缁翠慨鏃ユ湡锛堝彧鏄剧ず鏃ユ湡锛�
-});
+  // 鑷畾涔塻howToast鍑芥暟
+  const showToast = message => {
+    uni.showToast({
+      title: message,
+      icon: "none",
+    });
+  };
 
-// 娓呴櫎琛ㄥ崟鏍¢獙鐘舵��
-const clearValidate = () => {
-	// Vant4涓笉闇�瑕佹墜鍔ㄦ竻闄ら獙璇佺姸鎬侊紝閲嶇疆琛ㄥ崟鏃朵細鑷姩娓呴櫎
-	// formRef.value?.clearValidate(); // 鍒犻櫎杩欒
-};
+  // 閲嶇疆琛ㄥ崟鏁版嵁鍜屾牎楠岀姸鎬�
+  const resetForm = () => {
+    form.value = {
+      maintenanceName: userStore.nickName || "",
+      maintenanceResult: undefined,
+      maintenanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
+    };
+  };
 
-// 閲嶇疆琛ㄥ崟鏁版嵁鍜屾牎楠岀姸鎬�
-const resetForm = () => {
-	form.value = {
-		maintenanceName: userStore.nickName || '',
-		maintenanceResult: undefined,
-		maintenanceTime: dayjs().format("YYYY-MM-DD"),
-	};
-};
+  const resetFormAndValidate = () => {
+    resetForm();
+  };
 
-const resetFormAndValidate = () => {
-	resetForm();
-	// clearValidate(); // 鍒犻櫎杩欒锛孷ant4浼氳嚜鍔ㄥ鐞�
-};
+  // 鎻愪氦琛ㄥ崟
+  const submitForm = async () => {
+    try {
+      // 浣跨敤uview-plus鐨勮〃鍗曢獙璇佹柟寮�
+      const valid = await formRef.value.validate();
+      if (valid) {
+        submitFormData();
+      }
+    } catch (e) {
+      showToast("琛ㄥ崟楠岃瘉澶辫触");
+    }
+  };
 
-// 鎻愪氦琛ㄥ崟
-const sendForm = async () => {
-	try {
-		// 浣跨敤Vant4鐨勬纭獙璇佹柟寮�
-		formRef.value?.validate().then(() => {
-			// 楠岃瘉閫氳繃
-			submitFormData();
-		}).catch((errors) => {
-			// 楠岃瘉澶辫触
-			showToast('璇峰~鍐欏畬鏁翠俊鎭�');
-		});
-	} catch (e) {
-		showToast('琛ㄥ崟楠岃瘉澶辫触');
-	}
-};
+  // 鎻愪氦琛ㄥ崟鏁版嵁
+  const submitFormData = async () => {
+    try {
+      loading.value = true;
+      const id = getPageId();
 
-// 鎻愪氦琛ㄥ崟鏁版嵁
-const submitFormData = async () => {
-	try {
-		loading.value = true;
-		const id = getPageId();
-		
-		if (!id) {
-			showToast('鍙傛暟閿欒');
-			loading.value = false;
-			return;
-		}
-		
-		// 鍑嗗鎻愪氦鏁版嵁锛宮aintenanceTime 鍔犱笂褰撳墠鏃跺垎绉�
-		const submitData = { ...form.value };
-		if (submitData.maintenanceTime && !submitData.maintenanceTime.includes(':')) {
-			// 濡傛灉 maintenanceTime 鍙寘鍚棩鏈燂紝娣诲姞褰撳墠鏃跺垎绉�
-			submitData.maintenanceTime = submitData.maintenanceTime + ' ' + dayjs().format('HH:mm:ss');
-		}
-		
-		const { code } = await addMaintain({ id: id, ...submitData });
-		
-		if (code == 200) {
-			showToast('鏂板缁翠慨鎴愬姛');
-			resetFormAndValidate();
-			setTimeout(() => {
-				uni.navigateBack();
-			}, 1500);
-		} else {
-			loading.value = false;
-		}
-	} catch (e) {
-		loading.value = false;
-		showToast('鎿嶄綔澶辫触');
-	}
-};
+      if (!id) {
+        showToast("鍙傛暟閿欒");
+        loading.value = false;
+        return;
+      }
+      form.value.status = Number(form.value.status);
+      // 鍑嗗鎻愪氦鏁版嵁锛宮aintenanceTime 鍔犱笂褰撳墠鏃跺垎绉�
+      const submitData = { ...form.value };
 
-// 杩斿洖涓婁竴椤�
-const goBack = () => {
-	uni.navigateBack();
-};
+      const { code } = await addMaintain({ id: id, ...submitData });
 
-// 鑾峰彇椤甸潰ID
-const getPageId = () => {
-	const pages = getCurrentPages();
-	const currentPage = pages[pages.length - 1];
-	const options = currentPage.options;
-	return options.id;
-};
+      if (code == 200) {
+        showToast("鏂板缁翠慨鎴愬姛");
+        resetFormAndValidate();
+        setTimeout(() => {
+          goBack();
+        }, 500);
+      } else {
+        loading.value = false;
+      }
+    } catch (e) {
+      console.log(e);
 
-// 鏄剧ず鏃ユ湡閫夋嫨鍣�
-const showDatePicker = () => {
-	showDate.value = true;
-};
+      loading.value = false;
+      showToast("鎿嶄綔澶辫触");
+    }
+  };
 
-// 纭鏃ユ湡閫夋嫨
-const onDateConfirm = ({ selectedValues }) => {
-	// 鍙繚瀛樺勾鏈堟棩锛屼笉鍖呭惈鏃跺垎绉�
-	form.value.maintenanceTime = selectedValues.join('-');
-	currentDate.value = selectedValues;
-	showDate.value = false;
-};
+  // 杩斿洖涓婁竴椤�
+  const goBack = () => {
+    uni.removeStorageSync("repairId");
+    uni.navigateBack();
+  };
 
-// 鍒濆鍖栬〃鍗曟暟鎹�
-const initForm = () => {
-	// 璁剧疆缁翠慨浜轰负褰撳墠鐢ㄦ埛鏄电О
-	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()];
-};
+  // 鑾峰彇椤甸潰ID
+  const getPageId = () => {
+    const id = uni.getStorageSync("repairId");
+    return id;
+  };
 
-onShow(() => {
-	// 椤甸潰鏄剧ず鏃跺垵濮嬪寲琛ㄥ崟
-	initForm();
-});
+  // 纭鏃ユ湡閫夋嫨
+  const onDateConfirm = e => {
+    form.value.maintenanceTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss");
+    pickerDateValue.value = e.value;
+    showDatePicker.value = false;
+  };
 
-onMounted(() => {
-	// 椤甸潰鍔犺浇鏃跺垵濮嬪寲琛ㄥ崟
-	initForm();
-});
+  // 鍒濆鍖栬〃鍗曟暟鎹�
+  const initForm = () => {
+    form.value.status = "1";
+    // 璁剧疆缁翠慨浜轰负褰撳墠鐢ㄦ埛鏄电О
+    form.value.maintenanceName = userStore.nickName || "";
+    // 璁剧疆褰撳墠鏃ユ湡锛堝彧鍖呭惈骞存湀鏃ワ級
+    form.value.maintenanceTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
+  };
+
+  onShow(() => {
+    // 椤甸潰鏄剧ず鏃跺垵濮嬪寲琛ㄥ崟
+    initForm();
+  });
+
+  onMounted(() => {
+    // 椤甸潰鍔犺浇鏃跺垵濮嬪寲琛ㄥ崟
+    initForm();
+  });
 </script>
 
 <style scoped lang="scss">
-.repair-maintain {
-	min-height: 100vh;
-	background: #f8f9fa;
-	padding-bottom: 5rem;
-}
+  @import "@/static/scss/form-common.scss";
+  .repair-maintain {
+    min-height: 100vh;
+    background: #f8f9fa;
+    padding-bottom: 5rem;
+  }
 
-.footer-btns {
-	position: fixed;
-	left: 0;
-	right: 0;
-	bottom: 0;
-	background: #fff;
-	display: flex;
-	justify-content: space-around;
-	align-items: center;
-	padding: 0.75rem 0;
-	box-shadow: 0 -0.125rem 0.5rem rgba(0,0,0,0.05);
-	z-index: 1000;
-}
+  .footer-btns {
+    position: fixed;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    background: #fff;
+    display: flex;
+    justify-content: space-around;
+    align-items: center;
+    padding: 0.75rem 0;
+    box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
+    z-index: 1000;
+  }
 
-.cancel-btn {
-	font-weight: 400;
-	font-size: 1rem;
-	color: #FFFFFF;
-	width: 6.375rem;
-	background: #C7C9CC;
-	box-shadow: 0 0.25rem 0.625rem 0 rgba(3,88,185,0.2);
-	border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
-}
+  .cancel-btn {
+    font-weight: 400;
+    font-size: 1rem;
+    color: #ffffff;
+    width: 6.375rem;
+    background: #c7c9cc;
+    box-shadow: 0 0.25rem 0.625rem 0 rgba(3, 88, 185, 0.2);
+    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
+  }
 
-.save-btn {
-	font-weight: 400;
-	font-size: 1rem;
-	color: #FFFFFF;
-	width: 14rem;
-	background: linear-gradient( 140deg, #00BAFF 0%, #006CFB 100%);
-	box-shadow: 0 0.25rem 0.625rem 0 rgba(3,88,185,0.2);
-	border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
-}
+  .save-btn {
+    font-weight: 400;
+    font-size: 1rem;
+    color: #ffffff;
+    width: 14rem;
+    background: linear-gradient(140deg, #00baff 0%, #006cfb 100%);
+    box-shadow: 0 0.25rem 0.625rem 0 rgba(3, 88, 185, 0.2);
+    border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
+  }
 
-// 鍝嶅簲寮忚皟鏁�
-@media (max-width: 768px) {
-	.submit-section {
-		padding: 12px;
-	}
-}
+  // 鍝嶅簲寮忚皟鏁�
+  @media (max-width: 768px) {
+    .submit-section {
+      padding: 12px;
+    }
+  }
 
-.tip-text { 
-	padding: 4px 16px 0 16px; 
-	font-size: 12px; 
-	color: #888; 
-}
+  .tip-text {
+    padding: 4px 16px 0 16px;
+    font-size: 12px;
+    color: #888;
+  }
 </style>
\ No newline at end of file

--
Gitblit v1.9.3