<!--{include file="<!--{$oapath}-->public/ins_page.tpl"}-->
   <link rel='stylesheet' type='text/css' href="<!--{$oapath}-->Ins/js/layui/css/layui.css">
<block name="content">
	<input type="hidden" name="ajax" id="ajax" value="1">
	<select name="dept_list" id="dept_list" class="hidden">
		<!--{foreach $dept_list as  $key=>$vo}-->
                                                              <option value="<!--{$vo.id}-->"><!--{$vo.name}--></option>
                                                        <!--{/foreach}-->
	</select>
	<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>
	<form method="post" id="form_adv_search" name="form_adv_search" method="post">
		<input type="hidden" name="ajax" id="ajax" value="1">
		<div class="operate panel panel-default">
			<div class="panel-body">
				<div class="pull-left form-inline">
					<label  for="eq_is_del"><b>状态:</b></label>
					<select id="eq_is_del" name="eq_is_del" class="col-10 form-control" onchange="submit_adv_search();">
						<option value="0">启用</option>
						<option value="1">禁用</option>
						<option value="2">其他</option>
					</select>
					<!--<a onclick="import_user()" class="btn btn-sm btn-primary">导入</a>-->
					<!--<a onclick="weixin_sync()" class="hidden btn btn-sm btn-primary">同步到微信</a>-->
					<a onclick="reset_pwd()" class="btn btn-sm btn-primary">设置密码</a>
					<a onclick="del_pwd()" class="btn btn-sm btn-primary">清空工资密码</a>
				</div>
				<div class="pull-right">
					<a onclick="add()"  class="btn btn-sm btn-primary">新增</a>
					<a onclick="save()"  class="btn btn-sm btn-primary">保存</a>
					|
					<a onclick="del()"  class="btn btn-sm btn-danger">删除</a>
				</div>
			</div>
		</div>
	</form>
	<div class="row">
		<div class="col-sm-4 sub_left_menu ">
			<form id="form_user" name="form_data" method="post" class="form-horizontal">
				<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>员工编号</th>
							<th>姓名</th>
							<th>状态</th>
						</tr>
					</thead>
					<tbody>
						<!--{foreach $list as  $key=>$parent}-->
							<tr id="<!--{$parent.id}-->" class="tbody">
								<td class="text-center col-3"><label class="inline pull-left">
									<input class="ace" type="checkbox" name="user_id[]" value="<!--{$parent.id}-->" />
									<span class="lbl"></span></label></td>
								<td class="click"><!--{$parent.emp_no}--></td>
								<td class="click"><!--{$parent.name}--></td>
								<td class="click"> <!--{if $parent.is_del=='0'}--> 
                                                                        启用
                                                           <!--{else}-->
                                                                        禁用
                                                            <!--{/if}--></td>
							</tr>
						 <!--{/foreach}-->
					</tbody>
				</table>
			</form>
			<div class="pagination">
				<!--{$showpage}-->
			</div>
		</div>
		<div class="col-sm-8">
			<form id="form_data" name="form_data" method="post" class="form-horizontal">
				<input type="hidden" id="save_name" name="save_name">
				<input type="hidden" name="id" id="id">
				<input type="hidden" name="pic" id="pic" >
				<input type="hidden" name="signature" id="signature" >
				<input type="hidden" name="opmode" id="opmode" value="edit">
				<table class="table table-bordered" >
					<tr>
						<th class="col-10">
						<nobr>
							员工编号*
						</nobr></th>
						<td colspan="2" class="col-30">
						<input class="form-control" type="text" id="emp_no" name="emp_no"  check="require" msg="请输入员工编号" readonly="readonly">
						</td>
						<td rowspan="3" class="col-20">
							<img class="img-thumbnail col-12" id="emp_pic" onerror="javascript:this.src='<!--{$oapath}-->Ins/img/no_avatar.jpg'" >
							
						</td>
					</tr>
					<tr>
						<th>姓名*</th>
						<td colspan="2">
						<input  class="form-control" type="text" id="name" name="name" class="input-sm" check="require" msg="请输入姓名">
						</td>
					</tr>
					<tr>
						<th>昵称*</th>
						<td colspan="2">
						<input  class="form-control" type="text" id="nickname" name="nickname" class="input-sm" check="require" msg="请输入昵称">
						</td>
					</tr>
					<tr>
						<th>性别</th>
						<td colspan="2">
						<select name="sex" id="sex" class="form-control col-10">
							<option  value="male">男</option>
							<option value="female">女</option>
						</select></td>
					</tr>
					<tr>
						<th>生日</th>
						<td colspan="2">
						<input  type="text" id="birthday" name="birthday" readonly="readonly" class="input-date form-control" readonly="readonly">
						</td>
						<td colspan="2"><a class="btn btn-sm btn-primary" id="testList">上传头像</a>
							</td>
					</tr>
					<tr>
						<th>部门*</th>
						<td class="col-20">
						<div class="input-group ">
							<input class="form-control" name="dept_name"  id="dept_name" type="text" msg="请选择部门" check="require" readonly="readonly" />
							<input name="dept_id" id="dept_id" type="hidden" msg="请选择部门" check="require" />
							<div class="input-group-btn">
								<a class="btn btn-sm btn-primary" onclick="select_dept();" > <i class="fa fa-search" ></i> </a>
							</div>
						</div></td>
						<th class="col-10">职位*</th>
						<td>
						<select name="position_id" id="position_id" class="form-control" msg="请选择职位" check="require">
							<option value="">选择职位</option>
							<!--{foreach $position_list as  $key=>$vo}-->
                                                              <option value="<!--{$vo.id}-->"><!--{$vo.name}--></option>
                                                        <!--{/foreach}-->
						</select></td>
					</tr>
					<tr>
						<th>
						<nobr>
							办公室电话
						</nobr></th>
						<td>
						<input type="text" id="office_tel" name="office_tel" class="form-control">
						</td>
						<th>
						<nobr>
							移动电话
						</nobr></th>
						<td>
						<input type="text" id="mobile_tel" name="mobile_tel" class="form-control">
						</td>
					</tr>
					<tr>
					<tr>
						<th>电子邮箱</th>
						<td colspan="3">
						<input type="text" id="email" name="email" class="form-control">
						</td>
					</tr>
					<tr>
						<th>
						<nobr>
							负责业务
						</nobr></th>
						<td colspan="3">
						<input type="text" id="duty" name="duty" class="form-control">
						</td>
					</tr>
					<tr>
						<th>状态</th>
						<td colspan="3">
						<select class="form-control col-10"  name="is_del" id="is_del">
							<option  value="0">启用</option>
							<option value="1">禁用</option>
						</select></td>
					</tr>
					<tr>
						<td colspan="5">
						<p align="">
							带*为必填选项
						</p></td>
					</tr>
				</table>
			</form>
		</div>
	</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>
                <script src="<!--{$oapath}-->Ins/js/plugins/date-time/moment-with-locales.js"></script>
	        <script src="<!--{$oapath}-->Ins/js/plugins/date-time/bootstrap-datetimepicker.js"></script>
        <script type="text/javascript" src="<!--{$oapath}-->Ins/js/layui/layui.js"></script>
