<template>
	<div class="eibs-tab">
			<c-col :span="12" class="col-left">
				<c-col :span="24">
				<el-form-item label="发票代码" prop="imgInvmod.insel.bustyp">
					<c-input v-model="model.imgInvmod.insel.invcod" placeholder="请选择发票代码"></c-input>
				</el-form-item>
			</c-col>
			<c-col :span="24">
				<el-form-item label="起始操作日期" prop="imgInvmod.insel.prebnkdat">
					<c-date-picker type="date" v-model="model.imgInvmod.insel.prebnkdat" style="width: 100%" placeholder="请选择起始操作日期" value-format="yyyy-MM-dd"></c-date-picker>
				</el-form-item>
			</c-col>
		</c-col>

		<c-col :span="12" class="col-right">
			
			<c-col :span="24">
				<el-form-item label="发票号码" prop="imgInvmod.insel.invnum" style="width: 100%">
					<c-input v-model="model.imgInvmod.insel.invnum" placeholder="请输入发票号码" ></c-input>
				</el-form-item>
			</c-col>
			<c-col :span="24">
				<el-form-item label="结束操作日期" prop="imgInvmod.insel.prebnkdat2">
					<c-date-picker type="date" v-model="model.imgInvmod.insel.prebnkdat2" style="width: 100%" placeholder="请选择结束操作日期" value-format="yyyy-MM-dd"></c-date-picker>
				</el-form-item>
			</c-col>
			
		</c-col>
		<c-col :span="24" style="text-align: left; margin-left: 50px">
			<c-button @click="serachResult" type="primary"  size="small">查询</c-button>
			<c-button @click="exportExcel" type="primary" size="small">导出Excel</c-button>
			<c-button @click="printResult" type="primary"  size="small">打印查询结果</c-button>
		</c-col>
		<c-col :span="24">
			<el-table id='infgidBSTableRef2' v-loading="load2" @selection-change="changeSelection" ref="gidBt2" :data="tableData2" style="width:100%" size="small" :border="true" height="calc(100vh - 480px)" :highlight-current-row="true">
				<el-table-column  type="selection" align="left" min-width="50">
				</el-table-column>
				<el-table-column label="发票代码" prop="invcod" align="left" min-width="150" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="发票号码" prop="invnum" align="left" min-width="150"  sortable>
				</el-table-column>
				<el-table-column label="发票类型" prop="invtyp" align="left" min-width="150" sortable>
					<template slot-scope="scope">
						{{getLabel(dbCodes.invtyp,scope.row.invtyp)}}
					</template>
				</el-table-column>
				<el-table-column label="未税金额" prop="untamt" align="left" min-width="150"  :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="开票日期" prop="invdat" align="left" min-width="150" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="验证码后六位" prop="checkcode" align="left" min-width="150" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<!-- <el-table-column label="操作日期" prop="prebnkdat" align="left" min-width="150"  :show-overflow-tooltip="true" sortable>
				</el-table-column> -->
				<el-table-column label="是否重复性融资" prop="isfnc" align="left" min-width="180" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="批注方编号" prop="annotacode" align="left" min-width="150" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="批注方名称" prop="annotaname" align="left" min-width="150"  :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<!-- <el-table-column label="批注方日期" prop="antdat" align="left" min-width="150" :show-overflow-tooltip="true" sortable>
				</el-table-column> -->
				<el-table-column label="批注描述" prop="annotadesc" align="left" min-width="150" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<!-- <el-table-column label="业务类型" prop="bustyp" align="left" min-width="150" :show-overflow-tooltip="true" sortable>
					<template slot-scope="scope">
						{{getLabel(dbCodes.bustyp,scope.row.bustyp)}}
					</template>
				</el-table-column> -->
				<!-- <el-table-column label="系统外其他业务描述" prop="busdcr" align="left" min-width="200" :show-overflow-tooltip="true" sortable>
				</el-table-column> -->
			</el-table>
			<el-pagination
                @size-change="sizeChange2"
                @current-change="currentChange2"
                :current-page.sync="pagination2.pageNum2"
                :page-sizes="[10, 20, 50, 100, 500]"
                :page-size="pagination2.pageSize2"
                layout="sizes, prev, pager, next"
                :total="pagination2.total2">
            </el-pagination>
		</c-col>
		<el-dialog
			v-dialogDrag
			title="发票打印预览"
			custom-class="temp-rol"
			:visible.sync="tempRolVisible"
			:before-close="handleCloseDialogTable"
			v-if="tempRolVisible"
		>
		<div id="printResult">
			<table border="1">
			<tr>
				<td>发票代码</td>
				<td>发票号码</td>
				<td>发票类型</td>
				<td>未税金额</td>
				<td>开票日期</td>
				<td>验证码后六位</td>
				<td>操作日期</td>
				<td>是否重复性融资</td>
				<td>批注方编号</td>
				<td>批注方名称</td>
				<td>批注方日期</td>
				<td>批注描述</td>
				<td>业务类型</td>
				<td>系统外其他业务描述</td>
			</tr>
			<tr v-for="(item,index) in printResultData" :key="index" v-if="printResultData.length > 0">
				<td>{{item.invcod}}</td>
				<td>{{item.invnum}}</td>
				<td>{{getLabel(dbCodes.invtyp,item.invtyp)}}</td>
				<td>{{item.invamt}}</td>
				<td>{{item.opndat}}</td>
				<td>{{item.vrfcod}}</td>
				<td>{{item.prebnkdat}}</td>
				<td>{{item.isfnc}}</td>
				<td>{{item.antnum}}</td>
				<td>{{item.antnam}}</td>
				<td>{{item.antdat}}</td>
				<td>{{item.antdtl}}</td>
				<td>{{getLabel(dbCodes.bustyp,item.bustyp)}}</td>
				<td>{{item.busdcr}}</td>
			</tr>
			<tr v-if="printResultData.length == 0">
				<td colspan="14" style="text-align:center">暂无数据</td>
			</tr>
		</table>
		</div>
		
		<!-- <el-table id="printResult" v-loading="printResultLoad" ref="printResultRef" :data="printResultData" style="width:100%" size="small" height="calc(100vh - 480px)" :highlight-current-row="true">
				<el-table-column label="发票代码" prop="invcod" align="left" min-width="100" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="发票号码" prop="invnum" align="left" min-width="100" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="发票类型" prop="invtyp" align="left" min-width="100" sortable>
					<template slot-scope="scope">
						{{getLabel(dbCodes.invtyp,scope.row.invtyp)}}
					</template>
				</el-table-column>
				<el-table-column label="未税金额" prop="invamt" align="left" min-width="100"  :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="开票日期" prop="opndat" align="left" min-width="100" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="验证码后六位" prop="vrfcod" align="left" min-width="130" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="操作日期" prop="prebnkdat" align="left" min-width="100"  :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="重复性融资" prop="isfnc" align="left" min-width="115" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="批注方编号" prop="antnum" align="left" min-width="115" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="批注方名称" prop="antnam" align="left" min-width="115"  :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="批注方日期" prop="antdat" align="left" min-width="115" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="批注描述" prop="antdtl" align="left" min-width="100" :show-overflow-tooltip="true" sortable>
				</el-table-column>
				<el-table-column label="业务类型" prop="bustyp" align="left" min-width="100" :show-overflow-tooltip="true" sortable>
					<template slot-scope="scope">
						{{getLabel(dbCodes.bustyp,scope.row.bustyp)}}
					</template>
				</el-table-column>
				<el-table-column label="系统外其他业务描述" prop="busdcr" align="left" min-width="170" :show-overflow-tooltip="true" sortable>
				</el-table-column>
			</el-table>	 -->
			<c-button type="primary" @click="print()" size="small" style="margin-top:20px">打印</c-button>
		</el-dialog>
		
	</div>
