<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>发票一览</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
            //搜索框收放
            $('#moresee').click(function(){
                if($('#moresees').is(':visible'))
                {
                    $('#moresees').slideUp(0,resizeListWindow1);
                    $('#moresee i').removeClass("glyphicon glyphicon-menu-up").addClass("glyphicon glyphicon-menu-down");
                }else{
                    $('#moresees').slideDown(0,resizeListWindow1);
                    $('#moresee i').removeClass("glyphicon glyphicon-menu-down").addClass("glyphicon glyphicon-menu-up");
                }
            });
            laydate.render({
                elem: '#beginContractDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });


            laydate.render({
                elem: '#endContractDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });
		});
	</script>
	<style>
		body{
			background-color:transparent;
			filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#26FFFFFF, endColorstr=#26FFFFFF);
			color:#ffffff;
			background-color:rgba(255,255,255,0);
			height:100%;
		}
	</style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
	<sys:message content="${message}"/>
	<div class="layui-row">
		<div class="full-width fl">
			<div class="contentShadow layui-row" id="queryDiv">
				<form:form id="searchForm" modelAttribute="workInvoiceDetail" action="${ctx}/workinvoicedetail/workInvoiceDetail/" method="post" class="form-inline">
					<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
					<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
					<div class="commonQuery lw8">
						<div class="layui-item query athird">
							<label class="layui-form-label">实际开票单位：</label>
							<div class="layui-input-block">
								<form:input id="cName" path="workInvoice.client.name" htmlEscape="false" class="form-control  layui-input"/>
							</div>
						</div>
						<div class="layui-item query athird">
							<label class="layui-form-label">开票人：</label>
							<div class="layui-input-block">
								<form:input id="invoiceDrawerName" path="invoiceDrawerName" htmlEscape="false" class="form-control  layui-input"/>
							</div>
						</div>

						<div class="layui-item athird">
							<div class="input-group">
								<a href="#" id="moresee"><i class="glyphicon glyphicon-menu-down"></i></a>
								<button id="searchReset" class="fixed-btn searchReset fr" onclick="resetSearch()">重置</button>
								<button id="searchQuery" class="fixed-btn searchQuery fr" onclick="search()">查询</button>
							</div>
						</div>
						<div style="    clear:both;"></div>
					</div>
					<div id="moresees" class="lw8" style="clear:both;display:none;">

						<div class="layui-item query athird">
							<label class="layui-form-label">发票类型：</label>
							<div class="layui-input-block with-icon">
								<form:select path="invoiceInvoiceType"  class="form-control simple-select">
									<form:option value="" label=""/>
									<form:options items="${fns:getDictList('invoice_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
								</form:select>
							</div>
						</div>

						<div class="layui-item query athird">
							<label class="layui-form-label">所属部门：</label>
							<div class="layui-input-block">
								<form:input id="invoiceOfficeName" path="invoiceOfficeName" htmlEscape="false" class="form-control  layui-input"/>
							</div>
						</div>
						<div class="layui-item query athird">
							<label class="layui-form-label">合同名称：</label>
							<div class="layui-input-block">
								<form:input id="contractName" path="contractName" htmlEscape="false" class="form-control  layui-input"/>
							</div>
						</div>
						<div class="layui-item query athird">
							<label class="layui-form-label">开票日期：</label>
							<div class="layui-input-block">
								<input id="beginContractDate" name="beginContractDate" type="text" readonly="readonly" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
									   value="<fmt:formatDate value="${workInvoiceDetail.beginContractDate}" pattern="yyyy-MM-dd"/>"/>
								</input>
								<span class="group-sep">-</span>
								<input id="endContractDate" name="endContractDate" type="text" readonly="readonly" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
									   value="<fmt:formatDate value="${workInvoiceDetail.endContractDate}" pattern="yyyy-MM-dd"/>"/>
								</input>
							</div>
						</div>
					</div>
				</form:form>
			</div>
		</div>
		<div class="full-width fl">
			<div class="contentShadow layui-form contentDetails">
				<div class="nav-btns">
					<shiro:hasPermission name="workinvoicedetail:workInvoiceDetail:export">
						<table:exportExcel url="${ctx}/workinvoicedetail/workInvoiceDetail/export"></table:exportExcel><!-- 导出按钮 -->
					</shiro:hasPermission>
					<button class="nav-btn nav-btn-refresh" data-toggle="tooltip" data-placement="left" onclick="sortOrRefresh()" title="刷新"><i class="glyphicon glyphicon-repeat"></i>&nbsp;刷新</button>
					<div style="clear: both;"></div>
				</div>
				<table class="oa-table layui-table" id="contentTable"></table>

				<!-- 分页代码 -->
				<table:page page="${page}"></table:page>
				<div style="clear: both;"></div>
			</div>
		</div>
	</div>
	<div id="changewidth"></div>
</div>
<script src="${ctxStatic}/layer-v2.3/layui/layui.all.js" charset="utf-8"></script>
<script>
    layui.use('table', function(){
        layui.table.render({
            limit:${ page.pageSize }
            ,elem: '#contentTable'
            ,page: false
            ,cols: [[
                // {checkbox: true, fixed: true},
                {field:'index',align:'center', title: '序号',width:40}
                ,{field:'code',align:'center', title: '发票代码',minWidth:160,templet:function(d){
                    return "<span title='"+ d.code +"'>" + d.code + "</span>";
                }}
                ,{field:'number',align:'center', title: '发票号',minWidth:160,templet:function(d){
                    return "<span title='"+ d.number +"'>" + d.number + "</span>";
                }}
                ,{field:'totalMoney',align:'center', title: '价税合计',minWidth:160,templet:function(d){
                    return "<span title='"+ d.totalMoney +"'>" + d.totalMoney + "</span>";
                }}
                ,{field:'tax',align:'center', title: '税率',minWidth:160,templet:function(d){
                    return "<span title='"+ d.tax +"'>" + d.tax + "</span>";
                }}
                ,{field:'taxMoney',align:'center', title: '金额',minWidth:160,templet:function(d){
                    return "<span title='"+ d.taxMoney +"'>" + d.taxMoney + "</span>";
                }}
                ,{field:'taxRate',align:'center', title: '税额',minWidth:160,templet:function(d){
                    return "<span title='"+ d.taxRate +"'>" + d.taxRate + "</span>";
                }}
                ,{field:'incomeMoney',align:'center', title: '累计登记金额',minWidth:160,templet:function(d){
                    return "<span title='"+ d.incomeMoney +"'>" + d.incomeMoney + "</span>";
                }}
                ,{field:'date',align:'center', title: '开票日期',minWidth:160,templet:function(d){
                    return "<span title='"+ d.date +"'>" + d.date + "</span>";
                }}
                ,{field:'ext',align:'center', title: '上级/本公司开票',minWidth:160,templet:function(d){
                    return "<span title='"+ d.ext +"'>" + d.ext + "</span>";
                }}
                ,{field:'invoiceType',align:'center', title: '发票类型',minWidth:160,templet:function(d){
                    return "<span title='"+ d.invoiceType +"'>" + d.invoiceType + "</span>";
                }}
                ,{field:'client',align:'center', title: '实际开票单位',minWidth:160,templet:function(d){
                    return "<span title='"+ d.client +"'>" + d.client + "</span>";
                }}
                ,{field:'orUnicode',align:'center', title: '纳税人识别号',minWidth:160,templet:function(d){
                    return "<span title='"+ d.orUnicode +"'>" + d.orUnicode + "</span>";
                }}
                ,{field:'content',align:'center', title: '开票内容要求',minWidth:160,templet:function(d){
                    return "<span title='"+ d.content +"'>" + d.content + "</span>";
                }}
                ,{field:'remarks',align:'center', title: '备注',minWidth:160,templet:function(d){
                    return "<span title='"+ d.remarks +"'>" + d.remarks + "</span>";
                }}
                ,{field:'state',align:'center', title: '发票状态',minWidth:160,templet:function(d){
                    return "<span title='"+ d.state +"'>" + d.state + "</span>";
                }}
                ,{field:'backSign',align:'center', title: '被退标记',minWidth:160,templet:function(d){
                    return "<span title='"+ d.backSign +"'>" + d.backSign + "</span>";
                }}
                ,{field:'backNumber',align:'center', title: '被退票号及代码',minWidth:160,templet:function(d){
                    return "<span title='"+ d.backNumber +"'>" + d.backNumber + "</span>";
                }}
                ,{field:'invoiceNumber',align:'center', title: '申请编号',minWidth:210,templet:function(d){
                    return "<span title='"+ d.invoiceNumber +"'>" + d.invoiceNumber + "</span>";
                }}
                ,{field:'drawerName',align:'center', title: '开票人',minWidth:160,templet:function(d){
                    return "<span title='"+ d.drawerName +"'>" + d.drawerName + "</span>";
                }}
                ,{field:'office',align:'center', title: '所属部门',minWidth:160,templet:function(d){
                    return "<span title='"+ d.office +"'>" + d.office + "</span>";
                }}
                ,{field:'contractNum',align:'center', title: '合同编号',minWidth:210,templet:function(d){
                    return "<span title='"+ d.contractNum +"'>" + d.contractNum + "</span>";
                }}
                ,{field:'name',align:'center', title: '合同名称',minWidth:160,templet:function(d){
                    return "<span title='"+ d.name +"'>" + d.name + "</span>";
                }}
                ,{field:'clientName', align:'center',title: '主委托方',minWidth:210,templet:function(d){
                    return "<span title='"+ d.clientName +"'>" + d.clientName + "</span>";
                }}
            ]]
            ,data: [
                <c:if test="${ not empty page.list}">
                <c:forEach items="${page.list}" var="workInvoiceDetail" varStatus="index">
                <c:if test="${index.index != 0}">,</c:if>
                {
                    "index":"${index.index+1}"
                    ,"id":"${workInvoiceDetail.id}"
                    ,"code":"${workInvoiceDetail.code}"
                    ,"number":"${workInvoiceDetail.number}"
                    ,"totalMoney":"<fmt:formatNumber value="${workInvoiceDetail.totalMoney}" pattern="#,#00.00"/>"
                    ,"tax":"${workInvoiceDetail.tax}%"
                    ,"taxMoney":"<fmt:formatNumber value="${workInvoiceDetail.taxMoney}" pattern="#,#00.00"/>"
					<%--/*"${fns:getDictLabel(workInvoiceDetail.workContractInfo.contractType, 'contract_type', '')}"*/--%>
                    ,"taxRate":"<fmt:formatNumber value="${workInvoiceDetail.taxRate}" pattern="#,#00.00"/>"
					<%--"<fmt:formatDate value="${workInvoiceDetail.createDate}" pattern="yyyy-MM-dd"/>"--%>
                    ,"incomeMoney":"<fmt:formatNumber value="${workInvoiceDetail.incomeMoney}" pattern="#,#00.00"/>"
                    ,"date":"<fmt:formatDate value="${workInvoiceDetail.date}" pattern="yyyy-MM-dd"/>"
                    ,"ext":"<c:choose><c:when test="${workInvoiceDetail.invoiceExt eq '0'}">本公司开票</c:when><c:when test="${workInvoiceDetail.invoiceExt eq '1'}">上级公司开票</c:when></c:choose>"
                    ,"invoiceType":"<c:choose><c:when test="${workInvoiceDetail.invoiceInvoiceType eq '1'}">专票</c:when><c:when test="${workInvoiceDetail.invoiceInvoiceType eq '2'}">普票</c:when></c:choose>"
                    ,"client":"${workInvoiceDetail.invoiceClientName}"
                    ,"orUnicode":"${workInvoiceDetail.invoiceOrUnicode}"
                    ,"content":"${workInvoiceDetail.invoiceContent}"
                    ,"remarks":"${workInvoiceDetail.invoiceRemarks}"
                    ,"state":"${workInvoiceDetail.state}"
                    ,"backSign":"${workInvoiceDetail.backSign}"
                    ,"backNumber":"<c:choose><c:when test="${workInvoiceDetail.backSign eq '冲销'}">${workInvoiceDetail.backNumber},${workInvoiceDetail.backCode}</c:when><c:otherwise></c:otherwise></c:choose>"
                    ,"invoiceNumber":"<c:choose><c:when test="${workInvoiceDetail.backSign eq '冲销'}">${workInvoiceDetail.returnNumbers}</c:when><c:otherwise>${workInvoiceDetail.invocieNumber}</c:otherwise></c:choose>"
                    ,"drawerName":"${workInvoiceDetail.invoiceDrawerName}"
                    ,"office":"${workInvoiceDetail.invoiceOfficeName}"
                    ,"contractNum":"${workInvoiceDetail.contractNum}"
                    ,"name":"${workInvoiceDetail.contractName}"
                    ,"clientName":"${workInvoiceDetail.contractClientName}"
                }
                </c:forEach>
                </c:if>
            ]
            // ,even: true
            // ,height: 315
        });

    })

    resizeListTable();
</script>
<script>
    resizeListWindow1();
    $(window).resize(function(){
        resizeListWindow1();
    });
    var navg = window.navigator.userAgent;
    if(navg.indexOf('Chrome')!==-1&& navg.indexOf('Edge')==-1){
        $('.layui-table').children().eq(0).children().children().eq(1).css({"background":"transparent","position":"sticky","border-right":"1px solid #ccc","left":"0","background":"#F5F5F5","z-index":"999"});
        var tableft = $('.layui-table').children().eq(0).children().children().eq(1).width();
        $('.layui-table').children().eq(0).children().children().eq(2).css({"background":"transparent","position":"sticky","left":tableft,"background":"#F5F5F5","z-index":"999"});
        var trone = $('.layui-table').children().eq(1).children();
        var newArr = []
        for(var i=0;i<trone.length;i++){
            newArr.push(trone[i]);
            $(newArr[i]).children().eq(1).css({"background":"transparent","position":"sticky","left":"0","background":"#fff","z-index":"999"});
            $(newArr[i]).children().eq(2).css({"background":"transparent","position":"sticky","left":tableft,"background":"#fff","z-index":"999"});
        }
    }
</script>
	
</body>
</html>