<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" fixed="right">
					<template slot-scope="scope">
						<div v-if="scope.row.status=='CONTRACT_COMPLETE'">合同已完成</div>
						<div v-if="scope.row.status=='PRE_BIDDER_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_PLATFORM_TO_TENDER_CONTRACT'">等待与采购商签署合同</div>
						<div v-if="scope.row.status=='WAIT_CONTRACT_UPLOAD'">等待合同上传</div>
					</template>
				</el-table-column>
				<el-table-column slot="operate" label="操作" align="center" fixed="right" width="200">
					<template slot-scope="scope">
						<div v-if="scope.row.state==0||scope.row.state==1">
							<el-button type="text" size="small" @click="contractSign(scope.row)">合同签署</el-button>
						</div>
						<div v-if="scope.row.state==2">
							<el-button type="text" size="small" @click="contractSee(scope.row)">合同查看</el-button>
						</div>
						<div v-if="scope.row.state==3">
							<el-button type="text" size="small" @click="contractSign(scope.row)">合同签署</el-button>
							<el-button type="text" size="small" @click="voucherSign(scope.row)">确认凭证</el-button>
						</div>
						<div v-if="scope.row.state==4">
							<el-button type="text" size="small" @click="contractSign(scope.row)">合同查看</el-button>
							<el-button type="text" size="small" @click="voucherSee(scope.row)">查看凭证</el-button>
						</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.tenderCompanyId = localStorage.getItem("companyId")
		},
		methods: {
			contractSign() {
				this.$router.push('/purchaser/buyOut/contractSign')
			},
			contractSee() {
				this.$router.push('/purchaser/buyOut/contractSee')
			},
			voucherSee() {
				this.$router.push('/purchaser/buyOut/voucherSee')
			},
			voucherSign() {
				this.$router.push('/purchaser/buyOut/voucherSign')
			},
			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>
