巡检记录接口对接
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -4,23 +4,25 @@
|
||||
<view
|
||||
@click="handleClick"
|
||||
class="search_view flex-center"
|
||||
v-if="!queryParmas.keyword.trim() && Searching"
|
||||
v-if="!queryParmas.searchValue.trim() && Searching"
|
||||
>
|
||||
<uni-icons type="search" size="34rpx" color="rgba(0,0,0,0.26)"></uni-icons>
|
||||
<text>请输入关键字进行搜索</text>
|
||||
</view>
|
||||
<uni-easyinput
|
||||
@blur="handleInput"
|
||||
@change="handleSearch"
|
||||
@clear="handleInput"
|
||||
@confirm="handleSearch"
|
||||
@input="handleInputString"
|
||||
:focus="true"
|
||||
ref="inputRef"
|
||||
v-model="queryParmas.keyword"
|
||||
v-model="queryParmas.searchValue"
|
||||
v-else
|
||||
/>
|
||||
</view>
|
||||
<view class="search_list flex-1 flex">
|
||||
<scroll-view lower-threshold="160" scroll-y="true" @scrolltolower="scrolltolower">
|
||||
<radio-group @change="radioChange">
|
||||
<radio-group @change="radioChange" v-if="searchlist.length > 0">
|
||||
<label v-for="(item, index) in searchlist" :key="index">
|
||||
<view
|
||||
class="search_item flex flex-between"
|
||||
@@ -39,6 +41,9 @@
|
||||
</view>
|
||||
</label>
|
||||
</radio-group>
|
||||
<view class="noData" v-else>
|
||||
<text>暂无数据</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
@@ -54,18 +59,31 @@ import { getVillageHouseList_keyword } from '@/api/common.js'
|
||||
|
||||
const Searching = ref(true)
|
||||
const queryParmas = ref({
|
||||
keyword: '',
|
||||
searchValue: '',
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
/** 点击时切换到input,并聚焦 */
|
||||
function handleClick() {
|
||||
Searching.value = false
|
||||
queryParmas.value.searchValue = ''
|
||||
}
|
||||
/** 判断 失去焦点时 切换回 view */
|
||||
function handleInput() {
|
||||
if (queryParmas.value.keyword.trim()) {
|
||||
const value = queryParmas.value.searchValue.trim()
|
||||
if (value) {
|
||||
handleSearch()
|
||||
} else if (value === '') {
|
||||
queryParmas.value.searchValue = ''
|
||||
Searching.value = true
|
||||
handleSearch()
|
||||
}
|
||||
}
|
||||
function handleInputString() {
|
||||
if (queryParmas.value.searchValue.trim() === '') {
|
||||
queryParmas.value.searchValue = ''
|
||||
Searching.value = true
|
||||
handleSearch()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,13 +120,20 @@ function getlist() {
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
getVillageHouseList_keyword(queryParmas.value, queryParmas.value.keyword)
|
||||
getVillageHouseList_keyword(queryParmas.value, queryParmas.value.searchValue)
|
||||
.then(res => {
|
||||
// 追加数据(正确方式)
|
||||
searchlist.value = [...searchlist.value, ...res.rows]
|
||||
total.value = res.total
|
||||
// 判断是否还有更多
|
||||
hasMore.value = searchlist.value.length < total.value
|
||||
})
|
||||
.catch(() => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: '网络异常'
|
||||
})
|
||||
})
|
||||
.finally(() => {
|
||||
isLoading.value = false
|
||||
uni.hideLoading()
|
||||
@@ -126,6 +151,7 @@ function resetList() {
|
||||
|
||||
// Search
|
||||
function handleSearch() {
|
||||
hasMore.value = true
|
||||
queryParmas.value.pageNum = 1
|
||||
queryParmas.value.pageSize = 10
|
||||
searchlist.value = []
|
||||
@@ -211,6 +237,13 @@ function handleSelecthouse() {
|
||||
}
|
||||
}
|
||||
}
|
||||
.noData {
|
||||
text-align: center;
|
||||
color: rgba(0, 0, 0, 0.26);
|
||||
font-size: larger;
|
||||
padding-top: 50rpx;
|
||||
letter-spacing: 10rpx;
|
||||
}
|
||||
|
||||
.action_btn {
|
||||
width: 670rpx;
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
<image lazy-load src="/static/imgs/home.png" class="icon" mode=""></image>
|
||||
<view class="instrument_info">
|
||||
<view class="instrument_title">
|
||||
<text>{{ item.title }}</text>
|
||||
<text>{{ item.addressCn }}</text>
|
||||
</view>
|
||||
<view class="instrument_time">
|
||||
<text>换新时间时间:{{ item.time }}</text>
|
||||
<text>换新时间时间:{{ item.createTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="instrument_type">
|
||||
<text v-if="item.type === 2">电表</text>
|
||||
<text v-else>水表</text>
|
||||
<text v-if="item.deviceType === '1'">电表</text>
|
||||
<text v-else-if="item.deviceType === '2'">水表</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 底部加载状态提示 -->
|
||||
@@ -42,7 +42,10 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import TabsComponents from '@/components/tabs/tabs.vue'
|
||||
import { getReplaceMainList } from '@/api/instrument.js'
|
||||
|
||||
/** 加载状态 */
|
||||
const statusmore = computed(() => {
|
||||
if (isLoading.value === true) {
|
||||
@@ -65,25 +68,35 @@ const tabslist = [
|
||||
},
|
||||
{
|
||||
name: '水表',
|
||||
value: 1
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
name: '电表',
|
||||
value: 2
|
||||
value: 1
|
||||
}
|
||||
]
|
||||
|
||||
// 切换tabs
|
||||
function handleChangeTabs(val: number) {
|
||||
queryParmas.value.deviceType = val
|
||||
if (val === 0) {
|
||||
queryParmas.value.deviceType = undefined
|
||||
}
|
||||
queryParmas.value.pageNum = 1
|
||||
infolist.value = []
|
||||
hasMore.value = true
|
||||
getlist()
|
||||
}
|
||||
// ---------------------------------------------------------------------
|
||||
const infolist = ref([])
|
||||
const queryParmas = ref({
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
pageSize: 10,
|
||||
deviceType: undefined
|
||||
})
|
||||
const total = ref(21)
|
||||
// 总数
|
||||
const total = ref(0)
|
||||
// 上滑加载
|
||||
function scrolltolower() {
|
||||
// 必须加这两个判断!
|
||||
if (isLoading.value || !hasMore.value) {
|
||||
@@ -92,6 +105,7 @@ function scrolltolower() {
|
||||
queryParmas.value.pageNum += 1
|
||||
getlist()
|
||||
}
|
||||
|
||||
function getlist() {
|
||||
// 1. 如果正在加载或没有更多数据,直接返回
|
||||
if (isLoading.value || !hasMore.value) return
|
||||
@@ -101,29 +115,29 @@ function getlist() {
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
const { pageNum, pageSize } = queryParmas.value
|
||||
|
||||
const startId = (pageNum - 1) * pageSize + 1
|
||||
const arr = Array.from({ length: pageSize }).map((_, index) => {
|
||||
const realId = startId + index // ✅ 修复 ID 错误
|
||||
|
||||
// ✅ 随机生成 0、1、2
|
||||
const randomStatus = Math.floor(Math.random() * 2)
|
||||
return {
|
||||
title: 'M2栋3单元18' + realId + '室(M2-3-1801)',
|
||||
time: '2023-08-01 10:05:46',
|
||||
type: randomStatus //1水表 2电表
|
||||
}
|
||||
const { pageNum, pageSize, deviceType } = queryParmas.value
|
||||
getReplaceMainList({
|
||||
pageNum,
|
||||
pageSize,
|
||||
deviceType
|
||||
})
|
||||
|
||||
// 追加数据(正确方式)
|
||||
infolist.value = [...infolist.value, ...arr]
|
||||
// 判断是否还有更多
|
||||
hasMore.value = infolist.value.length < total.value
|
||||
isLoading.value = false
|
||||
uni.hideLoading()
|
||||
.then(res => {
|
||||
infolist.value = [...infolist.value, ...res.rows]
|
||||
total.value = res.total
|
||||
hasMore.value = infolist.value.length < total.value
|
||||
})
|
||||
.finally(() => {
|
||||
isLoading.value = false
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
getlist()
|
||||
onShow(() => {
|
||||
infolist.value = []
|
||||
hasMore.value = true
|
||||
getlist()
|
||||
})
|
||||
|
||||
// 重置
|
||||
function resetList() {
|
||||
infolist.value = []
|
||||
queryParmas.value.pageNum = 1
|
||||
@@ -131,6 +145,7 @@ function resetList() {
|
||||
getlist()
|
||||
}
|
||||
|
||||
// 跳转到 仪表换新
|
||||
function handleClick() {
|
||||
uni.navigateTo({
|
||||
url: '/pageSubPack/instrument/addreplacement'
|
||||
|
||||
Reference in New Issue
Block a user