Просмотр исходного кода

工单生产进程管理分页

qiuenguang 49 минут назад
Родитель
Сommit
000f550cf9

+ 26 - 2
application/api/controller/Course.php

@@ -147,6 +147,17 @@ class Course extends Api
             $this->error('请求错误');
         }
         $param = $this->request->param();
+        $page = (int)($param['page'] ?? 1);
+        $limit = (int)($param['limit'] ?? 20);
+        if ($page < 1) {
+            $page = 1;
+        }
+        if ($limit < 1) {
+            $limit = 20;
+        }
+        if ($limit > 200) {
+            $limit = 200;
+        }
         $where = [];
         if (!empty($param['order'])) {
             $where['a.Gd_cpdh|a.成品代号'] = ['like', $param['order'] . '%'];
@@ -179,11 +190,19 @@ class Course extends Api
         $this->applyCourseRange($listQuery, 'a.接单日期', $param['接单日期起'] ?? '', $param['接单日期止'] ?? '', true);
         $this->applyCourseRange($listQuery, 'a.交货日期', $param['交货日期起'] ?? '', $param['交货日期止'] ?? '', true);
         $this->applyCourseRange($listQuery, 'b.yj_平张投料', $param['计划投料起'] ?? '', $param['计划投料止'] ?? '');
+        $total = (clone $listQuery)->group('b.Yj_Gdbh,b.yj_Yjno')->count();
         $list = $listQuery
             ->group('b.Yj_Gdbh,b.yj_Yjno')
+            ->order('b.Yj_Gdbh asc, b.yj_Yjno asc')
+            ->limit(($page - 1) * $limit, $limit)
             ->select();
         if (empty($list)) {
-            $this->success('');
+            $this->success('成功', [
+                'total' => (int)$total,
+                'page' => $page,
+                'limit' => $limit,
+                'list' => [],
+            ]);
         }
 
         $orderNos = [];
@@ -242,7 +261,12 @@ class Course extends Api
             }
             unset($list[$key]['yj_Yjno']);
         }
-        $this->success('成功', $list);
+        $this->success('成功', [
+            'total' => (int)$total,
+            'page' => $page,
+            'limit' => $limit,
+            'list' => $list,
+        ]);
     }
 
     /**

+ 0 - 1
application/api/controller/OrderSuperLoss.php

@@ -2323,7 +2323,6 @@ class OrderSuperLoss extends Api
             ->field('a.jjcp_gdbh,a.jjcp_yjno')
             ->group('a.jjcp_gdbh,a.jjcp_yjno')
             ->select();
-
         $i = 0;
         if (empty($list)) {
             $this->error('未搜索到工单入仓数据');