This commit is contained in:
@@ -1,274 +1,293 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
|
||||
<view class="section-title">巡检点</view>
|
||||
|
||||
<!-- 时间轴列表 -->
|
||||
<view class="timeline">
|
||||
<view v-for="(item, idx) in taskList" :key="idx" class="node"
|
||||
:class="[{ 'is-last': idx === taskList.length - 1 }]">
|
||||
<!-- 左侧:点 + 竖线 -->
|
||||
<view class="rail">
|
||||
<view class="dot" :class="{
|
||||
'dot-circle': item.dotShape === 'circle',
|
||||
'dot-square': item.dotShape === 'square',
|
||||
'dot-active': item.dotColor === 'blue'
|
||||
}"></view>
|
||||
</view>
|
||||
|
||||
<!-- 右侧内容 -->
|
||||
<view class="card">
|
||||
<!-- 标题块 + 操作区(打包在一起,方便宽度同步) -->
|
||||
<view class="title-ops-wrapper">
|
||||
<!-- 标题块 -->
|
||||
<view v-if="item.headerStyle === 'solid'" class="title-solid">
|
||||
{{ item.pointName }}({{ item.date }} {{ item.time }})
|
||||
</view>
|
||||
<view v-else class="title-dashed">
|
||||
{{ item.pointName }}({{ item.date }} {{ item.time }})
|
||||
</view>
|
||||
|
||||
<!-- 操作区:宽度跟随标题块,内部居中 -->
|
||||
<view class="ops" v-if="item.status === '待巡检'">
|
||||
<view class="btn-outline" @click="startTask(item)">立即巡检</view>
|
||||
</view>
|
||||
|
||||
<view class="ops" v-else>
|
||||
<view class="btn-disabled">完成巡检</view>
|
||||
<view class="badge" :class="item.result === '正常' ? 'badge-success' : 'badge-warn'">
|
||||
{{ item.result }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="footer-placeholder">巡检提醒</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
taskList: []
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getTaskListMock()
|
||||
},
|
||||
methods: {
|
||||
// ---- 模拟接口数据(可替换成 uni.request)----
|
||||
getTaskListMock() {
|
||||
this.taskList = [
|
||||
{
|
||||
pointName: 'A区花园',
|
||||
date: '2025-07-16',
|
||||
time: '09:00—10:00',
|
||||
status: '待巡检',
|
||||
headerStyle: 'solid',
|
||||
result: '',
|
||||
dotShape: 'circle',
|
||||
dotColor: 'gray'
|
||||
},
|
||||
{
|
||||
pointName: 'A区花园',
|
||||
date: '2025-07-16',
|
||||
time: '09:00—10:00',
|
||||
status: '已完成',
|
||||
headerStyle: 'dashed',
|
||||
result: '正常',
|
||||
dotShape: 'circle',
|
||||
dotColor: 'blue'
|
||||
},
|
||||
{
|
||||
pointName: 'A区花园',
|
||||
date: '2025-07-16',
|
||||
time: '09:00—10:00',
|
||||
status: '待巡检',
|
||||
headerStyle: 'solid',
|
||||
result: '',
|
||||
dotShape: 'square',
|
||||
dotColor: 'gray'
|
||||
},
|
||||
{
|
||||
pointName: 'A区花园',
|
||||
date: '2025-07-16',
|
||||
time: '09:00—10:00',
|
||||
status: '已完成',
|
||||
headerStyle: 'dashed',
|
||||
result: '异常',
|
||||
dotShape: 'square',
|
||||
dotColor: 'blue'
|
||||
}
|
||||
]
|
||||
<template>
|
||||
<view class="page">
|
||||
|
||||
<view class="section-title">巡检点</view>
|
||||
|
||||
<!-- 时间轴列表 -->
|
||||
<view class="timeline">
|
||||
<view v-for="(item, idx) in taskList" :key="idx" class="node"
|
||||
:class="[{ 'is-last': idx === taskList.length - 1 }]">
|
||||
<!-- 左侧:点 + 竖线 -->
|
||||
<view class="rail">
|
||||
<view class="dot" :class="{
|
||||
'dot-active': item.inspectionState == 1,
|
||||
|
||||
}"></view>
|
||||
</view>
|
||||
|
||||
<!-- 右侧内容 -->
|
||||
<view class="card">
|
||||
<!-- 标题块 + 操作区(打包在一起,方便宽度同步) -->
|
||||
<view class="title-ops-wrapper">
|
||||
<!-- 标题块 -->
|
||||
<view v-if="item.inspectionState ==0 " class="title-solid">
|
||||
{{ item.pointName }}
|
||||
<view>
|
||||
{{ item.pointStartTime.substring(0,16) }} - {{ item.pointEndTime.substring(0,16) }}
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="title-dashed">
|
||||
{{ item.pointName }}
|
||||
<view>
|
||||
{{ item.pointStartTime.substring(0,16) }} - {{ item.pointEndTime.substring(0,16) }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 操作区:宽度跟随标题块,内部居中 -->
|
||||
<view class="ops" v-if="item.inspectionState ==0">
|
||||
<view class="btn-outline" @click="startTask(item)">立即巡检</view>
|
||||
</view>
|
||||
|
||||
<view class="status" v-else @click="goDetail(item)">
|
||||
<view>完成巡检</view>
|
||||
<view class="badge" :class="item.inspectionResults ==1 ? 'badge-success' : 'badge-warn'">
|
||||
{{ item.inspectionResults == 1 ? '正常' : '异常' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
taskInfo: {},
|
||||
taskList: []
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.item) {
|
||||
console.log('options.item:', options.item);
|
||||
try {
|
||||
// 首先尝试解析原始字符串(可能未编码)
|
||||
const item = JSON.parse(options.item);
|
||||
console.log('parsed item:', item);
|
||||
this.taskInfo = item;
|
||||
} catch (e) {
|
||||
// 如果直接解析失败,再尝试解码后解析
|
||||
try {
|
||||
const item = JSON.parse(decodeURIComponent(options.item));
|
||||
console.log('parsed decoded item:', item);
|
||||
this.taskInfo = item;
|
||||
} catch (e2) {
|
||||
// 如果两种方式都失败,记录错误并使用原始数据
|
||||
console.error('解析item失败:', e2);
|
||||
this.taskInfo = options.item;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.getTaskListMock();
|
||||
},
|
||||
onShow() {
|
||||
uni.$on('refreshData', () => {
|
||||
this.getTaskListMock();
|
||||
});
|
||||
},
|
||||
// 页面卸载时移除事件监听器
|
||||
onUnload() {
|
||||
uni.$off('refreshData');
|
||||
},
|
||||
methods: {
|
||||
async getTaskListMock() {
|
||||
let params = {
|
||||
taskId: this.taskInfo.id,
|
||||
};
|
||||
let res = await this.$u.api.getTaskList(params);
|
||||
if (res.code == 200 && res.rows) {
|
||||
// 提取res.data数组中每个对象的url字段
|
||||
this.taskList = res.rows
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
startTask(item) {
|
||||
const detailItemStr = encodeURIComponent(JSON.stringify(item));
|
||||
uni.navigateTo({
|
||||
url: `/pages/sys/workbench/inspection/inspectionOpt?item=${detailItemStr}`
|
||||
});
|
||||
},
|
||||
startTask(item) {
|
||||
uni.showToast({
|
||||
title: `开始巡检:${item.pointName}`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 页面基础 */
|
||||
.page {
|
||||
background: #f7f8fa;
|
||||
min-height: 100vh
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin: 24rpx 24rpx 8rpx
|
||||
}
|
||||
|
||||
/* 时间轴容器 */
|
||||
.timeline {
|
||||
position: relative;
|
||||
padding: 16rpx 24rpx 40rpx 24rpx
|
||||
}
|
||||
|
||||
/* 每个节点 */
|
||||
.node {
|
||||
position: relative;
|
||||
padding-left: 72rpx;
|
||||
margin-bottom: 32rpx
|
||||
}
|
||||
|
||||
.node:last-child {
|
||||
margin-bottom: 0
|
||||
}
|
||||
|
||||
/* 左侧导轨与连线 */
|
||||
.node::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 37rpx;
|
||||
top: 35rpx;
|
||||
bottom: -32rpx;
|
||||
width: 2rpx;
|
||||
background: #e8e9ee
|
||||
}
|
||||
|
||||
.node.is-last::after {
|
||||
display: none
|
||||
}
|
||||
|
||||
/* 左栏(点的容器) */
|
||||
.rail {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 72rpx;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 16rpx;
|
||||
height: 16rpx;
|
||||
margin-top: 20rpx;
|
||||
background: #cfd3dc
|
||||
}
|
||||
|
||||
.dot-circle {
|
||||
border-radius: 50%
|
||||
}
|
||||
|
||||
.dot-square {
|
||||
border-radius: 4rpx
|
||||
}
|
||||
|
||||
.dot-active {
|
||||
background: #2f6aff
|
||||
}
|
||||
|
||||
/* 右侧卡片 */
|
||||
.card {
|
||||
padding: 16rpx 20rpx;
|
||||
}
|
||||
|
||||
/* 标题 + 操作区包裹(宽度由标题决定) */
|
||||
.title-ops-wrapper {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* 标题两种样式 */
|
||||
.title-solid {
|
||||
background: #2f6aff;
|
||||
color: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 12rpx 18rpx;
|
||||
display: inline-block;
|
||||
font-size: 26rpx
|
||||
}
|
||||
|
||||
.title-dashed {
|
||||
border-radius: 12rpx;
|
||||
background: #fff;
|
||||
padding: 12rpx 18rpx;
|
||||
display: inline-block;
|
||||
font-size: 26rpx;
|
||||
color: #333
|
||||
}
|
||||
|
||||
/* 操作区:宽度继承标题块,内部居中 */
|
||||
.ops {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
border: 2rpx solid #2f6aff;
|
||||
color: #2f6aff;
|
||||
background: #fff;
|
||||
padding: 12rpx 28rpx;
|
||||
border-radius: 12rpx;
|
||||
font-size: 26rpx
|
||||
}
|
||||
|
||||
.btn-disabled {
|
||||
background: #f2f3f5;
|
||||
color: #a0a0a0;
|
||||
padding: 12rpx 24rpx;
|
||||
border-radius: 12rpx;
|
||||
font-size: 26rpx
|
||||
}
|
||||
|
||||
/* 结果徽标 */
|
||||
.badge {
|
||||
padding: 8rpx 18rpx;
|
||||
border-radius: 22rpx;
|
||||
font-size: 24rpx;
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
.badge-success {
|
||||
color: #16a34a;
|
||||
border: 2rpx solid #16a34a;
|
||||
background: #fff
|
||||
}
|
||||
|
||||
.badge-warn {
|
||||
color: #f59e0b;
|
||||
border: 2rpx solid #f59e0b;
|
||||
background: #fff
|
||||
}
|
||||
|
||||
/* 底部占位文字 */
|
||||
.footer-placeholder {
|
||||
text-align: center;
|
||||
color: #e5e6eb;
|
||||
font-size: 28rpx;
|
||||
margin-top: 80rpx;
|
||||
letter-spacing: 2rpx
|
||||
}
|
||||
</style>
|
||||
|
||||
goDetail(item) {
|
||||
// const detailItemStr = encodeURIComponent(JSON.stringify(item));
|
||||
// uni.navigateTo({
|
||||
// url: `/pages/sys/workbench/inspection/inspectionDetail?item=${detailItemStr}`
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 页面基础 */
|
||||
.page {
|
||||
background: #f7f8fa;
|
||||
min-height: 100vh
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 28rpx;
|
||||
color: #0B0B0B;
|
||||
font-weight: bold;
|
||||
padding-top: 24rpx;
|
||||
padding-left: 40rpx;
|
||||
}
|
||||
|
||||
/* 时间轴容器 */
|
||||
.timeline {
|
||||
position: relative;
|
||||
padding: 16rpx 24rpx 40rpx 24rpx
|
||||
}
|
||||
|
||||
/* 每个节点 */
|
||||
.node {
|
||||
position: relative;
|
||||
padding-left: 72rpx;
|
||||
margin-bottom: 32rpx
|
||||
}
|
||||
|
||||
.node:last-child {
|
||||
margin-bottom: 0
|
||||
}
|
||||
|
||||
/* 左侧导轨与连线 */
|
||||
.node::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 37rpx;
|
||||
top: 35rpx;
|
||||
bottom: -32rpx;
|
||||
width: 2rpx;
|
||||
background: #e8e9ee
|
||||
}
|
||||
|
||||
.node.is-last::after {
|
||||
display: none
|
||||
}
|
||||
|
||||
/* 左栏(点的容器) */
|
||||
.rail {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 72rpx;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 16rpx;
|
||||
height: 16rpx;
|
||||
margin-top: 20rpx;
|
||||
background: #cfd3dc;
|
||||
border-radius: 50%
|
||||
}
|
||||
|
||||
.dot-active {
|
||||
background: #2f6aff
|
||||
}
|
||||
|
||||
/* 右侧卡片 */
|
||||
.card {}
|
||||
|
||||
/* 标题 + 操作区包裹(宽度由标题决定) */
|
||||
.title-ops-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* 标题两种样式 */
|
||||
.title-solid {
|
||||
background: #2f6aff;
|
||||
color: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 12rpx 30rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.title-dashed {
|
||||
border-radius: 12rpx;
|
||||
background: #fff;
|
||||
padding: 12rpx 30rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
color: #000;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 操作区:宽度继承标题块,内部居中 */
|
||||
.ops {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.status {
|
||||
width: 280rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid #BFBFBF;
|
||||
margin-top: 20rpx;
|
||||
color: #BFBFBF;
|
||||
padding: 12rpx 24rpx;
|
||||
border-radius: 12rpx;
|
||||
font-size: 26rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
border: 2rpx solid #2f6aff;
|
||||
color: #2f6aff;
|
||||
background: #fff;
|
||||
padding: 12rpx 28rpx;
|
||||
border-radius: 12rpx;
|
||||
font-size: 26rpx
|
||||
}
|
||||
|
||||
.btn-disabled {
|
||||
background: #f2f3f5;
|
||||
color: #a0a0a0;
|
||||
padding: 12rpx 24rpx;
|
||||
border-radius: 12rpx;
|
||||
font-size: 26rpx
|
||||
}
|
||||
|
||||
/* 结果徽标 */
|
||||
.badge {
|
||||
font-size: 24rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.badge-success {
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
.badge-warn {
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
/* 底部占位文字 */
|
||||
.footer-placeholder {
|
||||
text-align: center;
|
||||
color: #e5e6eb;
|
||||
font-size: 28rpx;
|
||||
margin-top: 80rpx;
|
||||
letter-spacing: 2rpx
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user