<template>
	<van-nav-bar title="标题" left-arrow />
	<van-pull-refresh v-model="loading" @refresh="onRefresh">
		<div class="warpKnitting">
			<div class="stat">
				<div class="title">
					<span>设备状态</span>
					<div class="type">运行</div>
				</div>
				<ul>
					<li>
						<div class="icon">
							<van-icon name="location-o" />
						</div>
						<div class="text">EBC</div>
						<div class="btn">运行</div>
					</li>
					<li>
						<div class="icon">
							<van-icon name="location-o" />
						</div>
						<div class="text">EBC</div>
						<div class="btn">运行</div>
					</li>
					<li>
						<div class="icon">
							<van-icon name="location-o" />
						</div>
						<div class="text">EBC</div>
						<div class="btn">运行</div>
					</li>
				</ul>
			</div>
			<div class="speed">
				<div style="display: flex">
					<div class="icon">
						<van-icon name="location-o" />
					</div>
					<div class="text">主轴转速</div>
				</div>
				<div class="num">400 RPM</div>
			</div>
			<div class="commons-title">产量数据</div>
            <div class="chart-warp">
                <div class="chart-box" id="myCharts" ref="myCharts"></div>
                <div class="label-box">
                    
                </div>
            </div>
			<div class="commons-title">EBC</div>
			<ul class="buchang">
				<li>
					<div class="icon">
						<van-icon size="20px" name="location-o" />
					</div>
					<div class="text">当前布长</div>
					<div class="btn">200M</div>
				</li>
				<li>
					<div class="icon">
						<van-icon size="20px" name="location-o" />
					</div>
					<div class="text">设定布长</div>
					<div class="btn">300M</div>
				</li>
				<li>
					<div class="icon">
						<van-icon size="20px" name="location-o" />
					</div>
					<div class="text">密度</div>
					<div class="btn">50</div>
				</li>
			</ul>
			<ul class="qianla">
				<li>
					<div class="icon">
						<van-icon size="20px" name="location-o" />
					</div>
					<div class="text">牵拉</div>
				</li>
				<li>
					<div class="icon">
						<van-icon size="20px" name="location-o" />
					</div>
					<div class="text">卷曲</div>
				</li>
			</ul>
			<ul class="songjin">
				<li>
					<div style="display: flex">
						<div class="icon">
							<van-icon name="location-o" />
						</div>
						<div class="text" style="margin-left: 8px">
							主轴转速
						</div>
					</div>
					<div class="num">
						<p>剩余圈数: <span>35 N</span></p>
						<p>剩余圈数: <span>35 N</span></p>
					</div>
				</li>
				<li>
					<div style="display: flex">
						<div class="icon">
							<van-icon name="location-o" />
						</div>
						<div class="text" style="margin-left: 8px">
							主轴转速
						</div>
					</div>
					<div class="num">
						<p>剩余圈数: <span>35 N</span></p>
						<p>剩余圈数: <span>35 N</span></p>
					</div>
				</li>
				<li>
					<div style="display: flex">
						<div class="icon">
							<van-icon name="location-o" />
						</div>
						<div class="text" style="margin-left: 8px">
							主轴转速
						</div>
					</div>
					<div class="num">
						<p>剩余圈数: <span>35 N</span></p>
						<p>剩余圈数: <span>35 N</span></p>
					</div>
				</li>
			</ul>
		</div>
	</van-pull-refresh>
</template>
<script setup>
import * as echarts from 'echarts'
import { ref, onMounted,getCurrentInstance } from 'vue'
import { useRouter } from 'vue-router'
const proxy = getCurrentInstance().proxy
const loading = ref(false)
const onRefresh = () => {
	setTimeout(() => {
		loading.value = false
	}, 500)
}
const router = useRouter()

