<%@page trimDirectiveWhitespaces="true"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="gen" uri="http://help.jspgen.com/taglib/jstl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1" />
<title>节点</title>
<!-- 当前页面 -->
<link type="text/css" href="${config.statie}ui/admin/images/admin.css" rel="stylesheet">
<style type="text/css">
.span-text {padding:0 2px; color:#FFFFFF; background:#9AC621; border-radius:3px; max-width:120px;}
</style>
</head>
<body>
<div id="wrapper">
  <div class="area">
    <gen:if test='${!param.dialog}'><h2><i><gen:if test='${empty param.id}'>添加<gen:else />编辑</gen:if>节点权限</i></h2></gen:if>
    <div class="area-content">
      <form id="form" name="form" method="post" action="<gen:if test='${empty param.id}'>node_allow!save.gen<gen:else />node_allow!update.gen</gen:if>">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
          <tr>
            <td width="30%" align="right"><span class="red">*</span>&nbsp;姓名：</td>
            <td><a href="javascript:void(0);" id="choose"><gen:if test='${empty nodeAllow.name}'>选择<gen:else />${nodeAllow.name}</gen:if></a></td>
          </tr>
          <tr class="border-top">
            <td align="right"> 审核：</td>
            <td><label><input name="showReview" type="radio" value="0" <gen:if test="${empty nodeAllow.showReview || nodeAllow.showReview == '0'}">checked</gen:if> />
              禁止</label>&nbsp;&nbsp;
              <label><input name="showReview" type="radio" value="1" <gen:if test="${nodeAllow.showReview == '1'}">checked</gen:if> />
              允许</label>&nbsp;&nbsp;</td>
          </tr>
          <tr class="border-top">
            <td align="right"> 数据：</td>
            <td><label><input name="showData" type="radio" value="0" <gen:if test="${empty nodeAllow.showData || nodeAllow.showData == '0'}">checked</gen:if> />
              不限</label>&nbsp;&nbsp;
              <label><input name="showData" type="radio" value="1" <gen:if test="${nodeAllow.showData == '1'}">checked</gen:if> />
              部门</label>&nbsp;&nbsp;
              <label><input name="showData" type="radio" value="2" <gen:if test="${nodeAllow.showData == '2'}">checked</gen:if> />
              自己</label>&nbsp;&nbsp;</td>
          </tr>
          <tr class="border-top">
            <td align="right" valign="top"> 备注：</td>
            <td><textarea name="remark" class="text small textarea general">${nodeAllow.remark}</textarea></td>
          </tr>
          <tr class="border-top">
            <td align="right"> 节点：</td>
            <td><a href="javascript:void(0);" id="nodesChoose">选择</a>&nbsp;&nbsp;<span id="nodesText" class="span-text hide">${nodeAllow.nodeNames}</span></td>
          </tr>
          <tr class="border-top">
            <td colspan="2" class="push txt-c"><input type="hidden" name="formHash" value="${formHash}"/>
            	<input type="hidden" name="id" value="${nodeAllow.id}" />
                <input type="hidden" name="name" value="${nodeAllow.name}" />
                <input type="hidden" name="nodeIds" value="${nodeAllow.nodeIds}" />
                <input type="hidden" name="nodeNames" value="${nodeAllow.nodeNames}" />
                <input name="submit" class="button blue small" type="submit" value="确 定" />
                &nbsp;&nbsp;&nbsp;&nbsp;
                <input name="reset" class="button gray small" type="reset" value="取 消" /></td>
          </tr>
        </table>
      </form>
    </div>
  </div>
</div>
<!-- 必备插件 -->
<script type="text/javascript" src="${config.statie}js/jquery.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.form.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.grapes.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.timers.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="${config.statie}js/jquery.tablecolor.js"></script>
<!-- 弹窗插件 -->
<script type="text/javascript" src="${config.statie}js/dialog/jquery.dialog.js?self=true"></script>
<script type="text/javascript" src="${config.statie}js/dialog/jquery.dialog.plugins.js"></script>
<!-- 表单验证插件 -->
<script type="text/javascript" src="${config.statie}js/validate/jquery.validate.js"></script>
<script type="text/javascript" src="${config.statie}js/validate/validate.expand.js"></script>
<script type="text/javascript" src="${config.statie}js/validate/messages_zh.js"></script>
<!-- UI界面必备 -->
<script type="text/javascript" src="${config.statie}ui/js/jspgen.js"></script>
<script type="text/javascript" src="${config.statie}ui/js/jspgen.ajax.js"></script>
<script type="text/javascript" src="${config.statie}ui/js/jspgen.ready.js"></script>
<!-- 当前页面 -->

<script type="text/javascript">
// document.domain = "baidu.com";

// 调用
$(document).ready(function(){	
	var $form = $('#form'), $reset = $('input:reset');
	
	// 表单验证
	var validate = $form.validate({
		submitHandler: function(form) {
			if(grapes.isEmpty($('input[name="name"]').prop('value'))){
				alert('姓名不能为空!');
				return false;
			}
			
			$(form).ajaxSubmit($.extend({
				success: function(result) {
					// {'status':false,'message':'message', 'store':{'id':'id'}}
					if (result) {
						if (result.status) {
							$dialog.success(result.message, function() {
								refleshFromTab(); removeTab();
							});
						}else{
							$dialog.error(result.message);
						}
					}
				}
			}, formOptions));
			
			// 阻止表单默认提交
			return false;
		}
	});
	$reset.bind('click', function () {
		validate.resetForm();
	});
	
	// 管理选择
	var $adminChoose = $('#choose'), $adminId = $('input[name="id"]'), $adminName = $('input[name="name"]');
	$adminChoose.bind('click',function(){
		var dialog = $dialog.iframe('../../admin/admin!choose.gen', {title: '管理员', width:'650px', height:'300px', resize: false});
		dialog.callback = function(obj) {
			$adminId.prop('value', obj.id);
			$adminName.prop('value', obj.name);
			$adminChoose.text(obj.name);
		}
	});
	
	// 节点选择
	var $nodesChoose = $('#nodesChoose'), $nodesText = $('#nodesText'), $nodeIds = $('input[name="nodeIds"]'), $nodeNames = $('input[name="nodeNames"]');
	$nodesChoose.bind('click',function(){
		var dialog = $dialog.iframe('node!choose.gen?genre=all&pcheck=true', {title: '节点分配', width:'230px', height:'300px', resize: false});
		dialog.nodeIds = $nodeIds.prop('value');
		dialog.nodeNames = $nodeNames.prop('value');
		dialog.callback = function(obj) {
			$nodeIds.prop('value', obj.ids);
			$nodeNames.prop('value', obj.names);
			$nodesText.text(obj.names).toggle(grapes.isNotEmpty(obj.names));
		}
	});
	$nodesText.toggle(grapes.isNotEmpty($nodesText.text()));
});
</script>
</body>
</html>