巡检记录接口对接

This commit is contained in:
Zy
2026-05-19 09:23:23 +08:00
parent 9d06785fd2
commit 82200a3617
17 changed files with 880 additions and 467 deletions

View File

@@ -2,7 +2,7 @@
<view class="page_container addreplacement_box">
<uni-forms border :modelValue="formData" label-position="left">
<uni-forms-item label="仪表类型">
<uni-data-checkbox v-model="formData.type" :localdata="items"></uni-data-checkbox>
<uni-data-checkbox v-model="formData.deviceType" :localdata="items"></uni-data-checkbox>
</uni-forms-item>
<uni-forms-item label="设备编号">
<view class="flex items-center justify-between">
@@ -14,7 +14,13 @@
:clearable="true"
>
</uni-easyinput>
<uni-icons @tap="handleScan" size="48rpx" type="scan" color="#737373"></uni-icons>
<uni-icons
class="scanicons"
@tap="handleScan"
size="48rpx"
type="scan"
color="#737373"
></uni-icons>
</view>
</uni-forms-item>
<uni-forms-item label="房屋号">
@@ -42,19 +48,22 @@
<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { AddReplaceMainList } from '@/api/instrument.js'
const formData = ref({
type: 1,
deviceType: 2,
deviceCode: '',
houseId: ''
})
// 水表,电表列表
const items = [
{
text: '水表',
value: 1
value: 2
},
{
text: '电表',
value: 2
value: 1
}
]
@@ -74,15 +83,51 @@ function handleClick() {
}
/** 处理 扫码 */
function handleScan() {
// 允许从相机和相册扫码
uni.scanCode({
success: function (res) {
formData.value.deviceCode = res.result
},
error: err => {
uni.showToast({
icon: 'error',
title: '扫描异常'
})
}
})
}
function handleSubmit() {}
function handleSubmit() {
formData.value.deviceCode = formData.value.deviceCode.trim()
formData.value.houseId = formData.value.houseId.trim()
if (!formData.value.deviceCode.trim()) {
uni.showToast({
icon: 'exception',
title: '检查设备编号'
})
}
if (!formData.value.houseId.trim()) {
uni.showToast({
icon: 'exception',
title: '选择房屋'
})
}
AddReplaceMainList(formData.value)
.then(() => {
uni.showToast({
icon: 'success',
title: '操作成功',
success() {
uni.navigateBack()
}
})
})
.catch(err => {
uni.showToast({
icon: 'error',
title: '检查编号'
})
})
}
</script>
<style lang="scss" scoped>
@@ -116,5 +161,9 @@ function handleSubmit() {}
color: #ffffff;
line-height: 80rpx;
}
.scanicons {
margin-left: 20rpx;
}
}
</style>