<template>
	<el-drawer
		title="查看"
		v-model="visible"
		:size="1000"
		destroy-on-close
		@closed="$emit('closed')"
	>
		<el-container v-loading="loading">
			<el-main>
				<el-card shadow="hover">
				<el-descriptions :column="3" title="基本信息">
					<el-descriptions-item label="入厂项目:">{{form.name }}</el-descriptions-item>
					<el-descriptions-item label="项目类型:">{{types_[form.type]}}</el-descriptions-item>
					<el-descriptions-item label="合同编号:">{{form.contract_number}}</el-descriptions-item>
					<el-descriptions-item label="状态:">{{state_[form.state]}}</el-descriptions-item>
					<el-descriptions-item label="进厂时间:">{{form.come_time}}</el-descriptions-item>
					<el-descriptions-item label="离厂时间:">{{form.leave_time}}</el-descriptions-item>
					<el-descriptions-item label="所属部门:">{{form.belong_dept_name}}</el-descriptions-item>
					<el-descriptions-item label="相关方:">{{form.rparty_name}}</el-descriptions-item>
				</el-descriptions>
				</el-card>
				<el-card style="margin-top:8px" shadow="hover">
					<scTable
						ref="fileTable"
						:data="rpjFileList"
						row-key="id"
						hidePagination
						stripe
						hideDo
						style="height:200px"
					>
						<el-table-column
							label="#"
							fixed="left"
							type="index"
							width="50"
						></el-table-column>
						<el-table-column label="资质内容" prop="name">
							<template #default="scope">
								{{ scope.row.file_cate_.name }}
							</template>
						</el-table-column>
						<el-table-column label="文件资料" prop="name">
							<template #default="scope">
								<div v-for="item in scope.row.files_" :key="item.id">
           <el-link style="font-size:12px" type="primary" :href="item.path" target="_blank">{{item.name}}</el-link>
           </div>
							</template>
						</el-table-column>
					</scTable>
				</el-card>
				<el-card style="margin-top:8px" shadow="hover">
					<scTable
						ref="table"
						:data="memeberList"
						row-key="id"
						height='auto'
						stripe
						hideDo
						hidePagination
						style="height:200px"
					>
						<el-table-column label="#" fixed="left" type="index" width="50"></el-table-column>
						<el-table-column label="姓名" prop="remployee_.name">
							<template #default="scope">
								{{ scope.row.remployee_.name }}
							</template>
						</el-table-column>
						<el-table-column label="工作职责" prop="duty"></el-table-column>
						<el-table-column label="证书" prop="rcertificates">
							<template #default="scope">
								<el-tag
									v-for="item in scope.row.rcertificates_"
									:key="item.number"
									:label="item.name"
									:value="item.number"
								>{{ item.name }}
								</el-tag>
							</template>
						</el-table-column>
						<el-table-column label="是否负责人" prop="is_manager">
							<template #default="scope">
								<el-space v-if="scope.row.is_manager === true">是</el-space>
								<el-space v-else>否</el-space>
							</template>
						</el-table-column>
					</scTable>
				</el-card>
			</el-main>
		</el-container>
	</el-drawer>
</template>

<script>
	import {genTree} from "@/utils/verificate";

	export default {
		emits: ["success", "closed"],
		props: {
			rpjId: {
				type: String,
				default: ""
			}
		},
		data() {
			return {
				loading: false,
				visible: false,
				isSaveing: false,
				state_: {
					10: "创建中",
					20: "审批中",
					30: "待入厂",
					40: "进行中",
					50: "已完成",
				},
				types_: {
					10: "建筑施工",
					20: "设备设施检维修",
					30: "保安保洁服务",
					40: "其他",
				},
				form:{},
				rpjFileList: [],
				memeberList: [],
			};
		},
		mounted() {
		/*	this.getRpjfileList();
			this.getMemberList();*/
		},
		methods: {
			//显示
			open() {
				this.visible = true;
				return this;
			},
			//表单注入数据
			setData(data) {
				this.loading = true
				this.$API.rpm.rpj.item.req(data.id).then((res) => {
					this.loading = false
					this.form = res;
					this.getRpjfileList();
					this.getMemberList();
					this.visible = true;
				}).catch(e=>{this.loading=false});
			},
			//文件列表加载
			getRpjfileList() {
				this.$API.rpm.rpjfile.list.req({page: 0, rpj: this.form.id}).then((res) => {
					this.rpjFileList = res;
				});
			},
			//作业人员列表
			getMemberList() {
				this.$API.rpm.member.list.req({rpj: this.form.id, page: 0}).then((res) => {
					this.memeberList = res;
					console.log(res);
				});
			},
		},
	};
</script>

<style scoped>
	.el-transfer {
		--el-transfer-panel-width: 345px !important;
	}
</style>
