This commit is contained in:
@@ -8,24 +8,45 @@
|
||||
<view v-if="idx === activeTab" class="tab-underline"></view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 列表区 -->
|
||||
<view class="ins-list">
|
||||
<view v-for="(item, idx) in list" :key="idx" class="ins-card" @click="goProcess(item)">
|
||||
<view class="ins-row">
|
||||
<view class="ins-no">保洁部日常巡检 {{ item.createTime.substring(0,11) }}</view>
|
||||
<view class="ins-status" :class="getStatusColor(item.status)">
|
||||
{{ getStatusLabel(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
<image class="ins-line-image" src="/static/ic_my_repair_03.png" />
|
||||
<view class="ins-info">巡检人:{{ item.createTime }}</view>
|
||||
<view class="ins-info">计划完成时间:{{ item.typeName }}</view>
|
||||
<view class="ins-info">实际完成时间:{{ item.location }}</view>
|
||||
<view class="ins-info">巡检进度:{{ item.location }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 为每个标签页创建独立的scroll-view -->
|
||||
<view class="ins-list-container">
|
||||
<scroll-view
|
||||
v-for="(tab, idx) in tabs"
|
||||
:key="idx"
|
||||
v-show="idx === activeTab"
|
||||
class="ins-list"
|
||||
scroll-y
|
||||
refresher-enabled
|
||||
:refresher-triggered="refresherTriggered[idx]"
|
||||
refresher-background="#f7f7f7"
|
||||
@refresherrefresh="onRefresh"
|
||||
@scrolltolower="loadMore"
|
||||
:scroll-with-animation="true"
|
||||
>
|
||||
<view v-for="(item, index) in tabData[idx].list" :key="index" class="ins-card" @click="goProcess(item)">
|
||||
<view class="ins-row">
|
||||
<view class="ins-no">{{item.planName || ''}} {{ item.createTime ? item.createTime.substring(0,11) : '' }}</view>
|
||||
<view class="ins-status" :class="getStatusColor(item.status)">
|
||||
{{ getStatusLabel(item.status) }}
|
||||
</view>
|
||||
</view>
|
||||
<image class="ins-line-image" src="/static/ic_my_repair_03.png" />
|
||||
<view class="ins-info">巡检人:{{ item.actUserName || '' }}</view>
|
||||
<view class="ins-info">计划完成时间:{{ item.planInsTime || '' }}</view>
|
||||
<view class="ins-info">实际完成时间:{{ item.location || '' }}</view>
|
||||
<view class="ins-info">巡检进度:{{ item.inspectionProgress || '' }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多提示 -->
|
||||
<view v-if="loading[idx]" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
|
||||
加载中...
|
||||
</view>
|
||||
<view v-if="noMore[idx] && tabData[idx].list.length > 0" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
|
||||
没有更多数据了
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -33,65 +54,122 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
tabs: ['待进行', '处理中', '已完成'],
|
||||
tabs: ['待进行', '处理中', '已完成', '已超时'],
|
||||
activeTab: 0,
|
||||
tabData: [
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
], // 每个tab的数据
|
||||
tabLoaded: [false, false, false], // 每个tab是否已加载
|
||||
loading: false
|
||||
{ list: [], pageNum: 1, pageSize: 10 },
|
||||
{ list: [], pageNum: 1, pageSize: 10 },
|
||||
{ list: [], pageNum: 1, pageSize: 10 },
|
||||
{ list: [], pageNum: 1, pageSize: 10 }
|
||||
],
|
||||
pageNum: [1, 1, 1, 1], // 每个 tab 当前页码
|
||||
pageSize: 10,
|
||||
noMore: [false, false, false, false], // 每个 tab 是否没有更多数据
|
||||
tabLoaded: [false, false, false, false], // tab 是否加载过
|
||||
loading: [false, false, false, false], // 每个 tab 的加载状态
|
||||
refresherTriggered: [false, false, false, false] // 每个 tab 的下拉刷新状态
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
list() {
|
||||
return this.tabData[this.activeTab];
|
||||
return this.tabData[this.activeTab].list;
|
||||
},
|
||||
hasMore() {
|
||||
return !this.noMore[this.activeTab];
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loadTabData(this.activeTab); // 初始化加载当前tab数据
|
||||
this.loadAllTabsData();
|
||||
},
|
||||
methods: {
|
||||
goBack() {
|
||||
uni.navigateBack();
|
||||
},
|
||||
// 加载所有tab数据
|
||||
async loadAllTabsData() {
|
||||
for (let idx = 0; idx < this.tabs.length; idx++) {
|
||||
if (!this.tabLoaded[idx]) {
|
||||
await this.loadTabData(idx);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 切换 tab
|
||||
async changeTab(idx) {
|
||||
this.activeTab = idx;
|
||||
if (!this.tabLoaded[idx]) {
|
||||
await this.loadTabData(idx);
|
||||
await this.onRefresh();
|
||||
}
|
||||
},
|
||||
// 下拉刷新
|
||||
async onRefresh() {
|
||||
this.refresherTriggered[this.activeTab] = true;
|
||||
this.pageNum[this.activeTab] = 1;
|
||||
this.noMore[this.activeTab] = false;
|
||||
this.tabData[this.activeTab].list = [];
|
||||
await this.loadTabData(this.activeTab);
|
||||
this.refresherTriggered[this.activeTab] = false;
|
||||
},
|
||||
// 滚动加载更多
|
||||
async loadMore() {
|
||||
if (this.loading[this.activeTab] || this.noMore[this.activeTab]) return;
|
||||
this.pageNum[this.activeTab]++;
|
||||
this.loading[this.activeTab] = true;
|
||||
await this.loadTabData(this.activeTab);
|
||||
this.loading[this.activeTab] = false;
|
||||
},
|
||||
async loadTabData(idx) {
|
||||
this.loading = true;
|
||||
// 模拟接口请求,不同tab返回不同mock数据
|
||||
let params = {}
|
||||
|
||||
|
||||
let data = [];
|
||||
this.loading[idx] = true;
|
||||
let params = {
|
||||
pageNum: this.pageNum[idx],
|
||||
pageSize: this.pageSize
|
||||
};
|
||||
|
||||
// 根据tab索引设置不同的状态参数
|
||||
switch(idx) {
|
||||
case 0: // 待进行
|
||||
params.status = '0';
|
||||
break;
|
||||
case 1: // 处理中
|
||||
params.status = '1';
|
||||
break;
|
||||
case 2: // 已完成
|
||||
params.status = '2';
|
||||
break;
|
||||
case 3: // 已超时
|
||||
params.status = '3';
|
||||
break;
|
||||
}
|
||||
|
||||
let res = await this.$u.api.getInspection(params);
|
||||
if (res.code == '200') {
|
||||
data = res.rows
|
||||
let rows = res.rows || [];
|
||||
if (rows.length < this.pageSize) {
|
||||
this.noMore[idx] = true;
|
||||
}
|
||||
if (this.pageNum[idx] === 1) {
|
||||
// 刷新时重置数据
|
||||
this.tabData[idx].list = rows;
|
||||
} else {
|
||||
// 加载更多时追加数据
|
||||
this.tabData[idx].list = [...this.tabData[idx].list, ...rows];
|
||||
}
|
||||
}
|
||||
|
||||
this.$set(this.tabData, idx, data);
|
||||
this.$set(this.tabLoaded, idx, true);
|
||||
this.loading = false;
|
||||
this.loading[idx] = false;
|
||||
},
|
||||
goProcess(item) {
|
||||
const detailItemStr = encodeURIComponent(JSON.stringify(item));
|
||||
uni.navigateTo({
|
||||
url: `/pages/sys/workbench/inspection/inspectionProcess?detailItem=${item}`
|
||||
uni.navigateTo({
|
||||
url: `/pages/sys/workbench/inspection/inspectionProcess?item=${detailItemStr}`
|
||||
});
|
||||
},
|
||||
|
||||
getStatusLabel(status) {
|
||||
const statusMap = {
|
||||
0: '待确认',
|
||||
1: '已确认',
|
||||
2: '已取消',
|
||||
3: '已完成'
|
||||
0: '待进行',
|
||||
1: '处理中',
|
||||
2: '已完成',
|
||||
3: '已超时'
|
||||
};
|
||||
return statusMap[status] || '';
|
||||
},
|
||||
@@ -100,7 +178,8 @@
|
||||
0: '待确认',
|
||||
1: 'orange',
|
||||
2: '已取消',
|
||||
3: '已完成'
|
||||
3: 'done',
|
||||
4: 'done'
|
||||
};
|
||||
return statusMap[status] || '';
|
||||
}
|
||||
@@ -153,15 +232,15 @@
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.ins-list {
|
||||
margin: 25rpx 0 0 0;
|
||||
padding: 0 35rpx;
|
||||
.ins-list-container {
|
||||
flex: 1;
|
||||
/* 占据所有剩余空间 */
|
||||
overflow-y: auto;
|
||||
/* 内容超出时,开启垂直滚动 */
|
||||
padding-bottom: 200rpx;
|
||||
/* 为底部按钮留出空间 */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ins-list {
|
||||
height: 100%;
|
||||
padding: 25rpx 35rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.ins-card {
|
||||
@@ -180,43 +259,47 @@
|
||||
margin-top: 25rpx;
|
||||
margin-left: 19rpx;
|
||||
margin-right: 50rpx;
|
||||
}
|
||||
|
||||
.ins-no {
|
||||
font-size: 24rpx;
|
||||
color: #0B0B0B;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.ins-status {
|
||||
font-size: 24rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.ins-line-image {
|
||||
margin: left 29rpx;
|
||||
margin-right: 39rpx;
|
||||
height: 2rpx;
|
||||
margin-bottom: 29rpx;
|
||||
}
|
||||
|
||||
.ins-status.orange {
|
||||
color: #F3AB44;
|
||||
}
|
||||
|
||||
.ins-status.doing {
|
||||
color: #00C9AA;
|
||||
}
|
||||
|
||||
.ins-status.done {
|
||||
color: #8A8A8A;
|
||||
}
|
||||
|
||||
.ins-info {
|
||||
font-size: 24rpx;
|
||||
color: #888;
|
||||
margin-bottom: 30rpx;
|
||||
margin-left: 47rpx;
|
||||
}
|
||||
|
||||
.ins-no {
|
||||
font-size: 24rpx;
|
||||
color: #0B0B0B;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.ins-status {
|
||||
font-size: 24rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.ins-line-image {
|
||||
margin: left 29rpx;
|
||||
margin-right: 39rpx;
|
||||
height: 2rpx;
|
||||
margin-bottom: 29rpx;
|
||||
}
|
||||
|
||||
.ins-status.orange {
|
||||
color: #F3AB44;
|
||||
}
|
||||
|
||||
.ins-status.doing {
|
||||
color: #00C9AA;
|
||||
}
|
||||
|
||||
.ins-status.done {
|
||||
color: #8A8A8A;
|
||||
}
|
||||
|
||||
.ins-status.overdue {
|
||||
color: #FF4D4D;
|
||||
}
|
||||
|
||||
.ins-info {
|
||||
font-size: 24rpx;
|
||||
color: #888;
|
||||
margin-bottom: 30rpx;
|
||||
margin-left: 47rpx;
|
||||
}
|
||||
|
||||
</style>
|
452
pages/sys/workbench/inspection/inspectionDetail.vue
Normal file
452
pages/sys/workbench/inspection/inspectionDetail.vue
Normal file
@@ -0,0 +1,452 @@
|
||||
<template>
|
||||
<view class="inspection-opt-container">
|
||||
<view class="inspection-opt-lable"> 巡检人
|
||||
<view class="inspection-opt-round" />
|
||||
<text class="text">{{info.planInspectionPerson}}</text>
|
||||
</view>
|
||||
<view class="inspection-opt-lable"> 巡检位置
|
||||
<text class="required">*</text>
|
||||
</view>
|
||||
<view class="inspection-opt-row">
|
||||
<text class="text2">{{info.inspectionLocation}}</text>
|
||||
</view>
|
||||
<view class="inspection-opt-lable"> 巡检结果
|
||||
<text class="required">*</text>
|
||||
<view :class="info.inspectionResults == 1?'inspection-opt-round4':'inspection-opt-round2'"/>
|
||||
<text class="text">正常</text>
|
||||
<view :class="info.inspectionResults != 1?'inspection-opt-round3':'inspection-opt-round2'" />
|
||||
<text class="text"> 异常</text>
|
||||
</view>
|
||||
<view class="inspection-opt-lable"> 巡检描述
|
||||
<text class="required">*</text>
|
||||
</view>
|
||||
<text class="input" >{{ info.remark }}</text>
|
||||
|
||||
<!-- 上传照片 -->
|
||||
<view class="page">
|
||||
<!-- 已选图片预览 -->
|
||||
<view class="preview-item">
|
||||
<image :src="selectedImage" mode="aspectFill" @click="previewImage"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
info: {
|
||||
inspectionResults: 1 // 默认选中"正常"
|
||||
},
|
||||
selectedImage: '',
|
||||
isSign: false,
|
||||
showDialog: false // 控制弹窗显示
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.item) {
|
||||
try {
|
||||
// 首先尝试解析原始字符串(可能未编码)
|
||||
const item = JSON.parse(options.item);
|
||||
this.info = item;
|
||||
} catch (e) {
|
||||
// 如果直接解析失败,再尝试解码后解析
|
||||
try {
|
||||
const item = JSON.parse(decodeURIComponent(options.item));
|
||||
this.info = item;
|
||||
} catch (e2) {
|
||||
this.info = options.item;
|
||||
}
|
||||
}
|
||||
this.isSign = this.info.actualSignState == 1
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
|
||||
// 预览图片
|
||||
previewImage() {
|
||||
uni.previewImage({
|
||||
current: this.selectedImage,
|
||||
urls: [this.selectedImage]
|
||||
})
|
||||
},
|
||||
|
||||
// 切换巡检结果状态
|
||||
toggleInspectionResult(result) {
|
||||
// 使用$set确保响应式更新
|
||||
this.$set(this.info, 'inspectionResults', result);
|
||||
},
|
||||
beforeSubmit() {
|
||||
if (this.info.inspectionResults == 1) {
|
||||
// 直接提交
|
||||
this.submit();
|
||||
} else {
|
||||
// 弹窗显示,生成工单提交
|
||||
this.showDialog = true;
|
||||
}
|
||||
},
|
||||
closeDialog() {
|
||||
this.showDialog = false;
|
||||
},
|
||||
confirmDialog() {
|
||||
this.showDialog = false;
|
||||
// 生成工单提交
|
||||
this.submit();
|
||||
},
|
||||
|
||||
async taskSignIn() {
|
||||
|
||||
uni.scanCode({
|
||||
success: async (scanRes) => {
|
||||
// 使用扫码结果调用接口
|
||||
let params = {
|
||||
taskId: this.info.id,
|
||||
qrCode: scanRes.result // 将扫码结果作为参数传递
|
||||
};
|
||||
if (scanRes.result == this.info.pointId) {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
this.info.signType = 3
|
||||
let res = await this.$u.api.taskSignIn(this.info);
|
||||
|
||||
// 隐藏loading
|
||||
uni.hideLoading();
|
||||
|
||||
if (res.code == 200) {
|
||||
this.isSign = true
|
||||
uni.showToast({
|
||||
title: '签到成功',
|
||||
icon: 'none'
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '签到失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: '当前签到巡检点不是目标点',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
// 扫码失败处理
|
||||
uni.showToast({
|
||||
title: '扫码失败,请重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
async submit() {
|
||||
// 显示loading
|
||||
uni.showLoading({
|
||||
title: '提交中...'
|
||||
});
|
||||
|
||||
if (!this.selectedImage) {
|
||||
this.realSubmit()
|
||||
return
|
||||
}
|
||||
const images = [];
|
||||
images.push(this.selectedImage?.path?.replace('file://', '') || this.selectedImage);
|
||||
if (images.length === 0) {
|
||||
this.realSubmit();
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await uploadFiles({
|
||||
files: images,
|
||||
url: this.vuex_config.baseUrl + '/resource/oss/upload',
|
||||
name: 'file',
|
||||
vm: this // 关键:用于注入 token 等
|
||||
});
|
||||
const allSuccess = result.every(item => item.code == 200);
|
||||
if (!allSuccess) {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
// 隐藏loading
|
||||
uni.hideLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历result获取data.url加上,分割
|
||||
const urls = result.map(item => item.data?.url || '').filter(url => url !== '');
|
||||
this.info.inspectionImage = urls.join(',');
|
||||
this.realSubmit()
|
||||
|
||||
},
|
||||
|
||||
async realSubmit() {
|
||||
let res = await this.$u.api.taskSubmit(this.info);
|
||||
if (res.code == '200') {
|
||||
// 关闭页面前发送事件通知前页面刷新
|
||||
uni.$emit('refreshData', '');
|
||||
// 返回上一页
|
||||
uni.navigateBack();
|
||||
}
|
||||
// 隐藏loading
|
||||
uni.hideLoading();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.inspection-opt-container {
|
||||
height: 100vh;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.inspection-opt-lable {
|
||||
font-size: 32rpx;
|
||||
color: #000000;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-left: 40rpx;
|
||||
margin-top: 45rpx;
|
||||
}
|
||||
|
||||
.inspection-opt-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-left: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
margin-top: 34rpx;
|
||||
}
|
||||
|
||||
.required {
|
||||
color: #DC9100;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.text {
|
||||
color: #000000;
|
||||
font-size: 24rpx;
|
||||
margin-left: 10rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.text2 {
|
||||
height: 73rpx;
|
||||
flex: 1;
|
||||
background: #F7F7F7;
|
||||
border-radius: 10rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left: 20rpx;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.text3 {
|
||||
width: 88rpx;
|
||||
height: 73rpx;
|
||||
background: #296AEF;
|
||||
border-radius: 10rpx;
|
||||
color: #F7F7F7;
|
||||
text-align: center;
|
||||
margin-left: 18rpx;
|
||||
line-height: 73rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.input {
|
||||
height: 200rpx;
|
||||
width: auto;
|
||||
margin-left: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
margin-top: 40rpx;
|
||||
background: #F7F7F7;
|
||||
border-radius: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: #000000;
|
||||
padding: 15rpx;
|
||||
}
|
||||
|
||||
.image {
|
||||
width: 55rpx;
|
||||
height: 42rpx;
|
||||
}
|
||||
|
||||
.inspection-opt-round {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 17rpx;
|
||||
background: #3370FF;
|
||||
margin-left: 35rpx;
|
||||
}
|
||||
|
||||
.inspection-opt-round2 {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 17rpx;
|
||||
background: #fff;
|
||||
margin-left: 24rpx;
|
||||
border: 1rpx solid #3370FF;
|
||||
}
|
||||
|
||||
.inspection-opt-round3 {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 17rpx;
|
||||
background: #F27A0F;
|
||||
margin-left: 24rpx;
|
||||
}
|
||||
|
||||
.inspection-opt-round4 {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 17rpx;
|
||||
background: #3370FF;
|
||||
margin-left: 24rpx;
|
||||
}
|
||||
|
||||
.custom-upload-btn {
|
||||
width: auto;
|
||||
margin-left: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
margin-top: 24rpx;
|
||||
height: 244rpx;
|
||||
background: #f6f6f6;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.preview-item {
|
||||
position: relative;
|
||||
width: auto;
|
||||
/* 宽度自动 */
|
||||
margin-left: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
height: 244rpx;
|
||||
margin-top: 24rpx;
|
||||
/* 固定高度 */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
/* 水平居中 */
|
||||
align-items: center;
|
||||
/* 垂直居中 */
|
||||
overflow: hidden;
|
||||
/* 裁剪超出部分 */
|
||||
border-radius: 10rpx;
|
||||
/* 可选:圆角 */
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* 隐藏自带按钮 */
|
||||
::v-deep .u-upload__wrap__add {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.inspection-opt-submit-btn {
|
||||
width: 60vw;
|
||||
height: 73rpx;
|
||||
background: linear-gradient(90deg, #005DE9 0%, #4B9BFF 100%);
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
margin: 100rpx auto 0 auto;
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.18);
|
||||
}
|
||||
|
||||
/* 弹窗遮罩 */
|
||||
.custom-dialog {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
/* 弹窗背景图 */
|
||||
.dialog-bg {
|
||||
position: absolute;
|
||||
width: 656rpx;
|
||||
height: 560rpx;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
/* 弹窗内容覆盖在图片上 */
|
||||
.dialog-content {
|
||||
position: relative;
|
||||
width: 80vw;
|
||||
margin-top: 220rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.dialog-title {
|
||||
font-size: 42rpx;
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.dialog-desc {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
margin-bottom: 100rpx;
|
||||
}
|
||||
|
||||
.dialog-btns {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.btn-cancel,
|
||||
.btn-confirm {
|
||||
|
||||
font-size: 36rpx;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.btn-confirm {
|
||||
color: #FF6B00;
|
||||
}
|
||||
</style>
|
573
pages/sys/workbench/inspection/inspectionOpt.vue
Normal file
573
pages/sys/workbench/inspection/inspectionOpt.vue
Normal file
@@ -0,0 +1,573 @@
|
||||
<template>
|
||||
<view class="inspection-opt-container">
|
||||
<view class="inspection-opt-lable"> 巡检人
|
||||
<view class="inspection-opt-round" />
|
||||
<text class="text">{{info.planInspectionPerson}}</text>
|
||||
</view>
|
||||
<view class="inspection-opt-lable"> 巡检位置
|
||||
<text class="required">*</text>
|
||||
</view>
|
||||
<view class="inspection-opt-row">
|
||||
<text class="text2">{{info.inspectionLocation}}</text>
|
||||
<text v-if="!isSign" class="text3" @click="taskSignIn"> 签到</text>
|
||||
</view>
|
||||
<view class="inspection-opt-lable"> 巡检结果
|
||||
<text class="required">*</text>
|
||||
<view :class="info.inspectionResults == 1?'inspection-opt-round4':'inspection-opt-round2'"
|
||||
@click="toggleInspectionResult(1)" />
|
||||
<text class="text" @click="toggleInspectionResult(1)">正常</text>
|
||||
<view :class="info.inspectionResults != 1?'inspection-opt-round3':'inspection-opt-round2'"
|
||||
@click="toggleInspectionResult(0)" />
|
||||
<text class="text" @click="toggleInspectionResult(0)"> 异常</text>
|
||||
</view>
|
||||
<view class="inspection-opt-lable"> 巡检描述
|
||||
<text class="required">*</text>
|
||||
</view>
|
||||
<textarea type="text" v-model="info.remark" placeholder="请输入" class="input" />
|
||||
|
||||
<!-- 上传照片 -->
|
||||
<view class="page">
|
||||
<!-- 如果没有图片,显示上传按钮 -->
|
||||
<view class="custom-upload-btn" @click="chooseImage" v-if="!selectedImage">
|
||||
<image class="image" src="/static/ic_camera.png"></image>
|
||||
<text class="text">上传图片</text>
|
||||
</view>
|
||||
|
||||
<!-- 已选图片预览 -->
|
||||
<view class="preview-item" v-else>
|
||||
<image class="preview-img" :src="selectedImage" mode="aspectFill" @click="previewImage"></image>
|
||||
<view class="delete-btn" @click.stop="deletePic">✕</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="info.inspectionResults != 1" class="inspection-opt-lable">报事报修</view>
|
||||
<view v-if="info.inspectionResults != 1" class="repair-type" @click="chooseType">
|
||||
<text class="text-type">{{ selectedType.orderTypeName }}</text>
|
||||
<image class="right-arrow" src="/static/ic_right_arrow_g.png" />
|
||||
</view>
|
||||
|
||||
<!-- 提交按钮 -->
|
||||
<button class="inspection-opt-submit-btn"
|
||||
@click="beforeSubmit">{{ info.inspectionResults == 1 ? '提交' : '生成工单提交' }}</button>
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<view class="custom-dialog" v-if="showDialog">
|
||||
<image class="dialog-bg" src="/static/ic_dialog_01.png"></image>
|
||||
<view class="dialog-content">
|
||||
<text class="dialog-title">是否确定</text>
|
||||
<text class="dialog-desc">转送确定生成工单编号</text>
|
||||
|
||||
<view class="dialog-btns">
|
||||
<view class="btn-cancel" @click="closeDialog">下次再说</view>
|
||||
<view class="btn-confirm" @click="confirmDialog">确认生成</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 导入MediaSelector和MediaType
|
||||
import MediaSelector, {
|
||||
MediaType
|
||||
} from '@/utils/mediaSelector';
|
||||
import {
|
||||
uploadFiles
|
||||
} from '@/common/upload.js';
|
||||
import toast from '../../../../uview-ui/libs/function/toast';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
info: {
|
||||
inspectionResults: 1 // 默认选中"正常"
|
||||
},
|
||||
repairTypes: [],
|
||||
selectedType: {},
|
||||
selectedImage: '',
|
||||
isSign: false,
|
||||
showDialog: false // 控制弹窗显示
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.item) {
|
||||
try {
|
||||
// 首先尝试解析原始字符串(可能未编码)
|
||||
const item = JSON.parse(options.item);
|
||||
this.info = item;
|
||||
} catch (e) {
|
||||
// 如果直接解析失败,再尝试解码后解析
|
||||
try {
|
||||
const item = JSON.parse(decodeURIComponent(options.item));
|
||||
this.info = item;
|
||||
} catch (e2) {
|
||||
this.info = options.item;
|
||||
}
|
||||
}
|
||||
this.isSign = this.info.actualSignState == 1
|
||||
}
|
||||
this.loadFilterData()
|
||||
},
|
||||
methods: {
|
||||
async loadFilterData() {
|
||||
let resType = await this.$u.api.getOrdersType();
|
||||
if (resType.code === 200) {
|
||||
this.repairTypes = [...this.repairTypes, ...resType.rows];
|
||||
this.selectedType = this.repairTypes[0]
|
||||
}
|
||||
},
|
||||
chooseImage() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
success: (res) => {
|
||||
this.selectedImage = res.tempFilePaths[0]
|
||||
}
|
||||
})
|
||||
},
|
||||
// 预览图片
|
||||
previewImage() {
|
||||
uni.previewImage({
|
||||
current: this.selectedImage,
|
||||
urls: [this.selectedImage]
|
||||
})
|
||||
},
|
||||
// 删除图片
|
||||
deletePic(event) {
|
||||
this.selectedImage = ''
|
||||
},
|
||||
// 切换巡检结果状态
|
||||
toggleInspectionResult(result) {
|
||||
// 使用$set确保响应式更新
|
||||
this.$set(this.info, 'inspectionResults', result);
|
||||
},
|
||||
// 添加chooseType方法实现
|
||||
chooseType() {
|
||||
uni.showActionSheet({
|
||||
itemList: this.repairTypes.map(item => item.orderTypeName),
|
||||
success: (res) => {
|
||||
this.selectedType = this.repairTypes[res.tapIndex];
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('用户取消选择或出错', err);
|
||||
}
|
||||
});
|
||||
},
|
||||
beforeSubmit() {
|
||||
// if(!this.isSign){
|
||||
// uni.showToast({
|
||||
// title: '请先签到',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// return
|
||||
// }
|
||||
if (this.info.inspectionResults == 1) {
|
||||
// 直接提交
|
||||
this.submit();
|
||||
} else {
|
||||
// 弹窗显示,生成工单提交
|
||||
this.showDialog = true;
|
||||
}
|
||||
},
|
||||
closeDialog() {
|
||||
this.showDialog = false;
|
||||
},
|
||||
confirmDialog() {
|
||||
this.showDialog = false;
|
||||
// 生成工单提交
|
||||
this.orderSubmig();
|
||||
},
|
||||
|
||||
async taskSignIn() {
|
||||
|
||||
uni.scanCode({
|
||||
success: async (scanRes) => {
|
||||
// 使用扫码结果调用接口
|
||||
let params = {
|
||||
taskId: this.info.id,
|
||||
qrCode: scanRes.result // 将扫码结果作为参数传递
|
||||
};
|
||||
if (scanRes.result == this.info.pointId) {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
this.info.signType = 3
|
||||
let res = await this.$u.api.taskSignIn(this.info);
|
||||
|
||||
// 隐藏loading
|
||||
uni.hideLoading();
|
||||
|
||||
if (res.code == 200) {
|
||||
this.isSign = true
|
||||
uni.showToast({
|
||||
title: '签到成功',
|
||||
icon: 'none'
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '签到失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '当前签到巡检点不是目标点',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
// 扫码失败处理
|
||||
// uni.showToast({
|
||||
// title: '扫码失败,请重试',
|
||||
// icon: 'none'
|
||||
// });
|
||||
}
|
||||
});
|
||||
},
|
||||
async orderSubmig(){
|
||||
this.info.orderTypeId = this.selectedType.id
|
||||
uni.showLoading({
|
||||
title: '工单提交中...'
|
||||
});
|
||||
let res = await this.$u.api.taskOrderSubmit(this.info);
|
||||
uni.hideLoading();
|
||||
if (res.code == 200) {
|
||||
this.submit()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '工单提交失败',
|
||||
icon: 'none'
|
||||
});
|
||||
this.info.orderTypeId = ''
|
||||
}
|
||||
},
|
||||
async submit() {
|
||||
// 显示loading
|
||||
uni.showLoading({
|
||||
title: '提交中...'
|
||||
});
|
||||
|
||||
if (!this.selectedImage) {
|
||||
this.realSubmit()
|
||||
return
|
||||
}
|
||||
const images = [];
|
||||
images.push(this.selectedImage?.path?.replace('file://', '') || this.selectedImage);
|
||||
if (images.length === 0) {
|
||||
this.realSubmit();
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await uploadFiles({
|
||||
files: images,
|
||||
url: this.vuex_config.baseUrl + '/resource/oss/upload',
|
||||
name: 'file',
|
||||
vm: this // 关键:用于注入 token 等
|
||||
});
|
||||
const allSuccess = result.every(item => item.code == 200);
|
||||
if (!allSuccess) {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
// 隐藏loading
|
||||
uni.hideLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历result获取data.url加上,分割
|
||||
const urls = result.map(item => item.data?.url || '').filter(url => url !== '');
|
||||
this.info.inspectionImage = urls.join(',');
|
||||
this.realSubmit()
|
||||
|
||||
},
|
||||
|
||||
async realSubmit() {
|
||||
let res = await this.$u.api.taskSubmit(this.info);
|
||||
if (res.code == '200') {
|
||||
// 关闭页面前发送事件通知前页面刷新
|
||||
uni.$emit('refreshData', '');
|
||||
// 返回上一页
|
||||
uni.navigateBack();
|
||||
}
|
||||
// 隐藏loading
|
||||
uni.hideLoading();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.inspection-opt-container {
|
||||
height: 100vh;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.inspection-opt-lable {
|
||||
font-size: 32rpx;
|
||||
color: #000000;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-left: 40rpx;
|
||||
margin-top: 45rpx;
|
||||
}
|
||||
|
||||
.inspection-opt-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-left: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
margin-top: 34rpx;
|
||||
}
|
||||
|
||||
.required {
|
||||
color: #DC9100;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.text {
|
||||
color: #000000;
|
||||
font-size: 24rpx;
|
||||
margin-left: 10rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.text2 {
|
||||
height: 73rpx;
|
||||
flex: 1;
|
||||
background: #F7F7F7;
|
||||
border-radius: 10rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left: 20rpx;
|
||||
padding-right: 20rpx;
|
||||
}
|
||||
|
||||
.text3 {
|
||||
width: 88rpx;
|
||||
height: 73rpx;
|
||||
background: #296AEF;
|
||||
border-radius: 10rpx;
|
||||
color: #F7F7F7;
|
||||
text-align: center;
|
||||
margin-left: 18rpx;
|
||||
line-height: 73rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.input {
|
||||
height: 200rpx;
|
||||
width: auto;
|
||||
margin-left: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
margin-top: 40rpx;
|
||||
background: #F7F7F7;
|
||||
border-radius: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: #000000;
|
||||
padding: 15rpx;
|
||||
}
|
||||
|
||||
.image {
|
||||
width: 55rpx;
|
||||
height: 42rpx;
|
||||
}
|
||||
|
||||
.inspection-opt-round {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 17rpx;
|
||||
background: #3370FF;
|
||||
margin-left: 35rpx;
|
||||
}
|
||||
|
||||
.inspection-opt-round2 {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 17rpx;
|
||||
background: #fff;
|
||||
margin-left: 24rpx;
|
||||
border: 1rpx solid #3370FF;
|
||||
}
|
||||
|
||||
.inspection-opt-round3 {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 17rpx;
|
||||
background: #F27A0F;
|
||||
margin-left: 24rpx;
|
||||
}
|
||||
|
||||
.inspection-opt-round4 {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 17rpx;
|
||||
background: #3370FF;
|
||||
margin-left: 24rpx;
|
||||
}
|
||||
|
||||
.custom-upload-btn {
|
||||
width: auto;
|
||||
margin-left: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
margin-top: 24rpx;
|
||||
height: 244rpx;
|
||||
background: #f6f6f6;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.preview-item {
|
||||
position: relative;
|
||||
width: auto;
|
||||
/* 宽度自动 */
|
||||
margin-left: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
height: 244rpx;
|
||||
margin-top: 24rpx;
|
||||
/* 固定高度 */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
/* 水平居中 */
|
||||
align-items: center;
|
||||
/* 垂直居中 */
|
||||
overflow: hidden;
|
||||
/* 裁剪超出部分 */
|
||||
border-radius: 10rpx;
|
||||
/* 可选:圆角 */
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* 隐藏自带按钮 */
|
||||
::v-deep .u-upload__wrap__add {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.inspection-opt-submit-btn {
|
||||
width: 60vw;
|
||||
height: 73rpx;
|
||||
background: linear-gradient(90deg, #005DE9 0%, #4B9BFF 100%);
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
margin: 100rpx auto 0 auto;
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.18);
|
||||
}
|
||||
|
||||
/* 弹窗遮罩 */
|
||||
.custom-dialog {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
/* 弹窗背景图 */
|
||||
.dialog-bg {
|
||||
position: absolute;
|
||||
width: 656rpx;
|
||||
height: 560rpx;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
/* 弹窗内容覆盖在图片上 */
|
||||
.dialog-content {
|
||||
position: relative;
|
||||
width: 80vw;
|
||||
margin-top: 220rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.dialog-title {
|
||||
font-size: 42rpx;
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.dialog-desc {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
margin-bottom: 100rpx;
|
||||
}
|
||||
|
||||
.dialog-btns {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.btn-cancel,
|
||||
.btn-confirm {
|
||||
|
||||
font-size: 36rpx;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.btn-confirm {
|
||||
color: #FF6B00;
|
||||
}
|
||||
|
||||
.repair-type {
|
||||
height: 98rpx;
|
||||
background: #F7F8FA;
|
||||
border-radius: 10rpx;
|
||||
padding: 0 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20rpx;
|
||||
box-sizing: border-box;
|
||||
margin-left: 40rpx;
|
||||
margin-right: 40rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.text-type {
|
||||
font-size: 24rpx;
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
.right-arrow {
|
||||
width: 11rpx;
|
||||
height: 21rpx;
|
||||
}
|
||||
</style>
|
@@ -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