<!--
 * @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" statusBar="false" left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view class="nav-title">
				<text>{{title}}</text>
			</view>
		</uni-nav-bar>
		<view class="container">
			<uni-forms ref="baseForm" :model="formData">
				<uni-section title="审批意见" ftitleFontSize="0.8rem" style="width: 100%;">
					<template v-slot:decoration>
						<view class="decoration"></view>
					</template>
					<view style="padding-top: 10px;padding-bottom: 0px;padding-left: 15px;padding-right: 15px;">
						<uni-forms-item>
							<uni-easyinput :styles="styles" type="textarea" v-model="formData.processDesc"
								placeholder="请录入工单完结审批意见" />
						</uni-forms-item>
					</view>
				</uni-section>
				<uni-card title="评分">
					<uni-rate v-model="formData.orderRate" />
				</uni-card>
				<!-- 		<uni-section title="评分" ftitleFontSize="0.8rem" style="width: 100%;">
					<template v-slot:decoration>
						<view class="decoration"></view>
					</template>
					<uni-rate v-model="formData.orderRate" />
				</uni-section> -->
			</uni-forms>
			<view class="view-btn">
				<button style="background-color: lightcoral;" type="default"
					@click="toOrderCloseConfirm()">工单关闭</button>
			</view>
			<uni-section title="工单处理详情" type="line">
				<uni-list>
					<uni-list-item v-for="(item,index) in orderProcessList" :key="item.id" direction="column">
						<template v-slot:body>
							<view class="point">
								<view class="dot">
									{{index+1}}
								</view>
								<view class="time-title">{{item.createTime}}【{{item.orderStatusName}}】</view>
							</view>
							<view class="time-info">
								<view class="time-line">
									<view v-if="item.orderStatusCode ==2" class="list-item-block">
										<view class="line" style="padding-left:12px">
											<view v-if="orderType==1" class="text" style="color: gray;">工单类型:<span
													style="margin-left: 5px;color: cornflowerblue;">维修工单</span></view>
											<view v-else-if="orderType==2" class="text" style="color: gray;">工单类型:<span
													style="margin-left: 5px;color: cornflowerblue;">服务工单</span></view>
											<view v-else></view>
										</view>
										<view class="line" style="padding-left:12px">
											<view class="text" style="width: 90%;color: gray;">
												工单创建人:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.orderProcessUserName}}</span>
											</view>
										</view>
										<view class="line" style="padding-left:12px">
											<view class="text" style="width: 90%;color: gray;">
												创建时间:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.createTime}}</span>
											</view>
										</view>
										<uni-card title="问题描述">
											<view class="text" style="color: cornflowerblue;">{{item.processDesc}}
											</view>
										</uni-card>
						<!-- 				<view class="line">
											<view class="text" style="width: 90%;color: gray;">
												问题描述:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.processDesc}}</span>
											</view>
										</view> -->
										<uni-card title="处理照片">
											<view class="view-flex-rs-flex-wrap">
												<view v-for="(path, index) in item.failureProcessPhotoList" :key="index"
													class="view-flex-cc" style="width: 80px;">
													<view class="img-container">
														<view class="note-image-box">
															<view class="note-image-item">
																<view class="image-box">
																	<image :src="toOss(path)" mode="widthFix"
																		@click="openPhoto(path)">
																	</image>
																</view>
															</view>
														</view>
													</view>
												</view>
											</view>
											<!-- 									<view class="view-flex-block-center">
										<image v-for="(path, index) in item.failureProcessPhotoList" :key="index"
											mode="widthFix" style="width: 80%;margin-top: 10px;" :src="toOss(path)">
										</image>
									</view> -->
										</uni-card>
										<uni-card title="处理视频">
											<view class="view-flex-inline">
												<image v-for="(path, index) in item.failureProcessVideoList"
													:key="index" mode="widthFix" style="width: 80px;" :src="videoImg"
													@click="openVideo(path)">
												</image>
											</view>
										</uni-card>
									</view>
									<view v-else-if="item.orderStatusCode ==3" class="list-item-block">
										<view class="line" style="padding-left:12px">
											<view class="text" style="width: 90%;color: gray;">
												工单处理人:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.orderProcessUserName}}</span>
											</view>
										</view>
										<view class="line" style="padding-left:12px">
											<view class="text" style="width: 90%;color: gray;">
												处理时间:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.createTime}}</span>
											</view>
										</view>
										<uni-card v-if="orderType==1" title="故障现象描述">
											<view class="text" style="color: cornflowerblue;">{{item.failureCheckDesc}}
											</view>
										</uni-card>
		<!-- 								<view v-if="orderType==1" class="line">
											<view class="text" style="width: 90%;color: gray;">
												故障现象描述:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.failureCheckDesc}}</span>
											</view>
										</view> -->
										<uni-card v-else-if="orderType==2" title="服务内容描述">
											<view class="text" style="color: cornflowerblue;">{{item.failureCheckDesc}}
											</view>
										</uni-card>
