完成巡检模块
This commit is contained in:
parent
a4c0c42c29
commit
86c74c27b0
@ -143,3 +143,11 @@
|
||||
font-size: 32rpx;
|
||||
margin-top: 50rpx;
|
||||
}
|
||||
|
||||
.no-options {
|
||||
padding: 30rpx 20rpx;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
@ -4,14 +4,22 @@
|
||||
<view class="select-container">
|
||||
<label class="select-label">选择点位</label>
|
||||
<input type="text" class="search-input" v-model="searchKeyword" @focus="showOptions = true"
|
||||
placeholder="请选择点位" readonly />
|
||||
placeholder="请输入点位名称搜索" readonly />
|
||||
|
||||
<!-- 下拉选项 -->
|
||||
<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">
|
||||
暂无数据
|
||||
</view>
|
||||
<!-- 有选项时显示选项列表 -->
|
||||
<view v-else>
|
||||
<view v-for="option in pointsList"
|
||||
:key="option.point_id"
|
||||
class="option-item"
|
||||
@click="selectPointHandler(option)">
|
||||
{{ option.name }}
|
||||
{{ option.point_info.point_name }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -20,10 +28,8 @@
|
||||
<view class="camera-section">
|
||||
<!-- 拍照按钮,当图片数量达到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" mode="aspectFit" @click="takePhoto">
|
||||
</image>
|
||||
</view>
|
||||
<image class="camera-icon" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/zhaoxiangji.png"
|
||||
mode="aspectFit" @click="takePhoto"></image>
|
||||
<view class="camera-text">点击拍照上传</view>
|
||||
</view>
|
||||
|
||||
@ -45,6 +51,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
request,
|
||||
picUrl,
|
||||
uniqueByField,
|
||||
menuButtonInfo,
|
||||
NavgateTo,
|
||||
} from "../../../utils";
|
||||
|
||||
import { apiArr } from "../../../api/routingInspection";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -53,40 +68,38 @@ export default {
|
||||
selectedPoint: '',
|
||||
selectedPointInfo: null, // 存储完整的点位信息
|
||||
pointsList: [],
|
||||
images: [] // 存储多张图片路径
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
filteredOptions() {
|
||||
if (!this.searchKeyword) {
|
||||
return this.pointsList
|
||||
}
|
||||
return this.pointsList.filter(option =>
|
||||
option.name.toLowerCase().includes(this.searchKeyword.toLowerCase())
|
||||
)
|
||||
images: [], // 存储多张图片路径
|
||||
taskId: '',
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.item) {
|
||||
try {
|
||||
const item = JSON.parse(options.item)
|
||||
// 根据实际数据结构调整
|
||||
if (item.points && Array.isArray(item.points)) {
|
||||
this.pointsList = item.points
|
||||
} else if (Array.isArray(item)) {
|
||||
this.pointsList = item
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解析数据失败', e)
|
||||
}
|
||||
this.taskId = item.id
|
||||
this.getInfo(this.taskId)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getInfo(id) {
|
||||
const res = await request(apiArr.routingInspectionInfo, "POST", {
|
||||
task_id: id,
|
||||
});
|
||||
this.pointsList = res.task_point_info
|
||||
},
|
||||
selectPointHandler(option) {
|
||||
this.selectedPoint = option.id || option.name
|
||||
console.log("🚀 ~ selectPointHandler ~ option:", option)
|
||||
// 安全检查,确保必要的属性存在
|
||||
if (option && option.point_info && option.point_info.point_name) {
|
||||
// 根据实际数据结构选择正确的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.name
|
||||
this.searchKeyword = option.point_info.point_name
|
||||
this.showOptions = false
|
||||
} else {
|
||||
console.warn('选择的点位信息不完整', option)
|
||||
}
|
||||
},
|
||||
takePhoto() {
|
||||
// 调起手机拍照功能,不允许从相册选择
|
||||
@ -117,7 +130,7 @@ export default {
|
||||
// 删除指定索引的图片
|
||||
this.images.splice(index, 1)
|
||||
},
|
||||
submitForm() {
|
||||
async submitForm() {
|
||||
// 验证是否选择了点位
|
||||
if (!this.selectedPoint) {
|
||||
uni.showToast({
|
||||
@ -136,24 +149,32 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
// 准备提交数据
|
||||
const submitData = {
|
||||
point: this.selectedPointInfo, // 完整的点位信息
|
||||
photos: this.images.map(imagePath => ({
|
||||
url: imagePath, // 图片路径
|
||||
// 如果需要,可以添加额外的信息,如base64编码等
|
||||
// base64: this.getBase64FromPath(imagePath) // 示例:获取base64编码
|
||||
}))
|
||||
try {
|
||||
// 准备提交数据,使用正确的参数格式
|
||||
const params = {
|
||||
task_id: parseInt(this.taskId), // 巡检任务ID
|
||||
point_id: parseInt(this.selectedPoint), // 巡检点ID
|
||||
image: this.images // 巡检图片,格式为字符串数组
|
||||
}
|
||||
|
||||
// 输出提交的数据
|
||||
console.log('提交数据:', submitData)
|
||||
// 调用正确的接口
|
||||
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'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
page {
|
||||
background-color: #f9f9f9;
|
||||
background-color: #f6f7fb;
|
||||
padding: 15rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 98%;
|
||||
margin: 7rpx 0;
|
||||
width: 96%;
|
||||
margin: 10rpx 0;
|
||||
border-radius: 15rpx;
|
||||
background-color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.item-top {
|
||||
@ -14,7 +16,7 @@ page {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: #333;
|
||||
padding: 10rpx;
|
||||
padding: 20rpx;
|
||||
border-bottom: 1rpx solid #eeeeee;
|
||||
}
|
||||
|
||||
@ -23,16 +25,17 @@ page {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: #333;
|
||||
padding: 10rpx;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.Btn {
|
||||
width: 180rpx;
|
||||
height: 90rpx;
|
||||
width: 150rpx;
|
||||
height: 70rpx;
|
||||
color: #ffffff;
|
||||
background-color: #169bd5;
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
line-height: 70rpx;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.empty {
|
||||
|
||||
@ -5,17 +5,16 @@
|
||||
<view class="item">
|
||||
<view class="item-top">
|
||||
<view>任务编号:{{ item.task_no }}</view>
|
||||
<view> 任务类型:{{ item.task_type }}</view>
|
||||
<view>任务类型:{{ getStatusName(item.execution_status) }}</view>
|
||||
</view>
|
||||
<view class="item-content">
|
||||
<view class="item-content-left">
|
||||
<view>任务名称:{{ item.task_name }}</view>
|
||||
<view>路线编号:{{ item.task_name }}</view>
|
||||
<view>路线名称:{{ item.task_name }}</view>
|
||||
<view>任务开始时间:{{ item.task_name }}</view>
|
||||
<view>任务结束时间:{{ item.task_name }}</view>
|
||||
<view>巡检人:{{ item.task_name }}</view>
|
||||
<view>任务描述:{{ item.task_name }}</view>
|
||||
<view>任务名称:{{ item.inspection_plan_info.plan_name }}</view>
|
||||
<view>路线编号:{{ item.inspection_plan_info.inspection_route_info.route_code }}</view>
|
||||
<view>路线名称:{{ item.inspection_plan_info.inspection_route_info.route_name }}</view>
|
||||
<view>任务开始时间:{{ item.start_time }}</view>
|
||||
<view>任务结束时间:{{ item.end_time }}</view>
|
||||
<view>巡检人:{{ item.inspection_plan_info.community_worker_info.name }}</view>
|
||||
</view>
|
||||
<view class="item-content-right">
|
||||
<button class="Btn" @click="goInspection(item)">去巡检</button>
|
||||
@ -43,7 +42,7 @@ import {
|
||||
NavgateTo,
|
||||
} from "../../../utils";
|
||||
|
||||
import { apiArr } from "../../../api/community";
|
||||
import { apiArr } from "../../../api/routingInspection";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -53,17 +52,28 @@ export default {
|
||||
},
|
||||
onLoad(options) {
|
||||
this.communityId = JSON.parse(options.communityId);
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
async getList() {
|
||||
const res = await request(apiArr.routingInspectionList, "POST", {
|
||||
user_id: uni.getStorageSync('userId'),
|
||||
community_id: this.communityId,
|
||||
});
|
||||
this.list = res.rows;
|
||||
},
|
||||
goInspection(item) {
|
||||
NavgateTo('/packages/workOrderDashboard/addRoutingInspection/index?item=' + JSON.stringify(item),)
|
||||
},
|
||||
|
||||
// 将任务状态数字代码转换为中文名称
|
||||
getStatusName(status) {
|
||||
const statusMap = {
|
||||
1: '待开始',
|
||||
2: '进行中',
|
||||
3: '已超时',
|
||||
4: '已完成'
|
||||
};
|
||||
return statusMap[status] || status;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user