<template>
	<view class="mission-list-item" @click="gotoDetails(task.id)">
		<view v-if="!isDetails && !isComplete" class="time">
			<text class="com-text">{{ task.recordTime }}</text>
		</view>
		<view class="card">
	    <view class="top-box">
				<view v-show="!isDetails" :class="['bg-box', isComplete ? 'disabled-bg' : 'hight-bg']">
					<text>{{isComplete ? '改善结案' : '改善中'}}</text>
				</view>
			<text class="title">{{ task.checkItemName }}</text>
	    	<text class="subtitle">{{ task.checkPointName }}</text>
	    	<view class="row">
	    		<view class="col">
	    			<image class="com-icon" src="/static/search-icon.png"></image>
	    			<text class="com-text">{{ task.checkPlan }}</text>
	    		</view>
	    		<view class="col">
	    			<image class="com-icon" src="/static/location-icon.png"></image>
	    			<text class="com-text">{{ task.deptName }}</text>
	    		</view>
	    	</view>
	    </view>
			<view class="bottom-box">
				<text class="com-text">情境名称：{{ task.situationName }}</text>
				<text class="com-text">改善人：{{ task.improveEmpName }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			// 当前遍历的任务
			task: {
				type: Object,
				default: () => {
					return {}
				}
			},
			// 是否结案
			isComplete: {
				type: Boolean,
				default: false
			},
			// 是否是详情页面
			isDetails: {
				type: Boolean,
				default: false
			}
		},
		computed: {
			bgImage(){
				return `../../../static/${!this.isComplete ? 'hight' : 'disabled'}-bg.png`;
			}
		},
		methods: {
			// 跳转详情页面（改善任务）
			gotoDetails(id){
        uni.setStorageSync('taskId', id);
				uni.navigateTo({
				  url: `/pages/mission-details/mission-details?taskId=${id}&pathName=missionDetails`
				});
			}
		}
	}
</script>

<style lang="less">
	.mission-list-item {
		margin-bottom: 25rpx;
		overflow: hidden;

		.time {
			height: 47.5rpx;
			line-height: 45rpx;
			padding-left: 25rpx;
		}

		.card {
			position: relative;
			display: flex;
			flex-direction: column;
			height: 240.75rpx;
			background-color: #fff;
			padding: 0 25rpx;

			.top-box {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				flex: 1;
				margin-top: 35rpx;
				margin-bottom: 28.12rpx;
			}

			.title {
				width: 100%;
				font-size: 25rpx;
				font-weight: bold;
				color: #292C33;
				text-overflow: ellipsis;
				white-space: nowrap;
				overflow-x: hidden;
			}
            .subtitle {
				font-size: 12px;
				color: #666F80;
				margin:10rpx 0;
			}
			.row {
				display: flex;
				align-items: center;

				.col {
					display: flex;
					align-items: center;
					height: 20rpx;

					&:first-child {
						margin-right: 50rpx;
					}
					.com-icon {
						margin-right: 9.37rpx;
						width: 20rpx;
						height: 20rpx;
					}
				}
			}
			.bottom-box {
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 70rpx;
				border-top: 0.62rpx solid #DADEE6;
			}

			.bg-box {
				position: absolute;
				top: 0;
				right: 0;
				width: 112.5rpx;
				height: 35rpx;
				background-size: 100% 100%;
				padding-left: 12.5rpx;
				text-align: center;

				>text {
					line-height: 35rpx;
					font-size: 17.5rpx;
					color: #fff;
				}
			}

			.hight-bg {
				background-image: url('~@/static/hight-bg.png');
			}
			.disabled-bg {
				background-image: url('~@/static/disabled-bg.png');
			}
		}

		.com-text {
			font-size: 22.5rpx;
			color: #666F80;
		}
	}
</style>
