<!--
 * @Title: 
 * @Description: 我的维修任务列表
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
	<view class="wrap">
		<uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" status-bar left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view class="nav-title">
				<text>{{title}}</text>
			</view>
		</uni-nav-bar>
		<view class="container">
			<uni-list>
				<uni-list-item v-for="item in list" :key="item.id">
					<template v-slot:body>
						<view class="list-item-block">
							<view class="items-line">
								<view class="block">
									<image class="item-title-run-status-icon" style="box-shadow:0 0 2px 2px lightblue"
										src="/static/images/list/order_item.png" mode="widthFix">
									</image>
								</view>
								<text class="item-title-rtu-name">{{item.rtuName}}</text>
								<text class="item-title-rtu-code">[{{item.rtuCode}}]</text>
							</view>
							<view class="items-line">
								<uni-icons class="input-uni-icon" type="loop" size="18" color="lightblue" />
								<text class="item-text-lable">维修时长：</text>
								<text class="item-text-content" style="color: red;">{{item.taskProcessDuration}}</text>
							</view>
							<view class="items-line">
								<uni-icons class="input-uni-icon" type="location" size="18" color="lightblue" />
								<text class="item-text-lable">行政区划：</text>
								<text class="item-text-content">{{item.areaName}}</text>
							</view>
							<view class="item-button-group">
								<view class="item-button"
									@click="onLocationClick(item)">
									<view class="items-line">
										<uni-icons class="input-uni-icon" type="location" size="18" color="coral" />
										<text class="button-text">导航</text>
									</view>
								</view>
								<view class="item-button"
									@click="onReportDetailClick(item.id)">
									<view class="items-line">
										<uni-icons class="input-uni-icon" type="info" size="18" color="coral" />
										<text class="button-text">维修详情</text>
									</view>
								</view>
								<view class="item-button" @click="onCheckOrderReportEditClick(item.id)">
									<view class="items-line">
										<uni-icons class="input-uni-icon" type="compose" size="18" color="coral" />
										<text class="button-text">维修填报</text>
									</view>
								</view>
							</view>
						</view>
					</template>
				</uni-list-item>
			</uni-list>
			<uni-group>
				<view class="pagination-block">
					<uni-pagination show-icon :pageSize="pageSize" :current="pageCurrent" :total="total"
						@change="pageChange" />
				</view>
			</uni-group>
		</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';


	export default {
		components: {

		},
		onLoad(option) {
			this.getPage();
		},
		data() {
			return {
				list: [],
				title: '我的维修任务',
				desc: '',
				pageSize: 10,
				// 当前页
				pageCurrent: 1,
				// 数据总量
				total: 0,
				query: {},
			}
		},
		computed: {

		},
		onShow() {

		},
		created() {

		},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			// 分页触发
			pageChange(e) {
				this.pageCurrent = e.current;
				this.getPage()
			},
			getPage() {
				const current = this.pageCurrent;
				const size = this.pageSize;
				let that = this;
				http.request({
					url: '/galaxy-business/rtu/check/order/my/page',
					method: 'GET',
					params: {
						current,
						size,
					},
				}).then(res => {
					if (res.data.records != null) {
						that.list = res.data.records;
					}
					this.total = res.data.total;
				}).catch(err => {
					console.log(err)
				})
			},
			onCheckOrderReportEditClick(id) {
				console.log("iddd" + id)
				var url = '/pages/check-order/orderprocessreport?orderId=' + id;
				uni.navigateTo({
					url: url
				})
			},
			onReportDetailClick(id) {
				let url = '/pages/check-order/orderprocessreportdetail?orderId=' + id;
				uni.navigateTo({
					url: url
				})
			},
			onLocationClick(item) {
				let lat = item.lat;
				let lng = item.lng;
				let name = item.rtuName;
				let add = item.locationDesc;
				uni.openLocation({
					latitude: Number(lat),
					longitude: Number(lng),
					name: name,
					address: add,
					success() {

					}
				})
			},
		}
	}
</script>

<style>
	/* page {
		background-color: rgb(240, 242, 244);
	} */
</style>

<style lang="scss" scoped>

</style>
