kuaifan 5 år sedan
förälder
incheckning
e2ad1412b7

+ 3 - 1
app/Http/Controllers/Api/ChatController.php

@@ -114,6 +114,8 @@ class ChatController extends Controller
      * 消息列表
      *
      * @apiParam {String} username             用户名
+     * @apiParam {Number} [page]               当前页,默认:1
+     * @apiParam {Number} [pagesize]           每页显示数量,默认:20,最大:100
      */
     public function message__lists()
     {
@@ -139,7 +141,7 @@ class ChatController extends Controller
             ->where($whereArray)
             ->orderByDesc('indate')
             ->orderByDesc('id')
-            ->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists, false);
         //
         foreach ($lists['lists'] AS $key => $item) {

+ 2 - 2
app/Http/Controllers/Api/DocsController.php

@@ -59,7 +59,7 @@ class DocsController extends Controller
                 });
             })
             ->orderByDesc('id')
-            ->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('暂无知识库', $lists);
@@ -226,7 +226,7 @@ class DocsController extends Controller
             ->where([
                 ['docs_book.id', $id],
             ])
-            ->orderByDesc('docs_users.id')->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->orderByDesc('docs_users.id')->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的成员');

+ 6 - 6
app/Http/Controllers/Api/ProjectController.php

@@ -67,7 +67,7 @@ class ProjectController extends Controller
             ->join('project_users', 'project_lists.id', '=', 'project_users.projectid')
             ->select(['project_lists.*', 'project_users.isowner', 'project_users.indate as uindate'])
             ->where($whereArray)
-            ->orderByDesc('project_lists.id')->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->orderByDesc('project_lists.id')->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的项目');
@@ -791,7 +791,7 @@ class ProjectController extends Controller
                 ['project_lists.delete', 0],
                 ['project_users.type', '成员'],
             ])
-            ->orderByDesc('project_users.isowner')->orderByDesc('project_users.id')->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->orderByDesc('project_users.isowner')->orderByDesc('project_users.id')->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的成员');
@@ -1248,7 +1248,7 @@ class ProjectController extends Controller
         $lists = $builder->select($selectArray)
             ->where($whereArray)
             ->orderByRaw($orderBy)
-            ->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists, $taskid > 0 ? false : true);
         if (intval(Request::input('statistics')) == 1) {
             $lists['statistics_unfinished'] = $type === '未完成' ? $lists['total'] : DB::table('project_task')->where('projectid', $projectid)->where('delete', 0)->where('archived', 0)->where('complete', 0)->count();
@@ -2035,7 +2035,7 @@ class ProjectController extends Controller
                     ['taskid', '=', $taskid],
                     ['indate', '>', Base::time() - 60]
                 ])
-                ->orderBy('id')->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+                ->orderBy('id')->paginate(Base::getPaginate(100, 20));
             $lists = Base::getPageList($lists, false);
             if (count($lists['lists']) == 0) {
                 return Base::retError('no lists');
@@ -2137,7 +2137,7 @@ class ProjectController extends Controller
         //
         $lists = DB::table('project_files')
             ->where($whereArray)
-            ->orderByRaw($orderBy)->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->orderByRaw($orderBy)->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的文件', $lists);
@@ -2453,7 +2453,7 @@ class ProjectController extends Controller
         $lists = DB::table('project_log')
             ->where($whereArray)
             ->where($whereFunc)
-            ->orderByDesc('indate')->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->orderByDesc('indate')->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的记录', $lists);

+ 2 - 2
app/Http/Controllers/Api/ReportController.php

@@ -274,7 +274,7 @@ class ReportController extends Controller
         $lists = DB::table('report_lists')
             ->where($whereArray)
             ->orderByRaw($orderBy)
-            ->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的汇报', $lists);
@@ -340,7 +340,7 @@ class ReportController extends Controller
             ->select(['report_lists.*'])
             ->where($whereArray)
             ->orderByRaw($orderBy)
-            ->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+            ->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的汇报', $lists);

+ 1 - 1
app/Http/Controllers/Api/UsersController.php

@@ -351,7 +351,7 @@ class UsersController extends Controller
             }
         }
         //
-        $lists = DB::table('users')->where($whereArray)->select(['id', 'identity', 'username', 'nickname', 'userimg', 'profession', 'regdate'])->orderByRaw($orderBy)->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
+        $lists = DB::table('users')->where($whereArray)->select(['id', 'identity', 'username', 'nickname', 'userimg', 'profession', 'regdate'])->orderByRaw($orderBy)->paginate(Base::getPaginate(100, 10));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的团队成员');

