完成巡检模块

This commit is contained in:
赵毅 2025-09-20 18:26:36 +08:00
parent a4c0c42c29
commit 86c74c27b0
4 changed files with 113 additions and 71 deletions

View File

@ -143,3 +143,11 @@
font-size: 32rpx; font-size: 32rpx;
margin-top: 50rpx; margin-top: 50rpx;
} }
.no-options {
padding: 30rpx 20rpx;
text-align: center;
color: #999;
font-size: 28rpx;
background-color: #fff;
}

View File

@ -4,14 +4,22 @@
<view class="select-container"> <view class="select-container">
<label class="select-label">选择点位</label> <label class="select-label">选择点位</label>
<input type="text" class="search-input" v-model="searchKeyword" @focus="showOptions = true" <input type="text" class="search-input" v-model="searchKeyword" @focus="showOptions = true"
placeholder="请选择点位" readonly /> placeholder="请输入点位名称搜索" readonly />
<!-- 下拉选项 --> <!-- 下拉选项 -->
<view class="options-container" v-if="showOptions"> <view class="options-container" v-if="showOptions">
<view v-for="option in filteredOptions" :key="option.id || option.name" class="option-item" <!-- 为空时显示提示 -->
:class="{ 'selected': selectedPoint === (option.id || option.name) }" <view v-if="pointsList.length === 0" class="no-options">
@click="selectPointHandler(option)"> 暂无数据
{{ option.name }} </view>
<!-- 有选项时显示选项列表 -->
<view v-else>
<view v-for="option in pointsList"
:key="option.point_id"
class="option-item"
@click="selectPointHandler(option)">
{{ option.point_info.point_name }}
</view>
</view> </view>
</view> </view>
</view> </view>
@ -20,10 +28,8 @@
<view class="camera-section"> <view class="camera-section">
<!-- 拍照按钮当图片数量达到12张时隐藏 --> <!-- 拍照按钮当图片数量达到12张时隐藏 -->
<view class="camera-container" v-if="images.length < 12"> <view class="camera-container" v-if="images.length < 12">
<view class="camera-icon-container"> <image class="camera-icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/zhaoxiangji.png"
<image class="camera-icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/zhaoxiangji.png" mode="aspectFit" @click="takePhoto"> mode="aspectFit" @click="takePhoto"></image>
</image>
</view>
<view class="camera-text">点击拍照上传</view> <view class="camera-text">点击拍照上传</view>
</view> </view>
@ -45,6 +51,15 @@
</template> </template>
<script> <script>
import {
request,
picUrl,
uniqueByField,
menuButtonInfo,
NavgateTo,
} from "../../../utils";
import { apiArr } from "../../../api/routingInspection";
export default { export default {
data() { data() {
return { return {
@ -53,40 +68,38 @@ export default {
selectedPoint: '', selectedPoint: '',
selectedPointInfo: null, // selectedPointInfo: null, //
pointsList: [], pointsList: [],
images: [] // images: [], //
} taskId: '',
},
computed: {
filteredOptions() {
if (!this.searchKeyword) {
return this.pointsList
}
return this.pointsList.filter(option =>
option.name.toLowerCase().includes(this.searchKeyword.toLowerCase())
)
} }
}, },
onLoad(options) { onLoad(options) {
if (options.item) { if (options.item) {
try { const item = JSON.parse(options.item)
const item = JSON.parse(options.item) this.taskId = item.id
// this.getInfo(this.taskId)
if (item.points && Array.isArray(item.points)) {
this.pointsList = item.points
} else if (Array.isArray(item)) {
this.pointsList = item
}
} catch (e) {
console.error('解析数据失败', e)
}
} }
}, },
methods: { methods: {
async getInfo(id) {
const res = await request(apiArr.routingInspectionInfo, "POST", {
task_id: id,
});
this.pointsList = res.task_point_info
},
selectPointHandler(option) { selectPointHandler(option) {
this.selectedPoint = option.id || option.name console.log("🚀 ~ selectPointHandler ~ option:", option)
this.selectedPointInfo = option // //
this.searchKeyword = option.name if (option && option.point_info && option.point_info.point_name) {
this.showOptions = false // id
this.selectedPoint = option.location_info && option.point_id
? option.point_id
: option.id || option.point_info.point_name
this.selectedPointInfo = option //
this.searchKeyword = option.point_info.point_name
this.showOptions = false
} else {
console.warn('选择的点位信息不完整', option)
}
}, },
takePhoto() { takePhoto() {
// //
@ -117,7 +130,7 @@ export default {
// //
this.images.splice(index, 1) this.images.splice(index, 1)
}, },
submitForm() { async submitForm() {
// //
if (!this.selectedPoint) { if (!this.selectedPoint) {
uni.showToast({ uni.showToast({
@ -136,24 +149,32 @@ export default {
return return
} }
// try {
const submitData = { // 使
point: this.selectedPointInfo, // const params = {
photos: this.images.map(imagePath => ({ task_id: parseInt(this.taskId), // ID
url: imagePath, // point_id: parseInt(this.selectedPoint), // ID
// base64 image: this.images //
// base64: this.getBase64FromPath(imagePath) // base64 }
}))
//
const res = await request(apiArr.routingInspectionSubmit, "POST", params);
//
console.log('提交数据:', params)
//
uni.showToast({
title: '提交成功',
icon: 'success'
})
} catch (error) {
console.error('提交失败', error)
uni.showToast({
title: '提交失败',
icon: 'none'
})
} }
//
console.log('提交数据:', submitData)
//
uni.showToast({
title: '提交成功',
icon: 'success'
})
} }
} }
} }

View File

@ -1,12 +1,14 @@
page { page {
background-color: #f9f9f9; background-color: #f6f7fb;
padding: 15rpx;
} }
.item { .item {
width: 98%; width: 96%;
margin: 7rpx 0; margin: 10rpx 0;
border-radius: 15rpx; border-radius: 15rpx;
background-color: #ffffff; background-color: #ffffff;
font-size: 28rpx;
} }
.item-top { .item-top {
@ -14,7 +16,7 @@ page {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
color: #333; color: #333;
padding: 10rpx; padding: 20rpx;
border-bottom: 1rpx solid #eeeeee; border-bottom: 1rpx solid #eeeeee;
} }
@ -23,16 +25,17 @@ page {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
color: #333; color: #333;
padding: 10rpx; padding: 20rpx;
} }
.Btn { .Btn {
width: 180rpx; width: 150rpx;
height: 90rpx; height: 70rpx;
color: #ffffff; color: #ffffff;
background-color: #169bd5; background-color: #169bd5;
text-align: center; text-align: center;
line-height: 90rpx; line-height: 70rpx;
font-size: 26rpx;
} }
.empty { .empty {

View File

@ -5,17 +5,16 @@
<view class="item"> <view class="item">
<view class="item-top"> <view class="item-top">
<view>任务编号{{ item.task_no }}</view> <view>任务编号{{ item.task_no }}</view>
<view> 任务类型{{ item.task_type }}</view> <view>任务类型{{ getStatusName(item.execution_status) }}</view>
</view> </view>
<view class="item-content"> <view class="item-content">
<view class="item-content-left"> <view class="item-content-left">
<view>任务名称{{ item.task_name }}</view> <view>任务名称{{ item.inspection_plan_info.plan_name }}</view>
<view>路线编号{{ item.task_name }}</view> <view>路线编号{{ item.inspection_plan_info.inspection_route_info.route_code }}</view>
<view>路线名称{{ item.task_name }}</view> <view>路线名称{{ item.inspection_plan_info.inspection_route_info.route_name }}</view>
<view>任务开始时间{{ item.task_name }}</view> <view>任务开始时间{{ item.start_time }}</view>
<view>任务结束时间{{ item.task_name }}</view> <view>任务结束时间{{ item.end_time }}</view>
<view>巡检人{{ item.task_name }}</view> <view>巡检人{{ item.inspection_plan_info.community_worker_info.name }}</view>
<view>任务描述{{ item.task_name }}</view>
</view> </view>
<view class="item-content-right"> <view class="item-content-right">
<button class="Btn" @click="goInspection(item)">去巡检</button> <button class="Btn" @click="goInspection(item)">去巡检</button>
@ -43,7 +42,7 @@ import {
NavgateTo, NavgateTo,
} from "../../../utils"; } from "../../../utils";
import { apiArr } from "../../../api/community"; import { apiArr } from "../../../api/routingInspection";
export default { export default {
data() { data() {
@ -53,17 +52,28 @@ export default {
}, },
onLoad(options) { onLoad(options) {
this.communityId = JSON.parse(options.communityId); this.communityId = JSON.parse(options.communityId);
this.getList();
}, },
methods: { methods: {
async getList() { async getList() {
const res = await request(apiArr.routingInspectionList, "POST", { const res = await request(apiArr.routingInspectionList, "POST", {
user_id: uni.getStorageSync('userId'),
community_id: this.communityId, community_id: this.communityId,
}); });
this.list = res.rows; this.list = res.rows;
}, },
goInspection(item) { goInspection(item) {
NavgateTo('/packages/workOrderDashboard/addRoutingInspection/index?item=' + JSON.stringify(item),) NavgateTo('/packages/workOrderDashboard/addRoutingInspection/index?item=' + JSON.stringify(item),)
},
//
getStatusName(status) {
const statusMap = {
1: '待开始',
2: '进行中',
3: '已超时',
4: '已完成'
};
return statusMap[status] || status;
} }
}, },
} }