const getDtl = () => {
	proxy.post('/tdaDevice/data', { deviceId: router.currentRoute.value.params.id }).then(
		(res) => {
			console.log(res)
		}
	)
	
}
getDtl()
onMounted(() => {
	const myChart = echarts.init(document.getElementById('myCharts'))
	const option = {
		grid: {
			top: '8%',
			left: '4%',
			right: '8%',
			bottom: '8%',
			containLabel: true,
		},
		tooltip: {
			trigger: 'axis',
			axisPointer: {
				type: 'cross',
				label: {
					backgroundColor: '#6a7985',
				},
				
			},
		},

		xAxis: {
			type: 'category',
			boundaryGap: false,
			data: ['0', '1', '2', '3', '4', '5', '6'],
		},
		yAxis: {
			type: 'value',
		},
		series: [
			{
				data: [135, 135, 122, 211, 345, 567, 654],
				type: 'line',
                
                symbolSize: 10,
                showSymbol: false,
				areaStyle: {
					opacity: 0,
				},
				stack: 'Total',
				smooth: true,
				lineStyle: {
					normal: {
						color: '#0084FF',
                        width: 4,
					},
				},
			},
			{
				data: [150, 150, 150, 150, 150, 150, 150],
				type: 'line',
               
                symbolSize: 10,
                showSymbol: false,
				areaStyle: {
					opacity: 0,
				},
				lineStyle: {
					normal: {
						color: '#FF8C33',
                        width: 4,
					},
				},
			},
		],
	}
	myChart.setOption(option)
})
</script>
<style lang="scss" scoped>
.warpKnitting {
	padding: 0 12px 80px;
    .chart-warp{
        background: #fff;
        .chart-box {
            height: 250px;
            
	    }
    }   
	
	.songjin {
		li {
			height: 74px;
			background: #ffffff;
			border-radius: 5px 5px 5px 5px;
			line-height: 50px;
			display: flex;
			justify-content: space-between;
			margin-top: 12px;
			padding: 12px;
			box-sizing: border-box;
			font-size: 14px;
			.icon {
				width: 50px;
				height: 50px;
				border-radius: 50%;
				background: #eeeeee;
				text-align: center;
				.van-icon {
					color: #0084ff;
				}
			}
			.num {
				margin-left: 8px;
				font-size: 14px;
				font-weight: 500;
				color: #333;
				p {
					margin: 0;
					line-height: 25px;
					color: #999999;
				}
				span {
					color: #333333;
				}
			}
		}
	}

	.qianla {
		display: flex;
		justify-content: space-between;

		margin-top: 12px;
		li {
			display: flex;
			width: 49%;
			line-height: 50px;
			padding: 12px;
			box-sizing: border-box;
			font-size: 14px;
			background: #ffffff;
			border-radius: 5px 5px 5px 5px;
			.icon {
				width: 50px;
				height: 50px;
				border-radius: 50%;
				background: #eeeeee;
				text-align: center;
				.van-icon {
					color: #0084ff;
				}
			}

			.text {
				margin-left: 8px;
				font-size: 14px;
				font-weight: 500;
				color: #333;
			}
		}
	}
	.buchang {
		display: flex;
		justify-content: space-between;
		text-align: center;
		li {
			width: 32%;

			background: #ffffff;
			border-radius: 5px 5px 5px 5px;
			line-height: 50px;
			padding: 12px;
			box-sizing: border-box;
			font-size: 14px;
			.icon {
				width: 50px;
				height: 50px;
				border-radius: 50%;
				background: #eeeeee;
				display: flex;
				justify-content: center;
				align-items: center;
				margin: 0 auto;
				.van-icon {
					color: #0084ff;
				}
			}
			.btn {
				font-size: 16px;
				font-weight: bold;
				line-height: 20px;
			}
			.text {
				line-height: 20px;
				margin: 12px 0 8px;
			}
		}
	}
	.speed {
		height: 74px;
		background: #ffffff;
		border-radius: 5px 5px 5px 5px;
		line-height: 50px;
		display: flex;
		justify-content: space-between;
		margin-top: 12px;
		padding: 12px;
		box-sizing: border-box;
		font-size: 14px;
		.icon {
			width: 50px;
			height: 50px;
			border-radius: 15px;
			background: #00b0ff;
			display: flex;
			justify-content: center;
			align-items: center;
			margin-right: 12px;
			.van-icon {
				color: #fff;
			}
		}
		.num {
			font-size: 16px;
			font-weight: bold;
		}
	}
	.stat {
		background: #ffffff;
		border-radius: 5px 5px 5px 5px;
		margin-top: 12px;
		.title {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 48px;
			line-height: 48px;
			padding: 0 12px;
			border-bottom: 1px solid #dddddd;
			.type {
				color: #00b0ff;
				font-size: 14px;
				width: 60px;
				height: 24px;
				background: #f1f1f1;
				color: #3fbf31;
				line-height: 24px;
				position: relative;
				border-radius: 12px 12px 12px 12px;
				padding-left: 20px;
				box-sizing: border-box;
			}

			.type:before {
				content: '';
				position: absolute;
				left: 6px;
				top: 6px;
				width: 12px;
				height: 12px;
				background: #3fbf31;
				border-radius: 50%;
			}
		}
		ul {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20px 30px 22px;
			box-sizing: border-box;
			li {
				display: flex;
				flex-direction: column;
				align-items: center;
				.icon {
					width: 50px;
					height: 50px;
					border-radius: 15px;
					background: #00b0ff;
					display: flex;
					justify-content: center;
					align-items: center;
					margin-bottom: 12px;
					.van-icon {
						color: #fff;
					}
				}
				.text {
					color: #333;
					font-size: 14px;
				}
				.btn {
					width: 60px;
					height: 24px;
					background: #f1f1f1;
					border-radius: 12px 12px 12px 12px;
					margin-top: 8px;
					text-align: center;
					line-height: 24px;
					font-weight: 500;
					font-size: 14px;
					color: #3fbf31;
				}
			}
		}
	}
}
</style>