Selaa lähdekoodia

刘功能优化

liuhairui 3 vuotta sitten
vanhempi
commit
e3c17ac2d1
2 muutettua tiedostoa jossa 38 lisäystä ja 37 poistoa
  1. 26 25
      application/admin/controller/Product.php
  2. 12 12
      public/assets/js/backend/product.js

+ 26 - 25
application/admin/controller/Product.php

@@ -78,7 +78,7 @@ class Product extends Backend
         $str = explode(';',$bach);
         $batch = $str[(count($str))-1];
         $bach_info = Db::name('task')->where('bach',$batch)->find();
-//        Cache::set('bach',serialize($bach_info),0);
+        Cache::set('bach',serialize($bach_info),0);
         $form = Db::name('formula')->find($bach_info['fid']);
 //        $res = Db::name('formula_detail')->where('pid = '.$bach_info['fid'].' and version = "'.$form['version'].'"')->field('id,pid,material,version,is_replace,gy_name')->select();
         $res = Db::name('formula_detail')->where('pid',$bach_info['fid'])->where('version',$form['version'])->field('id,pid,material,version,is_replace,gy_name')->select();
@@ -101,32 +101,32 @@ class Product extends Backend
     public function get_formula(){
         $bach = unserialize(Cache::get('bach'));//获取配方单信息
         $formula = $this->request->post('formula');//配方名称
-        $data = unserialize(Cache::get('data'));//获取当前批次号缓存数据
+//        $data = unserialize(Cache::get('data'));//获取当前批次号缓存数据
         $arr = [];
         $arr['material']=$formula;
-        foreach($data as $vv) {
-            //没有替代料   error==0为有当前配方,   error==1为没有配方,,前台提示
-            if ($vv['is_replace'] == 0) {
-                if ($vv['material'] == $formula) {
-                    $arr['error'] = 0;
-                    break;
-                } else {
-                    $arr['error'] = 1;
-                }
-            } else {//有替代料
-                foreach ($vv['replace'] as $val) {
-                    if ($val['material'] == $formula) {
-                        $arr['error'] = 0;
-                        break;
-                    } else {
-                        $arr['error'] = 1;
-                    }
-                }
-                if ($arr['error'] == 0) {
-                    break;
-                }
-            }
-        }
+//        foreach($data as $vv) {
+//            //没有替代料   error==0为有当前配方,   error==1为没有配方,,前台提示
+//            if ($vv['is_replace'] == 0) {
+//                if ($vv['material'] == $formula) {
+//                    $arr['error'] = 0;
+//                    break;
+//                } else {
+//                    $arr['error'] = 1;
+//                }
+//            } else {//有替代料
+//                foreach ($vv['replace'] as $val) {
+//                    if ($val['material'] == $formula) {
+//                        $arr['error'] = 0;
+//                        break;
+//                    } else {
+//                        $arr['error'] = 1;
+//                    }
+//                }
+//                if ($arr['error'] == 0) {
+//                    break;
+//                }
+//            }
+//        }
         //查询数据库↓          缓存↑
         $form = Db::name('formula')->find($bach['fid']);
         $res = Db::name('formula_detail')->where('pid = '.$bach['fid'].' and material like "%'.encrypt($formula).'%" and version = "'.$form['version'].'"')->select();
@@ -144,6 +144,7 @@ class Product extends Backend
                 $arr['error']=0;
             }
         }
+
         $arr['pname']  = $bach['name'];//配方名称
         $arr['time'] = date("Y-m-d H:i:s");
         $arr['bach'] = $bach['bach'];

+ 12 - 12
public/assets/js/backend/product.js

@@ -88,6 +88,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jQuery.print'], funct
                     return false;
                 }
             });
+            window.i=0;
             var i=0;
             //扫描物料
             $("#wuliao").keydown( function (e) {
@@ -121,32 +122,31 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jQuery.print'], funct
                                         <td>${res.specifications}</td>
                                         <td></td>
                                     </tr>`;
-                            //写入页面
-                            $("#table").append(str);
-                            $("#print_gy").append(html);
+
+                            // $("#print_gy").append(html);
                             //清空物料扫描后的值,下次直接重新扫描即可
                             $("#wuliao").val('');
                             if($("#status").val()==1){
                                 if(res.error === 1){
                                     // Layer.confirm("此物料不在配方中,请确认!");
-                                    layer.confirm("此物料不在配方中,请确认!", {//物料不存在提示错误信息
+                                    layer.confirm("此物料不在配方中,请确认!", { //物料不存在提示错误信息
                                         title: ['信息'],
                                         btn: ['确认', '取消'],
                                         area: ['60%', '60%'],
-                                    },function(index) {//点击确定正常执行
+                                    },function(index) { //点击确定正常执行
+                                        //写入页面
+                                        $("#table").append(str);
+                                        $("#print_gy").append(html);
                                         layer.close(index);
-                                    },function(){//点击取消删除添加的最后一个元素
-                                        $("#table tr:last").remove();
-                                        var i = $(this).parent().prev().val();
-                                        $(".print"+i).remove();
+                                    },function(indexx){ //点击取消删除添加的最后一个元素
+                                        // $("#table tr:last").remove();
+                                        layer.close(indexx);
                                     });
+                                    //语音播报
                                     var synth = window.speechSynthesis;
                                     var msg = new window.SpeechSynthesisUtterance('此物料不在配方中,请确认!');
                                     window.speechSynthesis.cancel();
                                     synth.speak(msg);
-                                    //语音播报
-                                    // var msg = new SpeechSynthesisUtterance("此物料不在配方中,请确认!");
-                                    // window.speechSynthesis.speak(msg);
                                 }
                             }
                             i++;