From 7763f3b26fa7778491d8a5008e699aebc80b9518 Mon Sep 17 00:00:00 2001 From: hdm Date: Tue, 23 Nov 2021 23:09:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=91=8A=EF=BC=8C=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=E6=A8=A1=E5=9D=97=E4=BD=93=E9=AA=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/home/common.php | 27 ++++++ app/home/controller/Api.php | 68 +++++++------- app/home/controller/Article.php | 35 ++++--- app/home/controller/Department.php | 3 +- app/home/controller/Note.php | 37 +++++--- app/home/view/article/add.html | 2 +- app/home/view/article/cate.html | 94 +++++++++---------- app/home/view/article/cate_add.html | 45 ++++++--- app/home/view/article/edit.html | 2 +- app/home/view/article/index.html | 4 +- app/home/view/article/list.html | 4 +- app/home/view/article/view.html | 2 +- app/home/view/department/add.html | 4 +- app/home/view/department/index.html | 8 +- app/home/view/note/add.html | 4 +- app/home/view/note/cate.html | 138 +++++++++++++--------------- app/home/view/note/cate_add.html | 80 +++++++++------- app/home/view/note/index.html | 3 - 18 files changed, 312 insertions(+), 248 deletions(-) diff --git a/app/home/common.php b/app/home/common.php index dd9d86a..523efa4 100644 --- a/app/home/common.php +++ b/app/home/common.php @@ -158,6 +158,7 @@ function get_department_son($did = 0, $is_self = 1) function get_keywords() { $keywords = Db::name('Keywords')->where(['status' => 1])->order('id desc')->select()->toArray(); + return $keywords; } //读取公告分类列表 @@ -167,6 +168,19 @@ function get_note_cate() return $cate; } +//读取公告分类子分类ids +function get_note_son($id = 0, $is_self = 1) +{ + $note = get_note_cate(); + $note_list = get_data_node($note, $id); + $note_array = array_column($note_list, 'id'); + if ($is_self == 1) { + //包括自己在内 + $note_array[] = $id; + } + return $note_array; +} + //读取知识分类列表 function get_article_cate() { @@ -174,6 +188,19 @@ function get_article_cate() return $cate; } +//读取知识分类子分类ids +function get_article_son($id = 0, $is_self = 1) +{ + $article = get_article_cate(); + $article_list = get_data_node($article, $id); + $article_array = array_column($article_list, 'id'); + if ($is_self == 1) { + //包括自己在内 + $article_array[] = $id; + } + return $article_array; +} + //读取开票主体 function get_invoice_subject() { diff --git a/app/home/controller/Api.php b/app/home/controller/Api.php index 311544d..3306f46 100644 --- a/app/home/controller/Api.php +++ b/app/home/controller/Api.php @@ -154,36 +154,36 @@ class Api extends BaseController return to_assign(1, '邮件发送失败!'); } } - + //获取部门节点列表 public function get_department_tree() { $department = get_department(); - $list = get_tree($department, 0,2); + $list = get_tree($department, 0, 2); $data['trees'] = $list; return json($data); } - - //获取子部门所有员工 - public function get_employee($did=0) + + //获取子部门所有员工 + public function get_employee($did = 0) { - $did=get_params('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') + $did = get_params('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') ->join('Department d', 'a.did = d.id') - ->where(['a.status'=>1]) - ->where('a.did',"in",$department) - ->select(); - return to_assign(0,'',$employee); + ->where(['a.status' => 1]) + ->where('a.did', "in", $department) + ->select(); + return to_assign(0, '', $employee); } - + //获取角色列表 public function get_position() - { - $position = Db::name('Position')->field('id,title as name')->where([['status','=',1],['id','>',1]])->select(); - return to_assign(0,'',$position); + { + $position = Db::name('Position')->field('id,title as name')->where([['status', '=', 1], ['id', '>', 1]])->select(); + return to_assign(0, '', $position); } //首页公告 @@ -222,7 +222,6 @@ class Api extends BaseController return table_assign(0, '', $res); } - //修改个人信息 public function edit_personal() { @@ -289,20 +288,19 @@ class Api extends BaseController public function del_expense_interfix() { $id = get_params("id"); - $admin_id = Db::name('ExpenseInterfix')->where('id',$id)->value('admin_id'); - if($admin_id == $this->uid){ - if (Db::name('ExpenseInterfix')->where('id',$id)->delete() !== false) { - return to_assign(0, "删除成功"); - } else { - return to_assign(1, "删除失败"); - } - }else{ - return to_assign(1, "您没权限删除该报销数据"); - } + $admin_id = Db::name('ExpenseInterfix')->where('id', $id)->value('admin_id'); + if ($admin_id == $this->uid) { + if (Db::name('ExpenseInterfix')->where('id', $id)->delete() !== false) { + return to_assign(0, "删除成功"); + } else { + return to_assign(1, "删除失败"); + } + } else { + return to_assign(1, "您没权限删除该报销数据"); + } } - //系统操作日志 public function log_list() { @@ -317,23 +315,23 @@ class Api extends BaseController $content = $log->get_log_list($param); return table_assign(0, '', $content); } - + //获取访问记录 public function get_view_data() { $param = get_params(); $first_time = time(); $second_time = $first_time - 86400; - $three_time = $first_time - 86400*365; + $three_time = $first_time - 86400 * 365; $begin_first = strtotime(date('Y-m-d', $first_time) . " 00:00:00"); $end_first = strtotime(date('Y-m-d', $first_time) . " 23:59:59"); $begin_second = strtotime(date('Y-m-d', $second_time) . " 00:00:00"); $end_second = strtotime(date('Y-m-d', $second_time) . " 23:59:59"); - $begin_three = strtotime(date('Y-m-d', $three_time) . " 00:00:00"); + $begin_three = strtotime(date('Y-m-d', $three_time) . " 00:00:00"); $data_first = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_first,$end_first")->select(); $data_second = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_second,$end_second")->select(); - $data_three = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_three,$end_first")->select(); - return to_assign(0, '', ['data_first' => hour_document($data_first), 'data_second' => hour_document($data_second), 'data_three'=>date_document($data_three)]); + $data_three = Db::name('AdminLog')->field('create_time')->whereBetween('create_time', "$begin_three,$end_first")->select(); + return to_assign(0, '', ['data_first' => hour_document($data_first), 'data_second' => hour_document($data_second), 'data_three' => date_document($data_three)]); } } diff --git a/app/home/controller/Article.php b/app/home/controller/Article.php index bc5d3f2..d276eb9 100644 --- a/app/home/controller/Article.php +++ b/app/home/controller/Article.php @@ -36,22 +36,23 @@ class Article extends BaseController $param = get_params(); if (request()->isAjax()) { if (!empty($param['id']) && $param['id'] > 0) { - $data[$param['field']] = $param['value']; - $data['id'] = $param['id']; - $data['update_time'] = time(); - if (!empty($data['title'])) { - try { - validate(ArticleCateCheck::class)->scene('edit')->check($data); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); + try { + validate(ArticleCateCheck::class)->scene('edit')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $note_array = get_article_son($param['id']); + if (in_array($param['pid'], $note_array)) { + return to_assign(1, '父级分类不能是该分类本身或其子分类'); + } else { + $param['update_time'] = time(); + $res = ArticleCate::strict(false)->field(true)->update($param); + if($res){ + add_log('edit', $param['id'], $param); + return to_assign(); } } - $res = ArticleCate::strict(false)->field(true)->update($data); - if ($res) { - add_log('edit', $data['id'], $data); - } - return to_assign(); } else { try { validate(ArticleCateCheck::class)->scene('add')->check($param); @@ -67,7 +68,13 @@ class Article extends BaseController return to_assign(); } } else { + $id = isset($param['id']) ? $param['id'] : 0; $pid = isset($param['pid']) ? $param['pid'] : 0; + if ($id > 0) { + $detail = Db::name('ArticleCate')->where(['id' => $id])->find(); + View::assign('detail', $detail); + } + View::assign('id', $id); View::assign('pid', $pid); return view(); } diff --git a/app/home/controller/Department.php b/app/home/controller/Department.php index e039f56..e6dca68 100644 --- a/app/home/controller/Department.php +++ b/app/home/controller/Department.php @@ -51,6 +51,7 @@ class Department extends BaseController } else { Db::name('Department')->strict(false)->field(true)->update($param); add_log('edit', $param['id'], $param); + return to_assign(); } } else { try { @@ -61,8 +62,8 @@ class Department extends BaseController } $did = Db::name('Department')->strict(false)->field(true)->insertGetId($param); add_log('add', $did, $param); + return to_assign(); } - return to_assign(); } else { $id = isset($param['id']) ? $param['id'] : 0; $pid = isset($param['pid']) ? $param['pid'] : 0; diff --git a/app/home/controller/Note.php b/app/home/controller/Note.php index fd3fdf4..5fedb37 100644 --- a/app/home/controller/Note.php +++ b/app/home/controller/Note.php @@ -33,25 +33,26 @@ class Note extends BaseController //分类添加 public function cate_add() { + $param = get_params(); if (request()->isAjax()) { - $param = get_params(); if (!empty($param['id']) && $param['id'] > 0) { - $data[$param['field']] = $param['value']; - $data['id'] = $param['id']; - $data['update_time'] = time(); - if (!empty($data['title'])) { - try { - validate(NoteCateCheck::class)->scene('edit')->check($data); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); + try { + validate(NoteCateCheck::class)->scene('edit')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $note_array = get_note_son($param['id']); + if (in_array($param['pid'], $note_array)) { + return to_assign(1, '父级分类不能是该分类本身或其子分类'); + } else { + $param['update_time'] = time(); + $res = NoteCate::strict(false)->field(true)->update($param); + if ($res) { + add_log('edit', $param['id'], $param); } + return to_assign(); } - $res = NoteCate::strict(false)->field(true)->update($data); - if ($res) { - add_log('edit', $data['id'], $data); - } - return to_assign(); } else { try { validate(NoteCateCheck::class)->scene('add')->check($param); @@ -67,7 +68,13 @@ class Note extends BaseController return to_assign(); } } else { + $id = isset($param['id']) ? $param['id'] : 0; $pid = isset($param['pid']) ? $param['pid'] : 0; + if ($id > 0) { + $detail = Db::name('NoteCate')->where(['id' => $id])->find(); + View::assign('detail', $detail); + } + View::assign('id', $id); View::assign('pid', $pid); return view(); } diff --git a/app/home/view/article/add.html b/app/home/view/article/add.html index f4f81f2..2d71a2e 100644 --- a/app/home/view/article/add.html +++ b/app/home/view/article/add.html @@ -2,7 +2,7 @@ {block name="body"}
-

