diff --git a/app/home/controller/Files.php b/app/home/controller/Files.php new file mode 100644 index 0000000..95b585f --- /dev/null +++ b/app/home/controller/Files.php @@ -0,0 +1,176 @@ +isAjax()) { + $param = get_params(); + $where = array(); + $fileext = ['','jpg,jpeg,png,gif','mp4','doc,docx,xls,xlsx,ppt,pptx,txt,pdf','zip,rar,7z']; + if (!empty($param['keywords'])) { + $where[] = ['f.name|g.title', 'like', '%' . $param['keywords'] . '%']; + } + if (isset($param['group_id']) && $param['group_id']!='') { + $where[] = ['f.group_id','=',$param['group_id']]; + } + if (!empty($param['tab'])) { + $where[] = ['f.fileext','in',$fileext[$param['tab']]]; + } + $where[] = ['f.delete_time','=',0]; + $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; + $list = DB::name('File') + ->field("f.*,a.name as admin_name,g.title as group_title") + ->alias('f') + ->join('Admin a', 'f.admin_id = a.id','left') + ->join('FileGroup g', 'f.group_id = g.id','left') + ->order('f.create_time desc') + ->where($where) + ->paginate($rows, false, ['query' => $param]) + ->each(function($item, $key){ + $item['create_time'] = date('Y-m-d H:i:s', $item['create_time']); + return $item; + }); + return table_assign(0, '', $list); + } else { + return view(); + } + } + //编辑 + public function edit() + { + if (request()->isAjax()) { + $param = get_params(); + if (Db::name('File')->where('id',$param['id'])->update(['name'=>$param['title']]) !== false) { + add_log('edit', $param['id'], []); + return to_assign(0, "操作成功"); + } else { + return to_assign(1, "操作失败"); + } + } + } + + //移动 + public function move() + { + if (request()->isAjax()) { + $group_id = get_params("group_id"); + $ids = get_params("ids"); + $idArray = explode(',', strval($ids)); + $list = []; + foreach ($idArray as $key => $val) { + $list[] = [ + 'id' => $val, + 'group_id' => $group_id, + 'update_time' => time() + ]; + } + $res = (new File())->saveAll($list); + if ($res!== false) { + return to_assign(0, "操作成功"); + } else { + return to_assign(1, "操作失败"); + } + } + } + //删除 + public function delete() + { + if (request()->isDelete()) { + $ids = get_params("ids"); + $idArray = explode(',', strval($ids)); + $list = []; + foreach ($idArray as $key => $val) { + $list[] = [ + 'id' => $val, + 'delete_time' => time() + ]; + } + $res = (new File())->saveAll($list); + if ($res!== false) { + return to_assign(0, "删除成功"); + } else { + return to_assign(1, "删除失败"); + } + } else { + return to_assign(1, "错误的请求"); + } + } + + //获取分组 + public function get_group() + { + $list = Db::name('FileGroup')->where([['delete_time','=',0]])->select()->toArray(); + return to_assign(0, '',$list); + } + //添加&编辑 + public function add_group() + { + if (request()->isAjax()) { + $param = get_params(); + if($param['title'] == '全部' || $param['title']=='未分组'){ + return to_assign(1, '该分组名称已经存在'); + } + if (!empty($param['id']) && $param['id'] > 0) { + $count = Db::name('FileGroup')->where([['id','<>',$param['id']],['delete_time','=',0],['title','=',$param['title']]])->count(); + if ($count > 0) { + return to_assign(1, '该分组名称已经存在'); + } + $res = Db::name('FileGroup')->where(['id' => $param['id']])->strict(false)->field(true)->update($param); + if($res!=false){ + add_log('edit', $param['id'], $param); + return to_assign(0,'编辑成功',$param['id']); + }else{ + return to_assign(1,'操作失败'); + } + } else { + $count = Db::name('FileGroup')->where([['delete_time','=',0],['title','=',$param['title']]])->count(); + if ($count > 0) { + return to_assign(1, '该分组名称已经存在'); + } + $gid = Db::name('FileGroup')->strict(false)->field(true)->insertGetId($param); + if($gid!=false){ + add_log('add', $gid, $param); + return to_assign(0,'添加成功',$gid); + }else{ + return to_assign(1,'操作失败'); + } + } + } + } + + //删除 + public function del_group() + { + if (request()->isDelete()) { + $id = get_params("id"); + $count = Db::name('File')->where(["group_id" => $id])->count(); + if ($count > 0) { + return to_assign(1, "该分组还存在文件,请去除文件或者转移文件后再删除"); + } + if (Db::name('FileGroup')->delete($id) !== false) { + add_log('delete', $id, []); + return to_assign(0, "删除成功"); + } else { + return to_assign(1, "删除失败"); + } + } else { + return to_assign(1, "错误的请求"); + } + } +} diff --git a/app/home/model/File.php b/app/home/model/File.php new file mode 100644 index 0000000..4a71e72 --- /dev/null +++ b/app/home/model/File.php @@ -0,0 +1,16 @@ + + body { display: flex; overflow: hidden; height: 100vh; } + ::-webkit-scrollbar { display: none; width: 6px; height: 6px; } + ::-webkit-scrollbar-thumb { border-radius: 10px; background-color: #e1e1e1; } + .layui-tab{margin:0;} + .container { display: flex; flex: 1; flex-direction: column; overflow: hidden; padding:12px;} + .file-container { display: flex; flex: 1; flex-direction: column; overflow: hidden; border-radius: 2px; background: #ffffff; box-shadow: rgba(0, 0, 0, 0.05) 0 1px 2px 0; } + .file-item {display: flex; flex: 1; justify-content: space-between; overflow: hidden; } + .file-header {padding-top: 4px; } + + /** 分组 **/ + .file-item .group { position: relative; display: flex; flex-direction: column; padding-top: 8px; width: 200px; border-right: 1px solid #f6f6f6; } + .file-item .group ul::-webkit-scrollbar { display: block; } + .file-item .group ul { flex: 1; overflow: hidden; overflow-y: auto; } + .file-item .group ul li {display: flex; align-items: center; justify-content: space-between; cursor:pointer; padding: 0 12px; height: 38px; font-size: 13px; color: #666666; } + .file-item .group ul li i.iconfont{ margin-right:8px; font-size:24px; color:#E1AF1A; font-weight:800;} + .file-item .group ul li > span { display: flex; flex: 1; overflow: hidden; margin-right: 0.5rem; text-overflow: ellipsis; white-space: nowrap; } + .file-item .group ul li.active { background: #edefff; } + .file-item .group ul li:hover { background: #f5f7fa; } + .file-item .group ul li .dropdown:hover dl { display: block; } + .file-item .group ul li .dropdown dl { position: absolute; top: 36px; right: -15px; z-index: 10000; display: none; padding: 5px 0; width: 88px; border-radius: 2px; text-align: center; background-color: #ffffff; box-shadow: #cccccc 0 0 10px; } + .file-item .group ul li .dropdown dl dd { height: 32px; line-height: 32px; } + .file-item .group ul li .dropdown dl dd:hover { color: #4a5dff; background-color: #edefff; } + .file-item .group ul li .dropdown dl::before { position: absolute; top: -16px; left: 44px; z-index: 12; display: block; padding: 0; width: 0; height: 0; border-top: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 8px solid #ffffff; border-left: 8px solid transparent; content: ""; box-sizing: content-box; } + .file-item .group .footer { display: flex; align-items: center; justify-content: center; width: 100%; height: 50px; border-top: 1px solid #f2f2f2; border-right: 1px solid #f2f2f2; } + + /** 菜单 **/ + .file-item .attach #move:hover { position: relative; opacity: 1; } + .file-item .attach #move:hover .dropdown { display: block; background-color: #ffffff; } + .file-item .attach .dropdown { position: absolute; top: 38px; z-index: 100000; display: none; padding: 5px 0; width: 150px; border: 1px solid #dddddd; text-align: left; background-color: #ffffff; line-height: 1.6; } + .file-item .attach .dropdown em { font-size: 13px; font-weight: 400; color: #333333; font-style: normal; } + .file-item .attach .dropdown em { display: block; clear: both; padding: 6px 20px; white-space: nowrap; } + .file-item .attach .dropdown em:hover { background: #eeeeee; } + .file-item .attach .dropdown em:first-child { font-size: 12px; color: #999999; } + .file-item .attach .dropdown::before { position: absolute; top: -16px; left: 21px; z-index: 12; display: block; padding: 0; width: 0; height: 0; border-top: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 8px solid #ffffff; border-left: 8px solid transparent; content: ""; box-sizing: content-box; } + .file-item .attach .dropdown::after { position: absolute; top: -18px; left: 20px; z-index: 10; display: block; padding: 0; width: 0; height: 0; border-top: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 9px solid #cccccc; border-left: 9px solid transparent; content: ""; box-sizing: content-box; } + + /** 文件 **/ + .file-item .attach { position: relative; display: flex; flex: 1; flex-direction: column; } + .file-item .attach .header { display: flex; align-items: center; justify-content: space-between; padding:12px 15px; margin:0;} + .file-item .attach .header .search{ display: flex; } + .file-item .attach .header .search input { height: 30px; border-color: #eeeeee; border-top-right-radius: 0; border-bottom-right-radius: 0; } + .file-item .attach .header .search button { border-color: #eeeeee; background: #f5f7fa; border-top-left-radius: 0; border-bottom-left-radius: 0; } + .file-item .attach .header .search button:hover { background-color: #eeeeef; } + .file-item .attach .subject { flex: 1; overflow: hidden; overflow-y: auto; margin: 10px; box-sizing: border-box; } + .file-item .attach .subject:hover::-webkit-scrollbar { display: block; } + .file-item .attach .subject ul { display: flex; flex-wrap: wrap; } + .file-item .attach .subject ul li { position: relative; height: 120px; margin: 5px; padding: 9px; border: 1px solid rgba(0, 0, 0, 0.05); border-radius: 3px; transition: all 0.2s ease-in-out; } + .file-item .attach .subject ul li:hover {border: 1px solid #cccccc; } + .file-item .attach .subject ul li.on {border: 1px solid #ff5722; } + .file-item .attach .subject ul li img { width: 100px; height: 100px; border-radius: 2px; } + .file-item .attach .subject ul li video { width: 100px; height: 100px; border-radius: 3px; } + .file-item .attach .subject ul li p { overflow: hidden; margin: 5px 0 0; width: 98px; font-size: 13px; text-align: center; text-overflow: ellipsis; white-space: nowrap; } + .file-item .attach .subject ul li::after {position: absolute; width:22px; height:22px; right: -1px; bottom: -1px; display: none; font-size: 14px; font-family: layui-icon, serif; border-radius:3px 0 3px 0; text-align: center; color: #ffffff; background: #ff5722; content: "\e605"; line-height: 24px; } + .file-item .attach .subject ul li.on::after { display: block; } + .file-item .attach .subject ul li .layui-btn-group{position:absolute; top:3px; right:3px; display:none;} + .file-item .attach .subject ul li:hover .layui-btn-group{display:block} + + .file-item .attach .footer { display: flex; align-items: center; justify-content: end; padding: 5px 15px 0; height: 45px; border-top: 1px solid #f2f2f2; text-align: center; background: #ffffff; } + + /** 无数据 **/ + .file-item .empty { display: flex; flex: 1; align-items: center; flex-direction: column; justify-content: center; overflow: hidden; text-align: center; color: #cccccc; } + .file-item .empty i { font-size: 180px; } + .file-item .empty p { width: 180px; text-align: center; } + +{/block} + +{block name="body"} +
+
+
+
+
    +
  • 全部
  • +
  • 图片
  • +
  • 视频
  • +
  • 文档
  • +
  • 压缩包
  • +
