<template>
	<view class="container">
		<view class="content" v-if="pageData">
			<view class="content-item">
				<text>任务名称：</text>
				<view>{{pageData.name}}</view>
			</view>
			<view class="content-item">
				<text>任务周期：</text>
				<view>{{pageData.cycleTypeDictValue}}</view>
			</view>
			<view class="content-item">
				<text>执行日期：</text>
				<view>{{pageData.buildDateDay||pageData.buildDateWeekDictValue}}</view>
			</view>
			<view class="content-item">
				<text>执行时间：</text>
				<view>{{pageData.buildTime}}</view>
			</view>
			<view class="content-item">
				<text>开始日期：</text>
				<view>{{pageData.startDate}}</view>
			</view>
			<view class="content-item">
				<text>结束日期：</text>
				<view>{{pageData.endDate}}</view>
			</view>
			<view class="content-item">
				<text>考评指标：</text>
				<view style="color: #007AFF;" >
					{{pageData.assessTargetList.length}} 项 
					<u-icon name="icon-xian-11" custom-prefix="xd-icon" size="28" color="#888888" @click="openZBpage"></u-icon>
				</view>
			</view>
			<view class="content-item">
				<text>考评门店：</text>
				<view style="color: #007AFF;">
					{{pageData.storeList.length}} 个 <u-icon name="icon-xian-11" custom-prefix="xd-icon" size="28" color="#888888" @click="viewStores"></u-icon>
				</view>
			</view>
			<view class="content-item">
				<text>任务有效期天数：</text>
				<view>{{pageData.effectiveDay}}天</view>
			</view>
		</view>
		<view v-else>
			<view class="loadingStyle">
				<u-loading mode="circle"></u-loading>
				<view>正在加载</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getCheckTaskConfig} from '../../../api/checkTaskConfig.js'
	export default{
		data(){
			return{
				pageData:null,		// 接受上个页面传的数据
				id:''
			}
		},
		onLoad(opts) {
			this.id = opts.id
			this.getData()
		},
		methods:{
			// 详情
			getData(){
				getCheckTaskConfig({id:this.id}).then(res=>{
					console.log(res)
					if(res.status==200){
						this.pageData=res.data
					}
				})
			},
			// 考评指标选择
			openZBpage() {
				let item = this.pageData.assessTargetList
				if(item.length>0){
					uni.navigateTo({
						url: '/pages/spotCheckConfigure/spotCheckDetail/evaluateItemDetail?item='+encodeURIComponent(JSON.stringify(item))
					})
				}
			},
			viewStores(){
				let item = this.pageData.storeList
				if(item.length>0){
					uni.navigateTo({
						url: '/pages/userCenter/viewStores?item='+encodeURIComponent(JSON.stringify(item))
					})
				}
			}
		}
	}
</script>

<style lang="less">
	.loadingStyle{
		text-align: center;
		padding: 10vh 0 10vh 0;
	}
	.container{
		font-size: 28rpx;
		.content{
			position: relative;
			background-color: #FFFFFF;
			margin-bottom: 60rpx;
			.content-item{
				display: flex;
				justify-content: space-between;
				padding: 30rpx;
				border-bottom: 1px solid #e5e5e5;
				> view{
					color: #666;
				}
			}
		}
	}
</style>
