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"} +