瀏覽代碼

生产管理

tincey 3 年之前
父節點
當前提交
bc5d3611aa

+ 17 - 16
application/admin/controller/Product.php

@@ -60,10 +60,9 @@ class Product extends Backend
                     ->paginate($limit);
 
             foreach ($list as $row) {
-                $row->visible(['id','time','height','material','status']);
+                $row->visible(['id','time','weight','material','status']);
                 
             }
-//            halt($list->items());
             $result = array("total" => $list->total(), "rows" => $list->items());
 
             return json($result);
@@ -74,7 +73,10 @@ class Product extends Backend
     //获取生产批次号等相关信息
     public function ajax(){
         $bach = $this->request->post('bach');
-        $bach_info = Db::name('task')->where('bach',$bach)->find();
+
+        $str = explode(';',$bach);
+        $batch = $str[(count($str))-1];
+        $bach_info = Db::name('task')->where('bach',$batch)->find();
         Cache::set('bach',serialize($bach_info),0);
         return json($bach_info);
     }
@@ -83,11 +85,10 @@ class Product extends Backend
     public function get_formula(){
         $bach = unserialize(Cache::get('bach'));
         $formula = $this->request->post('formula');
-        $res = Db::name('formula_detail')->where('pid = '.$bach['fid'].' and material like "%'.$formula.'%"')->select();
+        $form = Db::name('formula')->find($bach['fid']);
+        $res = Db::name('formula_detail')->where('pid = '.$bach['fid'].' and material like "%'.$formula.'%" and version = "'.$form['version'].'"')->select();
         $arr = [];
-
         if(!$res){
-            $arr['time'] = date("Y-m-d H:i:s");
             $arr['material'] = $formula;
             $arr['error']=1;
         }
@@ -95,10 +96,12 @@ class Product extends Backend
             if($v['is_replace']==1){
                 $v['material'] = Db::name('formula_replace')->where('fid',$v['id'])->where('material',$formula)->order('id','desc')->value('material');
             }
-            $v['time'] = date("Y-m-d H:i:s");
             $arr=$v;
             $arr['error']=0;
         }
+        $arr['pname']  = $bach['name'];
+        $arr['time'] = date("Y-m-d H:i:s");
+        $arr['bach'] = $bach['bach'];
         return json($arr);
     }
     public function add()
@@ -111,19 +114,17 @@ class Product extends Backend
             $this->error(__('Parameter %s can not be empty', ''));
         }
         $arr = [];
-        $time = date("Y-m-d H:i:s");
         foreach($params['material'] as $k=>$v){
             $arr[$k]['status'] = $params['status'];
-            $arr[$k]['batch'] = $params['batch'];
-            $arr[$k]['pname'] = $params['pname'];
-            $arr[$k]['specifications'] = $params['specifications'];
-            $arr[$k]['time'] = $time;
+            $arr[$k]['batch'] = $params['batch'][$k];
+            $arr[$k]['pname'] = $params['pname'][$k];
+            $arr[$k]['specifications'] = $params['specifications'][$k];
+            $arr[$k]['time'] = $params['time'][$k];
             $arr[$k]['audit'] = $params['audit'];
-            $arr[$k]['unit'] = $params['unit'];
-            $arr[$k]['material'] = $v;
-            $arr[$k]['height'] = $params['height'][$k];
+            $arr[$k]['unit'] = $params['unit'][$k];
+            $arr[$k]['material'] = $params['material'][$k];
+            $arr[$k]['weight'] = $params['weight'][$k];
         }
-//        halt($arr);
         $result = $this->model->saveAll($arr);
         if ($result === false) {
             $this->error(__('No rows were inserted'));

+ 4 - 4
application/admin/lang/zh-cn/product.php

@@ -2,14 +2,14 @@
 
 return [
     'Time'           => '创建时间',
-    'Height'         => '重量',
+    'Weight'         => '重量',
     'Batch'          => '生产批次号',
-    'Pname'          => '产品名称',
+    'Pname'          => '配方名称',
     'Specifications' => '包装规格',
     'Audit'          => '审核人',
     'Unit'           => '机组',
     'Material'       => '原材料编号',
-    'Status'         => '料/退料',
-    'Status 1'       => '料',
+    'Status'         => '料/退料',
+    'Status 1'       => '料',
     'Status 2'       => '退料'
 ];

+ 2 - 2
application/admin/model/Product.php

@@ -49,10 +49,10 @@ class Product extends Model
         return isset($list[$value]) ? $list[$value] : '';
     }
 
-    protected function setTimeAttr($value)
+    /*protected function setTimeAttr($value)
     {
         return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
-    }
+    }*/
 
 
 }

+ 1 - 1
application/admin/view/index/login.html

@@ -227,7 +227,7 @@
                 console.log(res);
             })
         }else{
-            layer.msg('请输入正确的手机号');
+            layer.confirm('请输入正确的手机号');
         }
     })
     //如果有缓存,读缓存,,,

+ 10 - 6
application/admin/view/product/add.html

@@ -1,6 +1,6 @@
 <script src="__CDN__/assets/js/jquery.js"></script>
 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
-    <input type="hidden" name="row[status]" value="{$_GET['status']}">
+    <input type="hidden" id="status" name="row[status]" value="{$_GET['status']}">
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Batch')}:</label>
         <div class="col-xs-12 col-sm-3">
