<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>付款申请管理</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic}/layer-v2.3/laydate/laydate.js"></script>
	<script type="text/javascript">
		var validateForm;
		function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){
			  $("#inputForm").submit();
			  return true;
		  }
	
		  return false;
		}
		$(document).ready(function() {
			validateForm = $("#inputForm").validate({
				submitHandler: function(form){

				    var len = $("#showPeo span").length;
					if(len<=0){
                        parent.layer.msg("请选择审批人!",{icon:5});
					    return false;
					}
					if(len<0){

					}
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});

        function selectPeople(objId,objName){
            var currentUser = '${fns:getUser().id}';
            if(currentUser==objId){
                parent.layer.msg("不能选择自己为审批人!",{icon:5});
                return false;
            }
            var showPeo = $("#showPeo").html();
            var len = $("#showPeo span").length;
            if(len > 4){
                parent.layer.msg("最多添加5个审批人",{icon:5})
                return;
            }
            var arr = [];
            var a = $("#showPeo span").each(function(){
                var dataId = $(this).attr("data-id");
                arr.push(dataId)
            })
            if(arr.indexOf(objId) != -1){
                parent.layer.msg("该审批人已被选择，不能重复选择！！！",{icon:5})
                return ;
            }
            showPeo = showPeo + '<span class="badge badge-success fontSpan" data-id="'+objId+'">'+objName+'&nbsp;&nbsp;&nbsp;' +
                '<i onclick=deletePeo(this) class="fa fa-close"></i><input type="hidden" name=adds['+len+'] value="'+objId+'"></span>';
            $("#showPeo").html(showPeo)
        }
        function deletePeo(obj){
            $(obj).parent().remove()
        }
	</script>
</head>
<body class="gray-bg">

<div class="wrapper wrapper-content">
	<div class="ibox">
		<c:if test="${sessionScope.state!='disabled'}">
			<div class="ibox-title" style="height: 70px;">
				<h5>
					<ul class="nav nav-tabs">
						<li><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 class="active"><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>
		</c:if>
		<div class="ibox-content">
			<form:form id="inputForm" modelAttribute="workPayment" action="${ctx}/workpayment/workPayment/save" method="post" class="form-horizontal">
				<form:hidden path="id"/>
				<c:set var="id" value="${workPayment.id}" />
				<c:set var="ids" value="${workPayment.ids}" />
				<sys:message content="${message}"/>
				<div class="control-group">
					<label class="control-label"><font color="red">*</font>付款事由：</label>
					<div class="controls">
						<form:textarea path="reason" class="form-control required" rows="3" maxlength="20"/>
						<span class="help-inline"></span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label"><font color="red">*</font>付款金额(元)：</label>
					<div class="controls">
						<input id="amount" name="amount" type="text" class="form-control required number" value="${workPayment.amount}"/>
						<span class="help-inline"></span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">付款方式：</label>
					<div class="controls" style="width: 200px;">
						<form:select path="payType" class="form-control required">
							<form:options items="${fns:getDictList('pay_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
						<span class="help-inline"></span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label"><font color="red">*</font>支付日期：</label>
					<div class="controls" style="width: 200px;">
						<input class="form-control layer-date laydate-icon required" id="payDate" name="payDate" readonly="readonly" value="<fmt:formatDate value="${workPayment.payDate}" pattern="yyyy-MM-dd"/>" onclick="laydate({istime: false, format: 'YYYY-MM-DD'})">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">支付对象：</label>
					<div class="controls">
						<input id="payObject" name="payObject" type="text"  class="form-control" value="${workPayment.payObject}"/>
						<span class="help-inline"></span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">开户银行：</label>
					<div class="controls">
						<input id="payBank" name="payBank" type="text"  class="form-control" value="${workPayment.payBank}"/>
						<span class="help-inline"></span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">银行账户：</label>
					<div class="controls">
						<input id="payBankAccount" name="payBankAccount" type="text"  class="form-control number" value="${workPayment.payBankAccount}"/>
						<span class="help-inline"></span>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">备注：</label>
					<div class="controls">
						<form:textarea path="remarks" class="form-control" rows="3" maxlength="20"/>
						<span class="help-inline"></span>
					</div>
				</div>
				<c:if test="${empty id}">
					<div class="control-group">
						<label class="control-label"><font color="red">*</font>审批人：</label>
						<div id="" class="controls">
							<sys:treeselectleave id="" name="" value="" labelName="" labelValue=""
											title="审批人" url="/sys/office/treeDataAll?type=3" cssClass="form-control required" allowClear="true" notAllowSelectParent="true"/>
							<span class="help-inline"></span>
						</div>
						<div id="showPeo" class="controls">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label"><font color="red">*</font>抄送人：</label>
						<div id="CCid" class="controls">
							<sys:treeselect id="CCid" name="CCid" value="" labelName="" labelValue=""
											title="抄送人" url="/sys/office/treeDataAll?type=3&isAll=false" cssClass="form-control required" allowClear="true" checked="true" notAllowSelectParent="true"/>
							<span class="help-inline"></span>
						</div>
					</div>
					<c:if test="${not empty ids}">
						<div class="form-actions">
							<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
							<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
						</div>
					</c:if>
				</c:if>
			</form:form>
		</div>
	</div>
</div>
<%
	session.removeAttribute("state");
%>

</body>
</html>