<%@ 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() {
            function page(n,s){
                location = '${ctx}/workpayment/workPayment/list/?pageNo='+n+'&pageSize='+s;
            }
		});
        function openDialogre(title,url,width,height,target){
            if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端，就使用自适应大小弹窗
                width='auto';
                height='auto';
            }else{//如果是PC端，根据用户设置的width和height显示。

            }
            top.layer.open({
                type: 2,
                area: [width, height],
                title: title,
                maxmin: true, //开启最大化最小化按钮
                content: url ,
                btn: ['同意','驳回','关闭'],
                btn1: function(index, layero){
                    var body = top.layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    if(iframeWin.contentWindow.doSubmit(1) ){
                        // top.layer.close(index);//关闭对话框。
                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                    }
                },
                btn2:function(index,layero){
                    var body = top.layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    if(iframeWin.contentWindow.doSubmit(2) ){
                        // top.layer.close(index);//关闭对话框。
                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                    }
                },
                btn3: function(index){
                }
            });
        }
	</script>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
	<div class="ibox">
	<div class="ibox-title">
		<h5>
			<ul class="nav nav-tabs">
				<li class="active"><a href="${ctx}/workpayment/workPayment/list">付款申请信息</a></li>
				<li><a href="${ctx}/workpayment/workPayment/workPaymentTodoList">待办任务</a></li>
				<li><a href="${ctx}/workpayment/workPayment/workPaymentHistoricList">已办任务</a></li>
				<shiro:hasPermission name="workpayment:workPayment:edit"><li><a href="${ctx}/workpayment/workPayment/form?ids=0">付款申请</a></li></shiro:hasPermission>
			</ul>
		</h5>
		<%--<div class="ibox-tools">
			<a class="collapse-link">
				<i class="fa fa-chevron-up"></i>
			</a>
			<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">
				<i class="fa fa-wrench"></i>
			</a>
			<ul class="dropdown-menu dropdown-user">
				<li><a href="javascript:void(0)">选项1</a>
				</li>
				<li><a href="javascript:void(0)">选项2</a>
				</li>
			</ul>
			<a class="close-link">
				<i class="fa fa-times"></i>
			</a>
		</div>--%>
	</div>
    
    <div class="ibox-content">
	<sys:message content="${message}"/>
	
	<!--查询条件-->
	<div class="row">
	<div class="col-sm-12">
	<form:form id="searchForm" modelAttribute="workPayment" action="${ctx}/workpayment/workPayment/list" 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}"/>
		<table:sortColumn id="orderBy" name="orderBy" value="${page.orderBy}" callback="sortOrRefresh();"/><!-- 支持排序 -->
		<a href="#" id="moresee" class="fa fa-chevron-down" style="float: right;">更多</a>
		<div class="form-group">
			<span>申请部门：</span>
				<sys:treeselect id="officeId" name="officeId" value="${workPayment.officeId}" labelName="officeName" labelValue="${workPayment.officeName}"
					title="部门" url="/sys/office/treeDataAll?type=2" cssClass="form-control input-sm" allowClear="true" notAllowSelectParent="true"/>
			<label>审核状态：</label>
			<form:select path="status"  class="form-control m-b">
				<form:option value="" label=""/>
				<form:options items="${fns:getDictList('act_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
			</form:select>
		 </div>	
	</form:form>
	<br/>
	</div>
	</div>
	
	<!-- 工具栏 -->
	<div class="row">
	<div class="col-sm-12">
		<div class="pull-left">
	        <button class="btn btn-white btn-sm " data-toggle="tooltip" data-placement="left" onclick="sortOrRefresh()" title="刷新"><i class="glyphicon glyphicon-repeat"></i> 刷新</button>
		</div>
		<div class="pull-right">
			<button  class="btn btn-primary btn-rounded btn-outline btn-sm " onclick="search()" ><i class="fa fa-search"></i> 查询</button>
			<button  class="btn btn-primary btn-rounded btn-outline btn-sm " onclick="reset()" ><i class="fa fa-refresh"></i> 重置</button>
		</div>
	</div>
	</div>
	
	<!-- 表格 -->
	<table id="contentTable" class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
		<thead>
			<tr>
				<th style="text-align: center;">序号</th>
				<th style="text-align: center;"  class="sort-column company.name">申请公司</th>
				<th style="text-align: center;"  class="sort-column a.reason">事由</th>
				<th style="text-align: center;"  class="sort-column a.amount">付款金额(元)</th>
				<th style="text-align: center;"  class="sort-column a.pay_type">付款方式</th>
				<th style="text-align: center;"  class="sort-column a.pay_date">支付日期</th>
				<th style="text-align: center;"  class="sort-column a.pay_object">支付对象</th>
				<th style="text-align: center;"  class="sort-column a.pay_bank">开户银行</th>
				<th style="text-align: center;"  class="sort-column a.pay_bank_account">银行账户</th>
				<th style="text-align: center;"  class="sort-column a.status">审批状态</th>
				<th style="text-align: center;"  class="sort-column a.create_date">创建时间</th>
				<th style="text-align: center;">操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="workPayment" varStatus="varStatus">
			<c:set var="task" value="${workPayment.task }" />
			<c:set var="pi" value="${workPayment.processInstance }" />
			<c:set var="hpi" value="${workPayment.historicProcessInstance }" />
			<tr>
				<td>${varStatus.index+1}</td>
				<td>
					<%--${workPayment.company.name}--%>
					<span title="${workPayment.company.name}">${fns:abbr(workPayment.company.name, 30)}</span>
				</td>
				<td>
					<%--${workPayment.reason}--%>
					<span title="${workPayment.reason}">${fns:abbr(workPayment.reason, 16)}</span>
				</td>
				<td>
					${workPayment.amount}
				</td>
				<td>
					${fns:getDictLabel(workPayment.payType,'pay_type','')}
				</td>
				<td>
					<fmt:formatDate value="${workPayment.payDate}" pattern="yyyy-MM-dd"/>
				</td>
				<td>
					${workPayment.payObject}
				</td>
				<td>
					${workPayment.payBank}
				</td>
				<td>
					${workPayment.payBankAccount}
				</td>
				<c:if test="${not empty task}">
					<td>${fns:getDictLabel(workPayment.status, 'act_status', '')}</td>
					<td><fmt:formatDate value="${workPayment.createDate}" pattern="yyyy-MM-dd"/></td>
					<td>
						<div style="text-align: center">
						<shiro:hasPermission name="workpayment:workPayment:view">
							<a href="javascript:void(0)" onclick="openDialogView('详情', '${ctx}/workpayment/workPayment/form?id=${workPayment.id}&readAttr=disabled&name=view','80%','80%')" class="btn btn-info btn-xs" ><i class="fa fa-search-plus"></i> 查看</a>
						</shiro:hasPermission>&nbsp;&nbsp;
						<c:if test="${workPayment.createBy.id eq fns:getUser().id}">
							<c:if test="${workPayment.status!=3 && workPayment.status!=4 && workPayment.status!=5}">
								<a href="${ctx}/workpayment/workPayment/revoke?id=${workPayment.id}&processInstanceId=${workPayment.processInstanceId}&reason=${workPayment.reason}" onclick="return confirmx('确认要撤回该申请吗？', this.href)" class="btn btn-warning btn-xs"><i class="glyphicon glyphicon-share-alt"></i> 撤回</a>
							</c:if>
						</c:if>
						<c:if test="${not empty task.assignee}">
							<a href="${ctx}/workpayment/workPayment/applyOnWorkpayment?taskId=${task.id}&taskName=${fns:urlEncode(task.name)}&taskDefKey=${task.taskDefinitionKey}&procInsId=${task.processInstanceId}&procDefId=${task.processDefinitionId}&status=1" class="btn btn-success btn-xs">任务办理</a>
						</c:if>
						</div>
					</td>
				</c:if>
				<c:if test="${empty task}">
					<td>${fns:getDictLabel(workPayment.status, 'act_status', '')}</td>
					<td><fmt:formatDate value="${workPayment.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td>
						<div style="text-align: center">
						<shiro:hasPermission name="workpayment:workPayment:view">
							<a href="javascript:void(0)" onclick="openDialogView('详情', '${ctx}/workpayment/workPayment/form?id=${workPayment.id}&readAttr=disabled&name=view','80%','80%')" class="btn btn-info btn-xs" ><i class="fa fa-search-plus"></i> 查看</a>
						</shiro:hasPermission>
						<c:if test="${workPayment.createBy.id eq fns:getUser().id}">
							<c:if test="${workPayment.status!=3 && workPayment.status!=4 && workPayment.status!=5}">
								<a href="${ctx}/workpayment/workPayment/revoke?id=${workPayment.id}&processInstanceId=${workPayment.processInstanceId}&reason=${workPayment.reason}" onclick="return confirmx('确认要撤回该信息吗？', this.href)" class="btn btn-warning btn-xs"><i class="glyphicon glyphicon-share-alt"></i> 撤回</a>
							</c:if>
							<c:if test="${workPayment.status==4 || workPayment.status==5}">
								<shiro:hasPermission name="workpayment:workPayment:del">
									<a href="${ctx}/workpayment/workPayment/delete?id=${workPayment.id}" onclick="return confirmx('确认要删除该付款申请吗？', this.href)"   class="btn btn-danger btn-xs"><i class="fa fa-trash"></i> 删除</a>
								</shiro:hasPermission>
							</c:if>
							<c:if test="${workPayment.status==3}">
								<a href="javascript:void(0)" onclick="javascript:top.layer.alert('该申请已通过不允许删除',{icon: 0, title:'系统提示'})" class="btn btn-default btn-xs"><i class="fa fa-trash"></i>删除</a>
							</c:if>
						</c:if>
						</div>
					</td>
				</c:if>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
		<!-- 分页代码 -->
	<table:page page="${page}"></table:page>
	<br/>
	<br/>
	</div>
	</div>
</div>
</body>
</html>