2 Commits cff823664e ... c3715754fa

Author SHA1 Message Date
  曹鹤洋 c3715754fa Merge branch 'master' of https://git.7in6.com/wuwenqiang/dm-v3.7in6.com 1 year ago
  曹鹤洋 b4b3c6b46d 方法名称细节优化 1 year ago

+ 9 - 0
application/admin/controller/Deliver.php

@@ -729,6 +729,9 @@ class Deliver extends Backend
         $this->success('成功');
     }
 
+    /**
+     * 收货列表
+     */
     public function receive()
     {
         //当前是否为关联查询
@@ -790,6 +793,9 @@ class Deliver extends Backend
         return $this->view->fetch();
     }
 
+    /**
+     * 扫码/输入收货
+     */
     public function receive_add()
     {
         $req = $this->request->param();
@@ -815,6 +821,9 @@ class Deliver extends Backend
         }
     }
 
+    /**
+     * 取消收货
+     */
     public function receive_del()
     {
         $req = $this->request->param();

+ 19 - 206
application/admin/controller/QcodeBach.php

@@ -54,9 +54,9 @@ class QcodeBach extends Backend
     }
 
     /**
-     * 查看
+     * 主表查询
      */
-    public function table1()
+    public function bach()
     {
         //当前是否为关联查询
         $this->relationSearch = false;
@@ -107,9 +107,9 @@ class QcodeBach extends Backend
     }
 
     /**
-     * 查看
+     * 大件列表
      */
-    public function table2()
+    public function large()
     {
         //当前是否为关联查询
         $this->relationSearch = false;
@@ -231,7 +231,7 @@ class QcodeBach extends Backend
     }
 
     /**
-     * 修改小件导出状态
+     * 小件导出状态修改
      */
     public function small_status()
     {
@@ -484,7 +484,7 @@ class QcodeBach extends Backend
     }
 
     /**
-     * 设置打印数量
+     * 打印数量设置
      */
     public function set_num()
     {
@@ -518,92 +518,8 @@ class QcodeBach extends Backend
 
     }
 