<block name="js">
    <script type="text/javascript">
	$(document).ready(function() {

		 $('.input-date').datetimepicker({
			format : 'YYYY-MM-DD',
			locale : 'zh-cn',
			ignoreReadonly : true,
			widgetPositioning : {
				horizontal : 'auto',
				vertical : 'bottom'
			},
		});
		
		$(".input-daterange input").datetimepicker({
			format : "YYYY-MM-DD",
			locale : 'zh-cn',
			showTodayButton : true,
			showClose : true,
			ignoreReadonly : true,
			widgetPositioning : {
				horizontal : 'auto',
				vertical : 'bottom'
			},
		});

		$("#start_date").on("dp.change", function(e) {
			if ($("#end_date").length > 0) {
				$('#end_date').data("DateTimePicker").minDate(e.date);
			}
		});
		
		$("#end_date").on("dp.change", function(e) {
			if ($("#start_date").length > 0) {
				$('#start_date').data("DateTimePicker").maxDate(e.date);
			}
		});

		$(".input-date-time").datetimepicker({
			format : 'YYYY-MM-DD HH:mm',
			locale : 'zh-cn',
			sideBySide : true,
			showTodayButton : true,
			showClose : true,
			ignoreReadonly : true,
			widgetPositioning : {
				horizontal : 'auto',
				vertical : 'bottom'
			},
		});
			 
	}); 