+
+
+
+ +
+
    +
  • 全部
  • +
  • 未分组
  • +
+ +
+ +
+ +
+
+
+ 上传文件 + 批量删除 + 移动至 + +
+ + +
+
+ +
+
    +
    + + +
    +
    +
    +
    + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/install/data/gouguoa.sql b/app/install/data/gouguoa.sql index 75b5f33..67e8861 100644 --- a/app/install/data/gouguoa.sql +++ b/app/install/data/gouguoa.sql @@ -374,7 +374,13 @@ INSERT INTO `oa_admin_rule` VALUES (193, 192, 'article/index/add', '新建/编 INSERT INTO `oa_admin_rule` VALUES (194, 192, 'article/index/view', '查看', '知识文章', 'article', '', 2, 0, 1, 1656143065, 0); INSERT INTO `oa_admin_rule` VALUES (195, 192, 'article/index/delete', '删除', '知识文章', 'article', '', 2, 0, 1, 1656143065, 0); - +INSERT INTO `oa_admin_rule` VALUES (196, 2, 'home/files/index', '附件管理','附件管理', 'home', '', 1, 1, 1, 0, 0); +INSERT INTO `oa_admin_rule` VALUES (197, 196, 'home/files/edit', '编辑附件','附件', 'home', '', 2, 1, 1, 0, 0); +INSERT INTO `oa_admin_rule` VALUES (198, 196, 'home/files/move', '移动附件','附件', 'home', '', 2, 1, 1, 0, 0); +INSERT INTO `oa_admin_rule` VALUES (199, 196, 'home/files/delete', '删除附件','附件', 'home', '', 2, 1, 1, 0, 0); +INSERT INTO `oa_admin_rule` VALUES (200, 196, 'home/files/get_group', '附件分组','附件分组', 'home', '', 2, 1, 1, 0, 0); +INSERT INTO `oa_admin_rule` VALUES (201, 196, 'home/files/add_group', '新建/编辑','附件分组', 'home', '', 2, 1, 1, 0, 0); +INSERT INTO `oa_admin_rule` VALUES (202, 196, 'home/files/del_group', '删除附件分组','附件分组', 'home', '', 2, 1, 1, 0, 0); -- ---------------------------- -- Table structure for oa_admin_group -- ---------------------------- @@ -395,9 +401,9 @@ CREATE TABLE `oa_admin_group` ( -- ---------------------------- -- Records of oa_admin_group -- ---------------------------- -INSERT INTO `oa_admin_group` VALUES (1, '超级员工权限', 1, '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195', '1,2,3,4,5,6,7,8,9,10,11,12','超级员工权限,拥有系统的最高权限,不可修改。', 0, 0); -INSERT INTO `oa_admin_group` VALUES (2, '总经理权限', 1, '1,9,13,17,20,23,25,26,30,2,34,37,41,44,47,50,53,56,59,3,62,65,68,69,71,74,76,4,79,82,85,5,88,91,92,93,94,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195','1,2,3,4,5,6,7,8,9,10,11,12', '总经理的管理权限,可根据公司的具体需求调整。', 0, 0); -INSERT INTO `oa_admin_group` VALUES (3, '普通员工权限', 1, '5,88,91,92,93,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195','1,2,3,4,5,6,7,8,9,10,11,12', '普通员工管理权限,可根据公司的具体需求调整。', 0, 0); +INSERT INTO `oa_admin_group` VALUES (1, '超级员工权限', 1, '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202', '1,2,3,4,5,6,7,8,9,10,11,12','超级员工权限,拥有系统的最高权限,不可修改。', 0, 0); +INSERT INTO `oa_admin_group` VALUES (2, '总经理权限', 1, '1,9,13,17,20,23,25,26,30,2,34,37,41,44,47,50,53,56,59,3,62,65,68,69,71,74,76,4,79,82,85,5,88,91,92,93,94,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202','1,2,3,4,5,6,7,8,9,10,11,12', '总经理的管理权限,可根据公司的具体需求调整。', 0, 0); +INSERT INTO `oa_admin_group` VALUES (3, '普通员工权限', 1, '5,88,91,92,93,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202','1,2,3,4,5,6,7,8,9,10,11,12', '普通员工管理权限,可根据公司的具体需求调整。', 0, 0); -- ---------------------------- -- Table structure for oa_data_auth @@ -828,6 +834,20 @@ CREATE TABLE `oa_expense_interfix` ( PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '报销关联数据表'; +-- ---------------------------- +-- Table structure for oa_file_group +-- ---------------------------- +DROP TABLE IF EXISTS `oa_file_group`; +CREATE TABLE `oa_file_group` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `title` varchar(255) NOT NULL DEFAULT '' COMMENT '分组名', + `admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人', + `create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间', + `update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间', + `delete_time` int(11) NOT NULL DEFAULT 0 COMMENT '删除时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '文件分组表'; + -- ---------------------------- -- Table structure for oa_file -- ---------------------------- @@ -843,11 +863,13 @@ CREATE TABLE `oa_file` ( `filesize` int(10) NOT NULL DEFAULT 0 COMMENT '文件大小', `fileext` varchar(10) NOT NULL DEFAULT '' COMMENT '文件后缀', `mimetype` varchar(100) NOT NULL DEFAULT '' COMMENT '文件类型', + `group_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '文件分组ID', `user_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '上传会员ID', `uploadip` varchar(15) NOT NULL DEFAULT '' COMMENT '上传IP', `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0未审核1已审核-1不通过', `create_time` int(11) NOT NULL DEFAULT 0, `admin_id` int(11) NOT NULL COMMENT '审核者id', + `delete_time` int(11) NOT NULL DEFAULT 0 COMMENT '删除时间', `audit_time` int(11) NOT NULL DEFAULT 0 COMMENT '审核时间', `action` varchar(50) NOT NULL DEFAULT '' COMMENT '来源模块功能', `use` varchar(255) NULL DEFAULT NULL COMMENT '用处',