<template>
	<div class="info">
		<div class="content">
			<div>
				<dataBreadcrumb :breads="breads"></dataBreadcrumb>
				<noticeDetail>
					<slot>
						<div @click="jump" class="jump">项目报价</div>
					</slot>
				</noticeDetail>
			</div>
			<div class="centerButton" v-if='bidType==0'>
				<el-button @click="back">返回</el-button>
				<el-button type="primary" @click="signup">报名</el-button>
			</div>
			<div class="centerButton" v-if='bidType==1'>
				<div v-if="status==1">
					<el-button @click="back">返回</el-button>
					<el-button type="primary" @click="signup">接受邀请</el-button>
					<el-button type="primary" @click="reject">拒绝邀请</el-button>
				</div>
				<div v-else>
					<el-button @click="back">返回</el-button>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import {
		inviteStatus,
		refuseInvite
	} from '@api/supply/bid'
	import dataBreadcrumb from '@components/dataBreadcrumb.vue'
	import noticeDetail from '@components/detail/noticeDetail.vue'
	export default {
		components: {
			dataBreadcrumb,
			noticeDetail
		},
		data() {
			return {
				breads: ['投标管理', '在线报名', '招标公告'],
				id: "",
				status: "",
				bidType: ""
			}
		},
		methods: {
			jump() {
				this.$router.push("/supply/bid/signupOnline/seePrice")
			},
			signup(row) {
				this.$router.push("/supply/bid/signupOnline/SignUp")
			},
			back() {
				this.$router.go(-1)
			},
			async getinviteStatus() {
				let projectId = localStorage.getItem("projectId")
				const {
					data,
					code
				} = await inviteStatus(projectId)
				this.status = data.status
				this.bidType = data.bidType
			},
			async reject() {
				let projectId = localStorage.getItem("projectId")
				try {
					const {
						msg,
						code
					} = await refuseInvite(projectId)
					if (code == 200) {
						this.$message({
							message: msg,
							type: 'success',
							duration: 1500
						})
						setTimeout(() => {
							this.$router.push("/supply/bid/joinProject/projectList")
						}, 1500)
					}
				} catch (e) {
					console.log(e)
				}
			}
		},
		created() {
			this.getinviteStatus()
		}
	}
</script>

<style scoped>
	.jump {
		cursor: pointer;
		margin-top: 30px;
		color: #005CBF
	}

	.info {
		box-sizing: border-box;
		padding: 30px;
		background: rgb(240, 242, 245);
		width: 100%;
	}

	.info>.info_prev {
		box-sizing: border-box;
		padding-left: 30px;
		padding-top: 30px;
		background: #fff;
	}

	.info_mes {
		margin-bottom: 40px;
		display: flex;
		justify-content: center;
	}

	.info_mes p {
		display: inline-block;
	}

	.info_mes .left_mes {
		margin-right: 200px;
		font-size: 16px;
	}

	.right_mes {
		font-size: 16px;
	}

	h1 {
		display: flex;
		justify-content: center;
	}

	.content_list {
		margin-left: 100px;
		margin-right: 100px;
		margin-top: 50px;
	}

	.content_list h3 {
		margin-top: 30px;
		font-weight: bold;
		padding-bottom: 10px;
	}

	.content_list p {
		margin-top: 10px;
		margin-bottom: 10px;
	}

	.message>p {
		font-weight: bold;
	}
</style>
