tincey 3 жил өмнө
parent
commit
e1d2403865

+ 15 - 2
application/admin/controller/Stock.php

@@ -24,7 +24,7 @@ class Stock extends Backend
      */
     protected $model = null;
     protected $importHeadType = 'name';//以字段名为EXCEL表格首行
-
+    protected $noNeedLogin = ['warning'];
     public function _initialize()
     {
         parent::_initialize();
@@ -66,7 +66,20 @@ class Stock extends Backend
             ->where($map)
             ->order($sort, $order)
             ->paginate($limit);
-        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        //数量低于L库存标识为1
+        foreach($list as &$v){
+            if($v['l_number']>=$v['number']){
+                $v['warning']=1;
+            }else{
+                $v['warning']=0;
+            }
+        }
+        $res = $list->items();
+        //低于L库存的排在顶部
+        $pros4 = array_column($list->items(), 'warning');
+        $pros5 = array_column($list->items(), 'id');
+        array_multisort($pros4,SORT_DESC,$pros5,SORT_DESC,$res);
+        $result = ['total' => $list->total(), 'rows' => $res];
         return json($result);
     }
     /**

+ 8 - 0
public/assets/js/backend/stock.js

@@ -22,6 +22,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 url: $.fn.bootstrapTable.defaults.extend.index_url,
                 pk: 'id',
                 sortName: 'id',
+                rowStyle:Controller.api.rowStyle,
                 columns: [
                     [
                         {checkbox: true},
@@ -50,6 +51,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         api: {
             bindevent: function () {
                 Form.api.bindevent($("form[role=form]"));
+            },
+            rowStyle:function(row,index){
+                var style = {};
+                if(row.warning){
+                    style={css:{'color':'#ff0000'}};
+                }
+                return style;
             }
         }
     };