<template>
	<div id="pdf1">
		<el-descriptions class="margin-top" :title="readForm.taskInfo.task_class+'任务'" :column="2" :size="size" border>
			<el-descriptions-item>
				<template slot="label">
					发布单位
				</template>
				{{readForm.releaserInfo.rymc}}
			</el-descriptions-item>
			<el-descriptions-item>
				<template slot="label">
					年度
				</template>
				{{readForm.taskInfo.year}}
			</el-descriptions-item>
			<el-descriptions-item>
				<template slot="label">
					开始时间和结束时间
				</template>
				{{readForm.taskInfo.starttime}}-{{readForm.taskInfo.endtime}}
			</el-descriptions-item>
			<el-descriptions-item>
				<template slot="label">
					抽样信息上报截止时间
				</template>
				{{readForm.taskInfo.endtime_cydsb}}
			</el-descriptions-item>
			<el-descriptions-item>
				<template slot="label">
					监测类型
				</template>
				{{readForm.taskInfo.task_class}}
			</el-descriptions-item>
			<el-descriptions-item>
				<template slot="label">
					行业
				</template>
				<!-- <div v-if="readForm.product!=[]"> -->
				<span>{{readForm.model_type}}</span>
				<!-- </div> -->
				<!-- <div v-else>暂无</div> -->
			</el-descriptions-item>
			<el-descriptions-item>
				<template slot="label">
					抽检分离
				</template>
				<span v-if="readForm.taskInfo.is_divide==1">是</span>
				<span v-if="readForm.taskInfo.is_divide==0">否</span>
			</el-descriptions-item>
			<el-descriptions-item>
				<template slot="label">
					附件
				</template>
				<div v-if="readForm.taskInfo.file_url==null">无</div>
				<el-link v-else type="primary" :href="readForm.taskInfo.file_url">下载附件</el-link>
			</el-descriptions-item>

		</el-descriptions>
		<el-descriptions class="margin-top" :size="size" border>
			<el-descriptions-item>
				<template slot="label">
					备注
				</template>
				{{readForm.taskInfo.log}}
			</el-descriptions-item>
		</el-descriptions>
		<el-descriptions class="margin-top" :size="size" border>
			<el-descriptions-item>
				<template slot="label">
					检测对象
				</template>
				{{productNameText}}
				<!-- <span v-for="item in readForm.product">{{item.product_name}}、</span> -->
			</el-descriptions-item>
		</el-descriptions>
		<el-descriptions class="margin-top" :size="size" border>
			<el-descriptions-item>
				<template slot="label">
					检测项
				</template>
				{{pesticidesNameText}}
				<!-- <span v-for="item in readForm.pesticides">{{item.test_name}}、</span> -->
			</el-descriptions-item>
		</el-descriptions>
		<el-table :data="underTask" border stripe highlight-current-row style="width: 100%">
			<el-table-column :key="table.label" v-for="table in tableHeader" :label="table.label" :prop="table.prop"
				align="center" :width="table.width" :fixed="table.fixed" />
		</el-table>

	</div>
</template>

<script>
	export default {
		name: 'taskdetail',
		props: ['task_id'],
		data() {
			return {
				activeName: 'first',
				id: 0,
				task_id: this.task_id,
				readForm: {
					// releaser: '',
					// task_name: '',
					// level: '',
					// task_class: '',
					// year: '',
					modelInfo:{
						creattime:'',
						id:'',
						name:'',
						type_id:'',
						updatetime:'',
						user_id:'',
					},
					releaserInfo:{
						groupname: '',
						rymc:'',
					},
					taskInfo:{
						base_file_url: null,
						batch: '',
						creater: null,
						createtime: null,
						endtime: null,
						endtime_cydsb: null,
						file_name: null,
						file_url: null,
						filenum: null,
						id: null,
						industry: null,
						is_divide: null,
						ispublic:null,
						level:null,
						log: null,
						main_unit: null,
						releaser:null,
						starttime: null,
						status: null,
						task_class: null,
						task_name:null,
						test_model_id:null,
						year: null,
					},						
					endtime: '',
					file_url: '',
					filenum: '',
					log: ''
				},
				size: '',
				// 机构地域表格数据
				underTask: [],
				underTasktotal: 0,
				productNameText: '',
				pesticidesNameText: '',
				tableHeader: [{
						label: '抽样机构',
						prop: 'bear_name',
						width: 180,
					}, {
						label: '检测机构',
						prop: 'check_name'
					},
					{
						label: '抽样地区',
						prop: 'address'
					}, {
						label: '抽样数量',
						prop: 'sample_number'
					},
					{
						label: '报告上传单位',
						prop: 'report_name'
					}, {
						label: '报告上传截止时间',
						prop: 'uploadtime'
					}
				],
			};
		},
		created() {
			this.getTaskDetail();
			// this.getUnderTask();
		},
		methods: {
			handleClick(tab, event) {
				console.log(tab, event);
			},
			// 获取任务详情
			async getTaskDetail() {
				var that = this
				const {
					data: res
				} = await this.$http.post("getTaskDetail", {
					task_id: that.task_id
				});
				console.log(res.data.product)
				// if (res.data.modelInfo.product.length > 0) {
					if (res.data.modelInfo.type_id == '1') {
						res.data.model_type = '种植业'
					} else if (res.data.modelInfo.type_id == '2') {
						res.data.model_type = '畜牧业'
					} else if (res.data.modelInfo.type_id == '3') {
						res.data.model_type = '渔业'
					} else if (res.data.modelInfo.type_id == '4') {
						res.data.model_type = '其他'
					}else {
						res.data.model_type = '无'
					}
				// }
				this.readForm = res.data
				this.underTask = res.data.unitTaskList.rows
				this.underTasktotal = res.data.unitTaskList.total
				console.log(this.readForm.product)
				
				this.readForm.taskInfo.is_divide = res.data.taskInfo.is_divide
					
				this.readForm.taskInfo.endtime_cydsb = res.data.taskInfo.endtime_cydsb
			
				that.productNameText = that.readForm.product.map(el => el.product_name).join('、 ')
				console.log(that.productNameText)
				that.pesticidesNameText = that.readForm.pesticides.map(el => el.test_name).join('、 ')
			
				console.log(this.divideOptions.id)
			},
			// 获取机构地域表格
			// async getUnderTask() {

			// 	const result = await this.$http.post('getUnderTask', {
			// 		task_id: this.task_id
			// 	})
			// 	// 判断业务逻辑
			// 	if (result.data.code == 0) {
			// 		this.underTask = result.data.data.rows
			// 		this.underTasktotal = result.data.data.total
			// 	}
			// },
		}
	}
</script>

<style>

</style>