+ 11 - 0
app/Module/Base.php

@@ -1939,6 +1939,17 @@ class Base
     }
 
     /**
+     * 获取每页数量
+     * @param $max
+     * @param $default
+     * @param string $inputName
+     * @return mixed
+     */
+    public static function getPaginate($max, $default, $inputName = 'pagesize') {
+        return Min(Max(Base::nullShow(Request::input($inputName), $default), 1), $max);
+    }
+
+    /**
      * 上传文件
      * @param array $param [ type=[文件类型], file=>Request::file, path=>文件路径, fileName=>文件名称, scale=>[压缩原图宽,高, 压缩方式], size=>限制大小KB, autoThumb=>false不要自动生成缩略图 ]
      * @return array [name=>原文件名, size=>文件大小(单位KB),file=>绝对地址, path=>相对地址, url=>全路径地址, ext=>文件后缀名]

+ 1 - 1
package.json

@@ -1,5 +1,5 @@
 {
-    "version": "1.4.20",
+    "version": "1.4.21",
     "name": "wookteam",
     "private": true,
     "scripts": {

+ 34 - 5
resources/assets/js/main/pages/docs.vue

@@ -26,7 +26,9 @@
                                 <div class="docs-title">{{book.title}}</div>
                                 <div class="docs-time">{{$A.formatDate("Y-m-d H:i:s", book.indate)}}</div>
                             </li>
-                            <li v-if="bookLists.length == 0" class="none">{{bookNoDataText}}</li>
+                            <li v-if="bookHasMorePages" class="more" @click="getBookLists">{{$L('加载下一页...')}}</li>
+                            <li v-else-if="bookLoading" class="load"><WLoading/></li>
+                            <li v-else-if="bookLists.length == 0" class="none">{{bookNoDataText}}</li>
                         </ul>
                     </div>
                     <div class="docs-container">
@@ -137,6 +139,19 @@
                         li {
                             padding: 12px;
                             cursor: pointer;
+                            &.more {
+                                text-align: center;
+                                color: #555555;
+                                margin-bottom: 6px;
+                                &:hover {
+                                    color: #333333;
+                                }
+                            }
+                            &.load {
+                                text-align: center;
+                                height: 42px;
+                                margin-bottom: 9px;
+                            }
                             &.none {
                                 background-color: transparent;
                                 text-align: center;
@@ -226,6 +241,8 @@
                 bookLists: [],
                 bookListPage: 1,
                 bookListTotal: 0,
+                bookLoading: false,
+                bookHasMorePages: false,
                 bookNoDataText: "",
 
                 addBookId: 0,
@@ -342,9 +359,15 @@
             getBookLists(resetLoad) {
                 if (resetLoad === true) {
                     this.bookListPage = 1;
+                } else {
+                    if (this.bookHasMorePages === false) {
+                        return;
+                    }
+                    this.bookListPage++;
                 }
-                this.loadIng++;
+                this.bookLoading = true;
                 this.bookNoDataText = this.$L("数据加载中.....");
+                this.bookHasMorePages = false;
                 $A.apiAjax({
                     url: 'docs/book/lists',
                     data: {
@@ -352,21 +375,27 @@
                         pagesize: 20,
                     },
                     complete: () => {
-                        this.loadIng--;
+                        this.bookLoading = false;
                     },
                     error: () => {
                         this.bookNoDataText = this.$L("数据加载失败!");
                     },
                     success: (res) => {
                         if (res.ret === 1) {
-                            this.bookLists = res.data.lists;
+                            res.data.lists.forEach((item) => {
+                                let find = this.bookLists.find((t)=>{return t.id==item.id});
+                                if (!find) {
+                                    this.bookLists.push(item);
+                                }
+                            });
                             this.bookListTotal = res.data.total;
                             this.bookNoDataText = this.$L("没有相关的数据");
+                            this.bookHasMorePages = res.data.hasMorePages;
                             if (typeof this.selectBookData.id === "undefined") {
                                 this.selectBookData = this.bookLists[0];
                                 this.getSectionLists();
                             }
-                        }else{
+                        } else {
                             this.bookLists = [];
                             this.bookListTotal = 0;
                             this.bookNoDataText = res.msg;