-    public function vo2()
-    {
-        $num1 = 0;
-        $num2 = 1;
-        if($num2<=$num1){
-            $this->error('同步num1到num2之间的数据, 要求num2大于num1');
-        }
-
-        // 连接到其他数据库
-        $config = [
-            'type'     => 'mysql',
-            'hostname' => '127.0.0.1',
-            'database' => 'dm_7in6_com',
-            'username' => 'root',
-            'password' => 'root',
-            'charset'  => 'utf8mb4',
-            'prefix'   => 'qr_',
-        ];
-        $db = Db::connect($config);
-
-        //查询主表记录
-        $rows1 = $db->name('qcode_bach')
-            ->limit($num1,$num2-$num1)
-            ->order('id desc')
-            ->select();
-        $userInfo = Session::get('admin');
-        $company_id = (int)$userInfo['company'];
-        foreach($rows1 as $v){
-            //1. 查询mongodb中是否存在该条记录
-            $bool = $this->model->name($company_id.'_'."qcode_bach")->where('oid_id',$v['id'])->find();
-            if ($bool) continue;
-
-            //2. 获取设置主表数据
-            $row = $v;
-            unset($row['id']);
-            $row = array_merge(['oid_id'=>$v['id']],$row);
-
-            //3. 插入主表记录到mongodb中
-            $qcodeBach = new \app\admin\model\QcodeBach();
-            $qcodeBach->save($row);
-            $pid = $qcodeBach->getLastInsID();
-            $rows2 = $db->name('qcode_large')
-                ->where('bach_id',$v['id'])
-                ->select();
-
-            foreach ($rows2 as $value){
-                //1. 查询mongodb中是否存在该条记录
-                $qcodeLarge = new QcodeLarge();
-                $bool = $qcodeLarge->name($company_id.'_'."qcode_large")->where('oid_id',$value['id'])->find();
-                if ($bool) continue;
-
-                $row = $value;
-                $row['old_bach_id'] = $value['bach_id'];
-                $row['bach_id'] = $pid;
-                $row['old_id'] = $value['id'];
-                unset($row['id']);
-                $qcodeLarge->save($row);
-                $pid3 = $qcodeLarge->getLastInsID();
-                $rows3 = $db->name('qcode_small')
-                    ->where('large_id',$value['id'])
-                    ->select();
-
-                foreach ($rows3 as $value3){
-                    //1. 查询mongodb中是否存在该条记录
-                    $qcodeSmall = new QcodeSmall();
-                    $bool = $qcodeSmall->name($company_id.'_'."qcode_large")->where('oid_id',$value3['id'])->find();
-                    if ($bool) continue;
-
-                    $row = $value3;
-                    $row['old_bach_id'] = $value3['bach_id'];
-                    $row['old_large_id'] = $value3['large_id'];
-                    $row['old_id'] = $value3['id'];
-                    $row['bach_id'] = $pid;
-                    $row['large_id'] = $pid3;
-                    unset($row['id']);
-                    $qcodeSmall->save($row);
-                }
-            }
-        }
-
-        $this->success('成功');
-
-    }
-
     /**
-     * 跳转
+     * 导出excel跳转
      */
     public function exp()
     {
@@ -617,69 +533,7 @@ class QcodeBach extends Backend
     }
 
     /**
-     * 新增
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()){
-            $req = $this->request->post();
-            if(!isset($req['row']['product_code']) || empty($req['row']['product_code'])){
-                $this->error('请填写编号');
-            }else{
-                $data = [
-                    'product_code'=>$req['row']['product_code'],
-                    'delete_time'=>'',
-                ];
-                if ($this->model->where($data)->find()){
-                    $this->error('编号已存在');
-                }
-            }
-            if(!isset($req['row']['product_name']) || empty($req['row']['product_name'])){
-                $this->error('请填写名称');
-            }else{
-                $data = [
-                    'product_name'=>$req['row']['product_name'],
-                    'delete_time'=>'',
-                ];
-                if ($this->model->where($data)->find()){
-                    $this->error('名称已存在');
-                }
-            }
-            if(!isset($req['row']['temple']) || empty($req['row']['temple'])){
-                $this->error('请填写辅料代号');
-            }
-            if(!isset($req['row']['main_unit'])){
-                $this->error('请填写主计量单位');
-            }
-            if(!isset($req['row']['sec_unit'])){
-                $this->error('请填写辅计量单位');
-            }
-            if(!isset($req['row']['proportion'])){
-                $this->error('请填写换算关系');
-            }
-            $data = [
-                'product_code'      =>$req['row']['product_code'],
-                'product_name'      =>$req['row']['product_name'],
-                'temple'            =>$req['row']['temple'],
-                'main_unit'         =>$req['row']['main_unit'],
-                'sec_unit'          =>$req['row']['sec_unit'],
-                'proportion'        =>$req['row']['proportion'],
-                'create_time'       =>time(),
-            ];
-            //插入数据
-            $re = $this->model->save($data);
-            if($re){
-                $this->success('成功');
-            }else{
-                $this->error('失败');
-            }
-        }
-        return $this->view->fetch();
-
-    }
-
-    /**
-     * 编辑
+     * 修改大件重量数量
      */
     public function edit($ids = NULL)
     {
@@ -745,7 +599,7 @@ class QcodeBach extends Backend
     }
 
     /**
-     * 删除
+     * 删除批次
      */
     public function del($ids = NULL)
     {
@@ -768,54 +622,6 @@ class QcodeBach extends Backend
         }
     }
 
