<!--{include file="<!--{$oapath}-->public/ins_page.tpl"}-->

<block name="content">
	<style>
		.sub_left_menu{
			height:500px;
			overflow-y: scroll;
		}
	</style>
<div class="page-header clearfix">
	<h1 class="col-sm-8">权限分配</h1>
	<div class="col-sm-4">
		<form name="form_search" id="form_search" method="post" class="pull-right">
			<div class="input-group col-20">
				<input class="form-control" type="text" name="keyword" id="keyword">
				<div class="input-group-btn">
					<a class="btn btn-sm btn-primary" onclick="submit_search();"><i class="fa fa-search"></i></a>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="operate panel panel-default">
	<div class="panel-body">
		<div class="pull-right">
			<a onclick="save()" class="btn btn-sm btn-primary">保存</a>
		</div>
	</div>
</div>
<!-- 列表显示区域  -->
<div class="row">
	<form id="form_data" name="form_data" method="post" >
            <input type="hidden" name="ajax" id="ajax" value="1">
		<div class="col-sm-8 sub_left_menu">
			<table class="table table-bordered">
				<thead>
					<tr>
						<th class="text-center col-4"><label class="inline pull-left">
							<input class="ace" type="checkbox" name="id-toggle-all" id="id-toggle-all" />
							<span class="lbl"></span></label></th>
						<th>
						<nobr>
							员工编号
						</nobr></th>
						<th>
						<nobr>
							姓名
						</nobr></th>
						<th>
						<nobr>
							部门
						</nobr></th>
						<th class="hidden">
						<nobr>
							职级
						</nobr></th>
						<th>
						<nobr>
							职位
						</nobr></th>
						<th>
						<nobr>
							状态
						</nobr></th>
					</tr>
				</thead>
				<tbody class="tbody">
                                    <!--{foreach $user_list as  $key=>$data}-->
						<tr id="<!--{$data.id}-->">
							<td class="text-center col-3"><label class="inline pull-left">
								<input class="ace" type="checkbox" name="emp_id[]" value="<!--{$data.id}-->" />
								<span class="lbl"></span></label></td>
							<td>
							<nobr>
								<!--{$data.emp_no}-->
							</nobr></td>
							<td>
							<nobr>
								<!--{$data.name}-->
							</nobr></td>
							<td>
							<nobr>
								<!--{$data.dept_name}-->
							</nobr></td>
						
							<td>
							<nobr>
								<!--{$data.position_name}-->
							</nobr></td>
							<td>
							<nobr>
								  <!--{if $data.is_del=='0'}--> 
                                                                        启用
                                                           <!--{else}-->
                                                                        禁用
                                                            <!--{/if}-->
							</nobr></td>
						</tr>
				
                                	 <!--{/foreach}-->  
				</tbody>
			</table>
		</div>
		<div class="col-sm-4 sub_content">
			<input type="hidden" name="id" id="id">
			<input type="hidden" name="pid" id="pid" value="">
			<input type="hidden" name="ajax" id="ajax" value="0">
			<input type="hidden" name="opmode" id="opmode" value="">
			<table class="table table-bordered">
				<thead>
					<tr>
						<th>&nbsp;</th>
						<th>名称</th>
					</tr>
				</thead>
				<tbody>
                                     <!--{foreach $role_list as  $key=>$data}-->
						<tr id="<!--{$data.id}-->">
							<td class="col-4"><label class="inline pull-left ">
								<input class="ace" type="checkbox" id="role_<!--{$data.id}-->" name="role_list[]" value="<!--{$data.id}-->"/>
								<span class="lbl"></span></label></td>
							<td><!--{$data.name}--></td>
						</tr>
					
                                 <!--{/foreach}-->  
				</tbody>
			</table>
		</div>
	</form>
</div>

</block>

					
				</div>
			</div>
		</div>
		<!--<iframe src="{:U('push/client')}" class="push" id="push"></iframe>-->
		<!-- Mainly scripts -->
		<script src="<!--{$oapath}-->Ins/js/jquery-2.1.1.js"></script>
		<script src="<!--{$oapath}-->Ins/js/bootstrap.min.js"></script>
		<script src="<!--{$oapath}-->Ins/js/plugins/metisMenu/jquery.metisMenu.js"></script>
		<script src="<!--{$oapath}-->Ins/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
		<!-- Custom and plugin javascript -->
		<script src="<!--{$oapath}-->Ins/js/inspinia.js"></script>
		<script src="<!--{$oapath}-->Ins/js/common.js"></script>
		<script src="<!--{$oapath}-->Ins/js/plugins/pace/pace.min.js"></script>
                
		<script src="<!--{$oapath}-->Ins/js/plugins/toastr/toastr.min.js"></script>
                <script src="<!--{$oapath}-->Ins/js/plugins/gritter/jquery.gritter.min.js"></script>
                <script src="<!--{$oapath}-->Ins/js/plugins/bootbox/bootbox.min.js"></script>
		<include file="Layout:ins_plugin_js"/>
<block name="js">
<script type="text/javascript">
	function btn_search() {
		sendForm("form_search", "__SELF__");
		$("#form_search").submit();
	}

	function key_search() {
		if (event.keyCode == 13) {
			sendForm("form_search", "__SELF__");
			return false;
		}
	}

	function save() {
		if ($("input:checked[name='emp_id[]']").length < 1) {
			ui_error("请选择用户");
			return false;
		};
		if ($("input:checked[name='role_list[]']").length < 1) {
			ui_error("请选择权限");
			return false;
		};
		sendForm("form_data", "oa.php?c=Role&a=set_role","oa.php?c=Role&a=user");
	}

	function showdata(result) {
		$("input[name='role_list[]']").each(function() {
			$(this).prop('checked', false);
		});
		for (var s in result.data) {
			$("#role_" + result.data[s].role_id).prop('checked', true);
		}
	}


	$(document).ready(function() {
		set_return_url();
		$(".sub_left_menu tbody tr").click(function() {
			$(".sub_left_menu  tr").attr("class", "");
			$(this).attr("class", "active");
			sendAjax("oa.php?c=Role&a=get_role_list", "id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
		});
	}); 
</script>
	</body>
</html>
