<template>
	<div>
		<div class="content">
			<dataBreadcrumb :breads="breads"></dataBreadcrumb>
			<changeNav :navs="navs"></changeNav>
			<dataTable :columns="columns" :checklist="checklist" :sendData="sendData" url="/tender-payment/list">
				<el-table-column slot="operate" label="状态" align="center">
					<template slot-scope="scope">
						<div v-if="scope.row.status=='PRE_PLATFORM_TO_TENDER_CONTRACT'">待平台发起采购商合同签署</div>
						<div v-if="scope.row.status=='PRE_TENDERER_CONTRACT'">待采购商签署合同</div>
						<div v-if="scope.row.status=='PRE_PLATFORM_TO_BIDDER_CONTRACT'">待平台发起供应商合同签署</div>
						<div v-if="scope.row.status=='PRE_BIDDER_CONTRACT'">待供应商签署合同</div>
						<div v-if="scope.row.status=='PRE_BIDDER_VOUCHER'">待供应商上传凭证</div>
						<div v-if="scope.row.status=='PRE_TENDERER_AFFIRM'">待采购商确认</div>
						<div v-if="scope.row.status=='TENDERER_AFFIRM'">采购商已确认</div>
					</template>
				</el-table-column>            
				<el-table-column slot="operate" label="操作" align="center" width="200">
					<template slot-scope="scope">
						<div class="flex">
							<div>
								<el-button type="text" size="small" @click="contractSign(scope.row)" v-if="scope.row.constractOperation==1">合同签署</el-button>
								<el-button type="text" size="small" @click="contractSign(scope.row)" v-else-if="scope.row.constractOperation==2">合同查看</el-button>
								<el-button type="text" size="small" v-else disabled>合同查看</el-button>
							</div>
							<div>
								<el-button type="text" size="small" @click="upload(scope.row.projectId)" v-if="scope.row.voucherOperation==1">上传凭证</el-button>
								<el-button type="text" size="small" @click="voucherSee(scope.row.projectId)" v-else-if="scope.row.voucherOperation==2">查看凭证</el-button>
								<el-button type="text" size="small" v-else disabled>查看凭证</el-button>
							</div>
						</div>
					</template>
				</el-table-column>
			</dataTable>
		</div>
	</div>
</template>

<script>
	import {
		dropList
	} from '@api/purchaser/buyOut'
	import dataTable from '@components/queryTable.vue'
	import dataBreadcrumb from '@components/dataBreadcrumb.vue'
	import changeNav from '@components/changeNav.vue'
	export default {
		components: {
			dataTable,
			dataBreadcrumb,
			changeNav
		},
		data() {
			return {
				sendData: {},
				checklist: [{
					title: '供应商',
					type: 'input',
					model: 'bidCompanyName'
				}, {
					title: '状态',
					type: 'select',
					selectlist: [],
					change: row => '',
					model: 'status'
				}],
				breads: ['应收账款买断管理', '应收账款买断列表'],
				navs: ['应收账款买断列表'],
				columns: [{
						label: '供应商（中标）',
						prop: 'bidCompanyName'
					},
					{
						label: '项目名称',
						prop: 'projectName'
					},
					{
						slot: 'operate'
					}
				], // 操作列
			}
		},
		created() {
			this.getDropList();
			this.sendData.bidCompanyId = localStorage.getItem("companyId")
		},
		methods: {
			contractSign(row) {
				this.$router.push({
					name:"/supply/buyOut/contractSign",
					params:{
						id:row.projectId,
						url:row.bidderIframeUrl
					}
				})
			},
			contractSee(row) {
					this.$router.push({
					name:"/supply/buyOut/contractSee",
					params:{
						id:row.projectId,
						url:row.contractUrl
					}
				})
			},
			voucherSee(id) {
				this.$router.push(`/supply/buyOut/voucherSee?id=${id}`)
			},
			upload(id) {
				this.$router.push(`/supply/buyOut/upload?id=${id}`)
			},
			async getDropList() {
				const {
					data,
					code
				} = await dropList()
				if (code === 200) {
					let array = [];
					for (let item in data) {
						let message = {}
						message.label = item
						message.id = data[item]
						array.push(message)
					}
					console.log(array)
					this.checklist[1].selectlist = array
				}
			}
		},
	}
</script>

<style scoped>

</style>