-    /**
-     * 绑定
-     */
-    public function bind($ids = NULL)
-    {
-        $userInfo = Session::get('admin');
-        $company_id = (int)$userInfo['company'];
-        $db = new QcodeCompany();
-        //查询是否已经添加
-        $row = $db->name($company_id.'_'."qcode_company")
-            ->where(['delete_time'=>'','product_id'=>$ids])
-            ->find();
-        if($row) $this->success('已添加');
-
-        $data = [
-            'product_id'=>$ids,
-            'create_time'=>time(),
-        ];
-
-        //插入qcode_company数据
-        $bool = $db->save($data);
-        if($bool){
-            $this->success('添加成功');
-        }else{
-            $this->error('添加失败');
-        }
-    }
-
-    /**
-     * 解绑
-     */
-    public function unbind($ids = NULL)
-    {
-        $userInfo = Session::get('admin');
-        $company_id = (int)$userInfo['company'];
-        $db = new QcodeCompany();
-        //查询是否已经添加
-        $bool = $db->name($company_id.'_'."qcode_company")
-            ->where(['delete_time'=>'','product_id'=>$ids])
-            ->update(['delete_time'=>time()]);
-
-        if($bool){
-            $this->success('删除成功');
-        }else{
-            $this->error('删除失败');
-        }
-    }
-
     /**
      * 补打标签
      */
@@ -886,7 +692,9 @@ class QcodeBach extends Backend
         return $this->view->fetch();
     }
 
-    //公司搜索
+    /**
+     * 公司名称搜索
+     */
     public function sel_n()
     {
         $name = $this->request->param()['q_word'][0];
@@ -907,7 +715,9 @@ class QcodeBach extends Backend
 
     }
 
-    //辅料名称搜索
+    /**
+     * 辅料名称搜索
+     */
     public function sel_p()
     {
         $name = $this->request->param()['q_word'][0];
@@ -930,7 +740,10 @@ class QcodeBach extends Backend
         return json(['list' => $sel, 'total' => count($sel)]);
 
     }
-    //辅料编码搜索
+
+    /**
+     * 辅料编码搜索
+     */
     public function sel_c()
     {
         $name = $this->request->param()['q_word'][0];

+ 10 - 9
application/admin/controller/QcodeProduct.php

@@ -91,9 +91,9 @@ class QcodeProduct extends Backend
     }
 
     /**
-     * 查看
+     * 产品总列表
      */
-    public function table1()
+    public function products()
     {
         //当前是否为关联查询
         $this->relationSearch = false;
@@ -143,9 +143,9 @@ class QcodeProduct extends Backend
     }
 
     /**
-     * 查看
+     * 厂商产品列表
      */
-    public function table2()
+    public function product()
     {
         //当前是否为关联查询
         $this->relationSearch = false;
@@ -203,8 +203,9 @@ class QcodeProduct extends Backend
         }
         return $this->view->fetch();
     }
+
     /**
-     * 新增
+     * 新增产品
      */
     public function add()
     {
@@ -267,7 +268,7 @@ class QcodeProduct extends Backend
     }
 
     /**
-     * 编辑
+     * 编辑产品
      */
     public function edit($ids = NULL)
     {
@@ -335,7 +336,7 @@ class QcodeProduct extends Backend
     }
 
     /**
-     * 删除
+     * 删除产品
      */
     public function del($ids = NULL)
     {
@@ -351,7 +352,7 @@ class QcodeProduct extends Backend
     }
 
     /**
-     * 绑定
+     * 配置产品
      */
     public function bind($ids = NULL)
     {
@@ -379,7 +380,7 @@ class QcodeProduct extends Backend
     }
 
     /**
-     * 解绑
+     * 取消配置产品
      */
     public function unbind($ids = NULL)
     {

+ 93 - 1
application/api/controller/Index.php

@@ -108,7 +108,7 @@ class Index extends Api
     }
 
     /**
-     * 产品表qr_qcode_unit同步
+     * 公司名称表qr_qcode_gsmc同步
      */
     public function vo2()
     {
@@ -228,4 +228,96 @@ class Index extends Api
         $this->success('成功');
 
     }