</script>
	<script type="text/javascript">
		function add() {
			winopen("oa.php?c=User&a=add", 560, 470);
		};
		function del_pwd() {
			if ($("input[name='user_id[]']:checked").length == 0) {
				ui_error('请选择要清空密码的人员 ');
				return;
			}
			var vars = $("#form_user").serialize();
			ui_confirm('确定要清空密码吗?', function() {

				sendAjax("oa.php?c=User&a=del_pwd", vars, function(data) {
					if (data.status) {
						ui_alert(data.info, function() {
							location.reload(true);
						});
					}
				});
			});
		}

		function del() {
			if ($("input[name='user_id[]']:checked").length == 0) {
				ui_error('请选择要删除的人员 ');
				return;
			}
			var vars = $("#form_user").serialize();
			ui_confirm('确定要删除吗?', function() {
				sendAjax("oa.php?c=User&a=del", vars, function(data) {
					if (data.status) {
						ui_alert(data.info, function() {
							location.reload(true);
						});
					}
				});
			});
		}

		function reset_pwd() {
			if ($("#id").val().length < 1) {
				ui_error("请选择用户");
				return false;
			}
			winopen("oa.php?c=User&a=password?id=" + $("#id").val(), 560, 470);
		}

		function import_user() {
			window.open("{:U('import')}", "_self");
			return false;
		}

		function select_dept() {
			winopen("oa.php?c=Dept&a=winpop2", 560, 470);
		}

		function weixin_sync() {
			winopen("{:U('weixin_sync')}",560, 470);
		}

		function select_avatar() {
			if ($("#id").val().length < 1) {
				ui_error("请选择用户");
				return false;
			}
			winopen("oa.php?c=Popup&a=avatar?id=" + $("#id").val(), 560, 470);
		}

		function select_signature() {
			if ($("#id").val().length < 1) {
				ui_error("请选择用户");
				return false;
			}
			winopen("{:U('popup/signature')}?id=" + $("#id").val(), 560, 470);
		}

		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() {
			sendForm("form_data", "oa.php?c=User&a=save",fix_url("oa.php?c=User"));
		}

		function showdata(result) {
			$("#form_data select ").each(function() {
				$(this).find('option:first').attr('selected', 'selected');
			});
			for (var s in result.data) {
				set_val(s, result.data[s]);
			}
			$("#dept_name").val($("#dept_list option[value='" + $("#dept_id").val() + "']").text());
			img_url = $("#pic").val();
			if (img_url != "") {
                              
				img_url += "?t=" + Math.random();
				$("#emp_pic").attr("src", img_url);
			} else {
				$("#emp_pic").attr("src", "<!--{$oapath}-->Ins/img/no_avatar.jpg");
			}

			$("#save_name").val("");
			$("#opmode").val("edit");
		}


		$(document).ready(function() {
			set_return_url();
			set_val('eq_is_del', "<!--{$eq_is_del}-->");
			$(".sub_left_menu tbody td.click").click(function() {
				$tr = $(this).parent();
				$(".sub_left_menu tbody tr.active").removeClass("active");
				$tr.addClass("active");
				sendAjax("oa.php?c=User&a=read", "id=" + $tr.attr("id"), function(data) {
					showdata(data);
				});
				return false;
			});
		});

	</script>
        <script>
layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;
  
  //普通图片上传
  var uploadInst = upload.render({
    elem: '#testList'
    ,url: 'oa.php?c=Popup&a=upload'
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo1').attr('src', result); //图片链接（base64）
      });
    }
    ,done: function(res){
      //如果上传失败
      if(res.code > 0){
        return layer.msg('上传失败');
      }else{
          $("#emp_pic").attr("src",res.name);
          $("[name=pic]").val(res.name1);
      }
      //上传成功
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
  });
  

  
  //绑定原始文件域
  upload.render({
    elem: '#test20'
    ,url: '/upload/'
    ,done: function(res){
      console.log(res)
    }
  });
  
});
</script>
</block>
	</body>
</html>
