<template>
	<view class="deetailPage">
		<headers :showBack="true">
			<view class="headerName">
				进度管理系统
			</view>
		</headers>
		<view class="content" v-if="isPass">
			<view class="title">
				进度详情
			</view>
			<view class="type">
				<view class="textColor">所属承包商：<span class="textStyle">{{itemFrom.enterpriseName || ""}}</span></view>
			</view>
			<view class="type">
				<view class="textColor">所属厂区：<span class="textStyle">{{itemFrom.regionName || ""}}</span></view>
			</view>
			<view class="type">
				<view class="textColor">分部分项工程：<span class="textStyle">{{itemFrom.taskName || ""}}</span></view>
			</view>
			<view class="type">
				<view class="textColor">上报时间：<span class="textStyle">{{itemFrom.uploadDate || ""}}</span></view>
			</view>
			<view class="type">
				<view class="textColor">上报进度：<span class="textStyle">{{itemFrom.progressRatio || 0}}%</span></view>
			</view>
			<view class="type">
				<view class="textColor">反馈内容：</view>
				<view class="type-area">
					<view>{{itemFrom.feedbackContent || ""}}</view>
				</view>
			</view>
			<view class="type">
				<view class="textColor">图片：</view>
				<view class="type-img">
					<image :src="item" mode="" v-for="(item,index) in itemFrom.imgList" :key="index"></image>
				</view>
			</view>
			<view class="type">
				<view class="textColor">是否有延期误工事件：<span class="textStyle">{{itemFrom.hasDelayEvent == 1 ? "是" : "否"}}</span></view>
			</view>
			<view class="type">
				<view class="textColor">延期误工原因：</view>
				<view class="type-area">
					<view>{{itemFrom.delayEventReason || ""}}</view>
				</view>
			</view>
		</view>
		<view class="content" v-else>
			<view class="title">
				进度详情
			</view>
			<view class="b-bottom">
				<view class="name">驳回原因</view>
				<textarea auto-height @input='supplementTextarea' :value="form.feedbackContent" placeholder="多行输入"></textarea>
			</view>
		</view>
		<view class="btn-box" v-if="isPass && ![2,3].includes(itemFrom.auditType)">
			<view class="btn-box">
				<view class="cancle-btn" @click="isPass = false">驳回</view>
				<view class="pass-btn" @click="passAudit">通过</view>
			</view>
		</view>
		<view class="addProgess" v-if="!isPass && ![2,3].includes(itemFrom.auditType)" @click="submitAudit">
			提交
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				itemFrom: {},
				userInfo: {},
				tableData: [],
				projectSn: '',
				isPass: true,
				form: {
					feedbackContent: ''
				}
			}
		},
		onLoad(option) {
			this.itemFrom = JSON.parse(option.obj);
			if(this.itemFrom){
				this.filterItemForm();
			}
			this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
			this.projectSn = JSON.parse(uni.getStorageSync('projectDetail')).projectSn;
		},
		methods: {
			// 提交审核
			submitAudit(){
				// 获取统计信息
				this.sendRequest({
					url: "xmgl/xzTaskProgressContent/edit",
					data: {
						id: this.itemFrom.id,
						auditType: 3,
						rejectReason: this.form.feedbackContent
					},
					method: "post",
					success(res) {
						uni.showToast({
							title: '驳回审核'
						})
						setTimeout(function(){
							uni.navigateBack({
								delta: 1
							})
						},1000)
					}
				})
			},
			// 通过审核
			passAudit(){
				// 获取统计信息
				this.sendRequest({
					url: "xmgl/xzTaskProgressContent/edit",
					data: {
						id: this.itemFrom.id,
						auditType: 2
					},
					method: "post",
					success(res) {
						uni.showToast({
							title: '提交成功'
						})
						setTimeout(function(){
							uni.navigateBack({
								delta: 1
							})
						},1000)
					}
				})
			},
			//反馈内容
			supplementTextarea(e) {
				this.form.feedbackContent = e.detail.value
			},
			filterItemForm(){
				console.log(this.itemFrom)
				if(this.itemFrom.image){
					let imgArr = JSON.parse(this.itemFrom.image);
					let dealArr = [];
					imgArr.map(item => {
						if(item.url.indexOf("http") == -1){
							dealArr.push(this.url_config + 'image/' + item.url)
						} else {
							dealArr.push(item.url)
						}
					})
					this.itemFrom.imgList = dealArr
				}
			}
		}
	}
</script>

