From 952240909a036a341300ec25a2259e6faed33362 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期四, 04 九月 2025 16:09:49 +0800 Subject: [PATCH] 设备保修真机测试,bug修改 --- src/pages/equipmentManagement/repair/maintain.vue | 143 +++++++++++++++++++++-------------------------- 1 files changed, 64 insertions(+), 79 deletions(-) diff --git a/src/pages/equipmentManagement/repair/maintain.vue b/src/pages/equipmentManagement/repair/maintain.vue index 9900220..aa8a8e3 100644 --- a/src/pages/equipmentManagement/repair/maintain.vue +++ b/src/pages/equipmentManagement/repair/maintain.vue @@ -1,55 +1,61 @@ <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="datetime" + title="閫夋嫨鏃ユ湡" + format="YYYY-MM-DD HH:mm:ss" + @confirm="onDateConfirm" + @cancel="showDatePicker = false" + /> </view> </template> @@ -60,16 +66,6 @@ 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' - }) -} defineOptions({ name: "璁惧缁翠慨琛ㄥ崟", @@ -80,8 +76,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 = { @@ -94,13 +90,15 @@ const form = ref({ maintenanceName: userStore.nickName || '', // 榛樿浣跨敤褰撳墠鐢ㄦ埛鏄电О maintenanceResult: undefined, // 缁翠慨缁撴灉 - maintenanceTime: dayjs().format("YYYY-MM-DD"), // 缁翠慨鏃ユ湡锛堝彧鏄剧ず鏃ユ湡锛� + maintenanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), // 缁翠慨鏃ユ湡锛堝彧鏄剧ず鏃ユ湡锛� }); -// 娓呴櫎琛ㄥ崟鏍¢獙鐘舵�� -const clearValidate = () => { - // Vant4涓笉闇�瑕佹墜鍔ㄦ竻闄ら獙璇佺姸鎬侊紝閲嶇疆琛ㄥ崟鏃朵細鑷姩娓呴櫎 - // formRef.value?.clearValidate(); // 鍒犻櫎杩欒 +// 鑷畾涔塻howToast鍑芥暟 +const showToast = (message) => { + uni.showToast({ + title: message, + icon: 'none' + }) }; // 閲嶇疆琛ㄥ崟鏁版嵁鍜屾牎楠岀姸鎬� @@ -108,26 +106,22 @@ form.value = { maintenanceName: userStore.nickName || '', maintenanceResult: undefined, - maintenanceTime: dayjs().format("YYYY-MM-DD"), + maintenanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), }; }; 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('琛ㄥ崟楠岃瘉澶辫触'); } @@ -147,10 +141,6 @@ // 鍑嗗鎻愪氦鏁版嵁锛宮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 }); @@ -158,12 +148,14 @@ showToast('鏂板缁翠慨鎴愬姛'); resetFormAndValidate(); setTimeout(() => { - uni.navigateBack(); - }, 1500); + goBack(); + }, 500); } else { loading.value = false; } } catch (e) { + console.log(e); + loading.value = false; showToast('鎿嶄綔澶辫触'); } @@ -171,28 +163,21 @@ // 杩斿洖涓婁竴椤� const goBack = () => { + uni.removeStorageSync('repairId'); uni.navigateBack(); }; // 鑾峰彇椤甸潰ID const getPageId = () => { - const pages = getCurrentPages(); - const currentPage = pages[pages.length - 1]; - const options = currentPage.options; - return options.id; -}; - -// 鏄剧ず鏃ユ湡閫夋嫨鍣� -const showDatePicker = () => { - showDate.value = true; + const id = uni.getStorageSync('repairId'); + return id; }; // 纭鏃ユ湡閫夋嫨 -const onDateConfirm = ({ selectedValues }) => { - // 鍙繚瀛樺勾鏈堟棩锛屼笉鍖呭惈鏃跺垎绉� - form.value.maintenanceTime = selectedValues.join('-'); - currentDate.value = selectedValues; - showDate.value = false; +const onDateConfirm = (e) => { + form.value.maintenanceTime = dayjs(e.value).format('YYYY-MM-DD HH:mm:ss') + pickerDateValue.value = e.value + showDatePicker.value = false; }; // 鍒濆鍖栬〃鍗曟暟鎹� @@ -200,8 +185,7 @@ // 璁剧疆缁翠慨浜轰负褰撳墠鐢ㄦ埛鏄电О 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()]; + form.value.maintenanceTime = dayjs().format('YYYY-MM-DD HH:mm:ss'); }; onShow(() => { @@ -216,6 +200,7 @@ </script> <style scoped lang="scss"> +@import '@/static/scss/form-common.scss'; .repair-maintain { min-height: 100vh; background: #f8f9fa; -- Gitblit v1.9.3