@@ -17,10 +17,10 @@
         <div class="col-xs-12 col-sm-3">
             <input id="c-specifications" readonly class="form-control" name="row[specifications]" type="text">
         </div>
-        <label class="control-label col-xs-12 col-sm-2">{:__('Time')}:</label>
+        <!--<label class="control-label col-xs-12 col-sm-2">{:__('Time')}:</label>
         <div class="col-xs-12 col-sm-3">
             <input id="c-time" data-rule="required" readonly class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[time]" type="text" value="{:date('Y-m-d H:i:s')}">
-        </div>
+        </div>-->
     </div>
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Audit')}:</label>
@@ -59,9 +59,13 @@
     <div class="form-group">
         <table class="table table-striped table-bordered table-hover table-nowrap" id="table">
             <tr>
-                <th class="col-xs-12 col-sm-3">物料编号</th>
-                <th class="col-xs-12 col-sm-3">重量</th>
-                <th class="col-xs-12 col-sm-4">日期</th>
+                <th class="col-xs-12 col-sm-1">批次号</th>
+                <th class="col-xs-12 col-sm-3">配方名称</th>
+                <th class="col-xs-12 col-sm-1">物料编号</th>
+                <th class="col-xs-12 col-sm-1">包装规格</th>
+                <th class="col-xs-12 col-sm-1">重量</th>
+                <th class="col-xs-12 col-sm-2">机组</th>
+                <th class="col-xs-12 col-sm-2">日期</th>
                 <th class="col-xs-12 col-sm-2">操作</th>
             </tr>
         </table>

+ 15 - 38
public/assets/js/backend/product.js

@@ -31,7 +31,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','editable'], function
                         {checkbox: true},
                         // {field: 'id', title: __('Id')},
                         {field: 'material', title: __('Material'), operate: 'LIKE'},
-                        {field: 'height', title: __('Height'),operate: 'LIKE'},
+                        {field: 'weight', title: __('Weight'),operate: 'LIKE'},
                         {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.normal},
                         {field: 'time', title: __('Time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
@@ -56,6 +56,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','editable'], function
                             bach:$("#c-batch").val()
                         },
                         success(res){
+                            $("#c-batch").val($("#c-batch").val()+';');
                             $("#c-time").val(res.create);
                             $("#c-audit").val(res.examine_name);
                             $("#c-pname").val(res.name);
@@ -75,17 +76,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','editable'], function
                             formula: $("#wuliao").val(),
                         },
                         success(res) {
-                            str += "<tr><td><input class='form-control' type='text' name='row[material][]' readonly value='"+res.material+"'></td>";
-                            str += "<td><input class='form-control' type='number' name='row[height][]' data-rule='required' value=''></td>";
+                            str += "<tr><td><input class='form-control' type='text' name='row[batch][]' readonly value='"+res.bach+"'></td>";
+                            str += "<td><input class='form-control' type='text' name='row[pname][]' readonly value='"+res.pname+"'></td>";
+                            str += "<td><input class='form-control' type='text' name='row[material][]' readonly value='"+res.material+"'></td>";
+                            str += "<td><input class='form-control' type='text' name='row[specifications][]' value='"+ (res.specifications?res.specifications:'')+"'></td>";
+                            str += "<td><input class='form-control' type='number' name='row[weight][]' data-rule='required' value=''></td>";
+                            str += "<td><input class='form-control' type='text' name='row[unit][]'  value=''></td>";
                             str += "<td><input class='form-control' type='text' name='row[time][]' readonly value='"+res.time+"'></td>";
                             str += '<td><button type="button" class="btn btn-danger del">删除</button></td></tr>';
                             $("#table").append(str);
                             $("#wuliao").val('');
-                            if(res.error === 1){
-                                Layer.confirm("此物料不在配方中,请确认!");
-                                //语音播报
-                                var msg = new SpeechSynthesisUtterance("此物料不在配方中,请确认!");
-                                window.speechSynthesis.speak(msg);
+                            if($("#status").val()==1){
+                                if(res.error === 1){
+                                    Layer.confirm("此物料不在配方中,请确认!");
+                                    //语音播报
+                                    var msg = new SpeechSynthesisUtterance("此物料不在配方中,请确认!");
+                                    window.speechSynthesis.speak(msg);
+                                }
                             }
                         }
                     });
@@ -101,36 +108,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','editable'], function
                     return false;
                 }
             });
-            /**
-             * 播报
-             * @param {Object} text 播放内容
-             */
-            startSpeech = (text)=>{
-                const speech = new SpeechSynthesisUtterance()
-                // 设置播放内容
-                speech.text = text
-                // 设置话语的音调(0-2 默认1,值越大越尖锐,越低越低沉)
-                speech.pitch = 0.8
-                // 设置说话的速度(0.1-10 默认1,值越大语速越快,越小语速越慢)
-                speech.rate = 1
-                // 设置说话的音量
-                speech.volume = 10
-                // 设置播放语言
-                speech.lang = 'zh-CN'
-
-                // 播放结束后调用
-                speech.onend = (event)=>{
-
-                }
-                // 加入播放队列
-                window.speechSynthesis.speak(speech);
-            };
-            /**
-             * 停止播报,停止所有播报队列里面的语音
-             */
-            stopSpeech = () => {
-                window.speechSynthesis.cancel();
-            };
             Controller.api.bindevent();
         },
         edit: function () {