</template>

<script>
import event from "../event";
import { setTimeout } from 'timers';

export default {
	props: ["model"],
  mixins: [event],
  data() {
    return {
      tableData2: [],
      pagination2: {
        pageNum2: 1,
        pageSize2: 10,
        total2: 0
			},
			dbCodes:{
				invtyp: [],
				bustyp: [],
			},
			load2: false,
			tempRolVisible:false,
			printResultLoad:false,
			printResultData:[],
			selection:[],
			dialogTable:[
				"发票代码","发票号码","发票类型","未税金额","开票日期","验证码后六位","操作日期","是否重复性融资","批注方编号","批注方名称",
				"批注方日期","批注描述","业务类型","系统外其他业务描述"
			],
    };
  },
  mounted() {
		this.getdbCode('typinv','invtyp')
		this.getdbCode('typbus','bustyp')
  },
  methods: {
    changeSelection(val){
			this.selection = val
		},
		print(){
			const pritHTML = document.getElementById('printResult').innerHTML
			const newWindow = window.open('','')
			newWindow.document.write(pritHTML)
			newWindow.window.print()
			newWindow.window.close()
			
		}
  }
};
</script>

<style scoped>
.table-button-item-list {
  padding: 0;
  margin: 0;
}
.table-button-item-list li {
  list-style: none;
  padding: 5px 0;
  text-align: center;
  color: #606266;
  cursor: pointer;
}
.close-btn {
	width: 20px;
	height: 20px;
	position: absolute;
	top: 20px;
	right: 20px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}
.close-btn:hover {
	background: rgba(0, 0, 0, .1)
}
</style>