<template>
	<!-- 巡检管理 -->
	<view class="card_ledger">
		<uv-navbar title="巡检管理" :placeholder="true" :titleStyle="{color:'#ffffff'}" leftIconColor="#ffffff"
			bgColor="#1d345e" @leftClick="leftClick"></uv-navbar>
		<view class="head_sub">
			<uv-subsection :list="listType" mode="button" :current="current" activeColor="#3c9cff"
				inactiveColor="#ffffff"
				custom-item-style="border-radius: 6rpx;background-color: rgba(97, 156, 255, .5);" bgColor="#1d345e"
				@change="change">
			</uv-subsection>
		</view>
		<view style="margin: 0rpx 20rpx;" v-if="workData.length > 0">
			<view class="item_order_work" v-for="(item,index) in workData" :key="index" @click="goRoutingDetails(item)">
				<!-- <image class="logo_ledger" src="/static/logo.png" mode="widthFix" /> -->
				<view style="flex: 1;">
					<view class="space_between">
						<view class="white_color">{{item.projectName}}</view>
						<view class="state_title" :style="{color:getOrderColor(item.orderStatus)}">
							{{getOrderTitle(item.orderStatus)}}
						</view>
					</view>
					<view class="white_color">巡检编号: {{item.orderNo}}</view>
					<view class="white_color">巡检区域: {{item.orderContent}}</view>
					<view class="white_color" style="margin-bottom: 0rpx;">巡检人: {{item.name}}</view>
				</view>
			</view>
		</view>
		<view style="margin-top:30%;" v-else>
			<x-empty></x-empty>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue';
	import { onShow, onReady } from "@dcloudio/uni-app";
	onReady(() => {
		// #ifdef APP-PLUS
		plus.navigator.setStatusBarStyle("light");
		// #endif
	})
	onShow(() => {
		// #ifdef APP-PLUS
		plus.navigator.setStatusBarStyle("light");
		// #endif
	});
	const listType = ref([{
		id: '99',
		color: '#22c55e',
		name: '全部',
	}, {
		id: '0',
		color: '#4f46e5',
		name: '待巡检',
	}, {
		id: '1',
		color: '#22c55e',
		name: '已完成',
	}, {
		id: '2',
		color: '#f26a6a',
		name: '异常'
	}, {
		id: '3',
		color: '#efc43f',
		name: '超时'
	}])
	const workData : any = ref([{
		projectName: '安全隐患巡检',
		orderNo: 'EK864467',
		orderStatus: 0,
		orderContent: '办公区C',
		name: '赵工程师',
	}, {
		projectName: '安全隐患巡检',
		orderNo: 'EK864467',
		orderStatus: 1,
		orderContent: '办公区C',
		name: '赵工程师',
	}, {
		projectName: '安全隐患巡检',
		orderNo: 'EK864467',
		orderStatus: 2,
		orderContent: '办公区C',
		name: '赵工程师',
	}, {
		projectName: '安全隐患巡检',
		orderNo: 'EK864467',
		orderStatus: 3,
		orderContent: '办公区C',
		name: '赵工程师',
	}])
	const current = ref(0)
	// 选择
	function change(index : any) {
		current.value = index
	}
	// 订单状态汉化
	function getOrderColor(value : any) {
		let title = ''
		listType.value.forEach((item : any) => {
			if (item.id == value) {
				title = item.color
			}
		})
		return title
	}
	// 订单状态汉化
	function getOrderTitle(value : any) {
		let title = ''
		listType.value.forEach((item : any) => {
			if (item.id == value) {
				title = item.name
			}
		})
		return title
	}
	// 跳转设备详情
	function goRoutingDetails(params : any) {
		uni.navigateTo({
			url: '/pages/routing/details',
		})
	}
	function leftClick() {
		uni.navigateBack({
			delta: 1
		});
	}
</script>

<style lang="scss" scoped>
	.head_sub {
		padding: 20rpx;
	}

	.logo_ledger {
		width: 150rpx;
		height: 150rpx;
		margin-right: 20rpx;
		border-radius: 10rpx;
	}

	.item_order_work {
		display: flex;
		color: #fff;
		padding: 25rpx;
		background-color: rgba(85, 110, 143, .3);
		margin-bottom: 30rpx;
		border-radius: 10rpx;
	}

	.white_color {
		color: #fff;
		font-size: 26rpx;
		margin-bottom: 10rpx;
	}

	.state_title {
		color: #1af0f7;
		font-size: 26rpx;
	}
</style>