完成巡检模块
This commit is contained in:
parent
a4c0c42c29
commit
86c74c27b0
@ -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;
|
||||||
|
}
|
||||||
@ -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">
|
||||||
|
暂无数据
|
||||||
|
</view>
|
||||||
|
<!-- 有选项时显示选项列表 -->
|
||||||
|
<view v-else>
|
||||||
|
<view v-for="option in pointsList"
|
||||||
|
:key="option.point_id"
|
||||||
|
class="option-item"
|
||||||
@click="selectPointHandler(option)">
|
@click="selectPointHandler(option)">
|
||||||
{{ option.name }}
|
{{ 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
|
||||||
if (item.points && Array.isArray(item.points)) {
|
this.getInfo(this.taskId)
|
||||||
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)
|
||||||
|
// 安全检查,确保必要的属性存在
|
||||||
|
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.selectedPointInfo = option // 保存完整的点位信息
|
||||||
this.searchKeyword = option.name
|
this.searchKeyword = option.point_info.point_name
|
||||||
this.showOptions = false
|
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编码
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 输出提交的数据
|
// 调用正确的接口
|
||||||
console.log('提交数据:', submitData)
|
const res = await request(apiArr.routingInspectionSubmit, "POST", params);
|
||||||
|
|
||||||
// 这里可以添加实际的提交逻辑,调用后端接口
|
// 输出提交的数据
|
||||||
|
console.log('提交数据:', params)
|
||||||
|
|
||||||
|
// 显示提交成功提示
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '提交成功',
|
title: '提交成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
})
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error('提交失败', error)
|
||||||
|
uni.showToast({
|
||||||
|
title: '提交失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user