Browse Source

新增批次优化

qiuenguang 1 year ago
parent
commit
f979e0a863

+ 1 - 1
application/admin/controller/Deliver.php

@@ -233,7 +233,7 @@ class Deliver extends Backend
                 $this->error('发货失败');
             }
             $lager = new QcodeLarge();
-            $result =$lager->name($userinfo['company'].'_'.'qcode_large')->where('bach_id',$v)->whereIn('_id',$lagerId)->update(['l_status'=>1]);
+            $lager->name($userinfo['company'].'_'.'qcode_large')->where('bach_id',$v)->whereIn('_id',$lagerId)->update(['l_status'=>1]);
         }
         $this->success('成功');
     }

+ 12 - 3
application/admin/controller/QcodeAdd.php

@@ -55,6 +55,7 @@ class QcodeAdd extends Backend
     public function product(){
         $QcodeProduct = new QcodeProduct();
         $ResetFlow = new ResetFlow();
+        $userinfo = Session::get('admin');
         if ($this->request->isAjax() === false){
             $this->error('请求错误');
         }
@@ -66,11 +67,12 @@ class QcodeAdd extends Backend
         if (empty($product)){
             $this->error('未找到该产品信息');
         }
-        $flow = $ResetFlow->name((int)Session::get('admin')['company'].'_'."reset_flow")->where('product_id',substr(json_encode($product['_id']),9,-2))->find();
+
+        $flow = $ResetFlow->name($userinfo['company'].'_'."reset_flow")->where('product_id',substr(json_encode($product['_id']),9,-2))->find();
         $row = [
             'temple' => $product['temple'],
-            'flow' => '',
-            'bach' => '',
+            'flow' => isset($flow['l_flow'])?(int)$flow['l_flow']+1:'',
+            'bach' => isset($flow['bach_num'])?(int)$flow['bach_num']+1:'',
         ];
         if (!empty($flow)){
             $row['flow'] = $flow['l_flow']+1;
@@ -94,6 +96,7 @@ class QcodeAdd extends Backend
         $large = new QcodeLarge();
         $small = new QcodeSmall();
         $liushui = new QcodeLiushui();
+        $resetFlow = new ResetFlow();
         if ($this->request->isAjax() === false){
             $this->error('请求错误');
         }
@@ -158,6 +161,12 @@ class QcodeAdd extends Backend
         if ($res === 0){
             $this->error('添加失败');
         }
+        $flow = [
+            'product_id' => $batchList['matter_id'],
+            'l_flow' => $batchList['larger_num'],
+            'bach_num' => $batchList['bach_num'],
+        ];
+        $resetFlow->save($flow);
         $last_id = $bach->getLastInsID();
         if ($last_id){
             //插入大小二维码数据

+ 4 - 2
application/admin/view/qcode_add/index.html

@@ -137,13 +137,15 @@
             <tr>
                 <td><span>生产批次号</span></td>
                 <td>
-                    <input type="text" name="batch" id="c-batch"  data-rule="required" readonly>
+                    <input type="text" name="batch" id="c-batch"  data-rule="required" disabled>
+                    <button type="button" id="reset_batch">重置批次号</button>
                 </td>
             </tr>
             <tr>
                 <td><span>大件开始流水号</span></td>
                 <td>
-                    <input type="text" name="big_liushui" id="c-big_liushui" data-rule="required" readonly>
+                    <input type="text" name="big_liushui" id="c-big_liushui" data-rule="required" disabled>
+                    <button type="button" id="reset_liushui">重置流水号</button>
                 </td>
             </tr>
             <tr>

+ 16 - 0
public/assets/js/backend/qcode_add.js

@@ -1,7 +1,13 @@
+
 define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
 
     var Controller = {
         index: function () {
+            $(document).ready(function () {
+               var dateTime = new Date();
+               $('#c-manufacture_date').val(dateTime);
+               $('#c-print_date').val(dateTime);
+            });
             //选择产品获取产品编码、单位
             $('#c-product_name').change(function () {
                var product_code = $('#c-product_name').val();
@@ -114,6 +120,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     $('#c-box_num').val(box_num);
                 }
             }
+            //重置批次号按钮
+            $('#reset_batch').on('click',function () {
+               $('#c-batch').removeAttr('disabled');
+               $('#c-batch').val(201800000);
+            });
+            //重置流水号按钮
+            $('#reset_liushui').on('click',function () {
+               $('#c-big_liushui').removeAttr('disabled');
+               $('#c-big_liushui').val(1);
+            });
             //点击保存按钮,上传表单信息
             $('#submit').click(function () {
                 //表单验证