patrolRecord-detail.vue 6.73 KB
<template>
	<view class="device-detail-page">
		<!-- 公共组件-每个页面必须引入 -->
		<public-module></public-module>
		<u-sticky :bgColor="bgColor">
			<u-tabs :list="list.map(item=>({...item,name:$t(item.name)}))" :current="currentTab" :lineWidth="30" @click=" handleTabClick " :activeStyle="{activeColor}"
				:inactiveStyle="inActiveColor" :scrollable="isScrollable" itemStyle="padding: 0 11px;display:flex;flex-direction:row;align-items:center;justify-content:center;height:44px" />
		</u-sticky>
		<view class="mt-3">
			<view class="basic-box" v-show="currentTab == 0">
				<view class="basic-header">
					<view class="u-flex">
						<view class="basic-text text-clip ml-2">
							{{ listDetail.code }}
						</view>
						<view v-if="listDetail.recordResult" class="basic-text-status ml-2" :style="{ color: inspectionResult[listDetail.recordResult].color}">
							{{ listDetail.recordResult ? inspectionResult[listDetail.recordResult].name : '' }}
						</view>
					</view>
				</view>
				<view class="detail">
					<view class="detail-item">
						<view class="detail-label">{{ $t('deviceInspect.recordCode') }}</view>
						<view class="detail-value">{{ listDetail.code}}</view>
					</view>
					<u-line length="90%" margin="0 auto"></u-line>
					<view class="detail-item">
						<view class="detail-label">{{ $t('deviceInspect.patrolPlan') }}</view>
						<view class="detail-value">{{ listDetail.tkInspectionPlanDTO ? listDetail.tkInspectionPlanDTO.name :''}}</view>
					</view>
					<u-line length="90%" margin="0 auto"></u-line>
					<view class="detail-item">
						<view class="detail-label">{{ $t('deviceInspect.patrolByName') }}</view>
						<view class="detail-value">{{ listDetail.userDTO ? listDetail.userDTO.realName : '' }}</view>
					</view>
					<u-line length="90%" margin="0 auto"></u-line>
					<view class="detail-item">
						<view class="detail-label">{{ $t('deviceInspect.checkDate') }}</view>
						<view class="detail-value">{{ listDetail.checkDate }}</view>
					</view>
				</view>
			</view>
			<view class="record-box" v-show="currentTab == 1">
				<!-- 列表分页 -->
				<mescroll-body ref="mescrollRef" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback"
					@up="upCallback">
					<page-list :list="listData" @openDeviceDetail="openDeviceDetail"></page-list>
					<mescroll-empty v-if="!listData.length" />
				</mescroll-body>
			</view>
			
		</view>
	</view>
</template>

<script>
import fTabbar from "@/components/module/f-tabbar/f-tabbar";
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
import api from '@/api/index.js'
import {planType,preserveType,detailType,inspectionType,inspectionResult} from '@/pages/deviceInspect/enum/index.js'
import { list } from './config/data.js'
import baseUrl from '@/config/baseUrl.js'
import pageList from '@/components/common/page-list'


export default {
	mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
	components: {
		fTabbar,
		pageList
		
	},
	data() {
		return {
			bgColor: '#fff',
			activeColor: {
				fontWeight: 'bold',
				color: '#333',
			},
			inActiveColor: {
				color: '#999',
			},
			listDetail:{},
			list,
			inspectionType,
			inspectionResult,
			preserveType,
			currentTab: 0,
			detailType,
			isScrollable: false,
			planType,
			downOption: {
				auto: false //是否在初始化后,自动执行downCallback; 默认true
			},
			upOption: {
				isBounce: false,
				auto: false // 不自动加载
			},
			page: {
				num: 0,
				size: 10
			},
			preservePlanId:'', //保养计划id
			listData:[]
			
		};
	},
	onUnload() {
		
	},
	async onLoad(options) {
		// 隐藏原生的tabbar
		uni.hideTabBar();
		if (getApp().getBindNot()) {
			return
		}
		let id = options.id
		const res =	await api.deviceInspectApi.getPatrolRecordDetail(id)	
		if (!res) return
		this.listDetail = {...res}
		
	
	},
	onShow(){
		this.$nextTick(()=>{
			uni.setNavigationBarTitle({
				title:this.$t('menu.patrolRecordDetail')
			})
		})
		
		
	},
	watch: {
		currentTab: {
			immediate: true,
			handler(val) {
				if(val == 1){
					this.loadData();
				}
				
			}
		},
		
		
		
	},
	
	methods: {
		handleTabClick({index}) {
			this.currentTab = index;
		},
		
		formatImage(url) {
			return baseUrl.baseImgUrl + url
		},
		//下拉刷新
		downCallback() {
			if (getApp().getBindNot()) {
				setTimeout(() => {
					this.mescroll.endByPage(0, 0)
				}, 200)
				return
			}
			this.loadData();
			// this.listData = [];
			// this.page.num = 1;
			// this.loadData(this.page.num);
			// this.resetQuery();
		},
		//上拉加载
		upCallback() {
			if (getApp().getBindNot()) {
				setTimeout(() => {
					this.mescroll.endByPage(0, 0)
				}, 200)
				return
			}
			
			// this.page.num += 1;
			this.loadData();
		},
		//获取列表
		loadData() {	
			let data = this.listDetail.tkInspectionDetailsDTOList
			let newList  = data.map((item)=>{
				return {
					id:item.id,
					title:item.patrolDevice,
					status:item.recordResult ? inspectionResult[item.recordResult].name : '',
					iconUrl:item.recordResult ? inspectionResult[item.recordResult].iconUrl : '',
					color:item.recordResult ? inspectionResult[item.recordResult].color : '',
					child:[
						{
							label:'deviceInspect.patrolDevice',
							name:item.tkDeviceAccountDTO ? item.tkDeviceAccountDTO.name : ''
						},
						{
							label:'deviceInspect.patrolContent',
							name:item.planDetails
						},
					],
					detail:{
						...item
					}
				}
			})
			this.listData = newList
			
		},
		
		
	},
};
</script>

<style lang="scss" scoped>
.device-detail-page {
	min-height: 100vh;
	background-color: #f8f9fa;
	// padding: 0 30rpx;
	.mt-3{
		// padding: 0 30rpx;
		margin-top: 0;
		.basic-box{
			margin-top: 30rpx;
			padding: 0 30rpx;
		}
		.record-box{
			// padding: 0 30rpx 0 15rpx;
		}
	}
	.basic-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 140rpx;
		background-color: #fff;
		border-radius: 20rpx;
		padding-left: 40rpx;
		padding-right:20rpx;
		
	
		.basic-text {
			width: 370rpx;
		}
	
		.cu-item {
			background: #3388ff;
			border-radius: 12px;
			width: 120rpx;
			height: 48rpx;
			text-align: center;
			line-height: 40rpx;
	
			text {
				font-size: 12px;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #ffffff;
			}
		}
	
		.basic-text-status {
			font-size: 14px;
		}
	}
	.detail {
		background-color: #fff;
		margin-top: 30rpx;
		border-radius: 20rpx;
		width: 690rpx;
	
		.detail-item {
			padding: 30rpx;
			display: flex;
			align-items: center;
	
			.detail-label {
				color: #333;
				font-size: 15px;
			}
	
			.detail-value {
				color: #666;
				font-size: 14px;
				margin-left: 30rpx;
				.detail-img{
					width: 60rpx;
					height: 60rpx;
				}
			}
		}
	}
}
</style>