<?php use \common\libs\MyLib; ?> <?php $this->beginBlock('header_css'); ?> <link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"> <?php $this->endBlock(); ?> <div class="wrapper wrapper-content animated fadeInRight"> <div class="ibox float-e-margins"> <div class="ibox-title"> <h5>员工管理</h5> <div class="ibox-tools"> <a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="create(0)"> <i class="fa fa-plus"></i> 添加 </a> <a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="$('#listTable').bootstrapTable('refresh');"> <i class="fa fa-refresh"></i> 刷新 </a> </div> </div> <div class="ibox-content"> <form role="form" class="form-horizontal" onsubmit="return search();"> <div class="form-group"> <label class="control-label col-md-1">工号</label> <div class="col-md-2"> <input type="text" id="username" name="username" class="form-control"> </div> <label class="control-label col-md-1">真实姓名</label> <div class="col-md-2"> <input type="text" id="name" name="name" class="form-control"> </div> <label class="control-label col-md-1">电话</label> <div class="col-md-2"> <input type="text" id="phone" name="phone" class="form-control"> </div> <label class="control-label col-md-1">是否离职</label> <div class="col-md-2"> <select id="is_leave" name="is_leave" class="form-control"> <option value="">全部</option> <option value="0">在职</option> <option value="1">已离职</option> </select> </div> </div> <div class="form-group"> <label class="control-label col-md-1">岗位</label> <div class="col-md-3"> <select id="group_id" name="group_id" class="form-control"> <option value="">全部</option> <?php foreach($group_items as $item) { ?> <option value="<?=$item->id?>"><?=$item->name?></option> <?php } ?> </select> </div> <div class="col-md-3"> <button type="submit" class="btn btn-primary">搜索</button> </div> </div> </form> <div class="row"> <div class="col-md-12"> <table id="listTable"> <thead class="bg-warning"> <tr> <th data-field="id">ID</th> <th data-field="username">工号</th> <th data-field="name">真实姓名</th> <th data-field="phone">联系电话</th> <th data-field="is_login">允许登录</th> <th data-field="group_name">所属岗位</th> <th data-field="role_name">角色</th> <th data-field="is_leave">是否离职</th> <th data-formatter="opFormatter">操作</th> </tr> </thead> </table> </div> </div> </div> </div> </div> <?php $this->beginBlock('footer_js'); ?> <script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script> <script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script> <script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script> <script> function opFormatter(value, row, index) { var opStr = []; opStr.push('<a href="javascript:void(0);" onclick="edit(' + row.id + ')">'); opStr.push('<i class="fa fa-edit" title="编辑"></i>'); opStr.push('</a>'); opStr.push('<a href="javascript:void(0);" onclick="del(' + row.id + ')">'); opStr.push('<i class="fa fa-trash" title="删除"></i>'); opStr.push('</a>'); return opStr.join(' '); } function create() { title = '新增员工'; layer_show(title, '/user/edit?id=0'); } function edit(id) { var title = '编辑员工'; layer_show(title, '/user/edit?id=' + id); } function del(id) { parent.layer.confirm('是否确认删除?', { btn: ['删除','取消'], //按钮 shade: false //不显示遮罩 }, function(){ $.post('/user/delete',{id:id},function(data) { parent.layer.msg(data.msg); refreshList(); }, 'json'); }, function(){ // }); } function refreshList() { $('#listTable').bootstrapTable('refresh'); } function search() { $('#listTable').bootstrapTable('destroy'); $('#listTable').bootstrapTable({ url: "/user/index-json", pagination: true, sidePagination: 'server', queryParams: function(params) { params.username = $('#username').val(); params.name = $('#name').val(); params.phone = $('#phone').val(); params.group_id = $('#group_id').val(); params.is_leave = $('#is_leave').val(); return params; } }); return false; } $(function() { search(); }); </script> <?php $this->endBlock(); ?>