diff --git a/app/home/common.php b/app/home/common.php index 67eb77f..d4f8b84 100644 --- a/app/home/common.php +++ b/app/home/common.php @@ -137,16 +137,16 @@ function get_admin_menus() //读取部门列表 -function d_department() +function get_department() { $department = Db::name('Department')->select()->toArray(); return $department; } //获取某部门的子部门id -function d_department_son($did = 0,$is_self=1) +function get_department_son($did = 0,$is_self=1) { - $department=d_department(); + $department=get_department(); $department_list = get_data_node($department,$did); $department_array = array_column($department_list,'id'); if($is_self == 1){ diff --git a/app/home/controller/Admin.php b/app/home/controller/Admin.php index e52f2d3..db46b89 100644 --- a/app/home/controller/Admin.php +++ b/app/home/controller/Admin.php @@ -36,7 +36,7 @@ class Admin extends BaseController $where[] = ['type', '=', $param['type']]; } if (!empty($param['did'])) { - $department_array = d_department_son($param['did']); + $department_array = get_department_son($param['did']); $where[] = ['did', 'in', $department_array]; } $rows = empty($param['limit']) ? get_config(app . page_size) : $param['limit']; @@ -60,7 +60,7 @@ class Admin extends BaseController public function add() { $id = empty(get_params('id')) ? 0 : get_params('id'); - $department = set_recursion(d_department()); + $department = set_recursion(get_department()); $position = Db::name('Position')->where('status', '>=', 0)->order('create_time asc')->select(); if ($id > 0) { $detail = get_admin($id); diff --git a/app/home/controller/Api.php b/app/home/controller/Api.php index 482842f..311544d 100644 --- a/app/home/controller/Api.php +++ b/app/home/controller/Api.php @@ -158,7 +158,7 @@ class Api extends BaseController //获取部门节点列表 public function get_department_tree() { - $department = d_department(); + $department = get_department(); $list = get_tree($department, 0,2); $data['trees'] = $list; return json($data); @@ -168,7 +168,7 @@ class Api extends BaseController public function get_employee($did=0) { $did=get_params('did'); - $department=d_department_son($did); + $department=get_department_son($did); $employee = Db::name('admin') ->field('a.id,a.did,a.position_id,a.mobile,a.name,a.nickname,a.sex,a.status,a.thumb,a.username,d.title as department') ->alias('a') diff --git a/app/home/controller/Department.php b/app/home/controller/Department.php index 8c4fdde..40e7912 100644 --- a/app/home/controller/Department.php +++ b/app/home/controller/Department.php @@ -20,7 +20,12 @@ class Department extends BaseController public function index() { if (request()->isAjax()) { - $list = Db::name('Department')->order('create_time asc')->select(); + $list = Db::name('Department') + ->field('d.*,a.name as leader') + ->alias('d') + ->join('Admin a', 'a.id = d.uid','LEFT') + ->order('create_time asc') + ->select(); return to_assign(0, '', $list); } else { return view(); @@ -32,9 +37,11 @@ class Department extends BaseController { $id = empty(get_params('id')) ? 0 : get_params('id'); $pid = empty(get_params('pid')) ? 0 : get_params('pid'); - $department = set_recursion(d_department()); + $department = set_recursion(get_department()); if($id > 0) { $detail = Db::name('Department')->where(['id' => $id])->find(); + $users=Db::name('Admin')->where(['did'=>$id,'status'=>1])->select(); + View::assign('users', $users); View::assign('detail', $detail); } View::assign('department', $department); @@ -55,8 +62,14 @@ class Department extends BaseController return to_assign(1, $e->getError()); } $param['update_time'] = time(); - Db::name('Department')->strict(false)->field(true)->update($param); - add_log('edit', $param['id'], $param); + $department_array=get_department_son($param['id']); + if (in_array($param['pid'], $department_array)){ + return to_assign(1,'上级部门不能是该部门本身或其下属部门'); + } + else{ + Db::name('Department')->strict(false)->field(true)->update($param); + add_log('edit', $param['id'], $param); + } } else { try { validate(DepartmentCheck::class)->scene('add')->check($param); @@ -71,52 +84,15 @@ class Department extends BaseController } } - //提交添加 - public function save() - { - if($this->request->isPost()){ - $param = vae_get_param(); - if($param['id']>0){ - $result = $this->validate($param, 'app\home\validate\Department.edit'); - if ($result !== true) { - return vae_assign(0,$result); - } else { - $param['update_time'] = time(); - $department_array=[]; - $department_cate = vae_get_department(); - $department_ids=get_data_node($department_cate,$param['id']); - $department_array = array_column($department_ids, 'id'); - $department_array[]=$param['id']; - if (in_array($param['pid'], $department_array)){ - return vae_assign(0,'上级部门不能是该部门本身或其下属部门'); - } - else{ - $res = \think\loader::model('Department')->strict(false)->field(true)->update($param); - if($res) add_log('edit',$param['id'],$param); - } - } - }else{ - $result = $this->validate($param, 'app\home\validate\Department.add'); - if ($result !== true) { - return vae_assign(0,$result); - } else { - $param['create_time'] = time(); - $mid = \think\loader::model('Department')->strict(false)->field(true)->insertGetId($param); - } - } - return vae_assign(); - } - } - //删除 public function delete() { $id = get_params("id"); - $count = Db::name('Department')->where(["pid" => $id,'status'=>['egt',0]])->count(); - $users = Db::name('Admin')->where(["did" => $id,'status'=>['egt',0]])->count(); + $count = Db::name('Department')->where([['pid','=',$id],['status','>=',0]])->count(); if ($count > 0) { return to_assign(1,"该部门下还有子部门,无法删除"); } + $users = Db::name('Admin')->where([['did','=',$id],['status','>=',0]])->count(); if ($users > 0) { return to_assign(1,"该部门下还有员工,无法删除"); } diff --git a/app/home/view/admin/index.html b/app/home/view/admin/index.html index d033d79..fcae17f 100644 --- a/app/home/view/admin/index.html +++ b/app/home/view/admin/index.html @@ -5,9 +5,10 @@ .layui-tree-entry{font-size:15px; line-height:24px} .layui-tree-set{padding:2px 0} .layui-tree-iconClick .layui-icon{color:#1E9FFF} - .layui-tree-icon {height: 14px;line-height: 14px; width: 14px;text-align: center;border: 1px solid #1E9FFF; color:#1E9FFF} + .layui-icon layui-icon-file{font-size:16px;} + .layui-tree-icon {height: 14px;line-height: 14px; width: 14px; text-align: center;border: 1px solid #1E9FFF; color:#1E9FFF} .layui-tree-line .layui-tree-set .layui-tree-set:after{top:18px;} - .tree-left{width:200px; float:left; height:calc(100% - 30px); overflow: scroll; border:1px solid #e6e6e6; background-color:#f8f8f8; padding:12px 12px 12px 5px;} + .tree-left{width:200px; float:left; height:calc(100% - 30px); overflow: scroll; border:1px solid #eeeeee; background-color:#FAFAFA; padding:12px 12px 12px 5px;} .tree-left h3{font-size:16px; height:30px; padding-left:10px; font-weight:800} {/block} diff --git a/app/home/view/department/add.html b/app/home/view/department/add.html index 56a5ace..9277d99 100644 --- a/app/home/view/department/add.html +++ b/app/home/view/department/add.html @@ -5,6 +5,10 @@ {eq name="$id" value="0"} + + - - - - - -
部门名称* + + 上级部门* 部门名称* - -
部门负责人 - - 部门联系电话 @@ -33,6 +27,10 @@ {else/} + + - -
部门名称* + + 上级部门* 部门名称* - -
部门负责人 - + 部门联系电话 diff --git a/app/home/view/department/index.html b/app/home/view/department/index.html index 62c60ef..203eba4 100644 --- a/app/home/view/department/index.html +++ b/app/home/view/department/index.html @@ -43,8 +43,8 @@ { field: 'id', width: 100, title: 'ID号', align: 'center' } , { field: 'pid', title: '上级部门ID',width: 120, align: 'center'} , { field: 'title', title: '部门名称'} - , { field: 'uername', title: '部门负责人',width: 120, align: 'center'} - , { field: 'phone', title: '部门电话',width: 180, align: 'center'} + , { field: 'leader', title: '部门负责人',width: 120, align: 'center'} + , { field: 'phone', title: '部门电话',width: 160,} , { width: 200, title: '操作', align: 'center', templet: function (d) { var html = '添加下级部门编辑删除'; return html; diff --git a/app/home/view/role/add.html b/app/home/view/role/add.html index 3aec076..26322a0 100644 --- a/app/home/view/role/add.html +++ b/app/home/view/role/add.html @@ -173,7 +173,7 @@ //监听返回 $('.body-content').on('click', '[lay-event="back"]', function () { - history.back(-1); + window.location.href="{:url('home/role/index')}"; return false; }); diff --git a/app/home/view/role/index.html b/app/home/view/role/index.html index 520e160..d2d986f 100644 --- a/app/home/view/role/index.html +++ b/app/home/view/role/index.html @@ -40,10 +40,10 @@ limit: 20, cols: [[ //表头 { field: 'id', title: 'ID号', align: 'center', width: 80 } - , { field: 'title', title: '名称', width: 300 } + , { field: 'title', title: '名称', width: 200 } , { field: 'desc', title: '备注' } - , { field: 'status', title: '状态', toolbar: '#status', align: 'center', width: 90 } - , { width: 160, + , { field: 'status', title: '状态', toolbar: '#status', align: 'center', width: 80 } + , { width: 120, title: '操作', align: 'center', templet: function (d) { diff --git a/public/static/home/images/login_logo.png b/public/static/home/images/login_logo.png index d9b8f82..b3545a1 100644 Binary files a/public/static/home/images/login_logo.png and b/public/static/home/images/login_logo.png differ diff --git a/public/static/home/images/logo.png b/public/static/home/images/logo.png index 6ba6f7f..02e37e7 100644 Binary files a/public/static/home/images/logo.png and b/public/static/home/images/logo.png differ