<!-- 										<view v-else-if="orderType==2" class="line">
											<view class="text" style="width: 90%;color: gray;">
												服务内容描述:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.failureCheckDesc}}</span>
											</view>
										</view> -->
										<view v-else></view>
										<uni-card title="解决措施说明">
											<view class="text" style="color: cornflowerblue;">{{item.processDesc}}
											</view>
										</uni-card>
<!-- 										<view class="line">
											<view class="text" style="width: 90%;color: gray;">
												解决措施说明:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.processDesc}}</span>
											</view>
										</view> -->
										<uni-card v-if="orderType==1 && item.costsReport==2" title="费用说明">
											<view class="text" style="color: cornflowerblue;">{{item.costsReportDesc}}
											</view>
										</uni-card>
										
<!-- 										<view v-if="orderType==1 && item.costsReport==2" class="line">
											<view class="text" style="width: 90%;color: gray;">
												费用说明:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.costsReportDesc}}</span>
											</view>
										</view> -->
										<uni-card title="处理照片">
											<view class="view-flex-rs-flex-wrap">
												<view v-for="(path, index) in item.failureProcessPhotoList" :key="index"
													class="view-flex-cc" style="width: 80px;">
													<view class="img-container">
														<view class="note-image-box">
															<view class="note-image-item">
																<view class="image-box">
																	<image :src="toOss(path)" mode="widthFix"
																		@click="openPhoto(path)">
																	</image>
																</view>
															</view>
														</view>
													</view>
												</view>
											</view>
											<!-- 									<view class="view-flex-block-center">
										<image v-for="(path, index) in item.failureProcessPhotoList" :key="index"
											mode="widthFix" style="width: 80%;margin-top: 10px;" :src="toOss(path)">
										</image>
									</view> -->
										</uni-card>
									</view>
									<view v-else-if="item.orderStatusCode ==5" class="list-item-block">
										<view class="line" style="padding-left:12px">
											<view class="text" style="width: 90%;color: gray;">
												费用审批人:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.orderProcessUserName}}</span>
											</view>
										</view>
			<!-- 							<view class="line" style="padding-left:12px">
											<view class="text" style="width: 90%;color: gray;">
												审批时间:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.createTime}}</span>
											</view>
										</view> -->
										<uni-card title="审批意见">
											<view class="text" style="color: cornflowerblue;">{{item.processDesc}}
											</view>
										</uni-card>