+
+
+    /**
+     * 同步bach
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function vo5()
+    {
+        $num1 = 0;
+        $num2 = 1;
+        if($num2<=$num1){
+            $this->error('同步num1到num2之间的数据, 要求num2大于num1');
+        }
+
+        // 连接到其他数据库
+        $config = [
+            'type'     => 'mysql',
+            'hostname' => '127.0.0.1',
+            'database' => 'dm_7in6_com',
+            'username' => 'root',
+            'password' => 'root',
+            'charset'  => 'utf8mb4',
+            'prefix'   => 'qr_',
+        ];
+        $db = Db::connect($config);
+
+        //查询主表记录
+        $rows1 = $db->name('qcode_bach')
+            ->limit($num1,$num2-$num1)
+            ->order('id desc')
+            ->select();
+        $userInfo = Session::get('admin');
+        $company_id = (int)$userInfo['company'];
+        foreach($rows1 as $v){
+            //1. 查询mongodb中是否存在该条记录
+            $bool = $this->model->name($company_id.'_'."qcode_bach")->where('oid_id',$v['id'])->find();
+            if ($bool) continue;
+
+            //2. 获取设置主表数据
+            $row = $v;
+            unset($row['id']);
+            $row = array_merge(['oid_id'=>$v['id']],$row);
+
+            //3. 插入主表记录到mongodb中
+            $qcodeBach = new \app\admin\model\QcodeBach();
+            $qcodeBach->save($row);
+            $pid = $qcodeBach->getLastInsID();
+            $rows2 = $db->name('qcode_large')
+                ->where('bach_id',$v['id'])
+                ->select();
+
+            foreach ($rows2 as $value){
+                //1. 查询mongodb中是否存在该条记录
+                $qcodeLarge = new QcodeLarge();
+                $bool = $qcodeLarge->name($company_id.'_'."qcode_large")->where('oid_id',$value['id'])->find();
+                if ($bool) continue;
+
+                $row = $value;
+                $row['old_bach_id'] = $value['bach_id'];
+                $row['bach_id'] = $pid;
+                $row['old_id'] = $value['id'];
+                unset($row['id']);
+                $qcodeLarge->save($row);
+                $pid3 = $qcodeLarge->getLastInsID();
+                $rows3 = $db->name('qcode_small')
+                    ->where('large_id',$value['id'])
+                    ->select();
+
+                foreach ($rows3 as $value3){
+                    //1. 查询mongodb中是否存在该条记录
+                    $qcodeSmall = new QcodeSmall();
+                    $bool = $qcodeSmall->name($company_id.'_'."qcode_large")->where('oid_id',$value3['id'])->find();
+                    if ($bool) continue;
+
+                    $row = $value3;
+                    $row['old_bach_id'] = $value3['bach_id'];
+                    $row['old_large_id'] = $value3['large_id'];
+                    $row['old_id'] = $value3['id'];
+                    $row['bach_id'] = $pid;
+                    $row['large_id'] = $pid3;
+                    unset($row['id']);
+                    $qcodeSmall->save($row);
+                }
+            }
+        }
+
+        $this->success('成功');
+
+    }
 }

+ 4 - 23
public/assets/js/backend/qcode_bach.js

@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'LodopFuncs'], functi
             this.table.second();
 
 
-            //绑定
+            //跳转
             $('#exp').click(function (e) {
 
                 $.get('qcode_bach/exp', {}, function (data) {
@@ -19,25 +19,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'LodopFuncs'], functi
                     }
                 }, 'json');
             })
-                // var ids = $('#table1').bootstrapTable('getSelections')[0]['id'];
-                // layer.confirm('确定提交选中的 1 项?!', {
-                //     btn: ['确定', '取消'],
-                //     cancel: function(index, layero) {
-                //     }
-                // },function (index) {
-                //     $.get('qcode_bach/bind',{'ids':ids},function (data) {
-                //         if(data.code==1){
-                //             Toastr.success(data.msg)
-                //             table2.bootstrapTable('refresh');
-                //         }else{
-                //             Toastr.error(data.msg)
-                //         }
-                //     },'json');
-                //     Layer.close(index);
-                //
-                // },function (){})
-
-            // })
 
             //自动打码(大件)
             $('#print_l').click(function (e) {
@@ -98,9 +79,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'LodopFuncs'], functi
                 // 表格1
                 var table1 = $("#table1");
                 table1.bootstrapTable({
-                    url: 'qcode_bach/table1',
+                    url: 'qcode_bach/bach',
                     extend: {
-                        index_url: 'qcode_bach/table1' + location.search,
+                        index_url: 'qcode_bach/bach' + location.search,
                         add_url: 'qcode_bach/add',
                         edit_url: 'qcode_bach/edit',
                         del_url: 'qcode_bach/del',
@@ -145,7 +126,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'LodopFuncs'], functi
                 // 表格2
                 var table2 = $("#table2");
                 table2.bootstrapTable({
-                    url: 'qcode_bach/table2',
+                    url: 'qcode_bach/large',
                     extend: {
                         index_url: '',
                         add_url: '',

+ 4 - 82
public/assets/js/backend/qcode_product.js

@@ -20,26 +20,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     }
                 },'json');
 
-                // layer.confirm('确定提交选中的 1 项?!', {
-                //     btn: ['确定', '取消'],
-                //     cancel: function(index, layero) {
-                //     }
-                // },function (index) {
-                //     $.get('qcode_product/bind',{'ids':ids},function (data) {
-                //         if(data.code==1){
-                //             Toastr.success(data.msg)
-                //             table2.bootstrapTable('refresh');
-                //         }else{
-                //             Toastr.error(data.msg)
-                //         }
-                //     },'json');
-                //     Layer.close(index);
-                //
-                // },function (){})
-
             })
 
-            //绑
+            //解绑
             $('#unbind').click(function (e) {
                 layer.confirm('确定提交选中的 1 项?!', {
                     btn: ['确定', '取消'],
@@ -68,9 +51,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 // 表格1
                 var table1 = $("#table1");
                 table1.bootstrapTable({
-                    url: 'qcode_product/table1',
+                    url: 'qcode_product/products',
                     extend: {
-                        index_url: 'qcode_product/table1' + location.search,
+                        index_url: 'qcode_product/products' + location.search,
                         add_url: 'qcode_product/add',
                         edit_url: 'qcode_product/edit',
                         del_url: 'qcode_product/del',
@@ -112,7 +95,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 // 表格2
                 var table2 = $("#table2");
                 table2.bootstrapTable({
-                    url: 'qcode_product/table2',
+                    url: 'qcode_product/product',
                     extend: {
                         index_url: '',
                         add_url: '',
@@ -152,67 +135,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             }
         },
 
-        /*recyclebin: function () {
-            // 初始化表格参数配置
-            Table.api.init({
-                extend: {
-                    'dragsort_url': ''
-                }
-            });
-
-            var table = $("#table");
-
-            // 初始化表格
-            table.bootstrapTable({
-                url: 'qcode_product/recyclebin' + location.search,
-                pk: 'id',
-                sortName: 'id',
-                columns: [
-                    [
-                        {checkbox: true},
-                        {field: 'id', title: __('Id')},
-                        {field: 'name', title: __('Name'), align: 'left'},
-                        {
-                            field: 'deletetime',
-                            title: __('Deletetime'),
-                            operate: 'RANGE',
-                            addclass: 'datetimerange',
-                            formatter: Table.api.formatter.datetime
-                        },
-                        {
-                            field: 'operate',
-                            width: '140px',
-                            title: __('Operate'),
-                            table: table,
-                            events: Table.api.events.operate,
-                            buttons: [
-                                {
-                                    name: 'Restore',
-                                    text: __('Restore'),
-                                    classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
-                                    icon: 'fa fa-rotate-left',
-                                    url: 'qcode_product/restore',
-                                    refresh: true
-                                },
-                                {
-                                    name: 'Destroy',
-                                    text: __('Destroy'),
-                                    classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
-                                    icon: 'fa fa-times',
-                                    url: 'qcode_product/destroy',
-                                    refresh: true
-                                }
-                            ],
-                            formatter: Table.api.formatter.operate
-                        }
-                    ]
-                ]
-            });
-
-            // 为表格绑定事件
-            Table.api.bindevent(table);
-        },*/
-
         add: function () {
             Controller.api.bindevent();
         },