<style lang="less">
	.btn-box {
		position: fixed;
		bottom: 30rpx;
		left: 0;
		line-height: 96rpx;
		display: flex;
		justify-content: center;
		width: 100%;
		height: 96rpx;
		color: #fff;
		text-align: center;
	
		.cancle-btn {
			// flex: 1;
			width: 45%;
			height: 100%;
			// background: #DD4907;
			background-color: transparent;
			color: #EF636A;
			border: 2rpx solid #EE6B73;
			border-top-left-radius: 8rpx;
			border-bottom-left-radius: 8rpx;
		}
	
		.pass-btn {
			// flex: 1;
			width: 45%;
			height: 100%;
			background: #127FEC;
			border-top-right-radius: 8rpx;
			border-bottom-right-radius: 8rpx;
		}
	}
	.b-bottom {
		border-top: 2rpx solid #f0f0f0;
		display: flex;
		height: 200rpx;
		line-height: 80rpx;
		padding-top: 40rpx;
		.inputFrom {
			width: 80%;
			margin-left: 40rpx;
		}
	
		.name {
			width: 20%;
		}
	
		.icon-right {
			margin-left: 16rpx;
			width: 16rpx;
			height: 32rpx;
		}
	
	
	}
	.content {
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx 16rpx;

		.title {
			margin: 20rpx;
			font-weight: bold;
			font-size: 28rpx;
		}

		.type {
			color: #9f9f9f;
			margin: 40rpx 20rpx 0 20rpx;
			font-size: 28rpx;

			.textStyle {
				float: right;
				color: #000;
			}
			.type-img{
				margin-top: 20rpx;
				display: flex;
				flex-wrap: wrap;
				image{
					width: 80rpx;
					height: 80rpx;
					margin-right: 20rpx;
				}
			}
			.type-area{
				background-color: #F6F6F6;
				border-radius: 6rpx;
				padding: 15rpx;
				color: #626677;
				margin-top: 20rpx;
			}

		}
		
		.record-content{
			.record-item{
				display: flex;
				background-color: #F6F6F6;
				border-radius: 6rpx;
				padding: 15rpx;
				image{
					width: 30rpx;
					height: 30rpx;
					margin-top: 5rpx;
					margin-left: 20rpx;
					margin-right: 70rpx;
				}
				.item-text{
					display: flex;
					flex-direction: column;
					margin-right: auto;
					text:nth-child(1){
						margin-bottom: 20rpx;
					}
				}
				.record-status{
					width: 100rpx;
					height: 40rpx;
					line-height: 40rpx;
					text-align: center;
					font-size: 24rpx;
					color: white;
					border-radius: 30rpx;
				}
				.pass-status{
					background-color: #5382F6;
				}
				.noPass-status{
					background-color: #EB3B43;
				}
			}
			.record-item:not(:last-child){
				margin-bottom: 40rpx;
			}
		}
		
		.line {
			border-bottom: 1px solid #e6e6e6;
			margin-top: 60rpx;
		}

		.container {
			width: 100%;
			height: 100%;
			display: flex;
			flex-direction: column;
			font-size: 28rpx;
			margin-top: 40rpx;
		}

		.table-header {
			display: flex;
			background-color: #f7f8fa;

			text-align: center;
			height: 70rpx;
			line-height: 70rpx;

		}

		.header-cell {
			flex: 1;
			border: 1px solid #f0f0f0;
		}

		.table-body {
			display: flex;
			flex-direction: column;
			text-align: center;

		}

		.table-row {
			display: flex;

			height: 70rpx;
			line-height: 70rpx;
		}

		.table-cell {
			flex: 1;
			border: 1px solid #f0f0f0;
			width: 50rpx;
			white-space: nowrap;
			/* 防止换行 */
			overflow: hidden;
			/* 超出部分隐藏 */
			text-overflow: ellipsis;
			/* 超出部分显示省略号 */
		}

		.addProgess {
			width: 50%;
			background: #5181f6;
			text-align: center;
			margin: auto;
			height: 60rpx;
			color: #fff;
			border-radius: 40rpx;
			line-height: 60rpx;
			margin-top: 110rpx;
			font-size: 28rpx;
		}

		.closeProgess {
			width: 50%;
			text-align: center;
			margin: auto;
			height: 60rpx;
			border-radius: 40rpx;
			line-height: 60rpx;
			margin-top: 110rpx;
			font-size: 28rpx;
			background: #f7f8fa;
			color: #8c8c8c;
		}

		.greenText {
			color: green !important;
		}

		.blueText {
			color: #5181f6 !important;
		}

		.redText {
			color: red !important;
		}
	}
	.addProgess {
		width: 70%;
		background: #5181f6;
		text-align: center;
		margin: 0 auto;
		margin-top: auto;
		height: 80rpx;
		color: #fff;
		border-radius: 40rpx;
		line-height: 80rpx;
		font-size: 28rpx;
		position: fixed;
		bottom: 30rpx;
		left: 120rpx;
		display: flex;
		justify-content: center;
	}
</style>
