From 6cabfc40d57be63d1caed6181064235cf8879bc8 Mon Sep 17 00:00:00 2001 From: hdm Date: Sun, 20 Nov 2022 01:10:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9F=A5=E8=AF=86=E5=88=86?= =?UTF-8?q?=E4=BA=AB=EF=BC=8C=E4=BC=98=E5=8C=96=E9=80=89=E6=8B=A9=E9=83=A8?= =?UTF-8?q?=E9=97=A8=EF=BC=8C=E5=B2=97=E4=BD=8D=E9=80=89=E6=8B=A9=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Index.php | 7 + app/article/controller/Index.php | 43 ++++- app/article/view/index/add.html | 187 ++++++++++++++------ app/article/view/index/edit.html | 134 +++++++++++--- app/article/view/index/list.html | 2 +- app/article/view/index/view.html | 16 ++ app/install/data/gouguoa.sql | 5 +- public/static/assets/gougu/module/oaTool.js | 121 ++++++++++++- 8 files changed, 426 insertions(+), 89 deletions(-) diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php index 0758ed5..7ec7db6 100644 --- a/app/api/controller/Index.php +++ b/app/api/controller/Index.php @@ -146,6 +146,13 @@ class Index extends BaseController } } + //获取部门 + public function get_department() + { + $department = get_department(); + return to_assign(0, '', $department); + } + //获取部门树形节点列表 public function get_department_tree() { diff --git a/app/article/controller/Index.php b/app/article/controller/Index.php index 1555449..608314a 100644 --- a/app/article/controller/Index.php +++ b/app/article/controller/Index.php @@ -22,7 +22,10 @@ class Index extends BaseController { if (request()->isAjax()) { $param = get_params(); + $uid = $this->uid; + $did = $this->did; $where = array(); + $whereOr = array(); if (!empty($param['keywords'])) { $where[] = ['a.id|a.title|a.keywords|a.desc|a.content|c.title', 'like', '%' . $param['keywords'] . '%']; } @@ -30,9 +33,16 @@ class Index extends BaseController $where[] = ['a.cate_id', '=', $param['cate_id']]; } $where[] = ['a.delete_time', '=', 0]; - $where[] = ['a.is_share', '=', 1]; + + $whereOr[] = ['a.is_share', '=', 1]; + $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$did}',a.share_dids)")]; + $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',a.share_uids)")]; + $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $content = ArticleList::where($where) + ->where(function ($query) use($whereOr) { + $query->whereOr($whereOr); + }) ->field('a.*,a.id as id,c.title as cate_title,a.title as title,d.title as department,u.name as user') ->alias('a') ->join('article_cate c', 'a.cate_id = c.id') @@ -156,6 +166,20 @@ class Index extends BaseController View::assign('id', $id); if ($id > 0) { $article = (new ArticleList())->detail($id); + if($article['file_ids'] !=''){ + $fileArray = Db::name('File')->where('id','in',$article['file_ids'])->select(); + $article['fileArray'] = $fileArray; + } + $article['share_depaments'] = ''; + if($article['share_dids'] !=''){ + $depamentArray = Db::name('Department')->where('id','in',$article['share_dids'])->column('title'); + $article['share_depaments'] = implode(',',$depamentArray); + } + $article['share_names'] = ''; + if($article['share_uids'] !=''){ + $uidArray = Db::name('Admin')->where('id','in',$article['share_uids'])->column('name'); + $article['share_names'] = implode(',',$uidArray); + } View::assign('article', $article); return view('edit'); } @@ -167,8 +191,25 @@ class Index extends BaseController public function view() { $id = get_params("id"); + $uid=$this->uid; + $did=$this->did; $detail = (new ArticleList())->detail($id); + $share_uids = []; + if(!empty($detail['share_uids'])){ + $share_uids = explode(',', $detail['share_uids']); + } + $share_dids = []; + if(!empty($detail['share_dids'])){ + $share_uids = explode(',', $detail['share_dids']); + } + if($detail['uid'] !=$uid && !in_array($uid,$share_uids) && !in_array($did,$share_dids) && $detail['is_share'] !=1){ + throw new \think\exception\HttpException(405, '无权限访问'); + } $detail['cate_title'] = Db::name('ArticleCate')->where(['id' => $detail['cate_id']])->value('title'); + if($detail['file_ids'] !=''){ + $fileArray = Db::name('File')->where('id','in',$detail['file_ids'])->select(); + $detail['fileArray'] = $fileArray; + } // read 字段加 1 Db::name('article')->where('id', $id)->inc('read')->update(); View::assign('detail', $detail); diff --git a/app/article/view/index/add.html b/app/article/view/index/add.html index e3ffc98..1ef3efa 100644 --- a/app/article/view/index/add.html +++ b/app/article/view/index/add.html @@ -4,53 +4,82 @@

新增知识文章

- - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
文章标题*文章分类* - -
关键字* - - - 属性 - -
是否共享 - - - 状态 - - - 排序 - -
文章标题*文章分类* + +
关键字* + + + 属性 + +
共享设置 + + + + + 状态 + + + 排序 + +
+
关联附件
+
+ +
+
+
+ +
+
文章摘要 @@ -85,16 +114,38 @@ {block name="script"}