diff --git a/src/pages/dateUpdate/index.vue b/src/pages/dateUpdate/index.vue index 5d819e7..377c9e5 100644 --- a/src/pages/dateUpdate/index.vue +++ b/src/pages/dateUpdate/index.vue @@ -22,9 +22,9 @@ - + -
+
设备类型:{{ formData.maType }}
规格型号:{{ formData.typeName }}
设备编码:{{ formData.code }}
@@ -32,7 +32,7 @@
本次检修时间:{{ formData.repairTime }}
下次检修时间:{{ formData.nextRepairTime }}
- @@ -69,7 +69,7 @@ }) const scanQrCodeRef = ref() const popup = ref() - const typeName = ref('请选择对应机具') + const typeName = ref('') const typeList = ref([]) const range = ref([{ value: 0, text: '' }]) @@ -90,24 +90,30 @@ const handleSearch = () => { console.log('🚀 ~ handleSearch ~ 查询:', keyWord.value) - if (!keyWord.value) { - uni.showToast({ - title: '请输入设备编码', - icon: 'none', - }) - } - typeList.value =[]; + // typeList.value =[]; + reset() getWsMaInfoList({ maCode: keyWord.value }).then(res => { - if (res.code === 200) { + if (res.code === 200 && res.data && res.data.length > 0) { typeList.value = res.data.map(option => { return { id: option.id, - name: option.maName + option.maModel, + name: option.maName + '-' + option.maModel + '-' + option.maCode, isChecked: 1, item: option } }); + if (res.data.length === 1) { + console.log('🚀 ~ getWsMaInfoList ~ res.data.length:', res.data.length) + formData.id = res.data[0].id + formData.code = res.data[0].maCode + formData.maType = res.data[0].maName + formData.nextRepairTime = res.data[0].nextCheckTime + formData.repairTime = res.data[0].thisCheckTime + formData.typeName = res.data[0].maModel + formData.repairer = res.data[0].repairMan + console.log('🚀 ~ getWsMaInfoList ~ formData:', formData) + } } }).catch(error => { console.log(error) @@ -126,7 +132,6 @@ i.isChecked = i.id === item.id ? 0 : 1 }) - typeName.value = item.item.name formData.id = item.item.id formData.code = item.item.maCode formData.maType = item.item.maName @@ -154,6 +159,14 @@ console.error('扫描出错:', error.message) uni.showToast({ title: error.message, icon: 'none' }) } + // 清空表单 + const reset = () => { + Object.keys(formData).forEach(key => { + formData[key] = '' + }) + typeName.value = '' + typeList.value = [] + } // 提交 const handleSubmit = () => { @@ -163,6 +176,8 @@ title: res.msg, icon: 'none', }) + + handleSearch() } }).catch(error => { console.log(error) @@ -179,11 +194,12 @@ display: flex; align-items: center; justify-content: space-between; + margin-bottom: 30px; } .popup { background: #fff; - margin: 20px 0 30px; + margin: 0 0 30px; padding: 5px 10px; } @@ -202,7 +218,8 @@ ::v-deep .uni-popup__wrapper { width: calc(100% - 20px); - /* padding: 10px; */ + max-height: 80vh; + overflow: auto; } ::v-deep .uni-data-checklist { diff --git a/src/pages/nameplateUpdate/index.vue b/src/pages/nameplateUpdate/index.vue index 60e8ee3..b39a7b1 100644 --- a/src/pages/nameplateUpdate/index.vue +++ b/src/pages/nameplateUpdate/index.vue @@ -32,7 +32,14 @@
- +
设备类型:{{ formData.materialName }}
@@ -154,6 +161,7 @@ const getInfo = () => { maCode: keyWord.value, qrCode: qrCode.value, } + resetFormData() getInfoByCode(params) .then((res) => { if (res.code === 200 && res.data && res.data.length > 0) { @@ -165,6 +173,9 @@ const getInfo = () => { isChecked: 1, } }) + if (res.data.length === 1) { + formData = res.data[0] + } } }) .catch((error) => { @@ -271,7 +282,7 @@ const handleSubmit = () => { title: res.msg, icon: 'none', }) - resetFormData() + getInfo() } }) .catch((error) => { @@ -279,11 +290,12 @@ const handleSubmit = () => { }) } const resetFormData = () => { - Object.keys(formData).forEach(key => { + Object.keys(formData).forEach((key) => { formData[key] = '' }) + typeName.value = '' + typeList.value = [] } -