<!-- 										<view class="line">
											<view class="text" style="width: 90%;color: gray;">
												审批意见:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.processDesc}}</span>
											</view>
										</view> -->
									</view>
									<view v-else-if="item.orderStatusCode ==7" class="list-item-block">
										<view class="line" style="padding-left:12px">
											<view class="text" style="width: 90%;color: gray;">
												工单完结审批人:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.orderProcessUserName}}</span>
											</view>
										</view>
			<!-- 							<view class="line" style="padding-left:12px">
											<view class="text" style="width: 90%;color: gray;">
												审批时间:<span
													style="margin-left: 5px;color: cornflowerblue;">{{item.createTime}}</span>
											</view>
										</view> -->
										<uni-card title="审批意见">
											<view class="text" style="color: cornflowerblue;">{{item.processDesc}}
											</view>
										</uni-card> 
									</view>
								</view>
							</view>
						</template>
					</uni-list-item>
				</uni-list>
			</uni-section>
			<view style="margin-top: 5px;margin-bottom: 10px;padding-left: 10px;padding-right: 10px;">
				<button style="background-color: lightcoral;" type="default" @click="toTopClick()">返回顶部</button>
			</view>
		</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';
	import {
		oss,
		devUrl,
		prodUrl
	} from '@/common/setting';
	export default {
		components: {

		},
		data() {
			return {
				title: '工单完结审批',
				orderId: '',
				orderType: 1,
				orderProcessList: [],
				formData: {
					processDesc: '',
					orderRate: 5,
				},
				orderInfo: {
					'id': 0,
					'updateTime': '',
					'orderDesc': '',
					'orderConfirm': 0,
				},
				styles: {
					color: '#333',
					borderColor: '#e5e5e5',
					disableColor: '#FFFFFF'
				},
				baseURL: '',
				baseOSS: '',
				videoImg: '/static/images/video.png',
			}
		},
		computed: {},
		onLoad(option) {
			this.orderId = option.orderId;
			this.orderType = option.orderType;
			this.baseURL = process.env.NODE_ENV === 'development' ? devUrl : prodUrl;
			this.baseOSS = oss;
			this.getDetail();
		},
		onShow() {},
		methods: {
			toOss(path) {
				let url = this.baseOSS + path;
				//console.log("tooss " + url)
				return url;
			},
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			toTopClick() {
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 100,
				});
			},
			openPhoto(file) {
				let url = '/pages/check-order/photoView?url=' + file;
				uni.navigateTo({
					url: url
				})
			},
			openVideo(file) {
				let url = '/pages/check-order/videoView?url=' + file;
				uni.navigateTo({
					url: url
				})
			},
			getDetail() {
				let that = this;
				let postData = {};
				postData['orderId'] = this.orderId;
				http.request({
					url: '/galaxy-business/order/process/list',
					method: 'GET',
					data: postData,
				}).then(res => {
					if (res.data != null) {
						console.log(JSON.stringify(res.data))
						that.orderProcessList = res.data;
					}
				}).catch(err => {
					console.log(JOSN.stringify(err))
				})
			},
			toOrderCloseConfirm() {
				let that = this;
				uni.showModal({
					content: '确定关闭该工单？',
					showCancel: true,
					success(res) {
						if (res.confirm) {
							that.formData['orderId'] = that.orderId;
							http.request({
								url: '/galaxy-business/order/process/closeapprove',
								method: 'POST',
								params: that.formData
							}).then(res => {
								console.log(res)
								if (res.success) {
									that.toBack();
								}
							}).catch(err => {
								console.log(err)
							})
						}
					}
				});
			},
			toOrderProcessReport() {
				var url = '/pages/check-order/orderprocessreport?orderId=' + this.id + '&skipPage=2';
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

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

<style lang="scss" scoped>
	.view-btn {
		margin-top: 20px;
		margin-bottom: 20px;
		padding-left: 10px;
		padding-right: 10px;
	}

	.line-space {
		margin-top: 4px;
	}

	.point {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin: 15rpx 0;
	}

	.dot {
		//margin-left: -22rpx;
		background-color: #19be6b;
		box-shadow: 0 0 5rpx 5rpx #71d5a1;
		color: white;
		width: 50rpx;
		height: 50rpx;
		padding: 5rpx;
		font-size: 28rpx;
		text-align: center;
		border-radius: 50rpx;
	}

	.time-title {
		font-size: 30rpx;
		margin-left: 15rpx;
		background-color: whitesmoke;
		padding: 12rpx 25rpx;
		border-radius: 50rpx;
		color: orangered;
	}

	.time-info {
		padding: 0rpx 0rpx 0rpx 25rpx;
	}

	.time-line {
		border-left: 3rpx solid #71d5a1;
		padding: 10rpx 10rpx 30rpx 20rpx;
	}
</style>