巡检记录接口对接
This commit is contained in:
@@ -5,33 +5,32 @@
|
||||
<view class="title_box flex items-center justify-between">
|
||||
<view class="title flex items-center">
|
||||
<view class="line"> </view>
|
||||
<text>{{ info.taskName }}</text>
|
||||
</view>
|
||||
<view class="inspection_status" v-if="info.status === 0"> <text>已巡检</text> </view>
|
||||
<view class="inspection_status todo" v-else>
|
||||
<text>未巡检</text>
|
||||
<text>{{ info.villageName }} - {{ info.taskName }}</text>
|
||||
</view>
|
||||
<view class="inspection_status"> <text>已巡检</text> </view>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view class="item">
|
||||
<text>巡检项目:</text>
|
||||
<text>{{ info.items.join('; ') }}</text>
|
||||
<text>{{ info.planName }}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text>巡检时间:</text>
|
||||
<text>{{ info.time }}</text>
|
||||
<text>07:00:00 - 09:00:00</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text>巡检小区:</text>
|
||||
<text>{{ info.villageName }}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text>巡检路线:</text>
|
||||
<text>{{ info.planName }}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text>巡检点:</text>
|
||||
<text>{{ info.point.join('; ') }}</text>
|
||||
<view class="" v-for="(item, index) in baseFormData" :key="index">
|
||||
<view class="item">
|
||||
<text>巡检路线:</text>
|
||||
<text>{{ item.routeName }}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text>巡检点:</text>
|
||||
<text v-for="(ite, ind) in item.points" :key="ind">{{ ite.pointName }};</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -39,39 +38,49 @@
|
||||
<view class="inspecton_result_title">
|
||||
<text>巡检结果</text>
|
||||
</view>
|
||||
<view class="inspection_body" v-for="(item, index) in result" :key="index">
|
||||
<view class="inspection_items">
|
||||
<text class="label">巡检点:</text>
|
||||
<text>{{ item.pointName }}</text>
|
||||
<view class="inspection_body" v-for="(item, index) in baseFormData" :key="index">
|
||||
<view v-for="(ite, ind) in item.points" :key="ind">
|
||||
<view class="inspection_items">
|
||||
<text class="label">巡检路线:</text>
|
||||
<text style="font-weight: 550">{{ item.routeName }}</text>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<text class="label">巡检点:</text>
|
||||
<text>{{ ite.pointName }}</text>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<text class="label">巡检人:</text>
|
||||
<text>{{ ite.resientName }}</text>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<text class="label">手机号码:</text>
|
||||
<text>{{ ite.phone }}</text>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<text class="label">巡检时间:</text>
|
||||
<text>{{ ite.time }}</text>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<text class="label">巡检状态:</text>
|
||||
<text>{{ ite.status === 0 ? '正常' : '异常' }}</text>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<view class="label">巡检结果:</view>
|
||||
<view class="desction_value">{{ ite.descrtion }}</view>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<view class="label">巡检照片:</view>
|
||||
<image
|
||||
lazy-load
|
||||
class="inspection_photo"
|
||||
v-for="(it, ind) in ite.files"
|
||||
:key="ind"
|
||||
:src="it"
|
||||
mode="scaleToFill"
|
||||
></image>
|
||||
</view>
|
||||
<view class="linedash" v-show="ind + 1 !== item.points.length"> </view>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<text class="label">巡检人:</text>
|
||||
<text>{{ item.user }}</text>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<text class="label">手机号码:</text>
|
||||
<text>{{ item.phone }}</text>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<text class="label">巡检时间:</text>
|
||||
<text>{{ item.time }}</text>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<view class="label">巡检结果:</view>
|
||||
<view class="desction_value">{{ item.descrtion }}</view>
|
||||
</view>
|
||||
<view class="inspection_items">
|
||||
<view class="label">巡检照片:</view>
|
||||
<image
|
||||
lazy-load
|
||||
class="inspection_photo"
|
||||
v-for="(ite, ind) in item.photos"
|
||||
:key="ind"
|
||||
:src="ite"
|
||||
mode="scaleToFill"
|
||||
></image>
|
||||
</view>
|
||||
<view class="linedash" v-show="index + 1 !== result.length"> </view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -80,57 +89,65 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { getInspectionMain } from '@/api/insepction.js'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
|
||||
const taskid = ref('')
|
||||
const info = ref({
|
||||
items: ['设备巡检', '电力检查'],
|
||||
time: '07:00:00-12:00:00',
|
||||
villageName: '幸福苑小区',
|
||||
taskName: '幸福苑小区-B1层地下车区',
|
||||
status: 0, // 0 已巡检 1未巡检
|
||||
planName: '常规巡检路线1',
|
||||
point: ['安全出口1号', '巡检点2号', '巡检点3号']
|
||||
planName: '',
|
||||
remindTime: '',
|
||||
routes: [],
|
||||
taskId: '',
|
||||
taskName: '',
|
||||
taskTime: '',
|
||||
villageName: ''
|
||||
})
|
||||
const baseFormData = ref([])
|
||||
|
||||
function init() {
|
||||
if (!taskid.value) return
|
||||
getInspectionMain(taskid.value)
|
||||
.then(res => {
|
||||
info.value = res.data
|
||||
if (!res.data.routes) return
|
||||
let result = res.data.routes
|
||||
.map(item => {
|
||||
if (!item.points || item.points.length <= 0) return false
|
||||
const points = item.points.map(ite => {
|
||||
return {
|
||||
pointId: ite.pointId,
|
||||
pointName: ite.pointName,
|
||||
status: ite.status ?? 0,
|
||||
desition: ite.remark,
|
||||
files: ite.imgUrl ? ite.imgUrl.split(',') : [],
|
||||
phone: '',
|
||||
time: '',
|
||||
resientName: ''
|
||||
}
|
||||
})
|
||||
return {
|
||||
routeName: item.routeName,
|
||||
routeId: item.routeId,
|
||||
description: item.description,
|
||||
points: points
|
||||
}
|
||||
})
|
||||
.filter(item => item !== false)
|
||||
baseFormData.value = result
|
||||
console.log(result)
|
||||
})
|
||||
.catch(err => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: '网络异常'
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
onLoad(options => {
|
||||
taskid.value = options.id
|
||||
init()
|
||||
})
|
||||
const result = ref([
|
||||
{
|
||||
pointName: '安全出口1号',
|
||||
user: '李相龙',
|
||||
phone: '1502360831',
|
||||
time: '2026-10-25 08:10:01',
|
||||
descrtion: '设备正常运转,电力系统正常,设备使用正常',
|
||||
photos: [
|
||||
'https://picsum.photos/80',
|
||||
'https://picsum.photos/80',
|
||||
'https://picsum.photos/80',
|
||||
'https://picsum.photos/80'
|
||||
]
|
||||
},
|
||||
{
|
||||
pointName: '巡检点2号',
|
||||
user: '李相龙',
|
||||
phone: '1502360831',
|
||||
time: '2026-10-25 10:10:01',
|
||||
descrtion: '部分墙体漏水',
|
||||
photos: [
|
||||
'https://picsum.photos/80',
|
||||
'https://picsum.photos/80',
|
||||
'https://picsum.photos/80',
|
||||
'https://picsum.photos/80'
|
||||
]
|
||||
},
|
||||
{
|
||||
pointName: '巡检点3号',
|
||||
user: '李相龙',
|
||||
phone: '1502360831',
|
||||
time: '2026-10-25 12:10:01',
|
||||
descrtion: '正常',
|
||||
photos: [
|
||||
'https://picsum.photos/80',
|
||||
'https://picsum.photos/80',
|
||||
'https://picsum.photos/80',
|
||||
'https://picsum.photos/80'
|
||||
]
|
||||
}
|
||||
])
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -237,7 +254,9 @@ const result = ref([
|
||||
}
|
||||
.linedash {
|
||||
width: 100%;
|
||||
border: 2rpx dashed #ccc;
|
||||
height: 0;
|
||||
border: 1rpx dashed #ccc;
|
||||
margin: 40rpx 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,43 +3,53 @@
|
||||
<view class="page_padding">
|
||||
<view class="inspection_record_box flex-1 flex flex-col">
|
||||
<navBar @clickLeft="navBack" title="巡检记录"></navBar>
|
||||
|
||||
<TabsComponents :tabslist="tabslist" @update="handleChangeTabs"></TabsComponents>
|
||||
<view class="timebox">
|
||||
<view class="daybox flex items-center">
|
||||
<uni-datetime-picker
|
||||
type="date"
|
||||
:clear-icon="false"
|
||||
@change="handleChangeTime"
|
||||
v-model="queryParmas.date"
|
||||
>
|
||||
<view class="day">{{ showDate }}</view>
|
||||
</uni-datetime-picker>
|
||||
<view class="searchiconbox flex items-center">
|
||||
<view class="arrow"> </view>
|
||||
<view class="arrow1"> </view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view
|
||||
class="record_body record-list"
|
||||
scroll-y
|
||||
lower-threshold="60"
|
||||
lower-threshold="160"
|
||||
@scrolltolower="scrolltolower"
|
||||
>
|
||||
<!-- v-for -->
|
||||
<view class="record_item" v-for="(item, index) in list" :key="index">
|
||||
<view class="time">
|
||||
<view>{{ item.day }}</view>
|
||||
<view
|
||||
class="record_list_item"
|
||||
v-for="(ite, index) in list"
|
||||
:key="index"
|
||||
@tap="handleTap(ite)"
|
||||
>
|
||||
<view class="title flex items-center">
|
||||
<view class="title_name"> {{ ite.taskName }} </view>
|
||||
<view class="title_status" v-if="isComputed(ite.taskStatus)"> 已巡检 </view>
|
||||
<view class="title_status noinspection" v-else> 未巡检 </view>
|
||||
</view>
|
||||
<view class="record_list_box">
|
||||
<!-- v-for -->
|
||||
<view class="record_list_item" v-for="(ite, ind) in item.list" :key="ind">
|
||||
<view class="title flex items-center">
|
||||
<view class="title_name"> {{ ite.title }} </view>
|
||||
<view class="title_status" v-if="ite.status === 0"> 已巡检 </view>
|
||||
<view class="title_status noinspection" v-else> 未巡检 </view>
|
||||
</view>
|
||||
<view class="items">
|
||||
<!-- v-for -->
|
||||
<view class="item" v-for="(it, inde) in ite.items" :key="inde">
|
||||
<text>{{ it }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="time">
|
||||
<text>巡检时间:</text>
|
||||
<text>{{ ite.time }}</text>
|
||||
</view>
|
||||
<view class="time user">
|
||||
<text>巡检人:</text>
|
||||
<text>{{ ite.user }}</text>
|
||||
</view>
|
||||
<view class="items" v-if="ite.points">
|
||||
<view class="item" v-for="(itemname, itemindex) in ite.itemslist" :key="itemindex">
|
||||
<text>{{ itemname }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="time">
|
||||
<text>巡检时间:</text>
|
||||
<text>{{ ite.taskTime }}</text>
|
||||
</view>
|
||||
<view class="time user">
|
||||
<text>巡检人:</text>
|
||||
<text>{{ ite.inspectorName }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
@@ -49,62 +59,48 @@
|
||||
<script setup lang="ts">
|
||||
import TabsComponents from '@/components/tabs/tabs.vue'
|
||||
import navBar from '@/components/navbar/navbar.vue'
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { getInspectionList } from '@/api/insepction.js'
|
||||
import { parseTime } from '@/utils/time.js'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
|
||||
const isComputed = (status: string) => {
|
||||
const awaitlist = ['未完成', '待执行', '执行中']
|
||||
return !awaitlist.includes(status)
|
||||
}
|
||||
|
||||
const tabslist = [
|
||||
{
|
||||
name: '全部',
|
||||
value: 0
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
name: '未巡检',
|
||||
value: 1
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
name: ' 已巡检',
|
||||
value: 2
|
||||
value: 1
|
||||
}
|
||||
]
|
||||
function handleChangeTabs(val: number) {}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
const list = ref([
|
||||
{
|
||||
day: '10月11日',
|
||||
list: [
|
||||
{
|
||||
title: '标题1',
|
||||
status: 0,
|
||||
items: ['设备巡检'],
|
||||
time: '07:00:00-09:00:00',
|
||||
user: '李兴'
|
||||
},
|
||||
{
|
||||
title: '标题3',
|
||||
status: 0,
|
||||
items: ['设备巡检'],
|
||||
time: '07:00:00-09:00:00',
|
||||
user: '湖色'
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
|
||||
const list = ref([])
|
||||
const queryParmas = ref({
|
||||
date: '',
|
||||
status: 2,
|
||||
pageNum: 1,
|
||||
pageSize: 5
|
||||
pageSize: 10
|
||||
})
|
||||
const showDate = computed(() => {
|
||||
return parseTime(queryParmas.value.date, '{m}月{d}日')
|
||||
})
|
||||
const isLoading = ref(false) // 加载锁
|
||||
const hasMore = ref(true) // 是否还有更多数据
|
||||
const total = ref(21)
|
||||
function scrolltolower() {
|
||||
// 必须加这两个判断!
|
||||
if (isLoading.value || !hasMore.value) {
|
||||
return
|
||||
}
|
||||
queryParmas.value.pageNum += 1
|
||||
getlist()
|
||||
}
|
||||
const total = ref(0)
|
||||
|
||||
function getlist() {
|
||||
// 1. 如果正在加载或没有更多数据,直接返回
|
||||
if (isLoading.value || !hasMore.value) return
|
||||
@@ -114,51 +110,76 @@ 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 {
|
||||
day: '10月' + realId + '日',
|
||||
list: [
|
||||
{
|
||||
title: '标题1',
|
||||
status: randomStatus,
|
||||
items: ['设备巡检'],
|
||||
time: '07:00:00-09:00:00',
|
||||
user: '李兴'
|
||||
},
|
||||
{
|
||||
title: '标题3',
|
||||
status: randomStatus,
|
||||
items: ['设备巡检'],
|
||||
time: '07:00:00-09:00:00',
|
||||
user: '湖色'
|
||||
}
|
||||
]
|
||||
}
|
||||
const { pageNum, pageSize, date } = queryParmas.value
|
||||
getInspectionList({
|
||||
pageSize,
|
||||
pageNum,
|
||||
date
|
||||
})
|
||||
|
||||
// 追加数据(正确方式)
|
||||
list.value = [...list.value, ...arr]
|
||||
// 判断是否还有更多
|
||||
hasMore.value = list.value.length < total.value
|
||||
isLoading.value = false
|
||||
uni.hideLoading()
|
||||
.then(res => {
|
||||
list.value = res.rows
|
||||
let items: Set<string> = new Set()
|
||||
res.rows.forEach(item => {
|
||||
if (!item.points || item.points.length <= 0) return
|
||||
item.points.forEach(ite => {
|
||||
ite.itemNames.forEach(it => items.add(it))
|
||||
})
|
||||
item.itemslist = Array.from(items)
|
||||
console.log(item.itemslist)
|
||||
})
|
||||
hasMore.value = list.value.length < res.total
|
||||
total.value = res.total
|
||||
})
|
||||
.finally(() => {
|
||||
isLoading.value = false
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
getlist()
|
||||
function resetList() {
|
||||
list.value = []
|
||||
queryParmas.value.pageNum = 1
|
||||
|
||||
function handleChangeTime(event: string) {
|
||||
hasMore.value = true
|
||||
queryParmas.value.date = event
|
||||
getlist()
|
||||
}
|
||||
|
||||
function handleTap(ite) {
|
||||
if (isComputed(ite.taskStatus)) {
|
||||
uni.navigateTo({
|
||||
url: '/pageSubPack/inspection/inspection_main?id=' + ite.id
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pageSubPack/inspection/inspection_upload?id=' + ite.id
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function scrolltolower() {
|
||||
if (isLoading.value || !hasMore.value) {
|
||||
return
|
||||
}
|
||||
queryParmas.value.pageNum += 1
|
||||
getlist()
|
||||
}
|
||||
|
||||
function handleChangeTabs(val: number) {
|
||||
queryParmas.value.status = val
|
||||
queryParmas.value.pageNum = 1
|
||||
queryParmas.value.pageSize = 10
|
||||
getlist()
|
||||
}
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
function init() {
|
||||
queryParmas.value.date = parseTime(new Date(), '{y}-{m}-{d}')
|
||||
getlist()
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
hasMore.value = true
|
||||
console.log('show')
|
||||
init()
|
||||
})
|
||||
// 返回上一页
|
||||
const navBack = () => {
|
||||
uni.navigateBack()
|
||||
@@ -174,91 +195,121 @@ const navBack = () => {
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
.record_body {
|
||||
.timebox {
|
||||
width: 178rpx;
|
||||
height: 48rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
text-align: center;
|
||||
line-height: 48rpx;
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
margin-bottom: 20rpx;
|
||||
margin-top: 20rpx;
|
||||
.daybox {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
.day {
|
||||
flex: 1;
|
||||
font-size: 28rpx;
|
||||
text-align: left;
|
||||
padding-left: 15rpx;
|
||||
}
|
||||
.searchiconbox {
|
||||
width: 38rpx;
|
||||
height: 48rpx;
|
||||
padding-right: 10rpx;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
.arrow,
|
||||
.arrow1 {
|
||||
border: 1rpx solid #ccc;
|
||||
width: 8rpx;
|
||||
height: 8rpx;
|
||||
}
|
||||
.arrow {
|
||||
border-right-color: transparent;
|
||||
border-top-color: transparent;
|
||||
transform: rotateZ(135deg);
|
||||
}
|
||||
.arrow1 {
|
||||
border-left-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
transform: rotateZ(135deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.record_body {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
.record_item {
|
||||
& > .time {
|
||||
width: 168rpx;
|
||||
height: 48rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
text-align: center;
|
||||
line-height: 48rpx;
|
||||
|
||||
.record_list_item {
|
||||
margin-bottom: 20rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 16rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 32rpx;
|
||||
// 巡检标题
|
||||
.title {
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
font-size: 32rpx;
|
||||
color: #222222;
|
||||
line-height: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-bottom: 25rpx;
|
||||
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.record_list_box {
|
||||
margin-bottom: 20rpx;
|
||||
.record_list_item {
|
||||
margin-bottom: 20rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 16rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 32rpx;
|
||||
// 巡检标题
|
||||
.title {
|
||||
font-weight: 400;
|
||||
font-size: 32rpx;
|
||||
color: #222222;
|
||||
line-height: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-bottom: 25rpx;
|
||||
.title_status {
|
||||
width: 86rpx;
|
||||
height: 30rpx;
|
||||
background: #4d5dfa;
|
||||
border-radius: 198rpx 198rpx 198rpx 198rpx;
|
||||
text-align: center;
|
||||
font-weight: 400;
|
||||
font-size: 20rpx;
|
||||
color: #ffffff;
|
||||
line-height: 30rpx;
|
||||
margin-left: 5rpx;
|
||||
|
||||
.title_status {
|
||||
width: 86rpx;
|
||||
height: 30rpx;
|
||||
background: #4d5dfa;
|
||||
border-radius: 198rpx 198rpx 198rpx 198rpx;
|
||||
text-align: center;
|
||||
font-weight: 400;
|
||||
font-size: 20rpx;
|
||||
color: #ffffff;
|
||||
line-height: 30rpx;
|
||||
margin-left: 5rpx;
|
||||
|
||||
&.noinspection {
|
||||
background-color: #ccc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 巡检项目
|
||||
.items {
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
.item {
|
||||
padding: 0 10rpx;
|
||||
height: 42rpx;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
border: 1rpx solid #4d5dfa;
|
||||
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #4d5dfa;
|
||||
text-align: center;
|
||||
line-height: 42rpx;
|
||||
margin-right: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
// 巡检人 巡检时间
|
||||
& > .time {
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
&.noinspection {
|
||||
background-color: #ccc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 巡检项目
|
||||
.items {
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
.item {
|
||||
padding: 0 10rpx;
|
||||
height: 42rpx;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
border: 1rpx solid #4d5dfa;
|
||||
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #4d5dfa;
|
||||
text-align: center;
|
||||
line-height: 42rpx;
|
||||
margin-right: 20rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
// 巡检人 巡检时间
|
||||
& > .time {
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
<view class="inspection_title flex flex-between">
|
||||
<view class="title flex">
|
||||
<text class="line"></text>
|
||||
<text>幸福苑小区- B1层地下车库</text>
|
||||
<text>{{ info.villageName }} - {{ info.taskName }}</text>
|
||||
</view>
|
||||
<view class="status">
|
||||
<view class="status" v-if="!isComputed">
|
||||
<text>未巡检</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="inspection_item_info_box">
|
||||
<view class="inspection_item">
|
||||
<text>巡检项目:</text>
|
||||
<text>设备巡检</text>
|
||||
<text>{{ info.planName }}</text>
|
||||
</view>
|
||||
<view class="inspection_item">
|
||||
<text>巡检时间:</text>
|
||||
@@ -22,106 +22,92 @@
|
||||
</view>
|
||||
<view class="inspection_item">
|
||||
<text>巡检小区:</text>
|
||||
<text>幸福苑小区</text>
|
||||
<text>{{ info.villageName }}</text>
|
||||
</view>
|
||||
<view class="inspection_item">
|
||||
<text>巡检路线:</text>
|
||||
<text>常规巡检路线1</text>
|
||||
</view>
|
||||
<view class="inspection_item">
|
||||
<text>巡检点:</text>
|
||||
<text>安全巡检点1;</text>
|
||||
<text>安全巡检点2;</text>
|
||||
<text>安全巡检点3;</text>
|
||||
<text>安全巡检点4;</text>
|
||||
<view class="" v-for="(item, index) in baseFormData" :key="index">
|
||||
<view class="inspection_item">
|
||||
<text>巡检路线:</text>
|
||||
<text>{{ item.routeName }}</text>
|
||||
</view>
|
||||
<view class="inspection_item">
|
||||
<text>巡检点:</text>
|
||||
<text v-for="(ite, ind) in item.points" :key="ind">{{ ite.ponitName }};</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="inspection_info_upload_box">
|
||||
<view class="header"> <text>巡检结果</text> </view>
|
||||
<view class="info_body" :key="index" v-for="(item, index) in baseFormData">
|
||||
<view class="info_title" style="margin-bottom: 20rpx"> {{ item.name }} </view>
|
||||
<uni-forms :modelValue="item" :rules="rules" label-position="left" label-width="150">
|
||||
<uni-forms-item label="巡检状态" required>
|
||||
<uni-data-checkbox
|
||||
:disabled="item.complated"
|
||||
v-model="item.status"
|
||||
:localdata="statuslist"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="巡检描述">
|
||||
<uni-easyinput
|
||||
type="textarea"
|
||||
:disabled="item.complated"
|
||||
:input-border="true"
|
||||
v-model="item.desition"
|
||||
placeholder="请输入"
|
||||
></uni-easyinput>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="巡检时间">
|
||||
<uni-datetime-picker
|
||||
type="datetime"
|
||||
:disabled="item.complated"
|
||||
return-type="timestamp"
|
||||
v-model="item.datetimesingle"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<!-- <uni-forms-item label="巡检照片">
|
||||
<uni-file-picker
|
||||
@delete="deleteFile"
|
||||
@select="select"
|
||||
mode="grid"
|
||||
v-model="item.files"
|
||||
:auto-upload="false"
|
||||
:sourceType="['camera']"
|
||||
file-mediatype="image"
|
||||
>
|
||||
<view class="filePicker flex-center">
|
||||
<uni-icons color="#a6a6a6" type="plusempty" size="25"> </uni-icons>
|
||||
</view>
|
||||
</uni-file-picker>
|
||||
</uni-forms-item> -->
|
||||
<view class="items_picker_box">
|
||||
<view class="label"> 巡检照片 </view>
|
||||
<view class="filePickerbox" v-if="!item.complated">
|
||||
<filePicker
|
||||
v-model="item.files"
|
||||
:sourceType="['camera']"
|
||||
file-field-name="file"
|
||||
:extra-data="uploadParams"
|
||||
@success="onUploadSuccess"
|
||||
@fail="onUploadFail"
|
||||
></filePicker>
|
||||
</view>
|
||||
<view class="filePickerbox showimagegrid" v-else>
|
||||
<image
|
||||
class="img"
|
||||
mode="scaleToFill"
|
||||
v-for="(ite, ind) in item.files"
|
||||
lazy-load
|
||||
:key="ind"
|
||||
:src="ite"
|
||||
@tap="previewImages(item.files, index)"
|
||||
></image>
|
||||
</view>
|
||||
</view>
|
||||
</uni-forms>
|
||||
<view class="submitbox" @tap="handleSubmit(item.id)">
|
||||
<text>提交</text>
|
||||
<view class="inspection_info_upload_box" v-if="baseFormData.length > 0">
|
||||
<view class="inspection_routes" v-for="(item, index) in baseFormData" :key="index">
|
||||
<view class="header">
|
||||
<text>{{ item.routeName }} - 巡检结果</text>
|
||||
</view>
|
||||
<view class="info_body" v-for="(ite, ind) in item.points" :key="ind">
|
||||
<view class="info_title" style="margin-bottom: 20rpx"> {{ ite.ponitName }} </view>
|
||||
<uni-forms :modelValue="ite" :rules="rules" label-position="left" label-width="150">
|
||||
<uni-forms-item label="巡检状态" required>
|
||||
<uni-data-checkbox
|
||||
:disabled="ite.complated"
|
||||
v-model="ite.status"
|
||||
:localdata="statuslist"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="巡检描述" v-if="!ite.complated">
|
||||
<uni-easyinput
|
||||
type="textarea"
|
||||
:disabled="ite.complated"
|
||||
:input-border="true"
|
||||
v-model="ite.desition"
|
||||
placeholder="请输入"
|
||||
></uni-easyinput>
|
||||
</uni-forms-item>
|
||||
<view class="items_picker_box flex" style="align-items: baseline" v-else>
|
||||
<view class="label"> 巡检描述 </view>
|
||||
<view class="desitionbox flex-1">
|
||||
<text class="desition">{{ ite.desition }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="items_picker_box">
|
||||
<view class="label"> 巡检照片 </view>
|
||||
<view class="filePickerbox" v-if="!ite.complated">
|
||||
<filePicker
|
||||
v-model="ite.files"
|
||||
:sourceType="['camera']"
|
||||
file-field-name="file"
|
||||
:extra-data="uploadParams"
|
||||
uploadUrl="/resource/oss/upload"
|
||||
@fail="onUploadFail"
|
||||
></filePicker>
|
||||
</view>
|
||||
<view class="filePickerbox showimagegrid" v-else>
|
||||
<image
|
||||
class="img"
|
||||
mode="scaleToFill"
|
||||
v-for="(ite, ind) in ite.files"
|
||||
lazy-load
|
||||
:key="ind"
|
||||
:src="ite"
|
||||
@tap="previewImages(ite.files, index)"
|
||||
></image>
|
||||
</view>
|
||||
</view>
|
||||
</uni-forms>
|
||||
<view class="submitbox" @tap="handleSubmit(ite)" v-if="!ite.complated">
|
||||
<text>提交</text>
|
||||
</view>
|
||||
<view class="line" v-if="ind + 1 === baseFormData.length"> </view>
|
||||
</view>
|
||||
<view class="line" v-if="index + 1 !== baseFormData.length"> </view>
|
||||
</view>
|
||||
<!-- <view class="submitbox">
|
||||
<text>提交</text>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import filePicker from '@/components/filePicker/filePicker.vue'
|
||||
import { getInspectionMain } from '@/api/insepction.js'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { putInsepctionPoint } from '@/api/insepction.js'
|
||||
|
||||
const statuslist = [
|
||||
{
|
||||
@@ -133,27 +119,16 @@ const statuslist = [
|
||||
value: 1
|
||||
}
|
||||
]
|
||||
const taskid = ref('')
|
||||
const baseFormData = ref([])
|
||||
const info = ref({
|
||||
point: Array.from({ length: 4 }).map((_, index) => {
|
||||
let obj1 = {
|
||||
name: `巡检点${index + 1}`,
|
||||
id: index + ''
|
||||
}
|
||||
let obj = {
|
||||
id: index,
|
||||
name: obj1.name,
|
||||
desition: '', // 描述
|
||||
datetimesingle: '', // 时间
|
||||
status: 0, // 状态 0正常1异常
|
||||
files: [], // 图片
|
||||
complated: false, // 巡检点完成检查
|
||||
fileUrls: '' // 图片
|
||||
}
|
||||
|
||||
baseFormData.value.push(obj)
|
||||
return obj1
|
||||
})
|
||||
planName: '',
|
||||
remindTime: '',
|
||||
routes: [],
|
||||
taskId: '',
|
||||
taskName: '',
|
||||
taskTime: '',
|
||||
villageName: ''
|
||||
})
|
||||
const rules = {
|
||||
status: {
|
||||
@@ -166,36 +141,86 @@ const rules = {
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
const uploadParams = ref({
|
||||
type: 'repair', // 上传类型:报修
|
||||
businessId: '123456', // 关联业务ID
|
||||
userId: '789' // 用户ID
|
||||
function init() {
|
||||
if (!taskid.value) return
|
||||
getInspectionMain(taskid.value)
|
||||
.then(res => {
|
||||
info.value = res.data
|
||||
if (!res.data.routes) return
|
||||
let result = res.data.routes
|
||||
.map(item => {
|
||||
if (!item.points || item.points.length <= 0) return false
|
||||
const points = item.points.map(ite => {
|
||||
return {
|
||||
pointId: ite.pointId,
|
||||
ponitName: ite.pointName,
|
||||
status: ite.status ?? 0,
|
||||
desition: ite.remark,
|
||||
complated: ite.status !== null,
|
||||
files: ite.imgUrl ? ite.imgUrl.split(',') : []
|
||||
}
|
||||
})
|
||||
return {
|
||||
routeName: item.routeName,
|
||||
routeId: item.routeId,
|
||||
description: item.description,
|
||||
points: points
|
||||
}
|
||||
})
|
||||
.filter(item => item !== false)
|
||||
baseFormData.value = result
|
||||
console.log(result)
|
||||
console.log(isComputed.value)
|
||||
})
|
||||
.catch(err => {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: '网络异常'
|
||||
})
|
||||
})
|
||||
}
|
||||
onLoad(options => {
|
||||
taskid.value = options.id
|
||||
// taskid.value = '2044684785371725826'
|
||||
init()
|
||||
})
|
||||
|
||||
// 选择文件
|
||||
function onUploadSuccess(e) {
|
||||
console.log('上传成功', e)
|
||||
}
|
||||
// ----------------------------------------------
|
||||
const uploadParams = ref({})
|
||||
|
||||
function onUploadFail(e) {
|
||||
console.log('上传失败', e)
|
||||
}
|
||||
|
||||
function submit() {
|
||||
console.log('最终要提交的图片URL', imageList.value)
|
||||
// 这里调用你的提交接口
|
||||
}
|
||||
|
||||
/** 提交巡检点 检查情况 */
|
||||
function handleSubmit(id) {
|
||||
console.log(typeof id, id, baseFormData.value)
|
||||
const find = baseFormData.value.find(item => item.id === id)
|
||||
if (find) {
|
||||
find.complated = true
|
||||
function handleSubmit(item) {
|
||||
console.log(item, baseFormData.value)
|
||||
let obj = {
|
||||
pointId: item.pointId,
|
||||
imgUrl: item.files.length > 0 ? item.files.join(',') : '',
|
||||
remark: item.desition,
|
||||
status: item.status,
|
||||
taskId: taskid.value
|
||||
}
|
||||
console.log(obj)
|
||||
putInsepctionPoint(obj)
|
||||
.then(res => {
|
||||
item.complated = true
|
||||
console.log(isComputed.value)
|
||||
console.log(res)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
const isComputed = computed(() => {
|
||||
// 遍历每一项
|
||||
return baseFormData.value.every(item => {
|
||||
// 每一项里的所有 points 都必须是已完成
|
||||
return item.points.every(point => point.complated)
|
||||
})
|
||||
})
|
||||
/**
|
||||
* 预览图片
|
||||
* @param {Array} images - 所有图片的URL数组
|
||||
@@ -279,12 +304,22 @@ function previewImages(images, currentIndex) {
|
||||
}
|
||||
.info_body {
|
||||
margin-bottom: 40rpx;
|
||||
.desitionbox {
|
||||
.desition {
|
||||
font-size: small;
|
||||
color: #ccc;
|
||||
line-height: 1;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.info_title {
|
||||
font-weight: 550;
|
||||
}
|
||||
.line {
|
||||
width: 100%;
|
||||
margin-top: 40rpx;
|
||||
margin-bottom: 40rpx;
|
||||
border: 1rpx dashed #ccc;
|
||||
}
|
||||
.items_picker_box {
|
||||
@@ -320,7 +355,6 @@ function previewImages(images, currentIndex) {
|
||||
color: #ffffff;
|
||||
line-height: 80rpx;
|
||||
margin-top: 40rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import TabsComponents from '@/components/tabs/tabs.vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
// tabs =========================================================
|
||||
const activeValue = ref(0)
|
||||
const tabslist = ref([
|
||||
@@ -125,6 +126,12 @@ const list = ref([
|
||||
status: 1 // 0未巡检 1已巡检
|
||||
}
|
||||
])
|
||||
|
||||
function getInspectionList() {
|
||||
getInspectionList()
|
||||
}
|
||||
|
||||
onShow(() => getInspectionList())
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user