<template>
	<div>
		<div class="content-head">
			<dataBreadcrumb :breads="breads"></dataBreadcrumb>
			<h3>签署合同</h3>
			<h5>签署合同</h5>
		</div>
		<div class="content">
			<div class="flex">
				<div>下载合同：</div>
				<ul>
					<li class="flex-item">
						<div>{{detail.fileName}}</div>
						<el-button size="mini" @click="down(detail.fileUrl)">下载</el-button>
					</li>
				</ul>
			</div>
			<div class="contractContent flex-center">
				<iframe :src="detail.fileUrl" frameborder="0" style="width: 100%; height: 500px"></iframe>
			</div>
			<div class="button flex-center">
				<el-button @click="revoke">撤销签章</el-button>
				<el-button>电子签章</el-button>
			</div>
		</div>
		<div class="bottomButton">
			<el-button @click="back">取消</el-button>
			<el-button type="primary" @click="submitData">提交</el-button>
		</div>
	</div>
</template>

<script>
	
    import { signContract,contract} from '@api/purchaser/buyOut'
	import dataBreadcrumb from '@components/dataBreadcrumb.vue'
	import PDF from '@components/PDF/PDF.vue'
	export default {
		components: {
			dataBreadcrumb,
			PDF
		},
		data() {
			return {
				breads: ['应收账款买断管理', '应收账款买断列表'],
				detail:""
			}
		},
		created() {
			this.getcontract()
		},
		methods: {
			back() {
				this.$router.go(-1)
			}, // 删除操作
			revoke(row, index) {
				// 二次确认删除
				this.$confirm('该操作撤销全部电子签章，你还要继续吗？', '是否撤销电子签章', {
						type: 'warning'
					})
					.then(() => {
						this.$message.success('撤销成功')
					})
					.catch(() => {})
			},
			down(url){
				window.open(url)
			},
			// 查看详情
			async getcontract(){
				let projectId=localStorage.getItem("projectId")
				  const {
				          data,
				          code
				        } = await contract(projectId)
						if(code==200){
							this.detail=data
						}
			},
			// 提出
			async submitData() {
				try {
					let projectId = localStorage.getItem("projectId")
					const {
						msg,
						code
					} = await signContract(projectId)
					if (code == 200) {
						this.$message({
							message: msg,
							type: 'success',
							duration: 1500
						})
						setTimeout(() => {
							this.$router.go(-1)
						}, 1500)

					}
				} catch (e) {
					console.log(e)
				}
			},
		}

	}
</script>

<style scoped>
	.contractContent {
		width: 100%;
		height: 500px;
		border: 1px solid #000000;
		margin-top: 30px;
	}

	.button {
		margin-top: 30px;
		height: 50px;
		width: 100%;
	}

	ul>li>div {
		margin-right: 10px;
	}
</style>