新增文章

+

新增知识文章

diff --git a/app/home/view/article/cate.html b/app/home/view/article/cate.html index 14bf900..dae9b05 100644 --- a/app/home/view/article/cate.html +++ b/app/home/view/article/cate.html @@ -10,8 +10,8 @@ {block name="body"}
-
- + 添加分类点击表格内容可编辑 +
+
文章标题 *
@@ -26,14 +26,13 @@ {block name="script"} - {include file="common/layui" base='base' extend="['treeGrid']" callback="init" /} + {include file="common/layui" base='base' extend="['treeGrid','rightpage']" callback="init" /} {/block} \ No newline at end of file diff --git a/app/home/view/article/cate_add.html b/app/home/view/article/cate_add.html index 3d8ada7..e781fd0 100644 --- a/app/home/view/article/cate_add.html +++ b/app/home/view/article/cate_add.html @@ -2,14 +2,16 @@ {block name="body"} - +

知识分类

+ {eq name="$id" value="0"} +
@@ -27,10 +29,37 @@
父级分类*
+ {else/} + + + + + + + + + + + + + +
父级分类* + + 分类名称* + + 排序 + +
描述
+ {/eq}
+ -
{/block} @@ -51,9 +80,8 @@ data:data.field, success:function(e){ if(e.code==0){ - layer.confirm('保存成功,返回列表页吗?', {icon: 3, title:'提示'}, function(index){ - history.back(-1); - layer.close(index); + layer.confirm('保存成功,返回列表页吗?', { icon: 3, title: '提示' }, function (index) { + parent.location.reload(); }); }else{ layer.msg(e.msg); @@ -62,11 +90,6 @@ }) return false; }); - //监听返回 - $('.body-content').on('click','[lay-event="back"]',function () { - history.back(-1); - return false; - }); } {include file="common/layui" base='base' extend="[]" callback="init" /} diff --git a/app/home/view/article/edit.html b/app/home/view/article/edit.html index 4f696b8..13c5c4f 100644 --- a/app/home/view/article/edit.html +++ b/app/home/view/article/edit.html @@ -2,7 +2,7 @@ {block name="body"}
-

编辑文章

+

编辑知识文章

diff --git a/app/home/view/article/index.html b/app/home/view/article/index.html index 72ba83d..39917f7 100644 --- a/app/home/view/article/index.html +++ b/app/home/view/article/index.html @@ -5,7 +5,7 @@
文章标题 *
+

公告分类

+ {eq name="$id" value="0"} +
@@ -23,10 +25,33 @@
父级分类*
+ {else/} + + + + + + + + + +
父级分类* + + 分类名称* + + 排序 + +
+ {/eq}
+ -
{/block} @@ -34,38 +59,31 @@ {block name="script"} - - {include file="common/layui" base='base' extend="[]" callback="init" /} + }); + } + +{include file="common/layui" base='base' extend="[]" callback="init" /} {/block} \ No newline at end of file diff --git a/app/home/view/note/index.html b/app/home/view/note/index.html index f3e0c05..49af80a 100644 --- a/app/home/view/note/index.html +++ b/app/home/view/note/index.html @@ -3,9 +3,6 @@ {block name="body"}
-
- -