Browse Source

打码系统新版本

huangsanjia 2 years ago
parent
commit
ee8330bc41
100 changed files with 17554 additions and 0 deletions
  1. 96 0
      1.html
  2. 9 0
      1.php
  3. 1 0
      12.txt
  4. 603 0
      2.html
  5. 26 0
      404.html
  6. 308 0
      Addons/ModelConfigEditor/Controller/ModelConfigEditorController.class.php
  7. 45 0
      Addons/ModelConfigEditor/ModelConfigEditorAddon.class.php
  8. 7 0
      Addons/ModelConfigEditor/View/Index/menus.html
  9. 4 0
      Addons/ModelConfigEditor/config.php
  10. 45 0
      Addons/ModelConfigEditor/widget.html
  11. 53 0
      Addons/RocketToTop/RocketToTopAddon.class.php
  12. 12 0
      Addons/RocketToTop/config.php
  13. BIN
      Addons/RocketToTop/images/rocket_button_up.png
  14. 114 0
      Addons/RocketToTop/rocket.html
  15. 132 0
      Application/Admin/Controller/AccessController.class.php
  16. 186 0
      Application/Admin/Controller/Activate1Controller.class.php
  17. 142 0
      Application/Admin/Controller/ActivateController.class.php
  18. 125 0
      Application/Admin/Controller/ActivatelistController.class.php
  19. 446 0
      Application/Admin/Controller/AddonController.class.php
  20. 279 0
      Application/Admin/Controller/AdminController.class.php
  21. 492 0
      Application/Admin/Controller/ApplyBatchController.class.php
  22. 472 0
      Application/Admin/Controller/ApplyBatchController.class.php 11.28
  23. 343 0
      Application/Admin/Controller/ApplyBatchController.class.php 9.20
  24. 419 0
      Application/Admin/Controller/AutoController.class.php
  25. 465 0
      Application/Admin/Controller/BarController.class.php
  26. 220 0
      Application/Admin/Controller/ConfigController.class.php
  27. 1225 0
      Application/Admin/Controller/ExportController.class.php
  28. 129 0
      Application/Admin/Controller/ExportExcelController.class.php
  29. 180 0
      Application/Admin/Controller/GroupController.class.php
  30. 105 0
      Application/Admin/Controller/HomeController.class.php
  31. 55 0
      Application/Admin/Controller/IndexController.class.php
  32. 320 0
      Application/Admin/Controller/ModuleController.class.php
  33. 191 0
      Application/Admin/Controller/NavController.class.php
  34. 698 0
      Application/Admin/Controller/NewQcodeController.class.php
  35. 92 0
      Application/Admin/Controller/PublicController.class.php
  36. 804 0
      Application/Admin/Controller/QcodeController.class.php
  37. 198 0
      Application/Admin/Controller/Qr1Controller.class.php
  38. 224 0
      Application/Admin/Controller/QrController.class.php
  39. 30 0
      Application/Admin/Controller/TestTrueController.class.php
  40. 146 0
      Application/Admin/Controller/UploadController.class.php
  41. 215 0
      Application/Admin/Controller/UserController.class.php
  42. 157 0
      Application/Admin/Controller/VerifyCodeController.class.php
  43. 127 0
      Application/Admin/Controller/VersionController.class.php
  44. 52 0
      Application/Admin/Model/AccessModel.class.php
  45. 153 0
      Application/Admin/Model/AddonModel.class.php
  46. 92 0
      Application/Admin/Model/BarLargeModel.class.php
  47. 49 0
      Application/Admin/Model/BarProductModel.class.php
  48. 92 0
      Application/Admin/Model/BarSmallModel.class.php
  49. 68 0
      Application/Admin/Model/ConfigModel.class.php
  50. 61 0
      Application/Admin/Model/GroupModel.class.php
  51. 155 0
      Application/Admin/Model/HookModel.class.php
  52. 245 0
      Application/Admin/Model/ModuleModel.class.php
  53. 226 0
      Application/Admin/Model/NavModel.class.php
  54. 46 0
      Application/Admin/Model/QcodeCompanyModel.class.php
  55. 44 0
      Application/Admin/Model/QcodeProductModel.class.php
  56. 17 0
      Application/Admin/Model/QrViewModel.class.php
  57. 356 0
      Application/Admin/Model/UploadModel.class.php
  58. 224 0
      Application/Admin/Model/UserModel.class.php
  59. 42 0
      Application/Admin/Model/VersionModel.class.php
  60. 26 0
      Application/Admin/View/Activate/error.html
  61. 32 0
      Application/Admin/View/Activate/hjy.html
  62. 68 0
      Application/Admin/View/Activate/index.html
  63. 80 0
      Application/Admin/View/Activatelist/add.html
  64. 224 0
      Application/Admin/View/Activatelist/detail.html
  65. 83 0
      Application/Admin/View/Activatelist/index.html
  66. 108 0
      Application/Admin/View/ApplyBatch/addtaskindex.html
  67. 76 0
      Application/Admin/View/ApplyBatch/applylist.html
  68. 133 0
      Application/Admin/View/ApplyBatch/index.html
  69. 112 0
      Application/Admin/View/ApplyBatch/index_old.html
  70. 256 0
      Application/Admin/View/ApplyBatch/taskdetail.html
  71. 223 0
      Application/Admin/View/ApplyBatch/taskdetail.html 0205
  72. 105 0
      Application/Admin/View/ApplyBatch/tasklist.html
  73. 156 0
      Application/Admin/View/Bar/add.html
  74. 10 0
      Application/Admin/View/Bar/edit.html
  75. 224 0
      Application/Admin/View/Bar/list.html
  76. 163 0
      Application/Admin/View/Bar/smalladd.html
  77. 225 0
      Application/Admin/View/Bar/smalllist.html
  78. 145 0
      Application/Admin/View/Error/error.html
  79. 58 0
      Application/Admin/View/Error/exception.html
  80. 144 0
      Application/Admin/View/Error/success.html
  81. 239 0
      Application/Admin/View/Export/bach.html
  82. 390 0
      Application/Admin/View/Export/detail.html
  83. 379 0
      Application/Admin/View/Export/excel.html
  84. 435 0
      Application/Admin/View/Export/fahuo.html
  85. 310 0
      Application/Admin/View/Export/index.html
  86. 312 0
      Application/Admin/View/Export/index1.html
  87. 30 0
      Application/Admin/View/Export/shouhuo.html
  88. 506 0
      Application/Admin/View/Export/shouhuolist.html
  89. 63 0
      Application/Admin/View/Group/add_edit.html
  90. 26 0
      Application/Admin/View/Home 6.15/error.html
  91. 32 0
      Application/Admin/View/Home 6.15/hjy.html
  92. 32 0
      Application/Admin/View/Home 6.15/hjy_1.html
  93. 66 0
      Application/Admin/View/Home 6.15/index.html
  94. 32 0
      Application/Admin/View/Home 6.15/jingsilu.html
  95. 32 0
      Application/Admin/View/Home 6.15/jingsilu_1.html
  96. 32 0
      Application/Admin/View/Home 6.15/xuanshang.html
  97. 32 0
      Application/Admin/View/Home 6.15/xuanshang_1.html
  98. 27 0
      Application/Admin/View/Home/error.html
  99. 33 0
      Application/Admin/View/Home/hjy.html
  100. 33 0
      Application/Admin/View/Home/hjy_1.html

+ 96 - 0
1.html

@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8">
+    <title>jQueryStudy</title>
+    <style>
+     .int{ height: 30px; text-align: left; width: 600px; }
+     label{ width: 200px; margin-left: 20px; }
+     .high{ color: red; }
+     .msg{ font-size: 13px; }
+     .onError{ color: red; }
+     .onSuccess{ color: green; }
+    </style>
+    <script src="http://code.jquery.com/jquery-latest.js"></script>    
+</head>
+<body>
+    <form method="post" action="#">
+        <div class="int">
+            <label for="name">姓名:</label>
+            <input type="text" id="name" class="required" />
+        </div>
+        <div class="int">
+            <label for="email">邮箱:</label>
+            <input type="text" id="email" class="required" />
+        </div>
+        <div class="int">
+            <label for="address">住址:</label>
+            <input type="text" id="address" />
+        </div>
+        <div class="int">
+            <input type="submit" value="提交" id="send" style="margin-left: 70px;" />
+            <input type="reset" value="重置" id="res" />
+        </div>
+    </form>
+    <script>
+        //为表单的必填文本框添加提示信息(选择form中的所有后代input元素)
+        $("form :input.required").each(function () {
+            //通过jquery api:$("HTML字符串") 创建jquery对象
+            var $required = $("<strong class='high'>*</strong>");
+            //添加到this对象的父级对象下
+            $(this).parent().append($required);
+        });
+
+         //为表单元素添加失去焦点事件
+        $("form :input").blur(function(){
+            var $parent = $(this).parent();
+            $parent.find(".msg").remove(); //删除以前的提醒元素(find():查找匹配元素集中元素的所有匹配元素)
+            //验证姓名
+            if($(this).is("#name")){
+                var nameVal = $.trim(this.value); //原生js去空格方式:this.replace(/(^\s*)|(\s*$)/g, "")
+                var regName = /[~#^$@%&!*()<>:;'"{}【】  ]/;
+                if(nameVal == "" || nameVal.length < 6 || regName.test(nameVal)){
+                    var errorMsg = " 姓名非空,长度6位以上,不包含特殊字符!";
+                    //class='msg onError' 中间的空格是层叠样式的格式
+                    $parent.append("<span class='msg onError'>" + errorMsg + "</span>");
+                }
+                else{
+                    var okMsg=" 输入正确";
+                    $parent.find(".high").remove();
+                    $parent.append("<span class='msg onSuccess'>" + okMsg + "</span>");
+                }
+            }
+            //验证邮箱
+            if($(this).is("#email")){
+                var emailVal = $.trim(this.value);
+                var regEmail = /.+@.+\.[a-zA-Z]{2,4}$/;
+                if(emailVal== "" || (emailVal != "" && !regEmail.test(emailVal))){
+                    var errorMsg = " 请输入正确的E-Mail住址!";
+                    $parent.append("<span class='msg onError'>" + errorMsg + "</span>");
+                }
+                else{
+                    var okMsg=" 输入正确";
+                    $parent.find(".high").remove();
+                    $parent.append("<span class='msg onSuccess'>" + okMsg + "</span>");
+                }
+            }
+        }).keyup(function(){
+            //triggerHandler 防止事件执行完后,浏览器自动为标签获得焦点
+            $(this).triggerHandler("blur"); 
+        }).focus(function(){
+            $(this).triggerHandler("blur");
+        });
+        
+        //点击重置按钮时,通过trigger()来触发文本框的失去焦点事件
+        $("#send").click(function(){
+            //trigger 事件执行完后,浏览器会为submit按钮获得焦点
+            $("form .required:input").trigger("blur"); 
+            var numError = $("form .onError").length;
+            if(numError){
+                return false;
+            }
+            
+        });
+    </script>
+</body>
+</html>

+ 9 - 0
1.php

@@ -0,0 +1,9 @@
+<?php
+echo 'wwww';
+ 
+
+$data=$GLOBALS['HTTP_RAW_POST_DATA'];
+file_put_contents("data.txt",serialize($data));
+ 
+
+?>

+ 1 - 0
12.txt

@@ -0,0 +1 @@
+2

File diff suppressed because it is too large
+ 603 - 0
2.html


+ 26 - 0
404.html

@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+<title>404</title>
+<style>
+	body{
+		background-color:#444;
+		font-size:14px;
+	}
+	h3{
+		font-size:60px;
+		color:#eee;
+		text-align:center;
+		padding-top:30px;
+		font-weight:normal;
+	}
+</style>
+</head>
+
+<body>
+<h3>404,您请求的文件不存在!</h3>
+</body>
+</html>

+ 308 - 0
Addons/ModelConfigEditor/Controller/ModelConfigEditorController.class.php

@@ -0,0 +1,308 @@
+<?php
+
+namespace Addons\ModelConfigEditor\Controller;
+
+use Admin\Controller\AddonController;
+use Util\Tree;
+
+class ModelConfigEditorController extends AddonController
+{
+
+    // 模块菜单列表
+    public function menus()
+    {
+        $module_id = I('request.module_id');
+        $this->assign('module_id', $module_id);
+        $module_object = M('admin_module');
+        $module        = $module_object->find($module_id);
+        if (empty($module)) {
+            $this->error('插件不存在,请重新安装');
+        } else {
+            $menus = $this->getMenus($module_id);
+            // 转换成树状列表
+            $tree      = new Tree();
+            $data_list = $tree->array2tree($menus);
+
+            // 使用Builder快速建立列表页面。
+            $builder = new \Common\Builder\ListBuilder();
+            $builder->setMetaTitle('添加菜单') // 设置页面标题
+                ->addTopButton('addnew', ['href' => addons_url('ModelConfigEditor://ModelConfigEditor/add', ['module_id' => $module_id]),
+                ]) // 添加新增按钮
+            // ->addTopButton('delete') // 添加删除按钮
+                ->addTableColumn('id', 'ID')
+                ->addTableColumn('icon', '图标', 'icon')
+                ->addTableColumn('title_show', '标题')
+                ->addTableColumn('right_button', '操作', 'btn')
+                ->setTableDataList($data_list) // 数据列表
+                ->addRightButton('self', [
+                    'href'  => addons_url('ModelConfigEditor://ModelConfigEditor/add', ['pid' => '__data_id__', 'module_id' => $module_id]),
+                    'title' => '添加子菜单',
+                    'class' => 'label label-primary',
+                ]
+                ) // 添加编辑按钮
+                ->addRightButton('edit', [
+                    'href' => addons_url('ModelConfigEditor://ModelConfigEditor/edit', ['id' => '__data_id__', 'module_id' => $module_id]),
+                ]
+                ) // 添加编辑按钮
+                ->addRightButton('delete', [
+                    'href' => addons_url('ModelConfigEditor://ModelConfigEditor/delete', ['id' => '__data_id__', 'module_id' => $module_id]),
+                ]
+                ) // 添加删除按钮
+                ->display();
+        }
+    }
+
+    public function add()
+    {
+        $module_id = I('request.module_id');
+        $data      = I('post.');
+        if (isset($data['icon']) && stripos($data['icon'], 'fa ') === false) {
+            $data['icon'] = 'fa ' . $data['icon'];
+        }
+        $menus = $this->getMenus($module_id);
+        if (IS_POST) {
+            $ids = i_array_column($menus, 'id');
+            asort($ids, SORT_NUMERIC);
+            $next_id         = end($ids) + 1;
+            $menus[$next_id] = $data;
+            if (1 == $data['pid']) {
+                $data['icon'] = 'fa fa-folder-open-o';
+            }
+            $this->saveModule($module_id, $menus);
+        } else {
+            // 使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('新增链接') // 设置页面标题
+                ->setPostUrl(addons_url('ModelConfigEditor://ModelConfigEditor/add', ['module_id' => $module_id])) // 设置表单提交地址
+                ->addFormItem('pid', 'select', '上级链接', '上级链接', $this->list_as_tree($menus, '顶级链接'))
+                ->addFormItem('title', 'text', '链接标题', '链接前台显示标题')
+                ->addFormItem('url', 'text', '请填写外链URL地址', '支持http://格式或者TP的U函数解析格式')
+                ->addFormItem('icon', 'icon', '图标', '链接图标')
+                ->setFormData(['pid' => I('pid', 0)])
+                ->display();
+        }
+    }
+
+    // 编辑菜单
+    public function edit()
+    {
+        $id        = I('id');
+        $module_id = I('get.module_id');
+        if (IS_POST) {
+            $menus      = $this->getMenus($module_id);
+            $menus[$id] = I('post.');
+            if (stripos($menus[$id]['icon'], 'fa ') === false) {
+                $menus[$id]['icon'] = 'fa ' . $menus[$id]['icon'];
+            }
+            //第一层节点 的图标固定为目录展开图标
+            if (1 == $menus[$id]['pid']) {
+                $menus[$id]['icon'] = 'fa fa-folder-open-o';
+            }
+            $this->saveModule($module_id, $menus);
+
+        } else {
+            $menus = $this->getMenus($module_id);
+            $info  = $menus[$id] ?: null;
+
+            // 使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+
+            $builder->setMetaTitle('编辑链接') // 设置页面标题
+                ->setPostUrl(addons_url('ModelConfigEditor://ModelConfigEditor/edit', ['id' => $id, 'module_id' => $module_id])) // 设置表单提交地址
+                ->addFormItem('id', 'hidden', 'ID', 'ID')
+                ->addFormItem('pid', 'select', '上级链接', '上级链接', $this->list_as_tree($menus, '顶级链接'))
+                ->addFormItem('title', 'text', '链接标题', '链接前台显示标题')
+                ->addFormItem('url', 'text', '请填写外链URL地址', '支持http://格式或者TP的U函数解析格式')
+                ->addFormItem('icon', 'icon', '图标', '链接图标')
+                ->setFormData($info)
+                ->display();
+        }
+    }
+
+    //删除菜单
+    public function delete()
+    {
+        $id = I('request.id');
+        if (1 == $id) {
+            $this->error('根节点菜单不能删除');
+        } else {
+            $module_id = I('request.module_id');
+            $menus     = $this->getMenus($module_id);
+            unset($menus[$id]);
+            $this->saveModule($module_id, $menus);
+        }
+    }
+
+    // 保存菜单配置
+    public function saveModule($id, $data)
+    {
+        if ($module = $this->getModule($id)) {
+            // dump($module);
+            $config_file = APP_PATH . $module['name'] . '/opencmf.php';
+            if (is_writeable($config_file)) {
+                $old_config = include $config_file;
+                $new_config = array_merge($old_config, ['admin_menu' => $data]);
+                if (!$new_config) {
+                    $this->error('合并配置失败');
+                } else {
+                    $config_source   = var_export($new_config, true);
+                    $config_file_str = <<<PHP
+<?php
+// 模块信息配置
+return {$config_source}
+;
+PHP;
+                    $addon_index = addons_url('ModelConfigEditor://ModelConfigEditor/menus', ['id' => $id, 'module_id' => $module['id']]);
+                    if (file_put_contents($config_file, $config_file_str)) {
+                        $ret = $this->updateinfo($id);
+                        if (true === $ret) {
+                            // 清空所有缓存
+                            $cache = \Think\Cache::getInstance();
+                            $cache->clear();
+                            $this->success('更新配置成功', $addon_index);
+                        } else {
+                            $this->error('更新失败:' . $ret);
+                        }
+                    } else {
+                        $this->error('更新配置失败');
+                    }
+                }
+            } else {
+                $this->error("{$module['name']}下的opencmf.php 配置文件不可写");
+            }
+        } else {
+            $this->error('保存失败,模型数据获取不到');
+        }
+    }
+
+    // 获取模块名称
+    public function getModuleName($id)
+    {
+        if (!$module = $this->getModule($id)) {
+            return false;
+        } else {
+            return $module['name'];
+        }
+    }
+
+    // 获取模块路径
+    public function getModulePath($id)
+    {
+        if ($name = $this->getModuleName($id)) {
+            return APP_PATH . $module['name'];
+        } else {
+            return false;
+        }
+    }
+
+    // 获取全部模块
+    public function getMenus($module_id)
+    {
+        $module      = $this->getModule($module_id);
+        $module_path = APP_PATH . $module['name'];
+
+        $config = include $module_path . '/opencmf.php';
+        $menus  = $config['admin_menu'];
+        foreach ($menus as $key => &$value) {
+            $value['id'] = $key;
+        }
+        return $menus;
+    }
+
+    // 获取模块
+    public function getModule($module_id)
+    {
+        $module_object = M('admin_module');
+        $module        = $module_object->find($module_id);
+        return $module;
+    }
+
+    // 更新数据库模块菜单缓存
+    public function updateInfo($id)
+    {
+        $module_object = M('admin_module');
+        $record        = $module_object->find($id);
+        $name          = $record['name'];
+        $config_file   = realpath(APP_PATH . $name) . '/'
+        . D('Module')->install_file();
+        if (!$config_file) {
+            $this->error('不存在安装文件');
+        }
+        $config_info = include $config_file;
+        $data        = $config_info['info'];
+
+        // 读取数据库已有配置
+        $db_moduel_config = $record['config'];
+        $db_moduel_config = json_decode($db_moduel_config, true);
+
+        // 处理模块配置
+        if (isset($config_info['config'])) {
+            $temp_arr = $config_info['config'];
+            foreach ($temp_arr as $key => $value) {
+                if ($value['type'] == 'group') {
+                    foreach ($value['options'] as $gkey => $gvalue) {
+                        foreach ($gvalue['options'] as $ikey => $ivalue) {
+                            $config[$ikey] = $ivalue['value'];
+                        }
+                    }
+                } else {
+                    if (isset($db_moduel_config[$key])) {
+                        $config[$key] = $db_moduel_config[$key];
+                    } else {
+                        $config[$key] = isset($temp_arr[$key]['value']) ? $temp_arr[$key]['value'] : '';
+                    }
+                }
+            }
+            $data['config'] = json_encode($config);
+        } else {
+            $data['config'] = '';
+        }
+
+        // 获取后台菜单
+        if ($config_info['admin_menu']) {
+            // 将key值赋给id
+            foreach ($config_info['admin_menu'] as $key => &$val) {
+                $val['id'] = (string) $key;
+            }
+            $data['admin_menu'] = json_encode($config_info['admin_menu']);
+        }
+
+        // 获取用户中心导航
+        if (isset($config_info['user_nav'])) {
+            $data['user_nav'] = json_encode($config_info['user_nav']);
+        } else {
+            $data['user_nav'] = '';
+        }
+
+        $data['id'] = $id;
+        $data       = $module_object->create($data);
+        if ($data) {
+            $id = $module_object->save($data);
+            if (false !== $id) {
+                return true;
+            } else {
+                return '更新失败';
+            }
+        } else {
+            return $module_object->getError();
+        }
+    }
+
+    // 将树形列表转换为树
+    public function list_as_tree($list, $extra = null, $key = 'id', $title_field = 'title')
+    {
+        //转换成树状列表(非严格模式)
+        $tree = new \Util\Tree();
+        $list = $tree->array2tree($list, $title_field, 'id', 'pid', 0, false);
+
+        if ($extra) {
+            $result[0] = $extra;
+        }
+
+        //转换成一维数组
+        foreach ($list as $val) {
+            $result[$val[$key]] = $val['title_show'];
+        }
+        return $result;
+    }
+}

+ 45 - 0
Addons/ModelConfigEditor/ModelConfigEditorAddon.class.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace Addons\ModelConfigEditor;
+
+use Common\Controller\Addon;
+
+/**
+ * 模型配置器插件
+ * @author yangweijie
+ */
+
+class ModelConfigEditorAddon extends Addon
+{
+
+    public $info = array(
+        'name'        => 'ModelConfigEditor',
+        'title'       => '模型配置器',
+        'description' => '用于编辑已有模块的配置',
+        'status'      => 1,
+        'author'      => 'yangweijie',
+        'version'     => '0.3',
+    );
+
+    public function install()
+    {
+        return true;
+    }
+
+    public function uninstall()
+    {
+        return true;
+    }
+
+    //实现的app_begin钩子方法
+    public function AdminIndex($param)
+    {
+        $module_object = D('Admin/Module');
+        $data_list     = $module_object->getAll();
+        $addon         = D('Admin/Addon')->where("name='{$this->getName()}'")->getField('id');
+        $this->assign('addon_id', $addon);
+        $this->assign('list', $data_list);
+        $this->display('widget');
+    }
+
+}

+ 7 - 0
Addons/ModelConfigEditor/View/Index/menus.html

@@ -0,0 +1,7 @@
+<!-- <extend name="$_admin_public_layout" />
+
+<block name="main">
+
+	</script>
+</block>
+ -->

+ 4 - 0
Addons/ModelConfigEditor/config.php

@@ -0,0 +1,4 @@
+<?php
+return array(
+
+);

+ 45 - 0
Addons/ModelConfigEditor/widget.html

@@ -0,0 +1,45 @@
+<div class="col-xs-12 col-sm-6 col-lg-12 ct-update">
+	<div class="panel panel-default">
+		<div class="panel-heading">
+			<div class="update pull-right"></div>
+			<i class="fa fa-cog"></i> 模块列表
+		</div>
+		<div class="panel-body">
+			<div class="col-xs-12">
+				<div class="builder-table">
+					<div class="panel panel-default table-responsive">
+						<table class="table table-bordered table-striped table-hover">
+							<thead>
+								<tr>
+									<th>名称</th>
+									<th>标题</th>
+									<th>描述</th>
+									<th>版本</th>
+									<th>状态</th>
+									<th>操作</th>
+								</tr>
+							</thead>
+							<tbody>
+								<volist name="list" id="vo">
+								<tr>
+									<td>{$vo.name}</td>
+									<td>{$vo.title}</td>
+									<td>{$vo.description}</td>
+									<td>{$vo.version}</td>
+									<td>
+										<i class="fa <eq name="vo.status" value="1">fa-check text-success<else />fa-ban text-danger</eq>"></i>
+									</td>
+									<td>
+										<a class="label label-info" href="{:addons_url('ModelConfigEditor://ModelConfigEditor/menus', ['id'=>$addon_id, 'module_id'=>$vo['id']])}">编辑菜单</a>
+									</td>
+								</tr>
+								</volist>
+								</tbody>
+							</table>
+						</div>
+
+					</div>
+				</div>
+			</div>
+		</div>
+	</div>

+ 53 - 0
Addons/RocketToTop/RocketToTopAddon.class.php

@@ -0,0 +1,53 @@
+<?php
+namespace Addons\RocketToTop;
+
+use Common\Controller\Addon;
+
+/**
+ * 小火箭返回顶部
+ */
+class RocketToTopAddon extends Addon
+{
+    /**
+     * 插件信息
+     *
+     */
+    public $info = array(
+        'name'        => 'RocketToTop',
+        'title'       => '小火箭返回顶部',
+        'description' => '小火箭返回顶部',
+        'status'      => '1',
+        'author'      => 'OpenCMF',
+        'version'     => '1.3.0',
+    );
+
+    /**
+     * 插件安装方法
+     *
+     */
+    public function install()
+    {
+        return true;
+    }
+
+    /**
+     * 插件卸载方法
+     *
+     */
+    public function uninstall()
+    {
+        return true;
+    }
+
+    /**
+     * 实现的PageFooter钩子方法
+     *
+     */
+    public function PageFooter($param)
+    {
+        $addons_config = $this->getConfig();
+        if ($addons_config['status']) {
+            $this->display('rocket');
+        }
+    }
+}

+ 12 - 0
Addons/RocketToTop/config.php

@@ -0,0 +1,12 @@
+<?php
+return array(
+    'status' => array(
+        'title'   => '是否开启:',
+        'type'    => 'radio',
+        'options' => array(
+            '1' => '开启',
+            '0' => '关闭',
+        ),
+        'value'   => '1',
+    ),
+);

BIN
Addons/RocketToTop/images/rocket_button_up.png


+ 114 - 0
Addons/RocketToTop/rocket.html

@@ -0,0 +1,114 @@
+<style>
+    #rocket-to-top div {
+        left:0;
+        margin:0;
+        overflow:hidden;
+        padding:0;
+        position:absolute;
+        top:0;
+        width:88px;
+        background: red;
+    }
+    #rocket-to-top .level-2 {
+        background:url("__ADDONROOT__/images/rocket_button_up.png") no-repeat scroll -88px 0 transparent;
+        display:none;
+        height:200px;
+        opacity:0;
+        z-index:1;
+    }
+    #rocket-to-top .level-3 {
+        background:none repeat scroll 0 0 transparent;
+        cursor:pointer;
+        display:block;
+        height:150px;
+        z-index:2;
+    }
+    #rocket-to-top {
+        background:url("__ADDONROOT__/images/rocket_button_up.png") no-repeat scroll 0 0 transparent;
+        cursor:default;
+        display:block;
+        height:200px;
+        margin:-25px 0 0;
+        overflow:hidden;
+        padding:0;
+        position:fixed;
+        right:0;
+        top:70%;
+        width:88px;
+        z-index:11;
+    }
+    @media (max-width: 768px) {
+        .returntop {
+            display: none;
+        }
+    }
+</style>
+<div class="returntop">
+    <div style="display:none;" id="rocket-to-top">
+        <div style="opacity:0;display:block;" class="level-2"></div>
+        <div class="level-3"></div>
+    </div>
+    <script>
+        $(function() {
+            var e = $("#rocket-to-top"),
+            t = $(document).scrollTop(),
+            n,
+            r,
+            i = !0;
+            $(window).scroll(function() {
+                var t = $(document).scrollTop();
+                t == 0 ? e.css("background-position") == "0px 0px" ? e.fadeOut("slow") : i && (i = !1, $(".level-2").css("opacity", 1), e.delay(100).animate({
+                    marginTop: "-1000px"
+                },
+                "normal",
+                function() {
+                    e.css({
+                        "margin-top": "-25px",
+                        display: "none"
+                    }),
+                    i = !0
+                })) : e.fadeIn("slow")
+            }),
+            e.hover(function() {
+                $(".level-2").stop(!0).animate({
+                    opacity: 1
+                })
+            },
+            function() {
+                $(".level-2").stop(!0).animate({
+                    opacity: 0
+                })
+            }),
+            $(".level-3").click(function() {
+                function t() {
+                    var t = e.css("background-position");
+                    if (e.css("display") == "none" || i == 0) {
+                        clearInterval(n),
+                        e.css("background-position", "0px 0px");
+                        e.css("height", "200px;");
+                        return
+                    }
+                    switch (t){
+                    case "0px 0px":
+                        e.css("background-position", "-176px 0px");
+                        break;
+                    case "-176px 0px":
+                        e.css("background-position", "-264px 0px");
+                        break;
+                    case "-264px 0px":
+                        e.css("background-position", "-352px 0px");
+                        break;
+                    case "-352px 0px":
+                        e.css("background-position", "-440px 0px");
+                        break;
+                    case "-440px 0px":
+                        e.css("background-position", "-176px 0px");
+                    }
+                }
+                if (!i) return;
+                n = setInterval(t, 50),
+                $("html,body").animate({scrollTop: 0},"slow");
+            });
+        });
+    </script>
+</div>

+ 132 - 0
Application/Admin/Controller/AccessController.class.php

@@ -0,0 +1,132 @@
+<?php
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+/**
+ * 管理员控制器
+ *
+ */
+class AccessController extends AdminController
+{
+    /**
+     * 管理员列表
+     * @param $tab 配置分组ID
+     *
+     */
+    public function index()
+    {
+        // 搜索
+        $keyword       = I('keyword', '', 'string');
+        $condition     = array('like', '%' . $keyword . '%');
+        $map['id|uid'] = array(
+            $condition,
+            $condition,
+            '_multi' => true,
+        );
+
+        // 获取所有配置
+        $map['status'] = array('egt', '0'); // 禁用和正常状态
+        $p             = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $access_object = D('Access');
+        $data_list     = $access_object
+            ->page($p, C('ADMIN_PAGE_ROWS'))
+            ->where($map)
+            ->order('sort asc,id asc')
+            ->select();
+        $page = new Page(
+            $access_object->where($map)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+
+        // 设置Tab导航数据列表
+        $group_object = D('Group');
+        $user_object  = D('User');
+        foreach ($data_list as $key => &$val) {
+            $val['username']    = $user_object->getFieldById($val['uid'], 'username');
+            $val['group_title'] = $group_object->getFieldById($val['group'], 'title');
+        }
+
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('管理员列表') // 设置页面标题
+            ->addTopButton('addnew') // 添加新增按钮
+            ->addTopButton('resume') // 添加启用按钮
+            ->addTopButton('forbid') // 添加禁用按钮
+            ->addTopButton('delete') // 添加删除按钮
+            ->setSearch('请输入ID/UID', U('index'))
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('uid', 'UID')
+            ->addTableColumn('username', '用户名')
+            ->addTableColumn('group_title', '用户组')
+            ->addTableColumn('status', '状态', 'status')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list) // 数据列表
+            ->setTableDataPage($page->show()) // 数据列表分页
+            ->addRightButton('edit') // 添加编辑按钮
+            ->addRightButton('forbid') // 添加禁用/启用按钮
+            ->addRightButton('delete') // 添加删除按钮
+            ->display();
+    }
+
+    /**
+     * 新增
+     *
+     */
+    public function add()
+    {
+        if (IS_POST) {
+            $access_object = D('Access');
+            $data          = $access_object->create();
+            if ($data) {
+                if ($access_object->add($data)) {
+                    $this->success('新增成功', U('index'));
+                } else {
+                    $this->error('新增失败');
+                }
+            } else {
+                $this->error($access_object->getError());
+            }
+        } else {
+            //使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('新增配置') //设置页面标题
+                ->setPostUrl(U('add')) //设置表单提交地址
+                ->addFormItem('uid', 'uid', 'UID', '用户ID')
+                ->addFormItem('group', 'select', '用户组', '不同用户组对应相应的权限', select_list_as_tree('Group'))
+                ->display();
+        }
+    }
+
+    /**
+     * 编辑
+     *
+     */
+    public function edit($id)
+    {
+        if (IS_POST) {
+            $access_object = D('Access');
+            $data          = $access_object->create();
+            if ($data) {
+                if ($access_object->save($data)) {
+                    $this->success('更新成功', U('index'));
+                } else {
+                    $this->error('更新失败');
+                }
+            } else {
+                $this->error($access_object->getError());
+            }
+        } else {
+            // 使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('编辑配置') // 设置页面标题
+                ->setPostUrl(U('edit')) // 设置表单提交地址
+                ->addFormItem('id', 'hidden', 'ID', 'ID')
+                ->addFormItem('uid', 'uid', 'UID', '用户ID')
+                ->addFormItem('group', 'select', '用户组', '不同用户组对应相应的权限', select_list_as_tree('Group'))
+                ->setFormData(D('Access')->find($id))
+                ->display();
+        }
+    }
+}

+ 186 - 0
Application/Admin/Controller/Activate1Controller.class.php

@@ -0,0 +1,186 @@
+<?php
+/**
+ * author jade
+ * intro 激活类
+ */
+namespace Admin\Controller;
+
+
+class activate1Controller extends AdminController
+{
+    protected $config;
+
+    /**
+     * author jade
+     * intro 类初始化方法
+     * param
+     * return
+     */
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->config=D('Config');
+    }
+
+    /**
+     * author jade
+     * intro 激活码包方法
+     * param  $group 调用系统配置项目
+     * return  bool
+     */
+     /*public function index()
+    {
+		ini_set('memory_limit', '2048M');
+        set_time_limit(0);
+		$t1 = microtime(true);
+		$dir = 'Data/active/jsl_1_27.txt';
+        $cont = file_get_contents(iconv("utf-8","gbk",$dir));
+		$cont = preg_replace('/\n|\r\n/','*',$cont);
+        $data = explode("*",$cont);
+        $data = array_filter($data);
+        $total = count($data);
+		$succ = 0;
+		foreach($data as $v){
+			$time = time();
+			$res = $this->data($time,$v,$dir);
+			if($res){
+				$succ++;
+			}
+		}
+		$t2 = microtime(true);
+		echo '耗时'.round($t2-$t1,3).'秒<br>';
+		echo 'Now memory_get_usage: ' . memory_get_usage() . '<br />';
+		echo $succ;
+        
+    }
+	protected function data($time,$data,$dir){
+		$dir_arr = explode('/',$dir);
+		$dir = array_pop($dir_arr);
+		$param = explode(",",$data);
+		$url = parse_url($param[0]);
+        $url = substr($url['path'],1);
+		$re = M()->execute('update `qr_codes` set update_time = '.$time.', active_time= '.$time.', status=1 '.'where code='."'".$url."'");
+		//日志
+		if(!$re){
+			w_log('Data/log/'.$dir,$data."插入失败,错误原因,激活失败");
+			return 0;
+		}else{
+			return 1;
+		}	
+	}*/
+	
+	public function index()
+    {
+        ini_set('memory_limit', '512M');
+        set_time_limit(0);
+        G('begin');
+        if(empty(I('txt'))){
+            return "亲,输入文件名";
+        }
+        $dir = 'Data/active/'.I('txt').'.txt';
+        $cont='';
+        $cont.= file_get_contents(iconv("utf-8","gbk",$dir));
+        $cont = preg_replace('/\n|\r\n/','*',$cont);
+        $data = explode("*",$cont);
+        $data = array_filter($data);
+        $succ = 0;
+        foreach($data as $v){
+            $res = $this->data(time(),$v,$dir);
+            if($res){
+                $succ++;
+            }
+        }
+        G('end');
+        echo G('begin','end').'s,'.G('begin','end','m').'kb'.'<br/>';
+        //unlink($dir);
+        w_log('Data/log/update_succ.txt',I('txt').'文件 成功插入'.$succ.'条,耗时'.G('begin','end').'秒\n');
+        echo $succ;
+        
+    }
+
+	protected function data($time,$data,$dir){
+		$dir_arr = explode('/',$dir);
+		$dir = $dir_arr[2];
+		$param = explode(",",$data);
+        $url = substr(parse_url($param[0], PHP_URL_PATH),1);
+		$re = M()->execute('update `qr_codes` set update_time = '.$time.', active_time= '.$time.', status=1 '.'where code='."'".$url."' and status = 0");
+		
+		//日志
+		if(!$re){
+			w_log('Data/log/'.$dir,$data."插入失败,错误原因,".M()->getError());
+			return 0;
+		}else{
+			return 1;
+		}	
+	}
+	
+	protected function data1($time,$data,$dir){
+		$dir_arr = explode('/',$dir);
+		$dir = array_pop($dir_arr);
+		$param = explode(",",$data);
+		$url = parse_url($param[0]);
+        $url = substr($url['path'],1);
+		$where = array();
+		$where['code'] = $url;
+		if(count($param)==2){
+			$where['varify_code'] = $param[1];
+		}
+		$return = M('codes')->where($where)->find();
+		if(!$return){
+			//写入日志
+			w_log('Data/log/'.$dir,$data."插入失败,错误原因,不存在");
+		}else{
+			if($return['Status']==1){
+				w_log('Data/log/'.$dir,$data."插入失败,错误原因,已激活");
+				return 1;
+			}else{
+				//激活
+				$re = M()->execute('update `qr_codes` set update_time = '.$time.', active_time= '.$time.', status=1 '.'where id='.$return["id"]);
+				//日志
+				if(!$re){
+					w_log('Data/log/'.$dir,$data."插入失败,错误原因,激活失败");
+					return 0;
+				}else{
+					return 1;
+				}
+			}	
+		}
+	}
+	public function check_code(){
+		ini_set('memory_limit', '2048M');
+        set_time_limit(0);
+		$arr1 = array('jsl_1.txt','jsl_2.txt','jsl_3.txt','jsl_4.txt','jsl_5.txt','jsl_6.txt','jsl_7.txt');
+		$arr2 = array('jsl_114300.txt','jsl_352000.txt','jsl_389066.txt','jsl_435731.txt','jsl_449840.txt','jsl_453771.txt','jsl_501431.txt');
+		$code1 = '';
+		$code2 = '';
+		foreach($arr1 as $v){
+			$code1.= file_get_contents(iconv("utf-8","gbk",'Data/active/'.$v));
+		}
+		foreach($arr2 as $v){
+			$code2.= file_get_contents(iconv("utf-8","gbk",'Data/active/'.$v));
+		}
+		$code1 = preg_replace('/\n|\r\n/','*',$code1);
+        $code1_arr= explode("*",$code1);
+        $code1_arr = array_filter($code1_arr);
+		$code2 = preg_replace('/\n|\r\n/','*',$code2);
+        $code2_arr= explode("*",$code2);
+        $code2_arr = array_filter($code2_arr);
+		unset($arr1) ;unset($arr2) ;unset($code1) ;unset($code2) ;
+		//$result=array_intersect($code1_arr,$code2_arr);
+		$num = count($code2_arr)-count(array_unique($code2_arr));
+		$return  =  array_diff_assoc ($code2_arr, array_unique($code2_arr));
+		w_log('Data/log/chonghe.txt','自身重合数据:');
+		foreach($return as $v){
+			w_log('Data/log/chonghe.txt',$v);
+		}
+		w_log('Data/log/chonghe.txt','总数'.$num);
+		w_log('Data/log/chonghe.txt','和第一批重合数据:');
+		$return1 = array_intersect($code1_arr,array_unique($code2_arr));
+		foreach($return1 as $v){
+			w_log('Data/log/chonghe.txt',$v);
+		}
+		w_log('Data/log/chonghe.txt','总数'.count($return1));
+		unset($code1_arr) ;unset($code2_arr) ;
+		echo yes;
+	}
+}

+ 142 - 0
Application/Admin/Controller/ActivateController.class.php

@@ -0,0 +1,142 @@
+<?php
+/**
+ * author jade
+ * intro 激活类
+ */
+namespace Admin\Controller;
+
+
+class activateController extends AdminController
+{
+    protected $config;
+
+    /**
+     * author jade
+     * intro 类初始化方法
+     * param
+     * return
+     */
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->config=D('Config');
+    }
+
+    /**
+     * author xtj
+     * intro 上传txt码包方法
+     * param  $group 调用系统配置项目
+     * return  bool
+     */
+	
+    public function index($batch_id)
+    {
+        $file_log = M('file_log');
+        ini_set('memory_limit', '2048M');
+        set_time_limit(0);
+        /*获取文件*/
+        //$batch_id  = 2;
+        $where = array();
+        $where['batch_id'] = $batch_id;
+        $where['creator'] = 'admin';
+        $file = $file_log->where($where)->getField('path',true); 
+        $printer_id = M('bach')->where('id = '.$batch_id)->getField('printer_id');
+        $cont = '';
+        $cont1 = '';
+	$where = array();
+        $where['batch_id'] = array('eq',$batch_id);
+        $where['creator'] = array('neq','admin');
+        $where['status'] = array('eq',0);
+        $file1 = $file_log->field('id,path')->where($where)->select();
+        if(count($file1)>0){
+            foreach($file as $v){
+                $fp = fopen(iconv("utf-8","gbk",$v), "r");
+                $cont .= fread($fp,filesize(iconv("utf-8","gbk",$v)));
+                $cont .="\n";
+                $cont = preg_replace('/\n|\r\n/','*',$cont);
+            }
+            $data = array_filter(explode("*",$cont));
+            foreach($file1 as $v){
+                $name = explode('/',$v['path']);
+                $name  = explode('_',basename(array_pop($name),'.txt'));
+                $tasks_id = $name[2] ;
+                //查询任务对应的产品id
+                $where= array();
+		$where['id'] = $tasks_id ;
+                $product = M('task')->field('product_id,is_verif')->where($where)->find();
+                $product_id = $product['product_id'];
+                $is_verif = $product['is_verif'];
+                $cont1 = '';
+                $cont1 .= file_get_contents(iconv("utf-8","gbk",$v['path']));
+                $cont1 = preg_replace('/\n|\r\n/','*',$cont1);
+                $data1 = explode("*",$cont1);
+                $data1 = array_filter($data1);
+                $total = count($data1);
+                unset($cont1);
+                $result=array_intersect($data,$data1);
+                unset($data1);
+                $this->add_data($result,$total,$batch_id,$tasks_id,$product_id,$printer_id,$v['id'],$is_verif);
+            }
+        }
+		//批量修改task表
+		$where= array();
+		$where['bach_id'] = $batch_id ;
+		$where['status'] = 2;
+		$task_id = M('task')->where($where)->getField('id',true);
+		foreach($task_id as $v){
+			$where= array();
+			$where['creator'] = array('neq','admin');
+			$where['task_id'] = $v;
+			$success_num = $file_log -> where($where)->sum(success_num);
+			$error_num = $file_log -> where($where)->sum('error_num');
+			if($success_num != ''){
+				M()->execute('update `qr_task` set checked_num = '.$success_num.', wrong_num= '.$error_num.', status=3 '.'where id='.$v );
+			}
+		}
+    }
+	
+    public function add_data($result,$total,$bach_id,$tasks_id,$product_id,$printer_id,$id,$is_verif){
+        $data_new = array_chunk($result,10000);
+        $i = count($data_new);
+        if($i>0){
+            $j = 0;
+            $num = 0;
+            for($j=0;$j<$i;$j++){
+                    $res = $this->data($data_new[$j],$bach_id,$tasks_id,$product_id,$printer_id,$is_verif);
+                    $num+=$res;
+            }
+            $succ = $num;
+            $error = $total-$succ;
+            //修改日志表
+            M()->execute('update  `qr_file_log` set total='.$total.', success_num='.$succ.',error_num='.$error.', status = 1 where id= '.$id);       
+            unset($data_new);
+        }else{
+           //直接修改file_log表
+           M()->execute('update `qr_file_log` set total = '.$total.', success_num= 0 , error_num='.$total.', status = 1 where id='.$id );
+        }
+        unset($result);
+    }
+	
+    public function data($data,$bach_id,$tasks_id,$product_id,$printer_id,$is_verif){
+        $time = time();
+        $p = $bach_id.",".$tasks_id.",".$product_id.",".$printer_id.",".$time.",".$time.",".$time.","."0,1";
+        if($is_verif){
+            array_walk($data, function(&$value,$key,$p){
+                $value =parse_url($value);
+                $value = substr($value['path'],1,-1);
+                $value = "('" .str_replace(",","','",$value)."',".$p.")";
+            },$p);  
+        }else{
+            array_walk($data, function(&$value,$key,$p){
+                $value =parse_url($value);
+                $value = substr($value['path'],1,-1);
+                $value = "('" .$value."',"."'',".$p.")";
+            },$p);
+        }
+        $resultStr = join(",", $data);
+        M()->execute("insert ignore INTO `qr_codes` (`code`,`varify_code`,`bach_id`,`tasks_id`,`product_id`,`printer_id`,`add_time`,`update_time`,`active_time`,`delete_time`,`Status`) values {$resultStr}");
+        $res = M()->query('SELECT ROW_COUNT()');
+        $num = $res[0]['ROW_COUNT()'];
+        return $num;
+    } 
+}

+ 125 - 0
Application/Admin/Controller/ActivatelistController.class.php

@@ -0,0 +1,125 @@
+<?php
+/**
+ * author jade
+ * intro 激活类
+ */
+namespace Admin\Controller;
+
+
+class ActivatelistController extends AdminController
+{
+    protected $config;
+
+    /**
+     * author jade
+     * intro 类初始化方法
+     * param
+     * return
+     */
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->config=D('Config');
+    }
+
+
+   
+    public function index()
+    {
+        $activate = M('activate_list');
+        $count = $activate->count();
+        $p = getpage($count,8);
+        $list = $activate->field(true)->order('id desc')->limit($p->firstRow, $p->listRows)->select();
+        $this->assign('meta_title','激活列表');
+        $this->assign('list', $list); // 赋值数据集
+        $this->assign('page', $p->show()); // 赋值分页输出
+        $this->display();
+    }
+    public function detail()
+    {
+        $id = I('id');
+        if (empty($id)) {
+            $this->error('id不能为空');
+        }
+        $detail = M('activate_list') ->where('id = '.$id)->select();
+        //判断激活状态
+        $a = $detail[0][succ]+$detail[0][fail];
+        if($a==0){
+            $status = 0;
+        }else if($detail['num']>$a){
+            $status = 1;
+        }else{
+            $status = 1;
+        }
+		//读取文件 start
+		$upload = "Data/Code_Active_list/".$detail[0][active_batch].'/0/';
+		$active = "Data/Code_Active_list/".$detail[0][active_batch].'/1/';
+        $upload_files=scandir($upload);
+		$upload_txt = '';
+		$active_files=scandir($active);
+		$active_txt = '';
+		foreach($upload_files as $key ){
+           if(get_extension($key)=='txt'){
+               //更新缓存
+               $upload_txt.=$key.'&nbsp&nbsp';
+           }
+        }
+		if($upload_txt==''){
+			$upload_txt = '无';
+		}
+		foreach($active_files as $key ){
+           if(get_extension($key)=='txt'){
+               //更新缓存
+               $active_txt.=$key.'&nbsp&nbsp';
+           }
+        }
+		if($active_txt==''){
+			$active_txt = '无';
+		}
+		
+		$this->assign('upload_txt', $upload_txt);
+		$this->assign('active_txt', $active_txt);
+		
+		//读取文件 stop
+        $this->assign('status', $status);
+        $this->assign('detail', $detail);
+        $this->assign('meta_title', '激活详情');
+        $this->display();
+    }
+    public function add()
+    {  
+        if (IS_POST) {
+            $activate = M('activate_list');
+            $list = array();
+            $list['active_batch'] = $_POST['active_batch'];
+			/*查询 start*/
+			$list['active_batch'] = repeat($list['active_batch']);
+			/*查询 stop*/
+            $list['remark'] = $_POST['remark'];
+            $list['status'] = 0;
+            $list['time'] = time();
+            $return = $activate->add($list);
+            if($return){
+                //创建激活文件夹
+                $dir =  'Data/Code_Active_list/'.$list['active_batch'];
+                if(!file_exists($dir.'/0')){
+                    mkdir($dir.'/0',0777,true);
+                }
+                 if(!file_exists($dir.'/1')){
+                    mkdir($dir.'/1',0777,true);
+                }
+                alert(array('info' => '申请成功', 'url' => "index.php?s=/Admin/Activatelist/index.html", 'status' => 1)); 
+            }else{
+                alert(array('info' => '申请失败', 'url' => "index.php?s=/Admin/Activatelist/add.html", 'status' => 0));
+            }
+        }else{
+			$res = M('activate_list')->field('id')->order('id desc')->limit(1)->find();
+            $rand = $res['id']+100000+1;
+            $this->assign('rand',$rand);
+            $this->display();
+        }
+    }
+   
+	
+   
+}

+ 446 - 0
Application/Admin/Controller/AddonController.class.php

@@ -0,0 +1,446 @@
+<?php
+
+namespace Admin\Controller;
+
+use Think\Page;
+use Util\Sql;
+
+/**
+ * 扩展后台管理页面
+ * 该类参考了OneThink的部分实现
+ *
+ */
+class AddonController extends AdminController
+{
+    /**
+     * 插件列表
+     *
+     */
+    public function index()
+    {
+        // 获取所有插件信息
+        $p            = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $addon_object = D('Addon');
+        $addons       = $addon_object
+            ->getAllAddon();
+
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('插件列表') // 设置页面标题
+            ->addTopButton('resume') // 添加启用按钮
+            ->addTopButton('forbid') // 添加禁用按钮
+            ->addTableColumn('name', '标识')
+            ->addTableColumn('title', '名称')
+            ->addTableColumn('description', '描述')
+            ->addTableColumn('status', '状态')
+            ->addTableColumn('author', '作者')
+            ->addTableColumn('version', '版本')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($addons) // 数据列表
+            ->display();
+    }
+
+    /**
+     * 设置插件页面
+     *
+     */
+    public function config()
+    {
+        if (IS_POST) {
+            $id     = (int) I('id');
+            $config = I('config');
+            $flag   = D('Addon')
+                ->where("id={$id}")
+                ->setField('config', json_encode($config));
+            if ($flag !== false) {
+                $this->success('保存成功', U('index'));
+            } else {
+                $this->error('保存失败');
+            }
+        } else {
+            $id    = (int) I('id');
+            $addon = D('Addon')->find($id);
+            if (!$addon) {
+                $this->error('插件未安装');
+            }
+            $addon_class = get_addon_class($addon['name']);
+            if (!class_exists($addon_class)) {
+                trace("插件{$addon['name']}无法实例化,", 'ADDONS', 'ERR');
+            }
+            $data                   = new $addon_class;
+            $addon['addon_path']    = $data->addon_path;
+            $addon['custom_config'] = $data->custom_config;
+            $this->meta_title       = '设置插件-' . $data->info['title'];
+            $db_config              = $addon['config'];
+            $addon['config']        = include $data->config_file;
+            if ($db_config) {
+                $db_config = json_decode($db_config, true);
+                foreach ($addon['config'] as $key => $value) {
+                    if ($value['type'] != 'group') {
+                        $addon['config'][$key]['value'] = $db_config[$key];
+                    } else {
+                        foreach ($value['options'] as $gourp => $options) {
+                            foreach ($options['options'] as $gkey => $value) {
+                                $addon['config'][$key]['options'][$gourp]['options'][$gkey]['value'] = $db_config[$gkey];
+                            }
+                        }
+                    }
+                }
+            }
+            // 构造表单名
+            foreach ($addon['config'] as $key => $val) {
+                if ($val['type'] == 'group') {
+                    foreach ($val['options'] as $key2 => $val2) {
+                        foreach ($val2['options'] as $key3 => $val3) {
+                            $addon['config'][$key]['options'][$key2]['options'][$key3]['name'] = 'config[' . $key3 . ']';
+                        }
+                    }
+                } else {
+                    $addon['config'][$key]['name'] = 'config[' . $key . ']';
+                }
+            }
+            $this->assign('data', $addon);
+            $this->assign('form_items', $addon['config']);
+            if ($addon['custom_config']) {
+                $this->assign('custom_config', $this->fetch($addon['addon_path'] . $addon['custom_config']));
+                $this->display($addon['addon_path'] . $addon['custom_config']);
+            } else {
+                //使用FormBuilder快速建立表单页面。
+                $builder = new \Common\Builder\FormBuilder();
+                $builder->setMetaTitle('插件设置') //设置页面标题
+                    ->setPostUrl(U('config')) //设置表单提交地址
+                    ->addFormItem('id', 'hidden', 'ID', 'ID')
+                    ->setExtraItems($addon['config']) //直接设置表单数据
+                    ->setFormData($addon)
+                    ->display();
+            }
+        }
+    }
+
+    /**
+     * 安装插件
+     *
+     */
+    public function install()
+    {
+        $addon_name = trim(I('addon_name'));
+        $class      = get_addon_class($addon_name);
+        if (!class_exists($class)) {
+            $this->error('插件不存在');
+        }
+        $addons = new $class;
+        $info   = $addons->info;
+        $hooks  = $addons->hooks;
+
+        // 检测信息的正确性
+        if (!$info || !$addons->checkInfo()) {
+            $this->error('插件信息缺失');
+        }
+        session('addons_install_error', null);
+        $install_flag = $addons->install();
+        if (!$install_flag) {
+            $this->error('执行插件预安装操作失败' . session('addons_install_error'));
+        }
+
+        // 检查该插件所需的钩子
+        if ($hooks) {
+            $hook_object = D('Hook');
+            foreach ($hooks as $val) {
+                $hook_object->existHook($val, array('description' => $info['description']));
+            }
+        }
+
+        // 安装数据库
+        $sql_file = realpath(C('ADDON_PATH') . $addon_name) . '/Sql/install.sql';
+        if (file_exists($sql_file)) {
+            $sql_object = new Sql();
+            $sql_status = $sql_object->execute_sql_from_file($sql_file);
+            if (!$sql_status) {
+                $this->error('执行插件SQL安装语句失败' . session('addons_install_error'));
+            }
+        }
+
+        $addon_object = D('Addon');
+        $data         = $addon_object->create($info);
+        if (is_array($addons->admin_list) && $addons->admin_list !== array()) {
+            $data['adminlist'] = 1;
+        } else {
+            $data['adminlist'] = 0;
+        }
+        if (!$data) {
+            $this->error($addon_object->getError());
+        }
+        if ($addon_object->add($data)) {
+            $config = array('config' => json_encode($addons->getConfig()));
+            $addon_object->where("name='{$addon_name}'")->save($config);
+            $hooks_update = D('Hook')->updateHooks($addon_name);
+            if ($hooks_update) {
+                S('hooks', null);
+                $this->success('安装成功');
+            } else {
+                $addon_object->where("name='{$addon_name}'")->delete();
+                $this->error('更新钩子处插件失败,请卸载后尝试重新安装');
+            }
+        } else {
+            $this->error('写入插件数据失败');
+        }
+    }
+
+    /**
+     * 卸载插件
+     *
+     */
+    public function uninstall()
+    {
+        $addon_object = D('Addon');
+        $id           = trim(I('id'));
+        $db_addons    = $addon_object->find($id);
+        $class        = get_addon_class($db_addons['name']);
+        $this->assign('jumpUrl', U('index'));
+        if (!$db_addons || !class_exists($class)) {
+            $this->error('插件不存在');
+        }
+        session('addons_uninstall_error', null);
+        $addons         = new $class;
+        $uninstall_flag = $addons->uninstall();
+        if (!$uninstall_flag) {
+            $this->error('执行插件预卸载操作失败' . session('addons_uninstall_error'));
+        }
+        $hooks_update = D('Hook')->removeHooks($db_addons['name']);
+        if ($hooks_update === false) {
+            $this->error('卸载插件所挂载的钩子数据失败');
+        }
+        S('hooks', null);
+        $delete = $addon_object->where("name='{$db_addons['name']}'")->delete();
+
+        // 卸载数据库
+        $sql_file = realpath(C('ADDON_PATH') . $db_addons['name']) . '/Sql/uninstall.sql';
+        if (file_exists($sql_file)) {
+            $sql_object = new Sql();
+            $sql_status = $sql_object->execute_sql_from_file($sql_file);
+            if (!$sql_status) {
+                $this->error('执行插件SQL卸载语句失败' . session('addons_uninstall_error'));
+            }
+        }
+
+        if ($delete === false) {
+            $this->error('卸载插件失败');
+        } else {
+            $this->success('卸载成功');
+        }
+    }
+
+    /**
+     * 外部执行插件方法
+     *
+     */
+    public function execute($_addons = null, $_controller = null, $_action = null)
+    {
+        if (C('URL_CASE_INSENSITIVE')) {
+            $_addons     = ucfirst(parse_name($_addons, 1));
+            $_controller = parse_name($_controller, 1);
+        }
+
+        $TMPL_PARSE_STRING                  = C('TMPL_PARSE_STRING');
+        $TMPL_PARSE_STRING['__ADDONROOT__'] = __ROOT__ . "/Addons/{$_addons}";
+        C('TMPL_PARSE_STRING', $TMPL_PARSE_STRING);
+
+        if (!empty($_addons) && !empty($_controller) && !empty($_action)) {
+            $Addons = A("Addons://{$_addons}/{$_controller}")->$_action();
+        } else {
+            $this->error('没有指定插件名称,控制器或操作!');
+        }
+    }
+
+    /**
+     * 插件后台显示页面
+     * @param string $name 插件名
+     *
+     */
+    public function adminList($name, $tab = 1)
+    {
+        // 获取插件实例
+        $addon_class = get_addon_class($name);
+        if (!class_exists($addon_class)) {
+            $this->error('插件不存在');
+        } else {
+            $addon = new $addon_class();
+        }
+
+        // 自定义插件后台页面
+        if ($addon->custom_adminlist) {
+            $this->assign('custom_adminlist', $this->fetch($addon->custom_adminlist));
+            $this->display($addon->custom_adminlist);
+        } else {
+            // 获取插件的$admin_list配置
+            $admin_list = $addon->admin_list;
+            $tab_list   = array();
+            foreach ($admin_list as $key => $val) {
+                $tab_list[$key]['title'] = $val['title'];
+                $tab_list[$key]['href']  = U('Admin/Addon/adminList', array(
+                    'name' => $name,
+                    'tab'  => $key,
+                ));
+            }
+            $admin = $admin_list[$tab];
+            $param = D('Addons://' . $name . '/' . $admin['model'] . '')->adminList;
+            if ($param) {
+                // 搜索
+                $keyword                           = (string) I('keyword');
+                $condition                         = array('like', '%' . $keyword . '%');
+                $map['id|' . $param['search_key']] = array(
+                    $condition,
+                    $condition,
+                    '_multi' => true,
+                );
+
+                // 获取数据列表
+                $p         = !empty($_GET["p"]) ? $_GET['p'] : 1;
+                $data_list = M($param['model'])
+                    ->page($p, C('ADMIN_PAGE_ROWS'))
+                    ->where($map)
+                    ->field(true)
+                    ->order($param['order'])
+                    ->select();
+                $page = new Page(M($param['model'])
+                        ->where($map)
+                        ->count(), C('ADMIN_PAGE_ROWS'));
+
+                // 使用Builder快速建立列表页面。
+                $builder = new \Common\Builder\ListBuilder();
+                $builder->setMetaTitle($addon->info['title']) // 设置页面标题
+                    ->AddTopButton('addnew', array('href' => U('Admin/Addon/adminAdd', array('name' => $name, 'tab' => $tab)))) // 添加新增按钮
+                    ->AddTopButton('resume', array('model' => $param['model'])) // 添加启用按钮
+                    ->AddTopButton('forbid', array('model' => $param['model'])) // 添加禁用按钮
+                    ->setSearch('请输入关键字', U('Admin/Addon/adminList', array('name' => $name, 'tab' => $tab)))
+                    ->SetTabNav($tab_list, $tab) // 设置Tab按钮列表
+                    ->setTableDataList($data_list) // 数据列表
+                    ->setTableDataPage($page->show()); // 数据列表分页
+
+                // 根据插件的list_grid设置后台列表字段信息
+                foreach ($param['list_grid'] as $key => $val) {
+                    $builder->addTableColumn($key, $val['title'], $val['type']);
+                }
+
+                // 根据插件的right_button设置后台列表右侧按钮
+                foreach ($param['right_button'] as $key => $val) {
+                    $builder->addRightButton('self', $val);
+                }
+
+                // 定义编辑按钮
+                $attr          = array();
+                $attr['name']  = 'edit';
+                $attr['title'] = '编辑';
+                $attr['class'] = 'label label-info-outline label-pill';
+                $attr['href']  = U('Admin/Addon/adminEdit', array(
+                    'name' => $name,
+                    'tab'  => $tab,
+                    'id'   => '__data_id__',
+                ));
+
+                // 显示列表
+                $builder->addTableColumn('right_button', '操作', 'btn')
+                    ->addRightButton('self', $attr) //添加编辑按钮
+                    ->addRightButton('forbid', array('model' => $param['model'])) // 添加禁用/启用按钮
+                    ->addRightButton('delete', array('model' => $param['model'])) // 添加删除按钮
+                    ->display();
+            } else {
+                $this->error('插件列表信息不正确');
+            }
+        }
+    }
+
+    /**
+     * 插件后台数据增加
+     * @param string $name 插件名
+     *
+     */
+    public function adminAdd($name, $tab)
+    {
+        // 获取插件实例
+        $addon_class = get_addon_class($name);
+        if (!class_exists($addon_class)) {
+            $this->error('插件不存在');
+        } else {
+            $addon = new $addon_class();
+        }
+
+        // 获取插件的$admin_list配置
+        $admin_list         = $addon->admin_list;
+        $admin              = $admin_list[$tab];
+        $addon_model_object = D('Addons://' . $name . '/' . $admin['model']);
+        $param              = $addon_model_object->adminList;
+        if ($param) {
+            if (IS_POST) {
+                $data = $addon_model_object->create();
+                if ($data) {
+                    $result = $addon_model_object->add($data);
+                } else {
+                    $this->error($addon_model_object->getError());
+                }
+                if ($result) {
+                    $this->success('新增成功', U('Admin/Addon/adminlist', array('name' => $name, 'tab' => $tab)));
+                } else {
+                    $this->error('更新错误');
+                }
+            } else {
+                // 使用FormBuilder快速建立表单页面。
+                $builder = new \Common\Builder\FormBuilder();
+                $builder->setMetaTitle('新增数据') //设置页面标题
+                    ->setPostUrl(U('Admin/Addon/adminAdd', array('name' => $name, 'tab' => $tab))) // 设置表单提交地址
+                    ->setExtraItems($param['field'])
+                    ->display();
+            }
+        } else {
+            $this->error('插件列表信息不正确');
+        }
+    }
+
+    /**
+     * 插件后台数据编辑
+     * @param string $name 插件名
+     *
+     */
+    public function adminEdit($name, $tab, $id)
+    {
+        // 获取插件实例
+        $addon_class = get_addon_class($name);
+        if (!class_exists($addon_class)) {
+            $this->error('插件不存在');
+        } else {
+            $addon = new $addon_class();
+        }
+
+        // 获取插件的$admin_list配置
+        $admin_list         = $addon->admin_list;
+        $admin              = $admin_list[$tab];
+        $addon_model_object = D('Addons://' . $name . '/' . $admin['model']);
+        $param              = $addon_model_object->adminList;
+        if ($param) {
+            if (IS_POST) {
+                $data = $addon_model_object->create();
+                if ($data) {
+                    $result = $addon_model_object->save($data);
+                } else {
+                    $this->error($addon_model_object->getError());
+                }
+                if ($result) {
+                    $this->success('更新成功', U('Admin/Addon/adminlist', array('name' => $name, 'tab' => $tab)));
+                } else {
+                    $this->error('更新错误');
+                }
+            } else {
+                // 使用FormBuilder快速建立表单页面。
+                $builder = new \Common\Builder\FormBuilder();
+                $builder->setMetaTitle('编辑数据') // 设置页面标题
+                    ->setPostUrl(U('admin/addon/adminedit', array('name' => $name, 'tab' => $tab))) // 设置表单提交地址
+                    ->addFormItem('id', 'hidden', 'ID', 'ID')
+                    ->setExtraItems($param['field'])
+                    ->setFormData(M($param['model'])->find($id))
+                    ->display();
+            }
+        } else {
+            $this->error('插件列表信息不正确');
+        }
+    }
+}

+ 279 - 0
Application/Admin/Controller/AdminController.class.php

@@ -0,0 +1,279 @@
+<?php
+
+namespace Admin\Controller;
+
+use Common\Controller\ControllerController;
+
+/**
+ * 后台公共控制器
+ * 为什么要继承AdminController?
+ * 因为AdminController的初始化函数中读取了顶部导航栏和左侧的菜单,
+ * 如果不继承的话,只能复制AdminController中的代码来读取导航栏和左侧的菜单。
+ * 这样做会导致一个问题就是当AdminController被官方修改后不会同步更新,从而导致错误。
+ * 所以综合考虑还是继承比较好。
+ *
+ */
+class AdminController extends ControllerController
+{
+    /**
+     * 初始化方法
+     *
+     */
+    protected function _initialize()
+    {
+        // 登录检测
+        if (!is_login()) {
+            //还没登录跳转到登录页面
+            $this->redirect('Admin/Public/login');
+        }
+        C('PARSE_VAR', true);
+
+        // 权限检测
+        $current_url = MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME;
+        if ('Admin/Index/index' !== $current_url) {
+            if (!D('Admin/Group')->checkMenuAuth()) {
+                $this->error('权限不足!',$_SERVER['HTTP_REFERER']);
+            }
+            $this->assign('_admin_tabs', C('ADMIN_TABS'));
+        }
+
+        // 获取所有导航
+        $module_object = D('Admin/Module');
+        $menu_list     = $module_object->getAllMenu();
+        if(session('user_auth.uid')==1 && C('ADMIN_TABS')){
+            array_splice($menu_list[MODULE_NAME]['_child'][3]['_child'],0,2);//TODO 暂时没找到更好的办法,临时隐藏 xtj
+        }
+        $this->assign('_menu_list', $menu_list); // 后台主菜单
+
+        // 获取左侧导航
+        if (!C('ADMIN_TABS')) {
+            $parent_menu_list = $module_object->getParentMenu();
+            if (isset($parent_menu_list[0]['top'])) {
+                $current_menu_list = $menu_list[$parent_menu_list[0]['top']];
+            } else {
+                if(session('user_auth.uid')==1){
+                    array_splice($menu_list[MODULE_NAME]['_child'][3]['_child'],0,2);//TODO 暂时没找到更好的办法,临时隐藏 xtj
+                }
+                $current_menu_list = $menu_list[MODULE_NAME];
+            }
+
+            $this->assign('_current_menu_list', $current_menu_list); // 后台左侧菜单
+            $this->assign('_parent_menu_list', $parent_menu_list); // 后台父级菜单
+        }
+    }
+
+    /**
+     * 设置一条或者多条数据的状态
+     * @param $script 严格模式要求处理的纪录的uid等于当前登陆用户UID
+     *
+     */
+    public function setStatus($model = CONTROLLER_NAME, $script = false)
+    {
+        $ids    = I('request.ids');
+        $status = I('request.status');
+        if (empty($ids)) {
+            $this->error('请选择要操作的数据');
+        }
+        $model_primary_key       = D($model)->getPk();
+        $map[$model_primary_key] = array('in', $ids);
+        if ($script) {
+            $map['uid'] = array('eq', is_login());
+        }
+        switch ($status) {
+            case 'forbid': // 禁用条目
+                $data = array('status' => 0);
+                $this->editRow(
+                    $model,
+                    $data,
+                    $map,
+                    array('success' => '禁用成功', 'error' => '禁用失败')
+                );
+                break;
+            case 'resume': // 启用条目
+                $data = array('status' => 1);
+                $map  = array_merge(array('status' => 0), $map);
+                $this->editRow(
+                    $model,
+                    $data,
+                    $map,
+                    array('success' => '启用成功', 'error' => '启用失败')
+                );
+                break;
+            case 'recycle': // 移动至回收站
+                $data['status'] = -1;
+                $this->editRow(
+                    $model,
+                    $data,
+                    $map,
+                    array('success' => '成功移至回收站', 'error' => '删除失败')
+                );
+                break;
+            case 'restore': // 从回收站还原
+                $data = array('status' => 1);
+                $map  = array_merge(array('status' => -1), $map);
+                $this->editRow(
+                    $model,
+                    $data,
+                    $map,
+                    array('success' => '恢复成功', 'error' => '恢复失败')
+                );
+                break;
+            case 'delete': // 删除条目
+                $result = D($model)->where($map)->delete();
+                if ($result) {
+                    $this->success('删除成功,不可恢复!');
+                } else {
+                    $this->error('删除失败');
+                }
+                break;
+            default:
+                $this->error('参数错误');
+                break;
+        }
+    }
+
+    /**
+     * 对数据表中的单行或多行记录执行修改 GET参数id为数字或逗号分隔的数字
+     * @param string $model 模型名称,供M函数使用的参数
+     * @param array  $data  修改的数据
+     * @param array  $map   查询时的where()方法的参数
+     * @param array  $msg   执行正确和错误的消息
+     *                       array(
+     *                           'success' => '',
+     *                           'error'   => '',
+     *                           'url'     => '',   // url为跳转页面
+     *                           'ajax'    => false //是否ajax(数字则为倒数计时)
+     *                       )
+     *
+     */
+    final protected function editRow($model, $data, $map, $msg)
+    {
+        $id = array_unique((array) I('id', 0));
+        $id = is_array($id) ? implode(',', $id) : $id;
+        //如存在id字段,则加入该条件
+        $fields = D($model)->getDbFields();
+        if (in_array('id', $fields) && !empty($id)) {
+            $where = array_merge(
+                array('id' => array('in', $id)),
+                (array) $where
+            );
+        }
+        $msg = array_merge(
+            array(
+                'success' => '操作成功!',
+                'error'   => '操作失败!',
+                'url'     => ' ',
+                'ajax'    => IS_AJAX,
+            ),
+            (array) $msg
+        );
+        $result = D($model)->where($map)->save($data);
+        if ($result != false) {
+            $this->success($msg['success'], $msg['url'], $msg['ajax']);
+        } else {
+            $this->error($msg['error'], $msg['url'], $msg['ajax']);
+        }
+    }
+
+    /**
+     * 模块配置方法
+     *
+     */
+    public function module_config()
+    {
+        if (IS_POST) {
+            $id     = (int) I('id');
+            $config = I('config');
+            $flag   = D('Admin/Module')
+                ->where("id={$id}")
+                ->setField('config', json_encode($config));
+            if ($flag !== false) {
+                $this->success('保存成功');
+            } else {
+                $this->error('保存失败');
+            }
+        } else {
+            $name        = MODULE_NAME;
+            $config_file = realpath(APP_PATH . $name) . '/' . D('Admin/Module')->install_file();
+            if (!$config_file) {
+                $this->error('配置文件不存在');
+            }
+            $module_config = include $config_file;
+
+            $module_info = D('Admin/Module')->where(array('name' => $name))->find($id);
+            $db_config   = $module_info['config'];
+
+            // 构造配置
+            if ($db_config) {
+                $db_config = json_decode($db_config, true);
+                foreach ($module_config['config'] as $key => $value) {
+                    if ($value['type'] != 'group') {
+                        $module_config['config'][$key]['value'] = $db_config[$key];
+                    } else {
+                        foreach ($value['options'] as $gourp => $options) {
+                            foreach ($options['options'] as $gkey => $value) {
+                                $module_config['config'][$key]['options'][$gourp]['options'][$gkey]['value'] = $db_config[$gkey];
+                            }
+                        }
+                    }
+                }
+            }
+
+            // 构造表单名
+            foreach ($module_config['config'] as $key => $val) {
+                if ($val['type'] == 'group') {
+                    foreach ($val['options'] as $key2 => $val2) {
+                        foreach ($val2['options'] as $key3 => $val3) {
+                            $module_config['config'][$key]['options'][$key2]['options'][$key3]['name'] = 'config[' . $key3 . ']';
+                        }
+                    }
+                } else {
+                    $module_config['config'][$key]['name'] = 'config[' . $key . ']';
+                }
+            }
+
+            //使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('设置') //设置页面标题
+                ->setPostUrl(U('')) //设置表单提交地址
+                ->addFormItem('id', 'hidden', 'ID', 'ID')
+                ->setExtraItems($module_config['config']) //直接设置表单数据
+                ->setFormData($module_info)
+                ->display();
+        }
+    }
+
+    /**
+     * 扩展日期搜索map
+     * @param $map array 引用型
+     * @param string $field 搜索的时间范围字段
+     * @param string $type datetime  类型 或 timestamp 时间戳
+     * @param boolean $not_empty 是否允许空值搜索到
+     */
+    public function extendDates(&$map, $field = 'update_time', $type = 'datetime', $not_empty = false)
+    {
+        $dates = I('dates', '', 'trim');
+        if ($dates) {
+            $start_date = substr($dates, 0, 10);
+            $end_date   = substr($dates, 11, 10);
+            if ($type == 'datetime') {
+                $map[$field] = [
+                    ['egt', $start_date . ' 00:00:00'],
+                    ['lt', $end_date . ' 23:59:59'],
+                ];
+                if ($not_empty) {
+                    $map[$field][] = ['exp', 'IS NOT NUll'];
+                }
+            } else {
+                $map[$field] = [
+                    ['egt', strtotime($start_date . ' 00:00:00')],
+                    ['lt', strtotime($end_date . ' 23:59:59')],
+                ];
+            }
+        }
+        // else {
+        //     $start_date = datetime("-365 days", 'Y-m-d');
+        //     $end_date   = datetime('now', 'Y-m-d');
+        // }
+    }
+}

+ 492 - 0
Application/Admin/Controller/ApplyBatchController.class.php

@@ -0,0 +1,492 @@
+<?php
+/**
+ * author Gentle
+ * intro 申请批次
+ */
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+class ApplyBatchController extends AdminController
+{
+    /**
+     * author Gentle
+     * intro 类初始化方法
+     * param
+     * return
+     */
+    public function _initialize()
+    {
+        parent::_initialize(); // TODO: Change the autogenerated stub
+        $this->uid = session('user_auth.uid');
+        // $this->redundancy_s = 0.1;//冗码率
+        $this->redundancy_s = 0;//冗码率修改为0 时间:2017年11月30日16:22:17
+    }
+
+    /**
+     * author Gentle
+     * intro 获取用户组
+     * param
+     */
+    public function getGroups()
+    {
+        $uid = $this->uid;
+        $admin_access_model = D(Admin_access);
+        $groups = $admin_access_model->where('uid=' . $uid)->getField('group');//1 超级管理 2 印刷厂 3 中烟
+        return $groups;
+    }
+
+    /**
+     * author Gentle
+     * intro 申请批次首页
+     * param
+     */
+    public function index()
+    {
+        /**
+         * @author Gentle
+         * @tro 遍历展示产品名称、盒型
+         * @time 2017年9月11日09:35:58
+         */
+        if (session('user_auth.uid') == 1) {
+            $this->success('暂不支持管理员操作');
+            exit;
+        }
+        $printer_list = M(Admin_access)
+            ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __ADMIN_ACCESS__.uid')
+            ->field('QR_ADMIN_USER.id printer_id,QR_ADMIN_USER.nickname printer_name')
+            ->where('QR_ADMIN_ACCESS.group=2')->order('QR_ADMIN_USER.id asc')->select();
+        foreach ($printer_list as $val) {
+            $printer[] = $val;
+        }
+
+        $factory_model = D(Factory);
+        $list2 = $factory_model->field('id,name')->where('id>0')->order('id asc')->select();
+        foreach ($list2 as $val) {
+            $factory_result[] = $val;
+            $factory_id[] = $val['id'];
+        }
+        $product_model = D(Product);
+        $list = $product_model->field('id,name')->where('factory_id IN (' . implode(',', $factory_id) . ')')->order('id asc')->select();
+        foreach ($list as $val) {
+            $product_result[] = $val;
+            $product_id[] = $val['id'];
+        }
+
+        //暂时不使用
+        $list2 = M(Product_box_type)
+            ->join('__BOX_TYPE__ ON __BOX_TYPE__.id = __PRODUCT_BOX_TYPE__.box_type_id')
+            ->field('QR_BOX_TYPE.id type_id,QR_BOX_TYPE.name box_type_name')
+            ->where('QR_PRODUCT_BOX_TYPE.product_id>0')->order('QR_PRODUCT_BOX_TYPE.id asc')->select();
+        foreach ($list2 as $val) {
+            $box_type_result[] = $val['type_id'];
+        }
+        $this->assign('printer', $printer);
+        $this->assign('product_result', $product_result);
+        $this->assign('factory_result', $factory_result);
+        $this->assign('meta_title', '申请批次');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 申请批次列表页面
+     * param
+     */
+    public function applyList()
+    {
+        /**
+         * @author Gentle
+         * @tro 遍历展示申请批次列表
+         * @time 2017年9月12日14:17:17
+         */
+        //分页
+        $bach = M(Bach);
+        $uid = $this->uid;
+
+        $groups = $this->GetGroups();
+        if ($groups == '3') {
+            $where = 'QR_BACH.owner_id=' . $uid;
+            $page = new Page(
+                $bach->where('owner_id=' . $uid)->count(),
+                C('ADMIN_PAGE_ROWS')
+            );
+        } else if ($groups == '2') {
+            $where = 'QR_BACH.printer_id=' . $uid;
+            $page = new Page(
+                $bach->where('printer_id=' . $uid)->count(),
+                C('ADMIN_PAGE_ROWS')
+            );
+        } else {
+            $where = 'QR_BACH.id > 0';
+            $page = new Page(
+                $bach->where('id>0')->count(),
+                C('ADMIN_PAGE_ROWS')
+            );
+        }
+        $show = $page->show();
+        $bach_list = M(Bach)
+            ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __BACH__.printer_id')
+            ->field('QR_BACH.id bach_id,QR_BACH.name bach_name,QR_BACH.add_time,QR_ADMIN_USER.nickname printer_name')
+            ->limit($page->firstRow . ',' . $page->listRows)
+            ->where($where)->order('QR_BACH.id desc')->select();
+        
+        $task = M(Task);
+        foreach ($bach_list as $value) {
+            $task_ids[] = $task->field('id')->where('bach_id=' . $value['bach_id'])->order('id desc')->select();
+        }
+        foreach ($task_ids as $vals) {
+            foreach ($vals as $val) {
+                $task_list[] = M(Task)
+                    ->join('__FACTORY__ ON __FACTORY__.id=__TASK__.factory_id ')
+                    ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __TASK__.printer_id')
+                    ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.id=__TASK__.product_id')
+                    ->join('__PRODUCT__ ON __PRODUCT__.id=__PRODUCT_BOX_TYPE__.product_id')
+                    ->join('__BOX_TYPE__ ON __BOX_TYPE__.id=__PRODUCT_BOX_TYPE__.box_type_id')
+                    ->field('QR_TASK.id task_id,QR_TASK.quality,QR_TASK.bach_id,QR_PRODUCT.name product_name,QR_BOX_TYPE.name box_type_name')->where('QR_TASK.id= ' . $val['id'])->select();
+            }
+        }
+        foreach ($task_list as $val) {
+            foreach ($val as $v) {
+                $task_list2[] = $v;
+
+            }
+        }
+        
+        $this->assign('bach_page', $show);
+        $this->assign('bach_list', $bach_list);
+        $this->assign('task_list2', $task_list2);
+        $this->assign('meta_title', '批次列表');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 任务列表页面
+     * param
+     */
+    public function taskList()
+    {
+        /**
+         * @author Gentle
+         * @tro 遍历展示申请批次列表
+         * @time 2017年9月15日13:17:17
+         */
+        if (empty($_GET['bach_id'])) {
+            $this->error('批次id不能为空');
+        }
+        $bach_id = $_GET['bach_id'];
+        //分页
+        $task = M(Task);
+        $page = new Page(
+            $task->where('bach_id=' . $bach_id)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+        $show = $page->show();
+
+        $task_ids = $task->field('id')->where('bach_id=' . $bach_id)->order('id desc')->select();
+        foreach ($task_ids as $val) {
+            $task_list[] = M(Task)
+                ->join('__FACTORY__ ON __FACTORY__.id=__TASK__.factory_id ')
+                ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __TASK__.printer_id')
+                ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.id=__TASK__.product_id')
+                ->join('__PRODUCT__ ON __PRODUCT__.id=__PRODUCT_BOX_TYPE__.product_id')
+                ->join('__BOX_TYPE__ ON __BOX_TYPE__.id=__PRODUCT_BOX_TYPE__.box_type_id')
+                ->field('printer_id,QR_PRODUCT_BOX_TYPE.id product_id,QR_ADMIN_USER.nickname printer_name,QR_TASK.id task_id,QR_TASK.checked_num,QR_TASK.wrong_num,QR_TASK.name task_name,QR_TASK.quality,QR_TASK.add_time,QR_TASK.is_verif,QR_TASK.bach_id,QR_TASK.status,QR_FACTORY.name factory_name,QR_PRODUCT.name product_name,QR_BOX_TYPE.name box_type_name')->where('QR_TASK.id= ' . $val['id'])->find();
+        }
+        foreach ($task_list as &$val) {
+          	$val['checked_num'] = $val['checked_num']/10000;
+          	$val['wrong_numck_num'] = $val['wrong_num']/10000;
+        }
+        unset($val);
+        $this->assign('task_page', $show);
+        $this->assign('task_list', $task_list);
+        $this->assign('meta_title', '任务列表');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 任务详情页面
+     * param 2017年9月15日15:31:22
+     */
+    public function taskDetail()
+    {
+        /**
+         * @author Gentle
+         * @tro 批次详情页面展示
+         * @time 2017年9月13日19:27:28
+         */
+        if (empty($_GET['task_id'])) {
+            $this->error('任务id不能为空');
+        }
+        $task_id = $_GET['task_id'];
+        $task_detail = M(Task)
+            ->join('__FACTORY__ ON __FACTORY__.id=__TASK__.factory_id ')
+            ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.id=__TASK__.product_id')
+            ->join('__PRODUCT__ ON __PRODUCT__.id=__PRODUCT_BOX_TYPE__.product_id')
+            ->join('__BOX_TYPE__ ON __BOX_TYPE__.id=__PRODUCT_BOX_TYPE__.box_type_id')
+            ->field('QR_TASK.id task_id,QR_TASK.printer_id printer_id,QR_TASK.name task_name,QR_TASK.bach_id,QR_TASK.lock,QR_TASK.quality,QR_TASK.redundancy,QR_TASK.add_time,QR_TASK.is_verif,QR_TASK.bach_id,QR_TASK.status,QR_TASK.checked_num,QR_TASK.wrong_num,QR_FACTORY.name factory_name,qr_product_box_type.id product_id,QR_PRODUCT.name product_name,QR_BOX_TYPE.name box_type_name')
+            ->where('QR_TASK.id=' . $task_id)->order('QR_TASK.id asc')->select();
+      $task_detail[0][checked_num] = $task_detail[0][checked_num]/10000;
+      $task_detail[0][wrong_num] = $task_detail[0][wrong_num]/10000;
+        /*
+                foreach ($task_detail as $k=>$v){
+                    $task_ids=M('task')->where(array('name'=>$v['task_name']))->getField('id',true);
+                    if(in_array($v['task_id'],$task_ids)){
+
+                    }
+                }*/
+        $this->assign('task_detail', $task_detail);
+        $this->assign('meta_title', '任务详情');
+        $this->assign('redundancy_s', ($this->redundancy_s)*100);
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 申请批次方法
+     * param
+     * return  bool
+     */
+    public function applyForm()
+    {
+        if (IS_POST) {
+            $bach_object = D("Bach");
+            $bach_product_object = D("Bach_product");
+            $task_object = D("Task");
+            //校验$_POST数据
+            if (empty($_POST['product_id'])) {
+                alert(array('info' => '产品不能为空', 'status' => 2));
+                exit;
+            }
+            if (empty($_POST['factory_id'])) {
+                alert(array('info' => '工厂名称不能为空', 'status' => 3));
+                exit;
+            }
+            if (empty($_POST['printer_id'])) {
+                alert(array('info' => '印刷厂名称不能为空', 'status' => 4));
+                exit;
+            }
+            if (empty($_POST['code_num1']) and empty($_POST['code_num2'])) {
+                alert(array('info' => '条盒、小包数量不能都小于0', 'status' => 5));
+                exit;
+            }
+            
+            $product_id = $_POST['product_id'];
+            $factory_id = $_POST['factory_id'];
+            $printer_id = $_POST['printer_id'];
+            $is_verif = (int)$_POST['is_verif'];
+            $remark = $_POST['remark'];
+            $code_num = [
+                'code_num1' => $_POST['code_num1'],
+                'code_num2' => $_POST['code_num2']
+            ];
+            //查找产品、类别关联表
+            $product_box_type_ids = M(Product_box_type)
+                ->field('id')
+                ->where('product_id=' . $product_id)->order('box_type_id asc')->select();
+            foreach ($product_box_type_ids as $val) {
+                $product_box_type_id[] = $val['id'];
+            }
+
+            $data = [];
+            $data['name'] = 'MNYH_' . date("Ymdhi", time());
+            $data['add_time'] = time();
+            $data['remark'] = $remark;
+            $data['printer_id'] = $printer_id;
+            $data['owner_id'] = $this->uid;
+
+            $param = [];
+            $param['product_id'] = $product_id;
+            $param['is_verif'] = $is_verif;
+            $param['add_time'] = time();
+            $param['remark'] = $remark;
+            $param1 = $param;
+            $param2 = $param;
+            $param1['num'] = $code_num['code_num1'];
+            $param1['product_id'] = $product_box_type_id[0];
+            $param2['num'] = $code_num['code_num2'];
+            $param2['product_id'] = $product_box_type_id[1];
+            $add_param = [
+                $param1,
+                $param2
+            ];
+
+            $params = [];
+            $params['name'] = $data['name'];
+            $params['factory_id'] = $factory_id;
+            $params['is_verif'] = $is_verif;
+            $params['add_time'] = time();
+            $params['remark'] = $remark;
+            $params['status'] = '0';
+            $params['printer_id'] = $printer_id;
+            $params['owner_id'] = $this->uid;
+            $params1 = $params;
+            $params2 = $params;
+
+            $params1['quality'] = $code_num['code_num1'];
+            $params1['redundancy'] = $code_num['code_num1'] * $this->redundancy_s;
+            $params1['product_id'] = $product_box_type_id[0];
+            $params2['quality'] = $code_num['code_num2'];
+            $params2['redundancy'] = $code_num['code_num2'] * $this->redundancy_s;
+            $params2['product_id'] = $product_box_type_id[1];
+
+            if ($data && $add_param) {
+                $bach_id = $bach_object->add($data);
+                $param1['bach_id'] = $bach_id;
+                $param2['bach_id'] = $bach_id;
+                if(empty($code_num['code_num1']) and !empty($code_num['code_num2'])){
+                    $add_param = $param2;
+                    $bach_product_id = $bach_product_object->add($add_param);
+                }else if(empty($code_num['code_num2']) and !empty($code_num['code_num1'])){
+                    $add_param = $param1;
+                    $bach_product_id = $bach_product_object->add($add_param);
+                }else{
+                    $add_param = [
+                        $param1,
+                        $param2
+                    ];
+                    $bach_product_id = $bach_product_object->addAll($add_param);
+                }
+                
+                if ($bach_id && $bach_product_id) {
+                    $params1['bach_id'] = $bach_id;
+                    $params2['bach_id'] = $bach_id;
+                    if(empty($code_num['code_num1']) and !empty($code_num['code_num2'])){
+                        $add_params = $params2;
+                        $task_id = $task_object->add($add_params);
+                    }else if(empty($code_num['code_num2']) and !empty($code_num['code_num1'])){
+                        $add_params = $params1;
+                        $task_id = $task_object->add($add_params);
+                    }else{
+                        $add_params = [
+                            $params1,
+                            $params2
+                        ];
+                    $task_id = $task_object->addAll($add_params);
+                    }
+                    
+                    if ($task_id) {
+                        alert(array('info' => '申请成功', 'url' => "index.php?s=/Admin/ApplyBatch/applylist.html", 'status' => 1));
+                    } else {
+                        alert(array('info' => '申请失败', 'url' => "index.php?s=/Admin/ApplyBatch/Index.html", 'status' => 0));
+                    }
+                } else {
+                    $this->error($bach_object->getError());
+                }
+            } else {
+                $this->error($bach_object->getError());
+            }
+        } else {
+            // 跳转到申请批次页面
+            header("Location: {:U('ApplyBatch/applylist')}");
+
+        }
+    }
+
+    /**
+     * author Gentle
+     * intro 批次补单申请页面
+     * param
+     */
+    public function addTaskIndex()
+    {
+        if (empty($_GET['task_id'])) {
+            $this->error('补单任务id不能为空');
+        }
+        $task_id = $_GET['task_id'];
+        $task_model = D("Task");
+        $tasks = $task_model->field('bach_id')->where('id=' . $task_id)->order('id asc')->find();
+        $bach_id = $tasks['bach_id'];
+        $bach_model = D("Bach");
+        $bach_name = $bach_model->field('name')->where('id=' . $bach_id)->order('id asc')->find();
+        $bach_contents['task_id'] = $task_id;
+        $bach_contents['bach_id'] = $bach_id;
+        $bach_contents['bach_name'] = $bach_name['name'];
+        $task_list = $task_model->field('product_id')->where('bach_id=' . $bach_id)->order('id asc')->select();
+        if (empty($task_list)) {
+            $this->error('您未创建过该任务,请核对任务后操作!');
+        }
+        foreach ($task_list as $val) {
+            $product_id[] = $val['product_id'];
+            $product_id = array_unique($product_id);
+        }
+        foreach ($product_id as $val) {
+            $product_contents[] = M(Box_type)
+                ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.box_type_id = __BOX_TYPE__.id')
+                ->field('QR_PRODUCT_BOX_TYPE.id product_id,QR_BOX_TYPE.name box_type_name')
+                ->where('QR_PRODUCT_BOX_TYPE.id=' . $val)->order('QR_PRODUCT_BOX_TYPE.id asc')->select();
+        }
+
+        foreach ($product_contents as $val) {
+            foreach ($val as $v) {
+                $product_contents_list[] = $v;
+            }
+        }
+
+        $this->assign('bach_contents', $bach_contents);
+        $this->assign('product_contents_list', $product_contents_list);
+        $this->assign('meta_title', '任务补单申请');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 批次补单申请方法
+     * param
+     */
+    public function addTaskForm()
+    {
+        if ($_POST) {
+            //校验$_POST数据
+            if (empty($_POST['bach_id'])) {
+                alert(array('info' => '补单批次id不能为空', 'status' => 2));
+                exit;
+            }
+            if (empty($_POST['product_id'])) {
+                alert(array('info' => '补单产品盒型不能为空', 'status' => 3));
+                exit;
+            }
+            if (empty($_POST['code_num'])) {
+                alert(array('info' => '补单产品数量不能为空', 'status' => 4));
+                exit;
+            }
+            $datas['bach_id'] = $_POST['bach_id'];
+            $datas['product_id'] = $_POST['product_id'];
+            $datas['quality'] = $_POST['code_num'];
+            $datas['redundancy'] = $_POST['code_num'] * $this->redundancy_s;
+            $datas['remark'] = $_POST['remark'];
+            $datas['add_time'] = time();
+
+            $task_model = D("Task");
+            $task_contents = $task_model->field('name,factory_id,is_verif,printer_id,owner_id')->where('bach_id=' . $_POST['bach_id'])->order('id asc')->find();
+            $data = array_merge($datas, $task_contents);
+            $task_id = $task_model->add($data);
+            if ($task_id) {
+                alert(array('info' => '补单申请成功', 'url' => "index.php?s=/Admin/ApplyBatch/tasklist/bach_id/" . $_POST['bach_id'] . ".html", 'status' => 1));
+            } else {
+                alert(array('info' => '补单申请失败', 'url' => "index.php?s=/Admin/ApplyBatch/addTaskIndex/bach_id/" . $_POST['bach_id'] . ".html", 'status' => 0));
+            }
+        }
+    }
+
+    /**
+     * author Gentle
+     * intro 调用下载函数
+     * param
+     */
+    public function downloadZip()
+    {
+      	
+        $bach_name = I('bach_name');
+        $printer_id = I('printer_id');
+        if (!downZip($bach_name, $printer_id)) {
+            $this->error('文件不存在,请联系管理员');
+
+        }
+
+    }
+
+}

+ 472 - 0
Application/Admin/Controller/ApplyBatchController.class.php 11.28

@@ -0,0 +1,472 @@
+<?php
+/**
+ * author Gentle
+ * intro 申请批次
+ */
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+class ApplyBatchController extends AdminController
+{
+    /**
+     * author Gentle
+     * intro 类初始化方法
+     * param
+     * return
+     */
+    public function _initialize()
+    {
+        parent::_initialize(); // TODO: Change the autogenerated stub
+        $this->uid = session('user_auth.uid');
+        $this->redundancy_s = 0.1;//冗码率
+    }
+
+    /**
+     * author Gentle
+     * intro 获取用户组
+     * param
+     */
+    public function getGroups()
+    {
+        $uid = $this->uid;
+        $admin_access_model = D(Admin_access);
+        $groups = $admin_access_model->where('uid=' . $uid)->getField('group');//1 超级管理 2 印刷厂 3 中烟
+        return $groups;
+    }
+
+    /**
+     * author Gentle
+     * intro 申请批次首页
+     * param
+     */
+    public function index()
+    {
+        /**
+         * @author Gentle
+         * @tro 遍历展示产品名称、盒型
+         * @time 2017年9月11日09:35:58
+         */
+        if (session('user_auth.uid') == 1) {
+            $this->success('暂不支持管理员操作');
+            exit;
+        }
+        $printer_list = M(Admin_access)
+            ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __ADMIN_ACCESS__.uid')
+            ->field('QR_ADMIN_USER.id printer_id,QR_ADMIN_USER.nickname printer_name')
+            ->where('QR_ADMIN_ACCESS.group=2')->order('QR_ADMIN_USER.id asc')->select();
+        foreach ($printer_list as $val) {
+            $printer[] = $val;
+        }
+
+        $factory_model = D(Factory);
+        $list2 = $factory_model->field('id,name')->where('id>0')->order('id asc')->select();
+        foreach ($list2 as $val) {
+            $factory_result[] = $val;
+            $factory_id[] = $val['id'];
+        }
+        $product_model = D(Product);
+        $list = $product_model->field('id,name')->where('factory_id IN (' . implode(',', $factory_id) . ')')->order('id asc')->select();
+        foreach ($list as $val) {
+            $product_result[] = $val;
+            $product_id[] = $val['id'];
+        }
+
+        //暂时不使用
+        $list2 = M(Product_box_type)
+            ->join('__BOX_TYPE__ ON __BOX_TYPE__.id = __PRODUCT_BOX_TYPE__.box_type_id')
+            ->field('QR_BOX_TYPE.id type_id,QR_BOX_TYPE.name box_type_name')
+            ->where('QR_PRODUCT_BOX_TYPE.product_id>0')->order('QR_PRODUCT_BOX_TYPE.id asc')->select();
+        foreach ($list2 as $val) {
+            $box_type_result[] = $val['type_id'];
+        }
+        $this->assign('printer', $printer);
+        $this->assign('product_result', $product_result);
+        $this->assign('factory_result', $factory_result);
+        $this->assign('meta_title', '申请批次');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 申请批次列表页面
+     * param
+     */
+    public function applyList()
+    {
+
+        /**
+         * @author Gentle
+         * @tro 遍历展示申请批次列表
+         * @time 2017年9月12日14:17:17
+         */
+        //分页
+        $bach = M(Bach);
+        $uid = $this->uid;
+
+        $groups = $this->GetGroups();
+        if ($groups == '3') {
+            $where = 'QR_BACH.owner_id=' . $uid;
+            $page = new Page(
+                $bach->where('owner_id=' . $uid)->count(),
+                C('ADMIN_PAGE_ROWS')
+            );
+        } else if ($groups == '2') {
+            $where = 'QR_BACH.printer_id=' . $uid;
+            $page = new Page(
+                $bach->where('printer_id=' . $uid)->count(),
+                C('ADMIN_PAGE_ROWS')
+            );
+        } else {
+            $where = 'QR_BACH.id > 0';
+            $page = new Page(
+                $bach->where('id>0')->count(),
+                C('ADMIN_PAGE_ROWS')
+            );
+        }
+        $show = $page->show();
+        $bach_list = M(Bach)
+            ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __BACH__.printer_id')
+            ->field('QR_BACH.id bach_id,QR_BACH.name bach_name,QR_BACH.add_time,QR_ADMIN_USER.nickname printer_name')
+            ->limit($page->firstRow . ',' . $page->listRows)
+            ->where($where)->order('QR_BACH.id desc')->select();
+
+        $task = M(Task);
+        foreach ($bach_list as $value) {
+            $task_ids[] = $task->field('id')->where('bach_id=' . $value['bach_id'])->order('id desc')->select();
+        }
+        foreach ($task_ids as $vals) {
+            foreach ($vals as $val) {
+                $task_list[] = M(Task)
+                    ->join('__FACTORY__ ON __FACTORY__.id=__TASK__.factory_id ')
+                    ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __TASK__.printer_id')
+                    ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.id=__TASK__.product_id')
+                    ->join('__PRODUCT__ ON __PRODUCT__.id=__PRODUCT_BOX_TYPE__.product_id')
+                    ->join('__BOX_TYPE__ ON __BOX_TYPE__.id=__PRODUCT_BOX_TYPE__.box_type_id')
+                    ->field('QR_TASK.id task_id,QR_TASK.quality,QR_TASK.bach_id,QR_PRODUCT.name product_name,QR_BOX_TYPE.name box_type_name')->where('QR_TASK.id= ' . $val['id'])->select();
+            }
+        }
+        foreach ($task_list as $val) {
+            foreach ($val as $v) {
+                $task_list2[] = $v;
+
+            }
+        }
+
+        $this->assign('bach_page', $show);
+        $this->assign('bach_list', $bach_list);
+        $this->assign('task_list2', $task_list2);
+        $this->assign('meta_title', '批次列表');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 任务列表页面
+     * param
+     */
+    public function taskList()
+    {
+        /**
+         * @author Gentle
+         * @tro 遍历展示申请批次列表
+         * @time 2017年9月15日13:17:17
+         */
+        if (empty($_GET['bach_id'])) {
+            $this->error('批次id不能为空');
+        }
+        $bach_id = $_GET['bach_id'];
+        //分页
+        $task = M(Task);
+        $page = new Page(
+            $task->where('bach_id=' . $bach_id)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+        $show = $page->show();
+
+        $task_ids = $task->field('id')->where('bach_id=' . $bach_id)->order('id desc')->select();
+        foreach ($task_ids as $val) {
+            $task_list[] = M(Task)
+                ->join('__FACTORY__ ON __FACTORY__.id=__TASK__.factory_id ')
+                ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __TASK__.printer_id')
+                ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.id=__TASK__.product_id')
+                ->join('__PRODUCT__ ON __PRODUCT__.id=__PRODUCT_BOX_TYPE__.product_id')
+                ->join('__BOX_TYPE__ ON __BOX_TYPE__.id=__PRODUCT_BOX_TYPE__.box_type_id')
+                ->field('printer_id,QR_PRODUCT_BOX_TYPE.id product_id,QR_ADMIN_USER.nickname printer_name,QR_TASK.id task_id,QR_TASK.name task_name,QR_TASK.quality,QR_TASK.add_time,QR_TASK.is_verif,QR_TASK.bach_id,QR_TASK.status,QR_FACTORY.name factory_name,QR_PRODUCT.name product_name,QR_BOX_TYPE.name box_type_name')->where('QR_TASK.id= ' . $val['id'])->select();
+        }
+        foreach ($task_list as $val) {
+            foreach ($val as $v) {
+                $task_list2[] = $v;
+
+            }
+        }
+        $this->assign('task_page', $show);
+        $this->assign('task_list', $task_list2);
+        $this->assign('meta_title', '任务列表');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 任务详情页面
+     * param 2017年9月15日15:31:22
+     */
+    public function taskDetail()
+    {
+        /**
+         * @author Gentle
+         * @tro 批次详情页面展示
+         * @time 2017年9月13日19:27:28
+         */
+        if (empty($_GET['task_id'])) {
+            $this->error('任务id不能为空');
+        }
+        $task_id = $_GET['task_id'];
+        $task_detail = M(Task)
+            ->join('__FACTORY__ ON __FACTORY__.id=__TASK__.factory_id ')
+            ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.id=__TASK__.product_id')
+            ->join('__PRODUCT__ ON __PRODUCT__.id=__PRODUCT_BOX_TYPE__.product_id')
+            ->join('__BOX_TYPE__ ON __BOX_TYPE__.id=__PRODUCT_BOX_TYPE__.box_type_id')
+            ->field('QR_TASK.id task_id,QR_TASK.name task_name,QR_TASK.bach_id,QR_TASK.quality,QR_TASK.redundancy,QR_TASK.add_time,QR_TASK.is_verif,QR_TASK.bach_id,QR_TASK.status,QR_TASK.checked_num,QR_TASK.wrong_num,QR_FACTORY.name factory_name,QR_PRODUCT.name product_name,QR_BOX_TYPE.name box_type_name')
+            ->where('QR_TASK.id=' . $task_id)->order('QR_TASK.id asc')->select();
+        /*
+                foreach ($task_detail as $k=>$v){
+                    $task_ids=M('task')->where(array('name'=>$v['task_name']))->getField('id',true);
+                    if(in_array($v['task_id'],$task_ids)){
+
+                    }
+                }*/
+
+        $this->assign('task_detail', $task_detail);
+        $this->assign('meta_title', '任务详情');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 申请批次方法
+     * param
+     * return  bool
+     */
+    public function applyForm()
+    {
+        if (IS_POST) {
+            $bach_object = D("Bach");
+            $bach_product_object = D("Bach_product");
+            $task_object = D("Task");
+            //校验$_POST数据
+            if (empty($_POST['product_id'])) {
+                alert(array('info' => '产品不能为空', 'status' => 2));
+                exit;
+            }
+            if (empty($_POST['factory_id'])) {
+                alert(array('info' => '工厂名称不能为空', 'status' => 3));
+                exit;
+            }
+            if (empty($_POST['printer_id'])) {
+                alert(array('info' => '印刷厂名称不能为空', 'status' => 4));
+                exit;
+            }
+            if (empty($_POST['code_num1']) or empty($_POST['code_num2'])) {
+                alert(array('info' => '条盒、小包数量都不能小于0', 'status' => 5));
+                exit;
+            }
+
+            $product_id = $_POST['product_id'];
+            $factory_id = $_POST['factory_id'];
+            $printer_id = $_POST['printer_id'];
+            $is_verif = (int)$_POST['is_verif'];
+            $remark = $_POST['remark'];
+            $code_num = [
+                'code_num1' => $_POST['code_num1'],
+                'code_num2' => $_POST['code_num2']
+            ];
+            //查找产品、类别关联表
+            $product_box_type_ids = M(Product_box_type)
+                ->field('id')
+                ->where('product_id=' . $product_id)->order('box_type_id asc')->select();
+            foreach ($product_box_type_ids as $val) {
+                $product_box_type_id[] = $val['id'];
+            }
+
+            $data = [];
+            $data['name'] = 'MNYH_' . date("Ymdhi", time());
+            $data['add_time'] = time();
+            $data['remark'] = $remark;
+            $data['printer_id'] = $printer_id;
+            $data['owner_id'] = $this->uid;
+
+            $param = [];
+            $param['product_id'] = $product_id;
+            $param['is_verif'] = $is_verif;
+            $param['add_time'] = time();
+            $param['remark'] = $remark;
+            $param1 = $param;
+            $param2 = $param;
+            $param1['num'] = $code_num['code_num1'];
+            $param1['product_id'] = $product_box_type_id[0];
+            $param2['num'] = $code_num['code_num2'];
+            $param2['product_id'] = $product_box_type_id[1];
+            $add_param = [
+                $param1,
+                $param2
+            ];
+
+            $params = [];
+            $params['name'] = $data['name'];
+            $params['factory_id'] = $factory_id;
+            $params['is_verif'] = $is_verif;
+            $params['add_time'] = time();
+            $params['remark'] = $remark;
+            $params['status'] = '0';
+            $params['printer_id'] = $printer_id;
+            $params['owner_id'] = $this->uid;
+            $params1 = $params;
+            $params2 = $params;
+
+            $params1['quality'] = $code_num['code_num1'];
+            $params1['redundancy'] = $code_num['code_num1'] * $this->redundancy_s;
+            $params1['product_id'] = $product_box_type_id[0];
+            $params2['quality'] = $code_num['code_num2'];
+            $params2['redundancy'] = $code_num['code_num2'] * $this->redundancy_s;
+            $params2['product_id'] = $product_box_type_id[1];
+
+            if ($data && $add_param) {
+                $bach_id = $bach_object->add($data);
+                $param1['bach_id'] = $bach_id;
+                $param2['bach_id'] = $bach_id;
+                $add_param = [
+                    $param1,
+                    $param2
+                ];
+                $bach_product_id = $bach_product_object->addAll($add_param);
+                if ($bach_id && $bach_product_id) {
+                    $params1['bach_id'] = $bach_id;
+                    $params2['bach_id'] = $bach_id;
+                    $add_params = [
+                        $params1,
+                        $params2
+                    ];
+                    $task_id = $task_object->addAll($add_params);
+                    if ($task_id) {
+                        alert(array('info' => '申请成功', 'url' => "index.php?s=/Admin/ApplyBatch/applylist.html", 'status' => 1));
+                    } else {
+                        alert(array('info' => '申请失败', 'url' => "index.php?s=/Admin/ApplyBatch/Index.html", 'status' => 0));
+                    }
+                } else {
+                    $this->error($bach_object->getError());
+                }
+            } else {
+                $this->error($bach_object->getError());
+            }
+        } else {
+            // 跳转到申请批次页面
+            header("Location: {:U('ApplyBatch/applylist')}");
+
+        }
+    }
+
+    /**
+     * author Gentle
+     * intro 批次补单申请页面
+     * param
+     */
+    public function addTaskIndex()
+    {
+        if (empty($_GET['task_id'])) {
+            $this->error('补单任务id不能为空');
+        }
+        $task_id = $_GET['task_id'];
+        $task_model = D("Task");
+        $tasks = $task_model->field('bach_id')->where('id=' . $task_id)->order('id asc')->find();
+        $bach_id = $tasks['bach_id'];
+        $bach_model = D("Bach");
+        $bach_name = $bach_model->field('name')->where('id=' . $bach_id)->order('id asc')->find();
+        $bach_contents['task_id'] = $task_id;
+        $bach_contents['bach_id'] = $bach_id;
+        $bach_contents['bach_name'] = $bach_name['name'];
+        $task_list = $task_model->field('product_id')->where('bach_id=' . $bach_id)->order('id asc')->select();
+        if (empty($task_list)) {
+            $this->error('您未创建过该任务,请核对任务后操作!');
+        }
+        foreach ($task_list as $val) {
+            $product_id[] = $val['product_id'];
+            $product_id = array_unique($product_id);
+        }
+        foreach ($product_id as $val) {
+            $product_contents[] = M(Box_type)
+                ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.box_type_id = __BOX_TYPE__.id')
+                ->field('QR_PRODUCT_BOX_TYPE.id product_id,QR_BOX_TYPE.name box_type_name')
+                ->where('QR_PRODUCT_BOX_TYPE.id=' . $val)->order('QR_PRODUCT_BOX_TYPE.id asc')->select();
+        }
+
+        foreach ($product_contents as $val) {
+            foreach ($val as $v) {
+                $product_contents_list[] = $v;
+            }
+        }
+
+        $this->assign('bach_contents', $bach_contents);
+        $this->assign('product_contents_list', $product_contents_list);
+        $this->assign('meta_title', '任务补单申请');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 批次补单申请方法
+     * param
+     */
+    public function addTaskForm()
+    {
+        if ($_POST) {
+            //校验$_POST数据
+            if (empty($_POST['bach_id'])) {
+                alert(array('info' => '补单批次id不能为空', 'status' => 2));
+                exit;
+            }
+            if (empty($_POST['product_id'])) {
+                alert(array('info' => '补单产品盒型不能为空', 'status' => 3));
+                exit;
+            }
+            if (empty($_POST['code_num'])) {
+                alert(array('info' => '补单产品数量不能为空', 'status' => 4));
+                exit;
+            }
+            $datas['bach_id'] = $_POST['bach_id'];
+            $datas['product_id'] = $_POST['product_id'];
+            $datas['quality'] = $_POST['code_num'];
+            $datas['redundancy'] = $_POST['code_num'] * $this->redundancy_s;
+            $datas['remark'] = $_POST['remark'];
+            $datas['add_time'] = time();
+
+            $task_model = D("Task");
+            $task_contents = $task_model->field('name,factory_id,is_verif,printer_id,owner_id')->where('bach_id=' . $_POST['bach_id'])->order('id asc')->find();
+            $data = array_merge($datas, $task_contents);
+            $task_id = $task_model->add($data);
+            if ($task_id) {
+                alert(array('info' => '补单申请成功', 'url' => "index.php?s=/Admin/ApplyBatch/tasklist/bach_id/" . $_POST['bach_id'] . ".html", 'status' => 1));
+            } else {
+                alert(array('info' => '补单申请失败', 'url' => "index.php?s=/Admin/ApplyBatch/addTaskIndex/bach_id/" . $_POST['bach_id'] . ".html", 'status' => 0));
+            }
+        }
+    }
+
+    /**
+     * author Gentle
+     * intro 调用下载函数
+     * param
+     */
+    public function downloadZip()
+    {
+        $bach_name = I('bach_name');
+        $printer_id = I('printer_id');
+        if (!downZip($bach_name, $printer_id)) {
+            $this->error('文件不存在,请联系管理员');
+
+        }
+
+    }
+
+}

+ 343 - 0
Application/Admin/Controller/ApplyBatchController.class.php 9.20

@@ -0,0 +1,343 @@
+<?php
+/**
+ * author Gentle
+ * intro 申请批次
+ */
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+class ApplyBatchController extends AdminController
+{
+    /**
+     * author Gentle
+     * intro 类初始化方法
+     * param
+     * return
+     */
+    public function _initialize()
+    {
+        parent::_initialize(); // TODO: Change the autogenerated stub
+        $this->uid = session('user_auth.uid');
+    }
+
+    /**
+     * author Gentle
+     * intro 获取用户组
+     * param
+     */
+    public function GetGroups()
+    {
+        $uid = $this->uid;
+        $admin_access_model = D(Admin_access);
+        $groups = $admin_access_model->where('uid=' . $uid)->getField('group');//1 超级管理 2 印刷厂 3 中烟
+        return $groups;
+    }
+
+    /**
+     * author Gentle
+     * intro 申请批次首页
+     * param
+     */
+    public function Index()
+    {
+        /**
+         * @author Gentle
+         * @tro 遍历展示产品名称、盒型
+         * @time 2017年9月11日09:35:58
+         */
+        $printer_list = M(Admin_access)
+            ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __ADMIN_ACCESS__.uid')
+            ->field('QR_ADMIN_USER.id printer_id,QR_ADMIN_USER.nickname printer_name')
+            ->where('QR_ADMIN_ACCESS.group=2')->order('QR_ADMIN_USER.id asc')->select();
+        foreach ($printer_list as $val) {
+            $printer[] = $val;
+        }
+
+        $factory_model = D(Factory);
+        $list2 = $factory_model->field('id,name')->where('id>0')->order('id asc')->select();
+        foreach ($list2 as $val) {
+            $factory_result[] = $val;
+            $factory_id[] = $val['id'];
+        }
+        $product_model = D(Product);
+        $list = $product_model->field('id,name')->where('factory_id IN (' . implode(',', $factory_id) . ')')->order('id asc')->select();
+        foreach ($list as $val) {
+            $product_result[] = $val;
+            $product_id[] = $val['id'];
+        }
+
+        //暂时不使用
+        $list2 = M(Product_box_type)
+            ->join('__BOX_TYPE__ ON __BOX_TYPE__.id = __PRODUCT_BOX_TYPE__.box_type_id')
+            ->field('QR_BOX_TYPE.id type_id,QR_BOX_TYPE.name box_type_name')
+            ->where('QR_PRODUCT_BOX_TYPE.product_id>0')->order('QR_PRODUCT_BOX_TYPE.id asc')->select();
+        foreach ($list2 as $val) {
+            $box_type_result[] = $val['type_id'];
+        }
+
+        $this->assign('printer', $printer);
+        $this->assign('product_result', $product_result);
+        $this->assign('factory_result', $factory_result);
+        $this->assign('meta_title', '申请批次');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 申请批次列表页面
+     * param
+     */
+    public function ApplyList()
+    {
+        /**
+         * @author Gentle
+         * @tro 遍历展示申请批次列表
+         * @time 2017年9月12日14:17:17
+         */
+        //分页
+        $bach = M(Bach);
+        $owner_id = $this->uid;
+        $page = new Page(
+            $bach->where('owner_id=' . $owner_id)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+        $show = $page->show();
+        $groups = $this->GetGroups();
+        if ($groups = '3') {
+            $where = 'QR_BACH.owner_id';
+        } else if ($groups = '2') {
+            $where = 'QR_BACH.printer_id';
+        } else {
+            $where = 'QR_BACH.id > 0';
+        }
+
+        $bach_list = M(Bach)
+            ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __BACH__.printer_id')
+            ->field('QR_BACH.id bach_id,QR_BACH.name bach_name,QR_BACH.add_time,QR_ADMIN_USER.nickname printer_name')
+            ->limit($page->firstRow . ',' . $page->listRows)
+            ->where($where)->order('QR_BACH.id desc')->select();
+
+        $this->assign('bach_page', $show);
+        $this->assign('bach_list', $bach_list);
+        $this->assign('meta_title', '批次列表');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 任务列表页面
+     * param
+     */
+    public function TaskList()
+    {
+        /**
+         * @author Gentle
+         * @tro 遍历展示申请批次列表
+         * @time 2017年9月15日13:17:17
+         */
+        $bach_id = $_GET['bach_id'];
+        //分页
+        $task = M(Task);
+        $page = new Page(
+            $task->where('bach_id=' . $bach_id)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+        $show = $page->show();
+
+        $task_ids = $task->field('id,bach_id,product_id')->where('bach_id=' . $bach_id)->order('id desc')->select();
+        foreach ($task_ids as $val) {
+            $task_list[] = M(Task)
+                ->join('__FACTORY__ ON __FACTORY__.id=__TASK__.factory_id ')
+                ->join('__ADMIN_USER__ ON __ADMIN_USER__.id = __TASK__.printer_id')
+                ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.id=__TASK__.product_id')
+                ->join('__PRODUCT__ ON __PRODUCT__.id=__PRODUCT_BOX_TYPE__.product_id')
+                ->join('__BOX_TYPE__ ON __BOX_TYPE__.id=__PRODUCT_BOX_TYPE__.box_type_id')
+                ->field('QR_PRODUCT_BOX_TYPE.product_id,QR_ADMIN_USER.nickname printer_name,QR_TASK.id task_id,QR_TASK.name task_name,QR_TASK.quality,QR_TASK.add_time,QR_TASK.is_verif,QR_TASK.bach_id,QR_TASK.status,QR_FACTORY.name factory_name,QR_PRODUCT.name product_name,QR_BOX_TYPE.name box_type_name')
+                ->where('QR_TASK.id= ' . $val['id'])->select();
+        }
+        foreach ($task_list as $val) {
+            foreach ($val as $v) {
+                $v['filename'] = $v['bach_id'] . '_' . $v['task_id'] . '_' . $v['product_id'];
+                $task_list2[] = $v;
+
+            }
+        }
+        $this->assign('task_page', $show);
+        $this->assign('task_list', $task_list2);
+        $this->assign('meta_title', '批次列表');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 任务详情页面
+     * param 2017年9月15日15:31:22
+     */
+    public function TaskDetail()
+    {
+        /**
+         * @author Gentle
+         * @tro 批次详情页面展示
+         * @time 2017年9月13日19:27:28
+         */
+        $task_id = $_GET['task_id'];
+        $task_detail = M(Task)
+            ->join('__FACTORY__ ON __FACTORY__.id=__TASK__.factory_id ')
+            ->join('__PRODUCT_BOX_TYPE__ ON __PRODUCT_BOX_TYPE__.id=__TASK__.product_id')
+            ->join('__PRODUCT__ ON __PRODUCT__.id=__PRODUCT_BOX_TYPE__.product_id')
+            ->join('__BOX_TYPE__ ON __BOX_TYPE__.id=__PRODUCT_BOX_TYPE__.box_type_id')
+            ->field('QR_TASK.id task_id,QR_TASK.name task_name,QR_TASK.quality,QR_TASK.redundancy,QR_TASK.add_time,QR_TASK.is_verif,QR_TASK.bach_id,QR_TASK.status,QR_FACTORY.name factory_name,QR_PRODUCT.name product_name,QR_BOX_TYPE.name box_type_name')
+            ->where('QR_TASK.id=' . $task_id)->order('QR_TASK.id asc')->select();
+
+        $this->assign('task_detail', $task_detail);
+        $this->assign('meta_title', '批次详情');
+        $this->display();
+    }
+
+    /**
+     * author Gentle
+     * intro 申请批次方法
+     * param
+     * return  bool
+     */
+    public function ApplyForm()
+    {
+        if (IS_POST) {
+            $bach_object = D("Bach");
+            $bach_product_object = D("Bach_product");
+            $task_object = D("Task");
+            //校验$_POST数据
+            if (empty($_POST['product_id'])) {
+                alert(array('info' => '产品不能为空', 'status' => 2));
+                exit;
+            }
+            if (empty($_POST['factory_id'])) {
+                alert(array('info' => '工厂名称不能为空', 'status' => 3));
+                exit;
+            }
+            if (empty($_POST['printer_id'])) {
+                alert(array('info' => '印刷厂名称不能为空', 'status' => 4));
+                exit;
+            }
+            if (empty($_POST['code_num1']) and empty($_POST['code_num2'])) {
+                alert(array('info' => '条盒、小包数量必须有一个大于0', 'status' => 5));
+                exit;
+            }
+
+            $product_id = $_POST['product_id'];
+            $factory_id = $_POST['factory_id'];
+            $printer_id = $_POST['printer_id'];
+            $is_verif = $_POST['is_verif'];
+            $remark = $_POST['remark'];
+            $code_num = [
+                'code_num1' => $_POST['code_num1'],
+                'code_num2' => $_POST['code_num2']
+            ];
+            //查找产品、类别关联表
+            $product_box_type_ids = M(Product_box_type)
+                ->field('id')
+                ->where('product_id=' . $product_id)->order('box_type_id asc')->select();
+            foreach ($product_box_type_ids as $val) {
+                $product_box_type_id[] = $val['id'];
+            }
+
+            $data = [];
+            $data['name'] = 'MNYH_' . date("Ymdhi", time());
+            $data['add_time'] = time();
+            $data['remark'] = $remark;
+            $data['printer_id'] = $printer_id;
+            $data['owner_id'] = $this->uid;
+
+            $param = [];
+            $param['product_id'] = $product_id;
+            $param['is_verif'] = $is_verif;
+            $param['add_time'] = time();
+            $param['remark'] = $remark;
+            $param1 = $param;
+            $param2 = $param;
+            $param1['num'] = $code_num['code_num1'];
+            $param1['product_id'] = $product_box_type_id[0];
+            $param2['num'] = $code_num['code_num2'];
+            $param2['product_id'] = $product_box_type_id[1];
+
+            $add_param = [
+                $param1,
+                $param2
+            ];
+
+            $params = [];
+            $params['name'] = $data['name'];
+            $params['factory_id'] = $factory_id;
+            $redundancy_s = 0.1;//冗码率
+            $params['is_verif'] = $is_verif;
+            $params['add_time'] = time();
+            $params['remark'] = $remark;
+            $params['status'] = '0';
+            $params['printer_id'] = $printer_id;
+            $params['owner_id'] = $this->uid;
+            $params1 = $params;
+            $params2 = $params;
+
+            $params1['quality'] = $code_num['code_num1'];
+            $params1['redundancy'] = $code_num['code_num1'] * $redundancy_s;
+            $params1['product_id'] = $product_box_type_id[0];
+            $params2['quality'] = $code_num['code_num2'];
+            $params2['redundancy'] = $code_num['code_num2'] * $redundancy_s;
+            $params2['product_id'] = $product_box_type_id[1];
+
+            if ($data && $add_param) {
+                $bach_id = $bach_object->add($data);
+                $param1['bach_id'] = $bach_id;
+                $param2['bach_id'] = $bach_id;
+                $add_param = [
+                    $param1,
+                    $param2
+                ];
+                $bach_product_id = $bach_product_object->addAll($add_param);
+                if ($bach_id && $bach_product_id) {
+                    $params1['bach_id'] = $bach_id;
+                    $params2['bach_id'] = $bach_id;
+                    $add_params = [
+                        $params1,
+                        $params2
+                    ];
+                    $task_id = $task_object->addAll($add_params);
+                    if ($task_id) {
+                        alert(array('info' => '申请成功', 'url' => "index.php?s=/Admin/ApplyBatch/applylist.html", 'status' => 1));
+                    } else {
+                        alert(array('info' => '申请失败', 'url' => "__SELF__", 'status' => 0));
+                    }
+                } else {
+                    $this->error($bach_object->getError());
+                }
+            } else {
+                $this->error($bach_object->getError());
+            }
+        } else {
+            // 跳转到申请批次页面
+            header("Location: {:U('ApplyBatch/applylist')}");
+
+        }
+    }
+
+    /**
+     * author Gentle
+     * intro 调用下载函数
+     * param
+     */
+    public function DownloadZip()
+    {
+        $bach_id = $_GET['bach_id'];
+        if (!downZip($bach_id)) {
+            if (session('user_auth.uid') == 1) {
+                $this->error('暂不支持管理员操作');
+            } else {
+                $this->error('文件不存在,请联系管理员');
+            }
+        }
+
+    }
+
+}

+ 419 - 0
Application/Admin/Controller/AutoController.class.php

@@ -0,0 +1,419 @@
+<?php
+
+namespace Admin\Controller;
+use Think\Page;
+use Think\Cache\Driver\Redis;
+
+/**
+ * 后台默认控制器
+ *
+ */
+class AutoController extends AdminController
+{
+
+    protected $active_batch;
+    /**
+     * @return int
+     * @ flag 1清空 Code_Active_list 清空二维码激活缓存队列
+     * @ flag 2清空 Code_Add_list 清空二维码新增缓存队列
+     * @ flag 3清空 fenbiao_page清空分页缓存变量
+     * @ flag 4清空 $table_name.'_count' 分表操作缓存列表 无需清空
+     *
+     */
+    
+    /*参数的配置 start*/
+    protected $tasks_id;
+    protected $bach_id;
+    protected $product_id;
+    protected $printer_id;
+    protected $task_name;
+    /*参数的配置 stop*/
+    
+    public function clearS()
+    {
+       if(empty(I('flag'))){
+           echo '请输入操作动作';
+       }
+       $redis=new Redis();
+       $flag=I('flag');
+       $status=0;
+       switch ($flag){
+           case 1:
+               $num = $redis->lSize("Code_Active_list");
+               for($i=0;$i< $num;$i++){
+         		   $redis->rPop("Code_Active_list");
+       			}
+           		$status=1;
+               break;
+           case 2:
+           	   $num = $redis->lSize("Code_Add_list");
+               for($i=0;$i< $num;$i++){
+         		   $redis->rPop("Code_Add_list");
+       		   }
+               $status=1;
+               break;
+           case 3:
+           	   S('fenbiao_page',Null);
+               $status=1;
+               break;
+           default:
+               $status=2;
+       }
+       if($status==1){
+           echo '清空成功';
+       }
+       else{
+           echo '清空失败';
+       }
+    }
+  
+  	 /*查款redis里面的数据*/
+  	 public function getS()
+    {
+
+       if(empty(I('flag'))){
+           echo '请输入操作动作';
+       }
+	   $redis=new Redis();
+       $flag=I('flag');
+       switch ($flag){
+           case 1:
+               echo '待更新二维码:'. $redis->lSize("Code_Active_list");
+               break;
+           case 2:
+           	   echo '待新增二维码:'. $redis->lSize("Code_Add_list");
+               break;
+           case 3:
+               echo '待分表二维码:'. $redis->lSize("fenbiao_page");
+               break;
+           default:
+               $status=2;
+       }
+    }
+    
+    public function togetTxtActivefile(){
+     /* $redis=new Redis();
+      	$redis->rm('Code_Active_list');
+      echo '待更新二维码:'. $redis->lSize("Code_Active_list");die;*/
+        $result = array(); 
+        if(empty(I('active_batch'))){
+            $result['status'] = 0;
+            $result['cont'] = '激活批次号缺少';
+            $this->ajaxReturn($result);
+        }
+        /*修改激活批次表*/
+        $return1 = M('activate_list')-> where('active_batch ='.I('active_batch'))->setField('status',1);
+      	$return2 = $this->getTxtActivefile(I('active_batch'));
+        /*修改激活批次表*/
+        if($return1 && $return2){
+            $result['status'] = 1;
+            $result['cont'] = '任务已提交';
+          	$this->ajaxReturn($result);
+        }
+    }
+    /*
+   * 获取需要激活的二维码
+   * 并插入到redis 缓存中去
+   * 默认 需要插入的目录Data/active/
+   * 激活批次号:active_batch
+   */
+    public function getTxtActivefile($active_batch){
+      	/*$redis=new Redis();
+      	echo '待更新二维码:'. $redis->lSize("Code_Active_list"); die;
+        $active_batch = 991156;*/
+      	set_time_limit(0);
+        $this->active_batch = $active_batch;
+        $dir="Data/Code_Active_list/".$active_batch.'/0/';
+        $files=scandir($dir);
+        $txt_file_array=array();
+        $redis=new Redis();
+        foreach($files as $key ){
+           if(get_extension($key)=='txt'){
+               //更新缓存
+               $this->CodeStatusUpdateCache($key,'Code_Active_list','http://hn.6in7.cn/');
+           }
+        }
+      	/*修改表数据*/
+      	$return = M('activate_list')-> where('active_batch ='.$this->active_batch)->setField('status',0);
+      	return true;
+       //echo '待更新二维码:'. $redis->lSize("Code_Active_list");
+    }
+    
+    public function togetTxtAddfile(){
+        $result = array(); 
+        if( empty(I('bach_id')) || empty(I('tasks_id')) || empty(I('product_id')) || empty(I('printer_id')) || empty(I('task_name'))){
+            $result['status'] = 0;
+            $result['cont'] = '批次参数缺少';
+            $this->ajaxReturn($result);
+        }else{
+            $this->tasks_id = I('tasks_id');
+            $this->bach_id = I('bach_id');
+            $this->product_id = I('product_id');
+            $this->printer_id = I('printer_id');
+            $this->task_name = I('task_name');
+        }
+        /*修改任务表*/
+        $return1 = M('task')-> where('id ='.I('tasks_id'))->setField('lock',1);
+      	$return2 = $this->getTxtAddfile();
+        /*修改激活批次表*/
+        if($return1 && $return2){
+            $result['status'] = 1;
+            $result['cont'] = '任务已提交';
+          	$this->ajaxReturn($result);
+        }
+    }
+
+    /*
+     * 该函数需要后期后端操作,一个文件要对应 任务id,产品id,批次号等绑定
+     * 获取需要新增的二维码
+     * 并插入到redis 缓存中去
+     * 默认 需要插入的目录Data/add/
+     *
+     */
+    public function getTxtAddfile(){
+        $dir="Data/Code_Add_list/".$this->task_name.'/'.get_current_admin_name() . '/'.$this->task_name.'_'.$this->tasks_id.'/0/';
+        $files=scandir($dir);
+        $txt_file_array=array();
+        $redis=new Redis();
+        foreach($files as $key ){
+            if(get_extension($key)=='txt'){
+                //更新缓存
+                $this->CodeStatusUpdateCache($key,'Code_Add_list','http://hn.6in7.cn/');
+            }
+        }
+      	$return = M('task')-> where('id ='.I('tasks_id'))->setField('lock',0);
+      	return true;
+    }
+
+
+
+
+     /*
+      * 二维码插入
+      * redis主键  Code_Add_list
+     *  Code_Add_list每一条数据为serialize 数据,
+     * 平均单条插别人耗时间:0.0045s,单次插入数量:5000;预计耗时:22.5s~30s
+     * 一分钟访问两次 执行时间在30s~60s
+     * 一分钟处理1w条数据,100w 平均耗时 100分钟=1 h 40 m
+      */
+    public  function addCode(){
+        $redis=new Redis();
+        if(!$redis->lSize("Code_Add_list")){
+            echo '没有需要插入的二维码数据';
+        }
+        $i=0;$j=0;
+//        $CodeMode->startTrans();
+        w_log('Data/Add_log.txt',time()." : 插入开始");
+        $t1 = microtime(true);
+        //echo $redis->lSize("Code_Add_list").'<br/>';
+        //die;
+
+        for($kk=5000;$kk>0 && $redis->lSize("Code_Add_list")>0;$kk--){
+            $where=array();
+            $where=unserialize($redis->rPop("Code_Add_list")) ;
+            $where['add_time']=time();
+            $where['update_time']=time();
+            $where['varify_code']='';
+
+            if(strpos($where['code'], ',')){
+                $temp_code=explode(',', $where['code']);
+                $where['code']=current($temp_code);
+                $where['varify_code']=end($temp_code);
+            }
+          	$task_name = $where['task_name'];
+            $tasks_id = $where['tasks_id'];
+            $file = $where['file'];
+          	unset($where['file']);
+            unset($where['task_name']);
+            $where_str='';
+            $field_str='';
+            foreach ( $where as $key=>$value){
+                if($key=='varify_code'){
+                    $field_str.="`".$key."`";
+                    $where_str.="'".$value."'";
+                }else{
+                    $field_str.="`".$key."`,";
+                    $where_str.="'".$value."',";
+                }
+            }
+
+            $table_name=  getSubTable('codes',$where['code']);
+
+            $table_name = "INSERT ignore INTO `$table_name` ($field_str)  VALUES ($where_str)";
+
+            $Model = M();
+            $status = $Model->execute($table_name);
+
+            if($status)
+            {
+                $i++;
+                M('task')->where('id = '.$tasks_id)->setInc('checked_num',1);
+            }
+            else{
+              	//插入错误日志
+              	$j++;
+              	$dir = "Data/Code_Add_list/".$task_name.'/admin/'.$task_name.'_'.$tasks_id.'/2/';
+              	if(!file_exists($dir)){
+                	//判断文件是否存在
+                    mkdir($dir, 0777, true);
+                }
+                w_log($dir.$file,time().':'.$where['code'].$where['varify_code'].'添加失败');
+                /*错误记录表 +1*/
+                M('task')->where('id = '.$tasks_id)->setInc('wrong_num',1);
+            }
+
+        }
+        $t2 = microtime(true);
+        echo '耗时'.round($t2-$t1,3).'秒<br>';
+        echo '成功插入:'.$i.'条数据,失败:'.$j.'条数据<br>';
+    }
+       /*
+     * 二维码更新状态变更
+     * redis主键  Code_Active_list
+     * 平均单条插别人耗时间:0.0045s,单次插入数量:5000;预计耗时:22.5s~30s
+    * 一分钟访问两次 执行时间在30s~60s
+    * 一分钟处理1w条数据,100w 平均耗时 100分钟=1 h 40 m
+     */
+
+    public  function  activeCode(){
+ 
+        $redis=new Redis();
+        if(!$redis->lSize("Code_Active_list")){
+            echo '没有需要更新的二维码数据';
+            return 'ok';
+        }
+        w_log('Data/Active_log.txt',time()."更新开始");
+        $t1 = microtime(true);
+
+        $i=0;$j=0;
+      	$time = time();
+        for($kk=5000;$kk>0;$kk--){
+            $where=array();
+            $Active_data=unserialize($redis->rPop("Code_Active_list"));
+            $where['code']=$Active_data['code'];
+            if(strpos($where['code'], ',')){
+                $where['code']=current(explode(',', $where['code']));
+
+            }
+            $where['Status']=0;
+            $data=array();
+            $data['Status']=1;
+
+            $data['active_batch']=$Active_data['active_batch'];
+          	$data['update_time']= $time;
+            $data['active_time']= $time;
+
+            if($data['active_batch']){
+
+                $table_name=  getSubTable('codes',$where['code'],1);
+
+                $CodeMode= M($table_name);
+             
+                $status=$CodeMode->where($where)->save($data);
+
+                if($status)
+                {
+                    $i++;
+                    //修改激活批次表
+                    M('activate_list')->where('active_batch = '.$data['active_batch'])->setInc('succ',1);
+                }
+                else{
+                  	//0代表码错误,1代表重复激活,2代表系统错误
+                   $j++;
+                  	//写日志
+                  	$insert_data = array();
+                    $insert_data['code'] = $where['code'];
+                  	$insert_data['active_batch'] = $data['active_batch'];
+                  	$insert_data['time'] = $time;
+                  	$return1 = $CodeMode->field('id')->where('code = '.'"'.$where['code'].'"')->select();
+                  	if(count($return1)>0){
+                      $return2 = $CodeMode->field('id')->where($where)->find();
+                      if(count($return2)>0){
+                      	$insert_data['error'] = 2;
+                      }else{
+                      	$insert_data['error'] = 1;
+                      }  	
+                    }else{
+                      $insert_data['error'] = 0;
+                    }
+                   if( M('activate_list_log')->add($insert_data)){
+                    	M('activate_list')->where('active_batch = '.$data['active_batch'])->setInc('fail',1);
+                   }
+                  	//判断开始
+                    //w_log('Data/Active_wrong_'.$data['active_batch'].'_log.txt',time().':'.$where['code'].'更新失败');
+                }
+            }else{
+                $j++;
+                w_log('Data/Active_wrong_log.txt',time().':'.$where['code'].'更新失败,激活批次为空');
+            }
+        }
+        $t2 = microtime(true);
+        echo '耗时'.round($t2-$t1,3).'秒<br>';
+        echo '更新成功:'.$i.'条数据,失败:'.$j.'条数据<br>';
+        echo '还剩'.$redis->lSize("Code_Active_list").'条数据待更新<br/>';
+        w_log('Data/Active_log.txt',time().'更新结束 共插入 条数据');
+    }
+
+    /*
+     * redis 操作
+     * 把需要更新的二维码
+      * push 到 Code_Active_list主键
+      * & redis_key  redis主键
+     *  二维码中包含的主域名
+      */
+    protected  function CodeStatusUpdateCache($file,$redis_key='Code_Active_list',$host='http://hn.6in7.cn/'){
+      	if($redis_key=='Code_Active_list'){
+          	$dir = 'Data/'.$redis_key.'/'.$this->active_batch.'/0/'.$file;
+        	$path  = 'Data/'.$redis_key.'/'.$this->active_batch.'/1/'.$file;
+        }else{
+        	$dir = "Data/Code_Add_list/".$this->task_name.'/'.get_current_admin_name() . '/'.$this->task_name.'_'.$this->tasks_id.'/0/'.$file;
+        	$path  = "Data/Code_Add_list/".$this->task_name.'/'.get_current_admin_name() . '/'.$this->task_name.'_'.$this->tasks_id.'/1/'.$file;
+        }
+        $cont= file_get_contents(iconv("utf-8","gbk",$dir));
+        $cont = preg_replace('/\n|\r\n/','*',$cont);
+        $cont =str_replace($host,"",$cont);
+        $data = explode("*",$cont);
+        $data = array_filter($data);
+        $total = count($data);
+        //写入日志
+        w_log('Data/redis_log.txt',time().":".$file."文件插入Code_Active_list 队列中");
+        $redis=new Redis();
+        $i=0;
+        foreach($data as $k=>$v){
+            /*
+             * 如果是插入需要对数据重组
+             */
+            if($redis_key=='Code_Add_list'){
+                /*相关的参数 start*/
+                $Insert_data['code']=$v;
+                $Insert_data['bach_id']=$this->bach_id;
+                $Insert_data['tasks_id']=$this->tasks_id;
+                $Insert_data['product_id']=$this->product_id;
+                $Insert_data['printer_id']=$this->printer_id;
+                $Insert_data['file'] = $file;
+                $Insert_data['task_name'] = $this->task_name;
+                $Insert_data['Status']=0;
+                /*相关的参数 stop*/
+                $redis->lpush($redis_key,serialize($Insert_data));
+            }else if($redis_key=='Code_Active_list'){
+                $Active_data['code']=$v;
+                $Active_data['active_batch']=$this->active_batch;
+                $redis->lpush($redis_key,serialize($Active_data));
+            }
+            else{
+                $redis->lpush($redis_key,$v);
+            }
+            $i++;
+        }
+        copy($dir, $path);
+        unlink($dir);
+        w_log('Data/redis_log.txt',time().":".$file."共有数据:".$total.',已插入数据:'.$i.',{$redis_key} 目前共有数据:'.$redis->lSize($redis_key));
+    }
+
+    /*
+     * 获取分表表名
+     */
+
+
+ 
+}

+ 465 - 0
Application/Admin/Controller/BarController.class.php

@@ -0,0 +1,465 @@
+<?php
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+class BarController extends AddonController{
+
+    /*****************************************************大件模块*******************************************************************8888*/
+
+    public function Large(){
+        if(IS_POST){
+            $data = $_POST;
+            $where = array();
+            $search = $_POST['search'];
+            $where['name'] = array('like', '%'.$search.'%');
+            $where['title'] = array('like', '%'.$search.'%');
+            $where['no'] = array('like', '%'.$search.'%');
+            $where['board_no'] = array('like', '%'.$search.'%');
+            $where['mix_board'] = array('like', '%'.$search.'%');
+            $where['quality_no'] = array('like', '%'.$search.'%');
+            $where['batch_number'] = array('like', '%'.$search.'%');
+            $where['tray_no'] = array('like', '%'.$search.'%');
+            $where['inspector'] = array('like', '%'.$search.'%');
+            $where['_logic'] = 'or';
+        }else{
+            $where = array();
+        }
+        $model = D('BarLarge');
+        $count = $model->where($where)->count();
+        $p = getpage($count,50);
+        $list =  $model->getList($where,$p);
+        $this->assign('meta_title','条码大件打印');
+        $this->assign('list',$list);
+        $this->assign('page', $p->show()); // 赋值分页输出
+        $this->assign('search',$search);
+        $this->display('list');
+    }
+
+    public function largeEdit(){
+        if(IS_POST){
+            header("Content-type: text/html; charset=utf-8");
+            $data = $_POST['data'];
+            $return  = $this->dispose($data);
+            if($return){
+                $this->ajaxReturn(['status'=>1,'msg'=>'修改成功']);
+            }else{
+                $this->ajaxReturn(['status'=>0,'msg'=>'修改失败']);
+            }
+        }else {
+            $id = $_GET['id'];
+            $productList = D('BarProduct')->select();
+            $this->assign('productList', $productList);
+            $model = D('BarLarge');
+            $list = $model->slectById($id);
+            $url = "/index.php?s=/Admin/Bar/largeEdit.html";
+            $this->assign('url', $url);
+            $this->assign('list', $list[0]);
+            $this->display('add');
+        }
+    }
+
+    public function largeAdd(){
+        if(IS_POST){
+            header("Content-type: text/html; charset=utf-8");
+            $data = $_POST['data'];
+            $return  = $this->dispose($data);
+            if($return){
+                $this->ajaxReturn(['status'=>1,'msg'=>'增加成功']);
+            }else{
+                $this->ajaxReturn(['status'=>0,'msg'=>'增加失败']);
+            }
+        }else{
+            $productList = D('BarProduct')->select();
+            $this->assign('productList',$productList);
+            $url = "/index.php?s=/Admin/Bar/largeAdd.html";
+            $this->assign('url',$url);
+            $this->display('add');
+        }
+    }
+
+    public function LargeDel(){
+        if(IS_POST){
+            header("Content-type: text/html; charset=utf-8");
+            $id = $_POST['id'];
+            $model = D('BarLarge');
+            $return =  $model->delete($id);
+            if($return){
+                $this->ajaxReturn(['status'=>1,'msg'=>'删除成功']);
+            }else{
+                $this->ajaxReturn(['status'=>0,'msg'=>'删除失败']);
+            }
+        }else{
+            $this->error('非法请求','/index',5);
+        }
+    }
+
+    public function dispose($data){
+        $title = explode('|',$data['title']);
+        $data['title'] = $title[0];
+        if(strstr($title[0],'_')){
+            $arr = explode('_',$title[0]);
+        }else{
+            $arr = explode('-',$title[0]);
+        }
+        $data['name'] = $arr[0];
+        if(isset($data['mix_board'])){
+            $data['mix_board'] = 'Y';
+            $isMix = 1;
+        }else{
+            $data['mix_board'] = 'N';
+            $isMix = 0;
+        }
+        $bach = substr($data['batch_number'],-5);
+        $date = substr(preg_replace("/(-)/","",$data['time']),2);
+        $board_no =  $this->addZero($data['board_no'],3,'left');
+        $tray_no = $this->addZero($data['tray_no'],5,'left');
+        $data['sn'] = '(92)'.$data['custome_sn'].'01A'.'(11)'.$date.'(21)'.$bach.$board_no.$isMix.$tray_no;
+        $data['time'] = strtotime($data['time']);
+        $model = D('BarLarge');
+        $return  = $model->save1($data);
+        return $return;
+    }
+
+    public function addZero($a,$le,$pos='left'){
+        $str =$a;
+        $len = substr($a);
+        $cha = $le-$len;
+        if($cha>0){
+            if($pos=='left'){
+                $str = str_pad($str,$le,"0",STR_PAD_LEFT);
+            }else{
+                $str = str_pad($str,$le,"0",STR_PAD_RIGHT);
+            }
+        }
+        return $str;
+
+    }
+
+    /**************************************************小件*******************************************************************/
+
+    /*大件模块*/
+    public function small(){
+        if(IS_POST){
+            $data = $_POST;
+            $where = array();
+            $search = $_POST['search'];
+            $where['name'] = array('like', '%'.$search.'%');
+            $where['title'] = array('like', '%'.$search.'%');
+            $where['no'] = array('like', '%'.$search.'%');
+            $where['batch_number'] = array('like', '%'.$search.'%');
+            $where['technics_number'] = array('like', '%'.$search.'%');
+            $where['quality_no'] = array('like', '%'.$search.'%');
+            $where['_logic'] = 'or';
+        }else{
+            $where = array();
+        }
+        $model = D('BarSmall');
+        $count = $model->where($where)->count();
+        $p = getpage($count,100);
+        $list =  $model->getList($where,$p);
+        $this->assign('meta_title','条码小件件打印');
+        $this->assign('list',$list);
+        $this->assign('page', $p->show()); // 赋值分页输出
+        $this->assign('search',$search);
+        $this->display('smalllist');
+    }
+
+    public function smallAdd(){
+        if(IS_POST){
+            header("Content-type: text/html; charset=utf-8");
+            $data = $_POST['data'];
+            $return  = $this->disposeSmall($data);
+            $return_arr = json_decode($return);
+            $msg = '成功条数'.$return_arr[0].',失败条数'.($return_arr[1]-$return_arr[0]);
+            $this->ajaxReturn(['msg'=>$msg]);
+
+        }else{
+            $productList = D('BarProduct')->select();
+            $this->assign('productList',$productList);
+            $url = "/index.php?s=/Admin/Bar/smallAdd.html";
+            $this->assign('url',$url);
+            $this->display('smalladd');
+        }
+    }
+
+    public function smallEdit(){
+        if(IS_POST){
+            header("Content-type: text/html; charset=utf-8");
+            $data = $_POST['data'];
+            $return  = $this->disposeSmall($data);
+            $return_arr = json_decode($return);
+            if($return_arr[0]>0){
+                $msg = '编辑成功';
+            }else{
+                $msg = '编辑失败';
+            }
+            $this->ajaxReturn(['msg'=>$msg]);
+        }else {
+            $id = $_GET['id'];
+            $productList = D('BarProduct')->select();
+            $this->assign('productList', $productList);
+            $model = D('BarSmall');
+            $list = $model->slectById($id);
+            $list = $list[0];
+            $url = "/index.php?s=/Admin/Bar/smallEdit.html";
+            $this->assign('url', $url);
+            $this->assign('list', $list);
+            $this->display('smalladd');
+        }
+    }
+
+    public function smallDel(){
+        if(IS_POST){
+            header("Content-type: text/html; charset=utf-8");
+            $id = $_POST['id'];
+            $model = D('BarSmall');
+            $return =  $model->delete($id);
+            if($return){
+                $this->ajaxReturn(['status'=>1,'msg'=>'删除成功']);
+            }else{
+                $this->ajaxReturn(['status'=>0,'msg'=>'删除失败']);
+            }
+        }else{
+            $this->error('非法请求','/index',5);
+        }
+    }
+
+    public function disposeSmall($data){
+        $model = D('BarSmall');
+        $title = explode('|',$data['title']);
+        $data['title'] = $title[0];
+        if(strstr($title[0],'_')){
+            $arr = explode('_',$title[0]);
+        }else{
+            $arr = explode('-',$title[0]);
+        }
+        $data['name'] = $arr[0];
+        $data['num'] = $arr[1];
+        $date = substr(preg_replace("/(-)/","",$data['time']),2);
+        $quality = $this->addZero($data['technics_number'],9,'right');
+        $border = $this->addZero($data['board_no'],3,'left');
+        $mix_board = $this->addZero($data['mix_board'],3,'left');
+        $success = 0;
+        $i = (int)$data['start'];
+        $step = (int)$data['step'];
+        if($step==0){
+            $step = 1;
+        }
+        $end = $i+$step-1;
+        for ($i;$i<=$end;$i++) {
+           $new = array();
+           $new = $data;
+           $new['time'] = time();
+           $new['board_no_serial'] = $i;
+           $board_no_serial = $this->addZero($i,5,'left');
+           $new['sn'] = $data['custome_sn'].'01A'.$quality.$date.$border.$mix_board.$board_no_serial;
+           unset($new['start']);
+           unset($new['step']);
+           unset($new['custome_sn']);
+           $id = $model->save1($new);
+           if($id){
+               $success = $success+1;
+           }
+        }
+        return json_encode([$success,$step]);
+    }
+
+    /*****************************************************产品模块******************************************************************/
+    /*产品配置*/
+    public function product(){
+        // 搜索
+        $keyword              = I('keyword', '', 'string');
+        $condition            = array('like', '%' . $keyword . '%');
+        $map['code|title|code1|standard'] = array(
+            $condition,
+            $condition,
+            $condition,
+            $condition,
+            '_multi' => true,
+        );
+        $p = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $product_object = D('BarProduct');
+        $data_list     = $product_object
+            ->page($p, 50)
+            ->where($map)
+            ->order('id asc')
+            ->select();
+        $page = new Page(
+            $product_object->where($map)->count(),
+            50
+        );
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('配置列表') // 设置页面标题
+        ->addTopButton('addnew',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/barProductAdd')]) // 添加新增按钮
+        ->addTopButton('delete',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/barProductDel')]) // 添加删除按钮
+        ->setSearch(
+            '请输入代码/自定义名称',
+            U('product')
+        )
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('code', '代码')
+            ->addTableColumn('code1', '客户产品编码')
+            ->addTableColumn('standard', '产品规则')
+            ->addTableColumn('title', '自定义')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list) // 数据列表
+            ->setTableDataPage($page->show()) // 数据列表分页
+            ->addRightButton('edit',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/barProductEdit',array(
+                'id'    => '__data_id__',
+            ))]) // 添加编辑按钮
+            ->addRightButton('delete',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/barProductDel',array(
+                    'id'    => '__data_id__',
+                ))]) // 添加删除按钮
+            ->display();
+    }
+
+    /**
+     * 产品新增配置
+     *
+     */
+    public function barProductAdd()
+    {
+        if (IS_POST) {
+            $bar_object = D('BarProduct');
+            $data          = $bar_object->create();
+            if ($data) {
+                if ($bar_object->add($data)) {
+                    $this->success('新增成功', U('product'));
+                } else {
+                    $this->error('新增失败');
+                }
+            } else {
+                $this->error($bar_object->getError());
+            }
+        } else {
+            //使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('新增条形码产品配置') //设置页面标题
+            ->setPostUrl(U('barProductAdd')) //设置表单提交地址
+                ->addFormItem('code', 'text', '产品代码', '产品代码')
+                ->addFormItem('code1','text', '客户产品编码', '客户产品编码')
+                ->addFormItem('standard','text', '产品规则', '产品规则')
+                ->addFormItem('title', 'text', '自定义名称', '自定义名称')
+                ->display();
+        }
+    }
+
+    /*条形码产品删除*/
+    public function barProductDel(){
+        if(IS_POST){
+            if(empty($_POST)){
+                $this->error('请至少选择一个选项');
+            }else{
+                $bar = D('BarProduct');
+                $id = implode(',',$_POST['ids']);
+                $return  = $bar->DelQcodeProduct($id);
+                if($return){
+                    $this->success('删除成功', U('product'));
+                }else{
+                    $this->error('删除失败');
+                }
+            }
+        }else{
+            $id = $_GET['id'];
+            $bar = D('BarProduct');
+            $return  = $bar->DelQcodeProduct($id);
+            if($return){
+                $this->success('删除成功', U('product'));
+            }else{
+                $this->error('删除失败');
+            }
+        }
+    }
+
+    /*条形码产品修改*/
+    public function barProductEdit(){
+        if (IS_POST) {
+            $bar = D('BarProduct');
+            $data          = $bar->create();
+            if ($data) {
+                if ($bar->save($data)) {
+                    $this->success('更新成功', U('product'));
+                } else {
+                    $this->error('更新失败');
+                }
+            } else {
+                $this->error($bar->getError());
+            }
+        } else {
+            $id = $_GET['id'];
+            $bar = D('BarProduct');
+            if (!$id) {
+                $this->error('参数错误');
+            }
+            $data = $bar->where('id = ' . $id)->find();
+            if (!$data) {
+                $this->error('参数错误');
+            } else {
+                // 使用FormBuilder快速建立表单页面。
+
+                $builder = new \Common\Builder\FormBuilder();
+                $builder->setMetaTitle('编辑产品数据')// 设置页面标题
+                ->setPostUrl(U('barProductEdit'))// 设置表单提交地址
+                ->addFormItem('id', 'hidden', 'ID', 'ID')
+                    ->addFormItem('code', 'text', '产品代码', '产品代码')
+                    ->addFormItem('code1','text', '客户产品编码', '客户产品编码')
+                    ->addFormItem('standard','text', '产品规则', '产品规则')
+                    ->addFormItem('title', 'text', '自定义名称', '自定义名称')
+                    ->setFormData(D('BarProduct')->find($id))
+                    ->display();
+            }
+        }
+    }
+
+
+    /******************************************二维码********************************************************************************/
+    public function qrcode($url)//二维码生成类
+    {
+        Vendor('phpqrcode.phpqrcode');//加载生成二维码的核心类
+        $level=3;
+        $size=4;
+        $errorCorrectionLevel =intval($level) ;//容错级别
+        $matrixPointSize = intval($size);//生成图片大小
+        //生成二维码图片
+        $object = new \QRcode();
+        //打开缓冲区
+        ob_start();
+        $object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2);
+        //这里就是把生成的图片流从缓冲区保存到内存对象上,使用base64_encode变成编码字符串,通过json返回给页面。
+        $imageString = base64_encode(ob_get_contents());
+        //关闭缓冲区
+        ob_end_clean();
+        //把生成的base64字符串返回给前端
+        /*$data = array(
+            'labelcode'=>$url,
+            'code'=>200,
+            'data'=>$imageString
+        );
+        $this->ajaxReturn($data);*/
+    }
+
+    public function getLargeDate(){
+        $id = $_POST['id'];
+        $id_arr = explode(',',$id);
+        /*查询相关的数据*/
+        $data = [];
+        $Model = D('BarLarge');
+        $return  = $Model->getById($id);
+        $this->ajaxReturn($return);
+    }
+
+    public  function getSmallDate(){
+        $id = $_POST['id'];
+        /*查询相关的数据*/
+        $data = [];
+        $Model = D('BarSmall');
+        $return  = $Model->getById($id);
+        $this->ajaxReturn($return);
+    }
+
+
+}
+

+ 220 - 0
Application/Admin/Controller/ConfigController.class.php

@@ -0,0 +1,220 @@
+<?php
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+/**
+ * 系统配置控制器
+ *
+ */
+class ConfigController extends AdminController
+{
+    /**
+     * 配置列表
+     * @param $tab 配置分组ID
+     *
+     */
+    public function index($group = 1)
+    {
+        // 搜索
+        $keyword              = I('keyword', '', 'string');
+        $condition            = array('like', '%' . $keyword . '%');
+        $map['id|name|title'] = array(
+            $condition,
+            $condition,
+            $condition,
+            '_multi' => true,
+        );
+
+        // 获取所有配置
+        $map['status'] = array('egt', '0'); // 禁用和正常状态
+        $map['group']  = array('eq', $group);
+        $p             = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $config_object = D('Config');
+        $data_list     = $config_object
+            ->page($p, C('ADMIN_PAGE_ROWS'))
+            ->where($map)
+            ->order('sort asc,id asc')
+            ->select();
+        $page = new Page(
+            $config_object->where($map)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+
+        // 设置Tab导航数据列表
+        $config_group_list = C('CONFIG_GROUP_LIST'); // 获取配置分组
+        foreach ($config_group_list as $key => $val) {
+            $tab_list[$key]['title'] = $val;
+            $tab_list[$key]['href']  = U('index', array('group' => $key));
+        }
+
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('配置列表') // 设置页面标题
+            ->addTopButton('addnew') // 添加新增按钮
+            ->addTopButton('resume') // 添加启用按钮
+            ->addTopButton('forbid') // 添加禁用按钮
+            ->addTopButton('delete') // 添加删除按钮
+            ->setSearch(
+                '请输入ID/配置名称/配置标题',
+                U('index', array('group' => $group))
+            )
+            ->setTabNav($tab_list, $group) // 设置页面Tab导航
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('name', '名称')
+            ->addTableColumn('title', '标题')
+            ->addTableColumn('sort', '排序')
+            ->addTableColumn('status', '状态', 'status')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list) // 数据列表
+            ->setTableDataPage($page->show()) // 数据列表分页
+            ->addRightButton('edit') // 添加编辑按钮
+            ->addRightButton('forbid') // 添加禁用/启用按钮
+            ->addRightButton('delete') // 添加删除按钮
+            ->display();
+    }
+
+    /**
+     * 新增配置
+     *
+     */
+    public function add()
+    {
+        if (IS_POST) {
+            $config_object = D('Config');
+            $data          = $config_object->create();
+            if ($data) {
+                if ($config_object->add($data)) {
+                    S('DB_CONFIG_DATA', null);
+                    $this->success('新增成功', U('index'));
+                } else {
+                    $this->error('新增失败');
+                }
+            } else {
+                $this->error($config_object->getError());
+            }
+        } else {
+            //获取Builder表单类型转换成一维数组
+            $form_item_type = C('FORM_ITEM_TYPE');
+            foreach ($form_item_type as $key => $val) {
+                $form_item_type[$key] = $val[0];
+            }
+
+            //使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('新增配置') //设置页面标题
+                ->setPostUrl(U('add')) //设置表单提交地址
+                ->addFormItem('group', 'select', '配置分组', '配置所属的分组', C('CONFIG_GROUP_LIST'))
+                ->addFormItem('type', 'select', '配置类型', '配置类型的分组', $form_item_type)
+                ->addFormItem('name', 'text', '配置名称', '配置名称')
+                ->addFormItem('title', 'text', '配置标题', '配置标题')
+                ->addFormItem('value', 'textarea', '配置值', '配置值')
+                ->addFormItem('options', 'textarea', '配置项', '如果是单选、多选、下拉等类型 需要配置该项')
+                ->addFormItem('tip', 'textarea', '配置说明', '配置说明')
+                ->addFormItem('sort', 'num', '排序', '用于显示的顺序')
+                ->display();
+        }
+    }
+
+    /**
+     * 编辑配置
+     *
+     */
+    public function edit($id)
+    {
+        if (IS_POST) {
+            $config_object = D('Config');
+            $data          = $config_object->create();
+            if ($data) {
+                if ($config_object->save($data)) {
+                    S('DB_CONFIG_DATA', null);
+                    $this->success('更新成功', U('index'));
+                } else {
+                    $this->error('更新失败');
+                }
+            } else {
+                $this->error($config_object->getError());
+            }
+        } else {
+            // 获取Builder表单类型转换成一维数组
+            $form_item_type = C('FORM_ITEM_TYPE');
+            foreach ($form_item_type as $key => $val) {
+                $form_item_type[$key] = $val[0];
+            }
+
+            // 使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('编辑配置') // 设置页面标题
+                ->setPostUrl(U('edit')) // 设置表单提交地址
+                ->addFormItem('id', 'hidden', 'ID', 'ID')
+                ->addFormItem('group', 'select', '配置分组', '配置所属的分组', C('CONFIG_GROUP_LIST'))
+                ->addFormItem('type', 'select', '配置类型', '配置类型的分组', $form_item_type)
+                ->addFormItem('name', 'text', '配置名称', '配置名称')
+                ->addFormItem('title', 'text', '配置标题', '配置标题')
+                ->addFormItem('value', 'textarea', '配置值', '配置值')
+                ->addFormItem('options', 'textarea', '配置项', '如果是单选、多选、下拉等类型 需要配置该项')
+                ->addFormItem('tip', 'textarea', '配置说明', '配置说明')
+                ->addFormItem('sort', 'num', '排序', '用于显示的顺序')
+                ->setFormData(D('Config')->find($id))
+                ->display();
+        }
+    }
+
+    /**
+     * 获取某个分组的配置参数
+     *
+     */
+    public function group($group = 1)
+    {
+        //根据分组获取配置l
+        $map['status'] =array('egt', '0'); // 禁用和正常状态
+        $map['group']  = array('eq', $group);
+        $data_list     = D('Config')
+            ->where($map)
+            ->order('sort asc,id asc')
+            ->select();
+
+        // 设置Tab导航数据列表
+        $config_group_list = array_slice(C('CONFIG_GROUP_LIST'),0,4,true); // 获取配置分组
+        foreach ($config_group_list as $key => $val) {
+            $tab_list[$key]['title'] = $val;
+            $tab_list[$key]['href']  = U('group', array('group' => $key));
+        }
+
+        // 构造表单名、解析options
+        foreach ($data_list as &$data) {
+            $data['name']    = 'config[' . $data['name'] . ']';
+            $data['options'] = \Util\Str::parseAttr($data['options']);
+        }
+
+        // 使用FormBuilder快速建立表单页面。
+        $builder = new \Common\Builder\FormBuilder();
+        $builder->setMetaTitle('系统设置') // 设置页面标题
+            ->SetTabNav($tab_list, $group) // 设置Tab按钮列表
+            ->setPostUrl(U('groupSave')) // 设置表单提交地址
+            ->setExtraItems($data_list) // 直接设置表单数据
+            ->display();
+    }
+
+    /**
+     * 批量保存配置
+     *
+     */
+    public function groupSave($config)
+    {
+        if ($config && is_array($config)) {
+            $config_object = D('Config');
+            foreach ($config as $name => $value) {
+                $map = array('name' => $name);
+                // 如果值是数组则转换成字符串,适用于复选框等类型
+                if (is_array($value)) {
+                    $value = implode(',', $value);
+                }
+                $config_object->where($map)->setField('value', $value);
+            }
+        }
+        S('DB_CONFIG_DATA', null);
+        $this->success('保存成功!');
+    }
+}

+ 1225 - 0
Application/Admin/Controller/ExportController.class.php

@@ -0,0 +1,1225 @@
+<?php
+namespace Admin\Controller;
+
+use Think\Page;
+
+class ExportController extends AddonController
+{
+
+    /*导出列表*/
+    public function index(){
+        $this->display('index');
+    }
+
+    /*获取需要导出大件标签*/
+    public function exportDetail(){
+        $field="product_name";
+        if($_SESSION['ly_admin_']['user_auth']['uid']==1){
+
+            $productlist = M('qcode_product')->field($field)->where('id!=0')->select();
+            $user_list = array();
+            $user_list[0] = ['id'=>0,'nickname'=>'全部'];
+            $user_list_1 = M('admin_user')
+                ->alias('a')
+                ->join('qr_admin_access access on a.id = access.uid')
+                ->field('a.id,a.nickname')
+                ->where('a.status = 1 and (access.group = 4 or access.group = 1)')
+                ->select();
+            $user_list = array_merge($user_list,$user_list_1);
+
+        }else{
+            $product_id = M('admin_user')->where('id = '.$_SESSION['ly_admin_']['user_auth']['uid'])->getField('product_id');
+            $productlist = [];
+            if(!empty($product_id)){
+                $productlist = M('qcode_product')->where('id in ('.$product_id.')')->select();
+            }
+            $user_list = array();
+            $user_list[0] = ['id'=>$_SESSION['ly_admin_']['user_auth']['uid'],'nickname'=>$_SESSION['ly_admin_']['user_auth']['nickname']];
+        }
+
+        $this->assign('productlist',$productlist);
+        $this->assign('userlist',$user_list);
+        $this->display('detail');
+    }
+
+    /*获取导出列表*/
+    public function exportExcel(){
+        $field="product_name";
+
+        if($_SESSION['ly_admin_']['user_auth']['uid']==1){
+            $productlist = M('qcode_product')->field($field)->where('id!=0')->select();
+            $user_list = array();
+            $user_list[0] = ['id'=>0,'nickname'=>'全部'];
+            $user_list_1 = M('admin_user')
+                ->alias('a')
+                ->join('qr_admin_access access on a.id = access.uid')
+                ->field('a.id,a.nickname')
+                ->where('a.status = 1 and (access.group = 4 or access.group = 1)')
+                ->select();
+            $user_list = array_merge($user_list,$user_list_1);
+        }else{
+            $product_id = M('admin_user')->where('id = '.$_SESSION['ly_admin_']['user_auth']['uid'])->getField('product_id');
+            $productlist = [];
+            if(!empty($product_id)){
+                $productlist = M('qcode_product')->where('id in ('.$product_id.')')->select();
+            }
+            $user_list = array();
+            $user_list[0] = ['id'=>$_SESSION['ly_admin_']['user_auth']['uid'],'nickname'=>$_SESSION['ly_admin_']['user_auth']['nickname']];
+        }
+        $this->assign('productlist',$productlist);
+        $this->assign('userlist',$user_list);
+        $this->display('excel');
+    }
+
+    /*此方法暂时搁置*/
+    public function exportBach(){
+        $field="product_name";
+        if($_SESSION['ly_admin_']['user_auth']['uid']==1){
+            $productlist = M('qcode_product')->field($field)->where('id!=0')->select();
+            $user_list = array();
+            $user_list[0] = ['id'=>0,'nickname'=>'全部'];
+            $user_list_1 = M('admin_user')
+                ->alias('a')
+                ->join('qr_admin_access access on a.id = access.uid')
+                ->field('a.id,a.nickname')
+                ->where('a.status = 1 and (access.group = 4 or access.group = 1)')
+                ->select();
+            $user_list = array_merge($user_list,$user_list_1);
+        }else{
+            $product_id = M('admin_user')->where('id = '.$_SESSION['ly_admin_']['user_auth']['uid'])->getField('product_id');
+            $productlist = [];
+            if(!empty($product_id)){
+                $productlist = M('qcode_product')->where('id in ('.$product_id.')')->select();
+            }
+            $user_list = array();
+            $user_list[0] = ['id'=>$_SESSION['ly_admin_']['user_auth']['uid'],'nickname'=>$_SESSION['ly_admin_']['user_auth']['nickname']];
+        }
+        $this->assign('productlist',$productlist);
+        $this->assign('userlist',$user_list);
+        $this->display('bach');
+    }
+
+    /*获取大件详情*/
+    public function getBigData(){
+        /*批次有正常和删除状态,0为未删除,1为已删除;大件0为未删除,1为已删除*/
+        $session_config=I('session.ly_admin_');//获取登陆的session值
+        $where = [];
+        if($_POST['sysCdNm']){//有搜索产品名称
+            $where['a.matter_name'] = $_POST['sysCdNm'];
+        }
+        if($_POST['startDate']){//有开始打印日期
+            $statrtime=((int)date('Ymd',(strtotime($_POST['startDate'])))-20000000);
+            $endtime=((int)date('Ymd',(strtotime($_POST['endDate'])))-20000000);
+            $where['a.manufacture_date']=array(array('egt',$statrtime),array('elt',$endtime),'AND');
+        }
+        if($session_config['user_auth']['uid']==1){
+            if($_POST['user_name']!=0){
+                $where['a.userid']=$_POST['user_name'];
+            }
+        }else{
+            $where['a.userid']=$session_config['user_auth']['uid'];
+        }
+        if($_POST['bach_num']!=''){
+            $where['a.bach_num']=array('like','%'.trim($_POST['bach_num']).'%');
+        }
+        $where['a.bach_status']=0;
+        $where['large.l_status']=0;
+        $BatchList=M('qcode_bach')
+            ->alias('a')
+            ->join('qr_qcode_large large on large.bach_id=a.id')
+            ->field('a.id bach_id,a.matter_name,a.manufacture_date,a.tray_num,a.bach_num,large.code_cp1,large.id large_id,large.code')
+            ->order($_POST['sort'].' '.$_POST['order'])
+            ->page($_POST['page'],$_POST['rows'])
+            ->where($where)
+            ->select();
+        $total = M('qcode_bach')->alias('a')
+            ->join('qr_qcode_large large on large.bach_id=a.id')
+            ->where($where)
+            ->count();
+        /*查询第三个值*/
+        foreach($BatchList as &$v){
+            $v['count'] = M('qcode_small')->where('large_id = '.$v['large_id'].' and status = 0')->count();
+        }
+        $result  = [];
+        $result['total'] = $total;
+        $result['rows'] = $BatchList;
+        $bachlist = json_encode($result);
+        echo $bachlist;
+    }
+
+    /*获取excel详情*/
+    public function getExcelData(){
+        /*批次有正常和删除状态,0为未删除,1为已删除;大件0为未删除,1为已删除*/
+        $session_config=I('session.ly_admin_');//获取登陆的session值
+
+        $where = [];
+        if($_POST['sysCdNm']){//有搜索产品名称
+            $where['matter_name'] = $_POST['sysCdNm'];
+        }
+        if($_POST['startDate']){//有开始打印日期
+            $statrtime=strtotime($_POST['startDate']);
+            $endtime=strtotime($_POST['endDate'])+86400-1;
+            $where['date']=array(array('egt',$statrtime),array('elt',$endtime),'AND');
+        }
+        if($session_config['user_auth']['uid']==1){
+            if($_POST['user_name']!='全部'){
+                $where['username']=$_POST['user_name'];
+//                $where['userid']=$session_config['user_auth']['uid'];
+
+            }
+        }else{
+            $where['userid']=$session_config['user_auth']['uid'];
+//            $where['username'] = $session_config['user_auth']['nickname'];
+        }
+        $where['status']=$_POST['status'];
+        $BatchList=M('qcode_export')
+            ->order($_POST['sort'].' '.$_POST['order'])
+            ->page($_POST['page'],$_POST['rows'])
+            ->where($where)
+            ->select();
+        $total = M('qcode_export')
+            ->where($where)
+            ->count();
+        $result  = [];
+        $result['total'] = $total;
+        $result['rows'] = $BatchList;
+        $excellist = json_encode($result);
+        echo $excellist;
+    }
+
+    /*获取小件列表*/
+    public function getSmall(){
+        $id = $_POST['largeId']!=0?$_POST['largeId']:0;
+        $result=M('qcode_large')
+            ->alias('l')
+            ->join('qr_qcode_small s on s.large_id=l.id')
+            ->field('s.code,s.code_cp1,s.p_nums,s.status,s.large_id,l.code_cp1 as l_code_sp1')
+            ->where('l.id = '.$id)
+            ->select();
+        echo json_encode($result);
+    }
+
+    /*删除导出列表*/
+    public function changeExcelData(){
+        $id = $_POST['id'];
+
+        /*查询导出记录*/
+        $exportExcel = M('qcode_export')->find($id);
+        /*修改大件的发货状态*/
+        M()->startTrans();
+        $update_ret = M('qcode_large')->where('id in ('.$exportExcel['large_str'].')')->setField('l_status',0);
+        if($update_ret){
+            //无导出excel
+//            $return = M('qcode_export')->where('id = '.$id)->setField('status',1);
+//            if($return){
+//                M()->commit();
+//                $this->ajaxReturn(['status'=>1,'msg'=>'删除成功']);
+//                die;
+//            }else {
+//                M()->rollback();
+//                $this->ajaxReturn(['status' => 0, 'msg' => '系统飞走了,请稍后再试']);
+//            }
+
+            //插入数据库
+            $return = M('qcode_export')->where('id = '.$id)->setField('status',1);
+            if($return){
+                if(strtoupper(substr(PHP_OS,0,3))==='WIN'){
+                    $dir = iconv("utf-8", "gb2312",$exportExcel['file_dir']);
+                }else{
+                    $dir = $exportExcel['file_dir'];
+                }
+                $res = unlink($dir);
+                if($res){
+                    M()->commit();
+                    $this->ajaxReturn(['status'=>1,'msg'=>'删除成功']);
+                    die;
+                }else{
+                    M()->rollback();
+                    $this->ajaxReturn(['status' => 0, 'msg' => '系统飞走了,请稍后再试']);
+                }
+            }else {
+                M()->rollback();
+                $this->ajaxReturn(['status' => 0, 'msg' => '系统飞走了,请稍后再试']);
+            }
+        }
+
+    }
+
+    /*excel导出*/
+    public function export(){
+        header("Content-type: text/html; charset=utf-8");
+        $bach = I('bach_id');
+        $bach_list = M('qcode_bach')->find($bach);
+        $manufacture_date = $bach_list['manufacture_date'];
+        $print_date = $bach_list['print_date'];
+        $bach_list['manufacture_date'] = $this->getData($bach_list['manufacture_date']);
+        $bach_list['print_date'] = $this->getData($bach_list['print_date']);
+        if(empty($bach_list)){
+            $arr = array('status'=>0,'msg'=>'违法请求,请重新请求');
+        }else{
+            $bach_list['data'] = M('qcode_bach')
+                ->alias('bach')
+                ->join('qr_qcode_large large ON large.bach_id = bach.id')
+                ->join('qr_qcode_small small ON small.large_id = large.id')
+                ->field('large.code lcode,large.code_cp1 lcode_cp1,large.code_cp2 lcode_cp2,small.code scode,small.code_cp1 scode_cp1,small.code_cp2 scode_cp2')
+                ->where('bach.id = '.$bach.' and small.status = 0')
+                ->select();
+        }
+        $bach_list['count'] = count($bach_list['data']);
+        $return = $this->excelExport($bach_list);
+        if($return){
+            $arr = array('status'=>1,'msg'=>'导出完成','url'=>$return);
+        }
+        $this->ajaxReturn($arr);
+    }
+
+    /*获取时间格式*/
+    public function getData($date){
+        return '20'.substr($date,0,2).'/'.substr($date,2,2).'/'.substr($date,4,2);
+    }
+
+    /*补0*/
+    public function addZero($a,$le,$pos='left'){
+        $str =$a;
+        $len = substr($a);
+        $cha = $le-$len;
+        if($cha>0){
+            if($pos=='left'){
+                $str = str_pad($str,$le,"0",STR_PAD_LEFT);
+            }else{
+                $str = str_pad($str,$le,"0",STR_PAD_RIGHT);
+            }
+        }
+        return $str;
+    }
+
+    /**
+     * 支持多批次导出操作
+     */
+//    public function newexport(){
+//        $session_config=I('session.ly_admin_');
+//
+//        $id = substr($_POST['id'],0,-1);
+//
+//        /*检查所有大件的状态*/
+////        $return  = $this->checkStatus($id);
+////        if(!$return){
+////            $this->ajaxReturn(['status'=>0,'msg'=>'参数违法,请重新提交']);
+////        }
+//
+//        $bach_id_arr = M('qcode_large')
+//            ->where('l_status = 0 and id IN ('.$id.')')
+//            ->group(true)
+//            ->getField('bach_id',true);
+//
+//        for ($i=0; $i<count($bach_id_arr);$i++){
+//            /*获取基本数据*/
+//            $res =  M('qcode_bach')
+//                ->field('file_no,order_no,supplier_name,supplier_code,supplier_id,matter_name,matter_no,manufacture_date,print_date,l_reservation,s_reservation,l_flow,s_flow,l_weight,s_weight,larger_num,tray_num,box_num,bach_num')
+//                ->where('id ='.$bach_id_arr[$i])
+//                ->find();
+//
+//            $larger_id =  M('qcode_large')
+//                ->where('id in ('.$id.') and bach_id = '.$bach_id_arr[$i])
+//                ->getField('id',true);
+//
+//            $larger_id_str = implode(',',$larger_id);
+//
+//            $res['larger_num'] = count($larger_id);
+//            $res['small_num'] = M('qcode_small')->where('large_id in ('.$larger_id_str.')')->count();
+//
+//            //插入数据库
+//            $add = [];
+//            if ($res['box_num']!=1){
+//                $add['num'] = $res['box_num'];
+//                $add['mater_type'] = 1;
+//            }else{
+//                $add['num'] = $res['s_weight'];
+//                $add['mater_type'] = 2;
+//            }
+//            $add['userid'] = $session_config['user_auth']['uid'];
+//            $add['username'] = $res['supplier_name'];
+//            $add['matter_name'] = $res['matter_name'];
+//            $add['matter_no'] = $res['matter_no'];
+//            $add['large_str'] = $larger_id_str;
+//            $add['large_num'] = $res['larger_num'];
+//            $add['small_num'] = $res['small_num'];
+//            $add['bach_num'] = $res['bach_num'];
+//            $add['date'] = time();
+//            $add['file_dir'] = '';
+//            $add['status'] = 0;
+//            $data[$i] =  $add;
+//
+//        }
+//        M()->startTrans();
+//        $update_ret = M('qcode_large')->where('id in ('.$id.')')->setField('l_status',1);
+//
+//
+//        if($update_ret){
+//
+//            $return = M('qcode_export')->addAll($data);
+//
+//
+//            if($return){
+//                M()->commit();
+//
+//                $arr =  ['status'=>1,'msg'=>'操作成功','url'=>''];
+//            }else{
+//                M()->rollback();
+//                $arr =  ['status'=>0,'msg'=>'系统飞走了,请稍后再试'];
+//            }
+//        }
+//        $this->ajaxReturn($arr);
+//
+//    }
+    /*导出初版本*/
+    public function export1(){
+
+        $id = substr($_POST['id'],0,-1);
+        $count = $_POST['sum'];
+        /*检查数量是否正确*/
+        $return = $this->checkCount($id,$count);
+        if(!$return){
+            $this->ajaxReturn(['status'=>0,'msg'=>'导出数量错误,请重新请求']);
+        }
+
+        /*检查所有大件的状态*/
+        $return  = $this->checkStatus($id);
+        if(!$return){
+            $this->ajaxReturn(['status'=>0,'msg'=>'参数违法,请重新提交']);
+        }
+
+        /*判断所选择的大件是否同一辅料名称,统一供应商,并且获取基本数据*/
+        $return  = $this->check($id);
+        if($return['status']==0){
+            $this->ajaxReturn($return);
+        }
+
+        /*获取大小件绑定的的数据*/
+        $data = $return['data'];
+
+        /*获取大件的重量*/
+        $data['l_weight'] = $this->sumLarge($id);
+        $data['small_num'] = $count;
+        $data['id_str'] = $id;
+
+        $data['data'] =  M('qcode_large')
+            ->alias('large')
+            ->join('qr_qcode_small small ON small.large_id = large.id')
+            ->field('large.code lcode,large.code_cp1 lcode_cp1,large.code_cp2 lcode_cp2,small.code scode,small.code_cp1 scode_cp1,small.code_cp2 scode_cp2')
+            ->where('small.large_id in ('.$id.') and small.status = 0')
+            ->select();
+
+        $return = $this->excelExport1($data);
+
+        if($return['status']==1){
+            $arr = array('status'=>1,'msg'=>'导出完成','url'=>$return['msg']);
+        }else{
+            $arr = $return;
+        }
+        $this->ajaxReturn($arr);
+    }
+
+
+    /*excel导出方法2*/
+//    public function export1(){
+//
+//        $session_config=I('session.ly_admin_');
+//
+//        $id = substr($_POST['id'],0,-1);
+//
+//        /*检查所有大件的状态*/
+////        $return  = $this->checkStatus($id);
+////        if(!$return){
+////            $this->ajaxReturn(['status'=>0,'msg'=>'参数违法,请重新提交']);
+////        }
+//
+//        $bach_id_arr = M('qcode_large')
+//            ->where('l_status = 0 and id IN ('.$id.')')
+//            ->group(true)
+//            ->getField('bach_id',true);
+//
+//        for ($i=0; $i<count($bach_id_arr);$i++){
+//            /*获取基本数据*/
+//            $res =  M('qcode_bach')
+//                ->field('file_no,order_no,supplier_name,supplier_code,supplier_id,matter_name,matter_no,manufacture_date,print_date,l_reservation,s_reservation,l_flow,s_flow,l_weight,s_weight,larger_num,tray_num,box_num,bach_num')
+//                ->where('id ='.$bach_id_arr[$i])
+//                ->find();
+//
+//            $larger_id =  M('qcode_large')
+//                ->where('id in ('.$id.') and bach_id = '.$bach_id_arr[$i])
+//                ->getField('id',true);
+//
+//            $larger_id_str = implode(',',$larger_id);
+//
+//            $res['larger_num'] = count($larger_id);
+//            $res['small_num'] = M('qcode_small')->where('large_id in ('.$larger_id_str.')')->count();
+//
+//            //插入数据库
+//            $add = [];
+//            if ($res['box_num']!=1){
+//                $add['num'] = $res['box_num'];
+//                $add['mater_type'] = 1;
+//            }else{
+//                $add['num'] = $res['s_weight'];
+//                $add['mater_type'] = 2;
+//            }
+//            $add['userid'] = $session_config['user_auth']['uid'];
+//            $add['username'] = $res['supplier_name'];
+//            $add['matter_name'] = $res['matter_name'];
+//            $add['matter_no'] = $res['matter_no'];
+//            $add['large_str'] = $larger_id_str;
+//            $add['large_num'] = $res['larger_num'];
+//            $add['small_num'] = $res['small_num'];
+//            $add['bach_num'] = $res['bach_num'];
+//            $add['date'] = time();
+//            $add['file_dir'] = '';
+//            $add['status'] = 0;
+//            $data[$i] =  $add;
+//
+//        }
+//        M()->startTrans();
+//        $update_ret = M('qcode_large')->where('id in ('.$id.')')->setField('l_status',1);
+//
+//
+//        if($update_ret){
+//
+//            $return = M('qcode_export')->addAll($data);
+//
+//
+//            if($return){
+//                M()->commit();
+//
+//                $arr =  ['status'=>1,'msg'=>'操作成功','url'=>''];
+//            }else{
+//                M()->rollback();
+//                $arr =  ['status'=>0,'msg'=>'系统飞走了,请稍后再试'];
+//            }
+//        }
+//        $this->ajaxReturn($arr);
+//    }
+
+    /*获取发货单页面*/
+    public function exportFahuo(){
+        $field="product_name";
+        if($_SESSION['ly_admin_']['user_auth']['uid']==1){
+            $productlist = M('qcode_product')->field($field)->where('id!=0')->select();
+            $user_list = array();
+            $user_list[0] = ['id'=>0,'nickname'=>'全部'];
+            $user_list_1 = M('admin_user')
+                ->alias('a')
+                ->join('qr_admin_access access on a.id = access.uid')
+                ->field('a.id,a.nickname')
+                ->where('a.status = 1 and (access.group = 4 or access.group = 1)')
+                ->select();
+            $user_list = array_merge($user_list,$user_list_1);
+        }else{
+            $product_id = M('admin_user')->where('id = '.$_SESSION['ly_admin_']['user_auth']['uid'])->getField('product_id');
+            $productlist = [];
+            if(!empty($product_id)){
+                $productlist = M('qcode_product')->where('id in ('.$product_id.')')->select();
+            }
+            $user_list = array();
+            $user_list[0] = ['id'=>$_SESSION['ly_admin_']['user_auth']['uid'],'nickname'=>$_SESSION['ly_admin_']['user_auth']['nickname']];
+        }
+        $this->assign('productlist',$productlist);
+        $this->assign('userlist',$user_list);
+        $this->display('fahuo');
+    }
+
+    /*得到发货页列表*/
+    public function getFahuoData(){
+        /*批次有正常和删除状态,0为未删除,1为已删除;大件0为未删除,1为已删除*/
+        $session_config=I('session.ly_admin_');//获取登陆的session值
+        $where = [];
+        if($_POST['order_number']){//有搜索订单号
+            $where['order_number'] = $_POST['order_number'];
+        }
+        if($_POST['startDate']){//有开始打印日期
+            $statrtime=strtotime($_POST['startDate']);
+            $endtime=strtotime($_POST['endDate'])+86400-1;
+            $where['create_time']=array(array('egt',$statrtime),array('elt',$endtime),'AND');
+        }
+        if($session_config['user_auth']['uid']==1){
+            if($_POST['user_name']!=0){
+                $where['userid']=$_POST['user_name'];
+            }
+        }else{
+            $where['userid']=$session_config['user_auth']['uid'];
+        }
+        $where['status']=$_POST['status'];
+        $goodsList=M('goods')
+            ->order($_POST['sort'].' '.$_POST['order'])
+            ->page($_POST['page'],$_POST['rows'])
+            ->where($where)
+            ->select();
+        $total = M('goods')
+            ->where($where)
+            ->count();
+        $result  = [];
+        $result['total'] = $total;
+        $result['rows'] = $goodsList;
+        $fahuollist = json_encode($result);
+        echo $fahuollist;
+
+    }
+
+    /*删除发货列表*/
+    public function changeFahuoData(){
+        $id = $_POST['id'];
+        /*查询导出记录*/
+        $exportExcel = M('goods')->find($id);
+        /*修改大件的发货状态*/
+        M()->startTrans();
+        $update_ret = M('qcode_export')->where('id in ('.$exportExcel['export_ids'].')')->setField('status',0);
+        if($update_ret){
+            //插入数据库
+            $return = M('goods')->where('id = '.$id)->setField('status',1);
+            if($return){
+                M()->commit();
+                $this->ajaxReturn(['status'=>1,'msg'=>'删除成功']);
+                die;
+            }else {
+                M()->rollback();
+                $this->ajaxReturn(['status' => 0, 'msg' => '系统飞走了,请稍后再试']);
+            }
+        }
+
+    }
+
+
+    //发货申请
+    public function addFahuo(){
+
+        /*批次有正常和删除状态,0为未删除,1为已删除;大件0为未删除,1为已删除*/
+        $id = substr($_POST['id'],0,-1);
+        $session_config=I('session.ly_admin_');//获取登陆的session值
+        $return  = $this->checkExportStatus($id);
+        if(!$return){
+            $this->ajaxReturn(['status'=>0,'msg'=>'参数违法,请重新提交']);
+        }
+        /*修改发货状态*/
+        M()->startTrans();
+        $update_ret = M('qcode_export')->where('id in ('.$id.')')->setField('status',2);
+        if($update_ret) {
+            $export = M('qcode_export')->where('id in ('.$id.')')->select();
+            $daterq = date("Ymd",time());
+            //插入数据库
+            $add = [];
+            $add['userid'] = $session_config['user_auth']['uid'];
+            $add['supplier_id'] = $add['userid'];
+            $add['order_number'] = $_POST['order_num'];
+            $add['deliveryman'] = $_POST['deliveryman'];
+            $add['plate_number'] = $_POST['plate_number'];
+            $add['shr_phone'] = $_POST['shr_phone'];
+            $add['note'] = $_POST['note'];
+            $add['supplier_name'] = $export[0]['username'];
+            $add['export_ids'] = $id;
+            $add['shdh'] = substr($daterq,2,2).' '.substr($daterq,2,6).mt_rand(1000,9999);
+            $add['create_time'] = time();
+            $add['qrcode_add'] = $this->qrcode($add['shdh']);
+
+            $return = M('goods')->data($add)->add();
+            if ($return) {
+                M()->commit();
+            } else {
+                M()->rollback();
+                $this->ajaxReturn(['status' => 0, 'msg' => '系统飞走了,请稍后再试']);
+            }
+        }
+        $arr = array('status'=>1,'msg'=>'添加完成','url'=>'index.php?s=/Admin/Export/exportFahuo.html');
+        $this->ajaxReturn($arr);
+    }
+
+
+
+    /*excel导出方法2*/
+    public function export2(){
+
+        $id = substr($_POST['id'],0,-1);
+        $count = $_POST['sum'];
+        /*检查数量是否正确*/
+        $return = $this->checkCount($id,$count);
+        if(!$return){
+            $this->ajaxReturn(['status'=>0,'msg'=>'导出数量错误,请重新请求']);
+        }
+        /*检查所有大件的状态*/
+        $return  = $this->checkStatus($id);
+        if(!$return){
+            $this->ajaxReturn(['status'=>0,'msg'=>'参数违法,请重新提交']);
+        }
+
+        /*判断所选择的大件是否同一辅料名称,统一供应商,并且获取基本数据*/
+        $return  = $this->check($id);
+        if($return['status']==0){
+            $this->ajaxReturn($return);
+        }
+
+        /*获取大小件绑定的的数据*/
+        $data = $return['data'];
+
+        /*获取大件的重量*/
+        $data['l_weight'] = $this->sumLarge($id);
+        $data['small_num'] = $count;
+        $data['id_str'] = $id;
+
+        $data['data'] =  M('qcode_large')
+            ->alias('large')
+            ->join('qr_qcode_small small ON small.large_id = large.id')
+            ->field('large.code lcode,large.code_cp1 lcode_cp1,large.code_cp2 lcode_cp2,small.code scode,small.code_cp1 scode_cp1,small.code_cp2 scode_cp2')
+            ->where('small.large_id in ('.$id.') and small.status = 0')
+            ->select();
+
+        $return = $this->excelExport1($data);
+
+        if($return['status']==1){
+            $arr = array('status'=>1,'msg'=>'导出完成','url'=>$return['msg']);
+        }else{
+            $arr = $return;
+        }
+        $this->ajaxReturn($arr);
+    }
+
+    /*检查数量 status有两种状态,0为正常,1为已删除*/
+    public function checkCount($id,$count){
+        $total = M('qcode_small')
+            ->where('status = 0 and large_id IN ('.$id.')')
+            ->count();
+        if($total==$count){
+            return true;
+        }else{
+            return false;
+        }
+    }
+
+    /*检查状态*/
+    public function checkStatus($id){
+        $return = M('qcode_large')
+            ->where('l_status = 1 and id IN ('.$id.')')
+            ->count();
+        if($return==0){
+            return true;
+        }else{
+            return false;
+        }
+    }
+    /*检查导出状态*/
+    public function checkExportStatus($id){
+        $return = M('qcode_export')
+            ->where('status > 0 and id IN ('.$id.')')
+            ->count();
+        if($return==0){
+            return true;
+        }else{
+            return false;
+        }
+    }
+
+    /*其他数据验证,以及数据获取*/
+    public function check($id){
+
+        header("Content-type: text/html; charset=utf-8");
+
+        $bach_return = M('qcode_large')
+            ->where('l_status = 0 and id IN ('.$id.')')
+            ->distinct(true)
+            ->order("bach_id desc")
+            ->getField('bach_id',true);
+
+        $bach_str = implode(',',$bach_return);
+
+        /*验证辅料名称是否为1*/
+        $ret =  M('qcode_bach')
+            ->where('id IN ('.$bach_str.')')
+            ->distinct(true)
+            ->getField('matter_name',true);
+
+        if(count($ret)>1){
+            return ['status'=>0,'msg'=>'仅能选择一个辅料名称'];
+        }
+
+        /*验证供应商名称是否唯一*/
+        $supplier=  M('qcode_bach')
+            ->where('id IN ('.$bach_str.')')
+            ->distinct(true)
+            ->getField('supplier_name',true);
+
+        if(count($supplier)>1){
+            return ['status'=>0,'msg'=>'仅能选择一个供应商'];
+        }
+
+//        if(count($bach_return)!=1){
+//            return ['status'=>0,'msg'=>'仅能选择一个批次'];
+//        }
+
+        /*获取基本数据*/
+        $data =  M('qcode_bach')
+            ->field('file_no,order_no,supplier_name,supplier_code,supplier_id,matter_name,matter_no,manufacture_date,print_date,l_reservation,s_reservation,l_flow,s_flow,l_weight,s_weight,larger_num,tray_num,box_num,bach_num')
+            ->where('id ='.$bach_return['0'])
+            ->find();
+$data['s_weight'] = $data['s_weight']/1000;
+        if(count($bach_return)!=1){
+//
+            $data['l_reservation'] = 0;
+            $data['s_reservation'] = 0;
+//            $data['l_flow'] = 0;
+//            $data['s_flow'] = 0;
+//            $data['s_weight'] = 0;
+//            $data['tray_num'] = 0;
+        }
+
+        $data['larger_num'] = count(explode(',',$id));
+
+        $data['l_weight'] *= $data['larger_num'];
+
+        /*日期转化*/
+        $data['manufacture_date'] = $this->getData( $data['manufacture_date']);
+
+        $data['print_date'] = $this->getData($data['print_date']);
+
+        return ['status'=>1,'data'=>$data];
+
+    }
+
+    /*计算大件重量*/
+    public function sumLarge($id){
+        $l_count = M('qcode_large')
+            ->where('l_status = 0 and id IN ('.$id.')')
+            ->sum('l_weight');
+        return $l_count/100;
+    }
+
+    /**
+     * 客户导出 生成excel
+     *
+     **/
+    public function excelExport($data = false)
+    {
+        // $data['l_weight'] = $data['l_weight']/100;
+        
+        /*$fileName = iconv("utf-8", "gb2312", 'Data/'.date('Ymd', time()).$data['count'].$data['id'].'.xls');
+        if(file_exists($fileName)){
+            return $fileName;
+        }else {*/
+        //Vendor('Excel.Excel');//加载生成二维码的核心类
+        $session_config=I('session.ly_admin_');
+        $info=M('admin_user')->where('id='.$session_config['user_auth']['uid'])->field('nickname,username')->find();
+        Vendor('Excel.PHPExcel');
+        $objPHPExcel = new \PHPExcel();
+        $fileName = iconv("utf-8", "gb2312", 'Data/'.$info['username'].date('Ymd', time()).$data['count'].$data['id'].'.xls');
+        $objProps = $objPHPExcel->getProperties();
+        /*设置列宽*/
+        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(80);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
+        /*设置列宽结束*/
+        /*设置文本格式*/
+        $objPHPExcel->getActiveSheet()->getStyle('B')->getNumberFormat()->setFormatCode("@");
+        /*设置文本格式*/
+
+        /*第1~11 A行数据*/
+        $colum = 'A';
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '1', '文件流水号');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '2', '订单号');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '3', '供应商');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '4', '供应商代码');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '5', '物料名称');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '6', '物料代码');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '7', '生产日期');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '8', '打码日期');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '9', '大件数量');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '10', '托盘小件数量');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '11', '小件数量');
+        /*第1~11行A数据结束*/
+        $key = ord("A");
+        $key++;
+        $colum = chr($key);
+        /*第1~11 B行数据*/
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '1', $data['file_no']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '2', $data['order_no']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '3', $data['supplier_name']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '4', "'". $data['supplier_code']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '5', $data['matter_name']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '6', "'". $data['matter_no']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '7', $data['manufacture_date']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '8', $data['print_date']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '9', $data['larger_num']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '10', $data['tray_num']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '11', $data['small_num']);
+        /*第1~11行B数据结束*/
+        /*第3-14行数据 开始*/
+        $colum = 'C';
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '3', '大件预留码:');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '4',  $data['l_reservation']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '5', '小件预留码:');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '6',  $data['s_reservation']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '7', '大件开始流水号:');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '8',  $data['l_flow']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '9', '小件开始流水号:');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '10', $data['s_flow']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '11', '大件重量(KG)');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '12', $data['l_weight']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '13', '小件重量(KG)');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '14',  $data['s_weight']);
+        /*第3-14行数据 结束*/
+        /*第8行数据 开始*/
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A15', '大件二维码');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B15', '大件条码(预留)');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C15', '小件二维码');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('D15', '小件条码(预留)');
+        /*第8行数据 结束*/
+        foreach ($data['data'] as $i => $v) {
+            $j = $i + 16;
+            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $j, "'" . $v['lcode']);
+            //$objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$j, '大件条码(预留)');
+            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C' . $j, "'" . $v['scode']);
+            //$objPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$j, '小件条码(预留)');
+        }
+
+        //$fileName = iconv("utf-8", "gb2312", 'Data/' . date('Y-m-d_', time()) . $data['id'] . '_.xls');
+        //$saveName = iconv("utf-8", "gb2312", time() . '.xls');
+
+        /*header('Content-Type: application/vnd.ms-excel');
+        header("Content-Disposition: attachment;filename=\"$saveName\"");
+        header('Cache-Control: max-age=0');*/
+        /*$objWriter->save('php://output');
+        return true;*/
+        $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
+        $objWriter->save($fileName);
+        return $fileName;
+
+    }
+    /**
+     * 客户导出 生成excel方法2
+     *
+     **/
+//    public function excelExport1($data = false)
+//    {
+//
+//        $session_config=I('session.ly_admin_');
+//        /*修改大件的发货状态*/
+//        M()->startTrans();
+//        $update_ret = M('qcode_large')->where('id in ('.$data['id_str'].')')->setField('l_status',1);
+//        if($update_ret){
+//            //插入数据库
+//            $add = [];
+//            if ($data['box_num']!=1){
+//                $add['num'] = $data['box_num'];
+//                $add['mater_type'] = 1;
+//            }else{
+//                $add['num'] = $data['s_weight'];
+//                $add['mater_type'] = 2;
+//            }
+//            $add['userid'] = $session_config['user_auth']['uid'];
+//            $add['username'] = $data['supplier_name'];
+//            $add['matter_name'] = $data['matter_name'];
+//            $add['matter_no'] = $data['matter_no'];
+//            $add['large_str'] = $data['id_str'];
+//            $add['large_num'] = $data['larger_num'];
+//            $add['small_num'] = $data['small_num'];
+//            $add['bach_num'] = $data['bach_num'];
+//            $add['date'] = time();
+//            $add['file_dir'] = '';
+//            $add['status'] = 0;
+//            $return = M('qcode_export')->data($add)->add();
+//            if($return){
+//                M()->commit();
+//            }else{
+//                M()->rollback();
+//                return ['status'=>0,'msg'=>'系统飞走了,请稍后再试'];
+//            }
+//        }
+//
+//        return ['status'=>1,'msg'=>'添加成功'];
+//
+//    }
+
+
+
+//    /**
+//     * 客户导出 生成excel方法2
+//     *
+//     **/
+    public function excelExport1($data = false)
+    {
+        // $data['l_weight'] = $data['l_weight']/100;
+        
+        /*$fileName = iconv("utf-8", "gb2312", 'Data/'.date('Ymd', time()).$data['count'].$data['id'].'.xls');
+        if(file_exists($fileName)){
+            return $fileName;
+        }else {*/
+        //Vendor('Excel.Excel');//加载生成二维码的核心类
+
+        $session_config=I('session.ly_admin_');
+        $info=M('admin_user')->where('id='.$session_config['user_auth']['uid'])->field('nickname,username')->find();
+        Vendor('Excel.PHPExcel');
+        $objPHPExcel = new \PHPExcel();
+
+//        $fileName = 'Runtime/Data/'.date('Ymd', time()).rand(100,999).'_'.$info['nickname'].'_'.$data['matter_name'].'_'.$data['small_num'].'.xls';
+        $fileName = 'Runtime/Data/'.date('Ymd', time()).rand(100,999).'_'.$info['nickname'].'_'.str_replace('/','_',$data['matter_name']).'_'.$data['small_num'].'.xls';
+
+        /*修改大件的发货状态*/
+        M()->startTrans();
+        $update_ret = M('qcode_large')->where('id in ('.$data['id_str'].')')->setField('l_status',1);
+        if($update_ret){
+            //插入数据库
+            $add = [];
+            if ($data['box_num']!=1){
+                $add['num'] = $data['box_num'];
+                $add['mater_type'] = 1;
+            }else{
+                $add['num'] = $data['s_weight'];
+                $add['mater_type'] = 2;
+            }
+            $add['userid'] = $session_config['user_auth']['uid'];
+            $add['username'] = $data['supplier_name'];
+            $add['matter_name'] = $data['matter_name'];
+            $add['matter_no'] = $data['matter_no'];
+            $add['large_str'] = $data['id_str'];
+            $add['large_num'] = $data['larger_num'];
+            $add['small_num'] = $data['small_num'];
+            $add['bach_num'] = $data['bach_num'];
+            $add['date'] = time();
+            $add['file_dir'] = $fileName;
+            $add['status'] = 0;
+            $return = M('qcode_export')->data($add)->add();
+            if($return){
+                M()->commit();
+            }else{
+                M()->rollback();
+                return ['status'=>0,'msg'=>'系统飞走了,请稍后再试'];
+            }
+        }
+
+        $objProps = $objPHPExcel->getProperties();
+        /*设置列宽*/
+        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(80);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(15);
+        /*设置列宽结束*/
+        /*设置文本格式*/
+        $objPHPExcel->getActiveSheet()->getStyle('B')->getNumberFormat()->setFormatCode("@");
+        /*设置文本格式*/
+
+        /*第1~11 A行数据*/
+        $colum = 'A';
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '1', '文件流水号');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '2', '订单号');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '3', '供应商');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '4', '供应商代码');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '5', '物料名称');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '6', '物料代码');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '7', '生产日期');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '8', '打码日期');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '9', '大件数量');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '10', '托盘小件数量');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '11', '小件总数量');
+        /*第1~11行A数据结束*/
+        $key = ord("A");
+        $key++;
+        $colum = chr($key);
+        /*第1~11 B行数据*/
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '1', $data['file_no']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '2', $data['order_no']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '3', $data['supplier_name']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '4', "'". $data['supplier_code']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '5', $data['matter_name']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '6', "'". $data['matter_no']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '7', $data['manufacture_date']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '8', $data['print_date']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '9', $data['larger_num']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '10', $data['tray_num']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '11', $data['small_num']);
+        /*第1~11行B数据结束*/
+        /*第3-14行数据 开始*/
+        $colum = 'C';
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '3', '大件预留码:');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '4',  $data['l_reservation']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '5', '小件预留码:');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '6',  $data['s_reservation']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '7', '大件开始流水号:');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '8',  $data['l_flow']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '9', '小件开始流水号:');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '10', $data['s_flow']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '11', '大件重量(KG)');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '12', $data['l_weight']);
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '13', '小件重量(KG)');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '14',  $data['s_weight']);
+        /*第3-14行数据 结束*/
+        /*第8行数据 开始*/
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A15', '大件二维码');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B15', '大件条码(预留)');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C15', '小件二维码');
+        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('D15', '小件条码(预留)');
+        /*第8行数据 结束*/
+        foreach ($data['data'] as $i => $v) {
+            $j = $i + 16;
+            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $j, "'" . $v['lcode']);
+            //$objPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$j, '大件条码(预留)');
+            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C' . $j, "'" . $v['scode']);
+            //$objPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$j, '小件条码(预留)');
+        }
+
+
+        if(strtoupper(substr(PHP_OS,0,3))==='WIN'){
+            $saveName = iconv("utf-8", "gb2312",$fileName);
+        }else{
+            $saveName = $fileName;
+        }
+
+        $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
+        $objWriter->save($saveName);
+        return ['status'=>1,'msg'=>$fileName];
+
+    }
+
+    //打印发货单
+    public function print1($id){
+        $model = new \Think\Model();
+        $data = M('goods')->find($id);
+        $export_ids = explode(',',$data['export_ids']);
+        $arr = [];
+        foreach($export_ids as $v){
+            $arr[] = M('qcode_export')->find($v);
+        }
+        $address = $model->query("select u.company_address as address from qr_goods g left join qr_admin_user u on u.id=g.supplier_id where g.id=".$id)[0]['address'];
+        $data['address']=$address;
+        $data['arr']=$arr;
+        $data['count']=count($arr);
+        $data['shrq_date']=date("Y-m-d",$data['create_time']);
+        if (empty($data['qrcode_add'])){
+            $data['qrcode_add'] = $this->qrcode($data['shdh']);
+            M('goods')->where('id='.$id)->setField('qrcode_add',$data['qrcode_add']);
+        }
+        echo json_encode($data);
+    }
+
+    public function qrcode($url)//二维码生成类
+    {
+        $level=2;
+        $size=5;
+        Vendor('phpqrcode.phpqrcode');//加载生成二维码的核心类
+        $errorCorrectionLevel =intval($level) ;//容错级别
+        $matrixPointSize = intval($size);//生成图片大小
+        //生成二维码图片
+        $object = new \QRcode();
+        //打开缓冲区
+        ob_start();
+        $object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2);
+        //这里就是把生成的图片流从缓冲区保存到内存对象上,使用base64_encode变成编码字符串,通过json返回给页面。
+        $imageString = base64_encode(ob_get_contents());
+        //关闭缓冲区
+        ob_end_clean();
+        //把生成的base64字符串返回给前端
+        $data = array(
+            'labelcode'=>$url,
+            'code'=>200,
+            'data'=>$imageString,
+            'product_code'=>$url
+        );
+        return 'data:image/png;base64,'.$imageString;
+//        $this->ajaxReturn($data);
+    }
+
+    public function qrcode_up($qrcode_add,$ids){
+        $res = M('goods')->where('id='.$ids)->setField('qrcode_add',$qrcode_add);
+        return $res;
+    }
+
+    public function shouhuo(){
+
+        $this->display('shouhuo');
+    }
+
+    public function exportShouhuo(){
+        $field="product_name";
+        $productlist = M('qcode_product')->field($field)->where('id!=0')->select();
+        $user_list = array();
+        $user_list[0] = ['id'=>0,'nickname'=>'全部'];
+        $user_list_1 = M('admin_user')
+            ->alias('a')
+            ->join('qr_admin_access access on a.id = access.uid')
+            ->field('a.id,a.nickname')
+            ->where('a.status = 1 and (access.group = 4 or access.group = 1 or access.group = 3)')
+            ->select();
+        $user_list = array_merge($user_list,$user_list_1);
+//        if($_SESSION['ly_admin_']['user_auth']['uid']==1){
+//            $user_list[0] = ['id'=>0,'nickname'=>'全部'];
+//            $user_list_1 = M('admin_user')
+//                ->alias('a')
+//                ->join('qr_admin_access access on a.id = access.uid')
+//                ->field('a.id,a.nickname')
+//                ->where('a.status = 1')
+//                ->select();
+//            $user_list = array_merge($user_list,$user_list_1);
+//        }else{
+//            $product_id = M('admin_user')->where('id = '.$_SESSION['ly_admin_']['user_auth']['uid'])->getField('product_id');
+//            $productlist = M('qcode_product')->where('id in ('.$product_id.')')->select();
+//            $user_list = array();
+//            $user_list[0] = ['id'=>$_SESSION['ly_admin_']['user_auth']['uid'],'nickname'=>$_SESSION['ly_admin_']['user_auth']['nickname']];
+//        }
+        $this->assign('productlist',$productlist);
+        $this->assign('userlist',$user_list);
+        $this->display('shouhuolist');
+    }
+
+    public function getShouhuoData(){
+        /*批次有正常和删除状态,0为未删除,1为已删除;大件0为未删除,1为已删除*/
+        $session_config=I('session.ly_admin_');//获取登陆的session值
+        $where = [];
+        if($_POST['order_number']){//有搜索订单号
+            $where['order_number'] = $_POST['order_number'];
+        }
+        if($_POST['startDate']){//有开始打印日期
+            $statrtime=strtotime($_POST['startDate']);
+            $endtime=strtotime($_POST['endDate'])+86400-1;
+            $where['create_time']=array(array('egt',$statrtime),array('elt',$endtime),'AND');
+        }
+//        if($session_config['user_auth']['uid']==1 ){
+//            if($_POST['user_name']!=0){
+//                $where['userid']=$_POST['user_name'];
+//            }
+//        }else{
+//            $where['userid']=$session_config['user_auth']['uid'];
+//        }
+        $where['status']=$_POST['status'];
+        $goodsList=M('goods')
+            ->order($_POST['sort'].' '.$_POST['order'])
+            ->page($_POST['page'],$_POST['rows'])
+            ->where($where)
+            ->select();
+        $total = M('goods')
+            ->where($where)
+            ->count();
+        $result  = [];
+        $result['total'] = $total;
+        $result['rows'] = $goodsList;
+        $fahuollist = json_encode($result);
+        echo $fahuollist;
+    }
+
+    public function changeShouhuo(){
+        $where['shdh']=$_POST['shdh'];
+        $return = M('goods')->where($where)->setField('status',2);
+        if($return){
+            $this->ajaxReturn(['status'=>1,'msg'=> $where['shdh'].'发货单已收货','url' =>'index.php?s=/Admin/Export/exportShouhuo.html']);
+            die;
+        }else {
+            $this->ajaxReturn(['status' => 0, 'msg' => '系统飞走了,请稍后再试']);
+        }
+    }
+
+    public function dealShouhuo(){
+        $id = $_POST['id'];
+        $return = M('goods')->where('id = '.$id)->setField('status',0);
+        if($return){
+            $this->ajaxReturn(['status'=>1,'msg'=>'取消成功']);
+            die;
+        }else {
+            $this->ajaxReturn(['status' => 0, 'msg' => '系统飞走了,请稍后再试']);
+        }
+    }
+
+}

+ 129 - 0
Application/Admin/Controller/ExportExcelController.class.php

@@ -0,0 +1,129 @@
+<?php
+
+namespace Admin\Controller;
+
+
+class ExportExcelController extends AddonController
+{//导出Excel表格的类
+
+    public function index()
+    {
+        //取出需要导出的数据
+        //$user=M('User'); //此方法不通用
+        $model = M(I('qcode_product'));
+        $map = $this->_search(I('qcode_product')); //生成Map查询对象
+        //排序字段,默认为主键名
+        $order = I('_order') != '' ? I('_order') : $model->getPk();
+        //排序方式,默认倒序排列,首次显示时因为不会接收到提交数据,所以都是显示的默认值
+        $sort = I('_sort') == 'asc' ? 'asc' : 'desc';
+        $modellist = $model->where($map)->order($order . ' ' . $sort)->select();
+        //导入第三方扩展类库
+        Vendor('PHPExcel179.PHPExcel');
+        $objPHPExcel = new \PHPExcel(); //创建PHPExcel对象
+        //设置属性
+        $objPHPExcel->getProperties()->setCreator("StudyIM")->setLastModifiedBy("StudyIM")->setTitle("StudyIM.com")->setDescription("StudyIM.com")->setKeywords("StudyIM");
+        //设置宽度
+        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(8);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(18);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(35);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(10);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(12);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(20);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(15);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(15);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(10);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('N')->setWidth(20);
+
+
+//设置行高
+        $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(30);
+        $objPHPExcel->getActiveSheet()->getRowDimension('2')->setRowHeight(20);
+//设置字体样式
+        $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(10); //默认字体大小
+        $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(16)->setBold(true);
+        $objPHPExcel->getActiveSheet()->getStyle('A2:N2')->getFont()->setBold(true); //粗体
+
+//合并excel
+        $objPHPExcel->getActiveSheet()->mergeCells('A1:N1');
+
+//设置垂直、水平居中
+        $objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()
+            ->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER)
+            ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+        $objPHPExcel->getActiveSheet()->getStyle('A2:N2')->getAlignment()
+            ->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER)
+            ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+//设置边框
+        $objPHPExcel->getActiveSheet()->getStyle('A2:N2')->getBorders()->getAllBorders()
+            ->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
+
+//前两行单元格内容
+        $objPHPExcel->setActiveSheetIndex(0)
+            ->setCellValue('A1', I('module_name') . '表查询记录汇总表')
+            ->setCellValue('A2', 'ID')
+            ->setCellValue('B2', '用户名')
+            ->setCellValue('C2', '密码')
+            ->setCellValue('D2', '邮箱')
+            ->setCellValue('E2', '性别')
+            ->setCellValue('F2', '用户资金')
+            ->setCellValue('G2', '注册时间')
+            ->setCellValue('H2', '注册IP')
+            ->setCellValue('I2', '最后登录时间')
+            ->setCellValue('J2', '最后登录IP')
+            ->setCellValue('K2', 'QQ')
+            ->setCellValue('L2', '手机号')
+            ->setCellValue('M2', '状态')
+            ->setCellValue('N2', '备注');
+
+//数据行设置
+        for ($i = 0; $i < count($modellist); $i++) {
+            $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 3), $modellist[$i]['id']);
+            $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 3), $modellist[$i]['username']);
+            $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 3), $modellist[$i]['password']);
+            $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 3), $modellist[$i]['email']);
+            $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 3), $modellist[$i]['sex'] = 1 ? '男' : '女');
+            $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 3), $modellist[$i]['user_money']);
+            $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 3), $modellist[$i]['reg_time']);
+            $objPHPExcel->getActiveSheet()->setCellValue('H' . ($i + 3), $modellist[$i]['reg_ip']);
+            $objPHPExcel->getActiveSheet()->setCellValue('I' . ($i + 3), $modellist[$i]['last_login'] ? date('Y-m-d H:i:s', $modellist[$i]['last_login']) : '');
+            $objPHPExcel->getActiveSheet()->setCellValue('J' . ($i + 3), $modellist[$i]['last_ip']);
+            $objPHPExcel->getActiveSheet()->setCellValue('K' . ($i + 3), $modellist[$i]['qq']);
+            $objPHPExcel->getActiveSheet()->setCellValue('L' . ($i + 3), $modellist[$i]['mobile']);
+            $objPHPExcel->getActiveSheet()->setCellValue('M' . ($i + 3), $modellist[$i]['status'] = 1 ? '正常' : '禁止');
+            $objPHPExcel->getActiveSheet()->setCellValue('N' . ($i + 3), $modellist[$i]['remark']);
+
+//设置垂直、水平居中
+            $objPHPExcel->getActiveSheet()->getStyle('A' . ($i + 3) . ':N' . ($i + 3))->getAlignment()
+                ->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER)
+                ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+            $objPHPExcel->getActiveSheet()->getRowDimension($i + 3)->setRowHeight(16);//行高
+
+//设置边框
+            $objPHPExcel->getActiveSheet()->getStyle('A' . ($i + 3) . ':N' . ($i + 3))->getBorders()->getAllBorders()
+                ->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
+        }
+
+//sheet命名
+        $objPHPExcel->getActiveSheet()->setTitle(I('module_name') . '表');
+//默认打开的sheet
+        $objPHPExcel->setActiveSheetIndex(0);
+
+//excel头参数
+        header("Content-Type:application/vnd.ms-execl");
+        header('Content-Disposition:attachment;filename=' . I('module_name') . '表查询结果(' . date('YmdHis') . ').xls');//日期文件名后缀
+        header('Cache-Control:max-age=0');
+
+        $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); //excel2007为xlsx
+        $objWriter->save('php://output');
+
+
+    }
+
+
+}

+ 180 - 0
Application/Admin/Controller/GroupController.class.php

@@ -0,0 +1,180 @@
+<?php
+
+namespace Admin\Controller;
+
+use Util\Tree;
+
+/**
+ * 部门控制器
+ *
+ */
+class GroupController extends AdminController
+{
+    /**
+     * 部门列表
+     *
+     */
+    public function index()
+    {
+        // 搜索
+        $keyword         = I('keyword', '', 'string');
+        $condition       = array('like', '%' . $keyword . '%');
+        $map['id|title'] = array(
+            $condition,
+            $condition,
+            '_multi' => true,
+        );
+
+        // 获取所有部门
+        $map['status'] = array('egt', '0'); //禁用和正常状态
+        $data_list     = D('Group')
+            ->where($map)
+            ->order('sort asc, id asc')
+            ->select();
+
+        // 转换成树状列表
+        $tree      = new Tree();
+        $data_list = $tree->array2tree($data_list);
+
+        $right_button['no']['title']     = '超级管理员无需操作';
+        $right_button['no']['attribute'] = 'class="label label-warning" href="#"';
+
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('部门列表') // 设置页面标题
+            ->addTopButton('addnew') // 添加新增按钮
+            ->addTopButton('resume') // 添加启用按钮
+            ->addTopButton('forbid') // 添加禁用按钮
+            ->addTopButton('delete') // 添加删除按钮
+            ->setSearch('请输入ID/部门名称', U('index'))
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('title_show', '标题')
+            ->addTableColumn('icon', '图标', 'icon')
+            ->addTableColumn('sort', '排序')
+            ->addTableColumn('status', '状态', 'status')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list) // 数据列表
+            ->addRightButton('edit') // 添加编辑按钮
+            ->addRightButton('forbid') // 添加禁用/启用按钮
+            ->addRightButton('delete') // 添加删除按钮
+            ->alterTableData( // 修改列表数据
+                array('key' => 'id', 'value' => '1'),
+                array('right_button' => $right_button)
+            )
+            ->display();
+    }
+
+    /**
+     * 新增部门
+     *
+     */
+    public function add()
+    {
+        if (IS_POST) {
+            $group_object       = D('Group');
+            $_POST['menu_auth'] = json_encode(I('post.menu_auth'));
+            $data               = $group_object->create();
+            if ($data) {
+                $id = $group_object->add($data);
+                if ($id) {
+                    $this->success('新增成功', U('index'));
+                } else {
+                    $this->error('新增失败');
+                }
+            } else {
+                $this->error($group_object->getError());
+            }
+        } else {
+            // 获取现有部门
+            $map['status'] = array('egt', 0);
+            $all_group     = select_list_as_tree('Group', $map, '顶级部门');
+
+            // 获取功能模块的后台菜单列表
+            $tree       = new Tree();
+            $moule_list = D('Module')
+                ->where(array('status' => 1))
+                ->select(); // 获取所有安装并启用的功能模块
+            $all_module_menu_list = array();
+            foreach ($moule_list as $key => $val) {
+                $temp                               = json_decode($val['admin_menu'], true);
+                $menu_list_item                     = $tree->list2tree($temp);
+                $all_module_menu_list[$val['name']] = $menu_list_item[0];
+            }
+
+            $this->assign('all_module_menu_list', $all_module_menu_list);
+            $this->assign('all_group', $all_group);
+            $this->assign('meta_title', '新增部门');
+            $this->display('add_edit');
+        }
+    }
+
+    /**
+     * 编辑部门
+     *
+     */
+    public function edit($id)
+    {
+        if (IS_POST) {
+            $group_object       = D('Group');
+            $_POST['menu_auth'] = json_encode(I('post.menu_auth'));
+            $data               = $group_object->create();
+            if ($data) {
+                if ($group_object->save($data) !== false) {
+                    $this->success('更新成功', U('index'));
+                } else {
+                    $this->error('更新失败');
+                }
+            } else {
+                $this->error($group_object->getError());
+            }
+        } else {
+            // 获取部门信息
+            $info              = D('Group')->find($id);
+            $info['menu_auth'] = json_decode($info['menu_auth'], true);
+            // 获取现有部门
+            $map['status'] = array('egt', 0);
+            $all_group     = select_list_as_tree('Group', $map, '顶级部门');
+
+            // 获取所有安装并启用的功能模块
+            $moule_list = D('Module')
+                ->where(array('status' => 1))
+                ->select();
+
+            // 获取功能模块的后台菜单列表
+            $tree                 = new Tree();
+            $all_module_menu_list = array();
+            foreach ($moule_list as $key => $val) {
+                $temp                               = json_decode($val['admin_menu'], true);
+                $menu_list_item                     = $tree->list2tree($temp);
+                $all_module_menu_list[$val['name']] = $menu_list_item[0];
+            }
+           /* echo '<pre>';
+            print_r($all_module_menu_list);*/
+            $this->assign('info', $info);
+            $this->assign('all_module_menu_list', $all_module_menu_list);
+            /*print_r($all_module_menu_list);die;*/
+            $this->assign('all_group', $all_group);
+            $this->assign('meta_title', '编辑部门');
+            $this->display('add_edit');
+        }
+    }
+
+    /**
+     * 设置一条或者多条数据的状态
+     *
+     */
+    public function setStatus($model = CONTROLLER_NAME, $script = false)
+    {
+        $ids = I('request.ids');
+        if (is_array($ids)) {
+            if (in_array('1', $ids)) {
+                $this->error('超级管理员组不允许操作');
+            }
+        } else {
+            if ($ids === '1') {
+                $this->error('超级管理员组不允许操作');
+            }
+        }
+        parent::setStatus($model);
+    }
+}

+ 105 - 0
Application/Admin/Controller/HomeController.class.php

@@ -0,0 +1,105 @@
+<?php
+/**
+ * author jade
+ * intro 激活类
+ */
+namespace Admin\Controller;
+
+use Think\Controller;
+
+class HomeController extends Controller
+{
+    protected $config;
+
+    public function _initialize()
+    {
+        $this->config=D('Config');
+    }
+	
+    public function selectdata(){ 
+        $URL = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+        $geturl=str_replace('.html','',$URL);
+      	$get = $_GET;
+      	if((count($get)!==1 or !isset($get['code']))){
+        		header("HTTP/1.1 404 Not Found"); 
+                $this->display('error');
+          		return false;
+        }
+        $data = base64_decode($_GET['code']);
+      	/*if(!preg_match('/[a-z0-9]/',substr($data,-1))){
+         		header("HTTP/1.1 404 Not Found"); 
+                $this->display('error');
+          		return false;
+        }*/
+        if($_POST['code'] != ''&& $_POST['varify'] != ''){
+            $where = array();
+            $where['code'] = $_POST['code'];
+            $where['varify_code'] = (int)$_POST['varify'];
+            $code_table = getSubTable1('codes',$where['code']);
+            $return  = M($code_table)->where($where)->select();
+            $count = count($return);
+            if($count>0){
+                echo 1;
+            }else{
+                echo 0;
+            }
+        }else{
+            if($data==''){
+              	header("HTTP/1.1 404 Not Found"); 
+                $this->display('error');
+          		return false;
+            }else{
+                /*$code =parse_url($data);
+                $code = substr($code['path'],1);*/
+                $where = array();
+                $where['code'] = $data;
+                $code_table = getSubTable1('codes',$where['code']);
+                $return  = M($code_table)->field('varify_code,Status,product_id')->where($where)->find();
+                if(count($return)>0){
+                    if($return['Status']==0){
+                        //未激活的状态
+                        $return1 = M('product_box_type')->field('product_id')->where('id = '.$return['product_id'])->find();
+                        switch ($return1['product_id']) {
+                            case 1:
+                                //金丝路
+                                $this->display('jingsilu_1');
+                                break;
+                            case 2:
+                                //小黄金
+				$this->display('hjy_1');
+                                break;
+                            case 3:
+                                //炫尚
+                                $this->display('xuanshang_1');
+                                break;
+                        }
+                    }else{
+			$return1 = M('product_box_type')->field('product_id')->where('id = '.$return['product_id'])->find();
+                        switch ($return1['product_id']) {
+                            case 1:
+                                //金丝路
+                                $this->display('jingsilu');
+                                break;
+                            case 2:
+                                //小黄金
+				$this->display('hjy');
+                                break;
+                            case 3:
+                                //炫尚
+                                $this->display('xuanshang');
+                                break;
+                        }
+                    }   
+                }else{
+                    header("HTTP/1.1 404 Not Found"); 
+                    $this->display('error');
+                }
+            }
+        } 
+    }
+    public function gosuccess(){ 
+        $this->display('hjy');
+    }
+
+}
+

+ 55 - 0
Application/Admin/Controller/IndexController.class.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 后台默认控制器
+ *
+ */
+class IndexController extends AdminController
+{
+    /**
+     * 默认方法
+     *
+     */
+    public function index()
+    {
+        $version=M('version')->where('id!=0')->order('id desc')->select();
+        $this->assign('meta_title', "首页");
+        $this->assign('version', $version);
+        $this->display();
+    }
+  /**
+     * 默认方法
+     *
+     */
+    public function index2()
+    {
+ 
+        $this->display();
+    }
+
+    /**
+     * 默认方法
+     *
+     */
+    public function index3()
+    {
+ 
+        $this->display();
+    }
+    /**
+     * 删除缓存
+     *
+     */
+    public function removeRuntime()
+    {
+        $file   = new \Util\File();
+        $result = $file->del_dir(RUNTIME_PATH);
+        if ($result) {
+            $this->success("缓存清理成功");
+        } else {
+            $this->error("缓存清理失败");
+        }
+    }
+}

+ 320 - 0
Application/Admin/Controller/ModuleController.class.php

@@ -0,0 +1,320 @@
+<?php
+
+namespace Admin\Controller;
+
+use Util\Sql;
+
+/**
+ * 功能模块控制器
+ *
+ */
+class ModuleController extends AdminController
+{
+    /**
+     * 默认方法
+     *
+     */
+    public function index()
+    {
+        $module_object = D('Module');
+        $data_list     = $module_object->getAll();
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('模块列表') // 设置页面标题
+            ->addTopButton('resume') // 添加启用按钮
+            ->addTopButton('forbid') // 添加禁用按钮
+            ->setSearch('请输入ID/标题', U('index'))
+            ->addTableColumn('name', '名称')
+            ->addTableColumn('title', '标题')
+            ->addTableColumn('description', '描述')
+            ->addTableColumn('developer', '开发者')
+            ->addTableColumn('version', '版本')
+            ->addTableColumn('create_time', '创建时间', 'time')
+            ->addTableColumn('status_icon', '状态', 'text')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list) // 数据列表
+            ->display();
+    }
+
+    /**
+     * 检查模块依赖
+     *
+     */
+    public function checkDependence($dependences)
+    {
+        if (is_array($dependences)) {
+            foreach ($dependences as $key => $val) {
+                $con['name'] = $key;
+                $module_info = D('Module')->where($con)->find();
+                if (!$module_info) {
+                    $this->error('该模块依赖' . $key . '模块');
+                }
+                if (version_compare($module_info['version'], $val) >= 0) {
+                    continue;
+                } else {
+                    $this->error($module_info['title'] . '模块版本不得低于v' . $val);
+                    return false;
+                }
+            }
+            return true;
+        }
+    }
+
+    /**
+     * 安装模块之前
+     *
+     */
+    public function install_before($name)
+    {
+        // 使用FormBuilder快速建立表单页面。
+        $builder = new \Common\Builder\FormBuilder();
+        $builder->setMetaTitle('准备安装模块') // 设置页面标题
+            ->setPostUrl(U('install')) // 设置表单提交地址
+            ->addFormItem('name', 'hidden', 'name', 'name')
+            ->addFormItem('clear', 'radio', '是否清除历史数据', '是否清除历史数据', array('1' => '是', '0' => '否'))
+            ->setFormData(array('name' => $name))
+            ->display();
+    }
+
+    /**
+     * 安装模块
+     *
+     */
+    public function install($name, $clear = true)
+    {
+        // 获取当前模块信息
+        $config_file = realpath(APP_PATH . $name) . '/'
+        . D('Module')->install_file();
+        if (!$config_file) {
+            $this->error('安装失败');
+        }
+        $config_info = include $config_file;
+        $data        = $config_info['info'];
+
+        // 处理模块配置
+        if ($config_info['config']) {
+            $temp_arr = $config_info['config'];
+            foreach ($temp_arr as $key => $value) {
+                if ($value['type'] == 'group') {
+                    foreach ($value['options'] as $gkey => $gvalue) {
+                        foreach ($gvalue['options'] as $ikey => $ivalue) {
+                            $config[$ikey] = $ivalue['value'];
+                        }
+                    }
+                } else {
+                    $config[$key] = $temp_arr[$key]['value'];
+                }
+            }
+            $data['config'] = json_encode($config);
+        } else {
+            $data['config'] = '';
+        }
+
+        // 检查依赖
+        if ($data['dependences']) {
+            $result = $this->checkDependence($data['dependences']);
+            if (!$result) {
+                return false;
+            }
+        }
+
+        // 获取后台菜单
+        if ($config_info['admin_menu']) {
+            // 将key值赋给id
+            foreach ($config_info['admin_menu'] as $key => &$val) {
+                $val['id'] = (string) $key;
+            }
+            $data['admin_menu'] = json_encode($config_info['admin_menu']);
+        }
+
+        // 获取用户中心导航
+        if ($config_info['user_nav']) {
+            $data['user_nav'] = json_encode($config_info['user_nav']);
+        } else {
+            $data['user_nav'] = '';
+        }
+
+        // 安装数据库
+        $sql_object           = new Sql();
+        $uninstall_sql_status = true;
+        // 清除旧数据
+        if ($clear) {
+            $sql_file             = realpath(APP_PATH . $name) . '/Sql/uninstall.sql';
+            $uninstall_sql_status = $sql_object->execute_sql_from_file($sql_file);
+        }
+        // 安装新数据表
+        if (!$uninstall_sql_status) {
+            $this->error('安装失败');
+        }
+        $sql_file   = realpath(APP_PATH . $name) . '/Sql/install.sql';
+        $sql_status = $sql_object->execute_sql_from_file($sql_file);
+
+        if ($sql_status) {
+            // 写入数据库记录
+            $module_object = D('Module');
+            $data          = $module_object->create($data);
+            if ($data) {
+                $id = $module_object->add($data);
+                if ($id) {
+                    // 安装成功后自动在前台新增导航
+                    $nav_data['group'] = 'top';
+                    $nav_data['title'] = $data['title'];
+                    $nav_data['type']  = 'module';
+                    $nav_data['value'] = $data['name'];
+                    $nav_data['icon']  = $data['icon'] ?: '';
+                    $nav_object        = D('Nav');
+                    $nav_data_created  = $nav_object->create($nav_data);
+                    if ($nav_data_created) {
+                        $nav_add_result = $nav_object->add($nav_data_created);
+                    }
+                    $this->success('安装成功', U('index'));
+                } else {
+                    $this->error('安装失败');
+                }
+            } else {
+                $this->error($module_object->getError());
+            }
+        } else {
+            $sql_file   = realpath(APP_PATH . $name) . '/Sql/uninstall.sql';
+            $sql_status = $sql_object->execute_sql_from_file($sql_file);
+            $this->error('安装失败');
+        }
+    }
+
+    /**
+     * 卸载模块之前
+     *
+     */
+    public function uninstall_before($id)
+    {
+        // 使用FormBuilder快速建立表单页面。
+        $builder = new \Common\Builder\FormBuilder();
+        $builder->setMetaTitle('准备卸载模块') // 设置页面标题
+            ->setPostUrl(U('uninstall')) // 设置表单提交地址
+            ->addFormItem('id', 'hidden', 'ID', 'ID')
+            ->addFormItem('clear', 'radio', '是否清除数据', '是否清除数据', array('1' => '是', '0' => '否'))
+            ->setFormData(array('id' => $id))
+            ->display();
+    }
+
+    /**
+     * 卸载模块
+     *
+     */
+    public function uninstall($id, $clear = false)
+    {
+        $module_object = D('Module');
+        $module_info   = $module_object->find($id);
+        if ($module_info['is_system'] === '1') {
+            $this->error('系统模块不允许卸载!');
+        }
+        $result = $module_object->delete($id);
+        if ($result) {
+            if ($clear) {
+                $sql_object = new Sql();
+                $sql_file   = realpath(APP_PATH . $module_info['name']) . '/Sql/uninstall.sql';
+                $sql_status = $sql_object->execute_sql_from_file($sql_file);
+                if ($sql_status) {
+                    $this->success('卸载成功,相关数据彻底删除!', U('index'));
+                }
+            } else {
+                $this->success('卸载成功,相关数据未卸载!', U('index'));
+            }
+        } else {
+            $this->error('卸载失败', U('index'));
+        }
+    }
+
+    /**
+     * 更新模块信息
+     *
+     */
+    public function updateInfo($id)
+    {
+        $module_object = D('Module');
+        $name          = $module_object->getFieldById($id, 'name');
+        $config_file   = realpath(APP_PATH . $name) . '/' . D('Module')->install_file();
+        if (!$config_file) {
+            $this->error('不存在安装文件');
+        }
+        $config_info = include $config_file;
+        $data        = $config_info['info'];
+        // 读取数据库已有配置
+        $db_moduel_config = D('Module')->getFieldByName($name, 'config');
+        $db_moduel_config = json_decode($db_moduel_config, true);
+
+        // 处理模块配置
+        if ($config_info['config']) {
+            $temp_arr = $config_info['config'];
+            foreach ($temp_arr as $key => $value) {
+                if ($value['type'] == 'group') {
+                    foreach ($value['options'] as $gkey => $gvalue) {
+                        foreach ($gvalue['options'] as $ikey => $ivalue) {
+                            $config[$ikey] = $ivalue['value'];
+                        }
+                    }
+                } else {
+                    if (isset($db_moduel_config[$key])) {
+                        $config[$key] = $db_moduel_config[$key];
+                    } else {
+                        $config[$key] = $temp_arr[$key]['value'];
+                    }
+                }
+            }
+            $data['config'] = json_encode($config);
+        } else {
+            $data['config'] = '';
+        }
+
+        // 获取后台菜单
+        if ($config_info['admin_menu']) {
+            // 将key值赋给id
+            foreach ($config_info['admin_menu'] as $key => &$val) {
+                $val['id'] = (string) $key;
+            }
+            $data['admin_menu'] = json_encode($config_info['admin_menu']);
+        }
+        // 获取用户中心导航
+        if ($config_info['user_nav']) {
+            $data['user_nav'] = json_encode($config_info['user_nav']);
+        } else {
+            $data['user_nav'] = '';
+        }
+
+        $data['id'] = $id;
+        $data       = $module_object->create($data);
+        if ($data) {
+            $id = $module_object->save($data);
+            if ($id) {
+                $this->success('更新成功', U('index'));
+            } else {
+                $this->error('更新失败');
+            }
+        } else {
+            $this->error($module_object->getError());
+        }
+    }
+
+    /**
+     * 设置一条或者多条数据的状态
+     *
+     */
+    public function setStatus($model = CONTROLLER_NAME, $script = false)
+    {
+        $ids = I('request.ids');
+        if (is_array($ids)) {
+            foreach ($ids as $id) {
+                $is_system = D($model)->getFieldById($id, 'is_system');
+                if ($is_system) {
+                    $this->error('系统模块不允许操作');
+                }
+            }
+        } else {
+            $is_system = D($model)->getFieldById($ids, 'is_system');
+            if ($is_system) {
+                $this->error('系统模块不允许操作');
+            }
+        }
+        parent::setStatus($model);
+    }
+}

+ 191 - 0
Application/Admin/Controller/NavController.class.php

@@ -0,0 +1,191 @@
+<?php
+
+namespace Admin\Controller;
+
+use \Util\Tree;
+
+/**
+ * 导航控制器
+ *
+ */
+class NavController extends AdminController
+{
+    /**
+     * 导航列表
+     *
+     */
+    public function index($group = 'main')
+    {
+        //搜索
+        $keyword         = I('keyword', '', 'string');
+        $condition       = array('like', '%' . $keyword . '%');
+        $map['id|title'] = array(
+            $condition,
+            $condition,
+            '_multi' => true,
+        );
+
+        // 获取所有导航
+        $map['status'] = array('egt', '0');
+        $map['group']  = $group;
+        $data_list     = D('Admin/Nav')
+            ->where($map)
+            ->order('sort asc, id asc')
+            ->select();
+
+        // 给文章列表类型加上链接
+        foreach ($data_list as &$val) {
+            if ($val['type'] == 'post') {
+                $val['title'] = '<a href="' . U('Admin/Post/index', array('cid' => $val['id'])) . '">' . $val['title'] . '</a>';
+            }
+        }
+
+        // 转换成树状列表
+        $tree      = new Tree();
+        $data_list = $tree->array2tree($data_list);
+
+        // 设置Tab导航数据列表
+        $nav_group_list = C('NAV_GROUP_LIST'); // 获取分类分组
+        foreach ($nav_group_list as $key => $val) {
+            $tab_list[$key]['title'] = $val;
+            $tab_list[$key]['href']  = U('index', array('group' => $key));
+        }
+
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('导航列表') // 设置页面标题
+            ->addTopButton('addnew', array('href' => U('Admin/Nav/add', array('group' => $group)))) // 添加新增按钮
+            ->addTopButton('resume') // 添加启用按钮
+            ->addTopButton('forbid') // 添加禁用按钮
+            ->addTopButton('delete') // 添加删除按钮
+            ->setSearch('请输入ID/导航名称', U('index', array('group' => $group)))
+            ->setTabNav($tab_list, $group) // 设置页面Tab导航
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('icon', '图标', 'icon')
+            ->addTableColumn('title_show', '标题')
+            ->addTableColumn('sort', '排序')
+            ->addTableColumn('status', '状态', 'status')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list) // 数据列表
+            ->addRightButton('edit', array('href' => U('edit', array('group' => $group, 'id' => '__data_id__')))) // 添加编辑按钮
+            ->addRightButton('forbid') // 添加禁用/启用按钮
+            ->addRightButton('delete') // 添加删除按钮
+            ->display();
+    }
+
+    // 根据导航类型设置表单项目
+    private $extra_html = <<<EOF
+    <script type="text/javascript">
+        $(function(){
+            $('input[name="type"]').change(function() {
+                var type = $(this).val();
+                // 链接类型
+                if (type == 'link') {
+                    $('.item_url').removeClass('hidden');
+                    $('.item_content').addClass('hidden');
+                    $('.item_module_name').addClass('hidden');
+                // 模块类型
+                } else if (type == 'module') {
+                    $('.item_url').addClass('hidden');
+                    $('.item_content').addClass('hidden');
+                    $('.item_module_name').removeClass('hidden');
+                // 单页类型
+                } else if (type == 'page') {
+                    $('.item_url').addClass('hidden');
+                    $('.item_content').removeClass('hidden');
+                    $('.item_module_name').addClass('hidden');
+                // 文章列表类型
+                } else if (type == 'post') {
+                    $('.item_url').addClass('hidden');
+                    $('.item_content').addClass('hidden');
+                    $('.item_module_name').addClass('hidden');
+                } else {
+                    $('.item_url').addClass('hidden');
+                    $('.item_content').addClass('hidden');
+                    $('.item_module_name').addClass('hidden');
+                }
+            });
+        });
+    </script>
+EOF;
+
+    /**
+     * 新增导航
+     *
+     */
+    public function add($group)
+    {
+        if (IS_POST) {
+            $nav_object = D('Admin/Nav');
+            $data       = $nav_object->create();
+            if ($data) {
+                $id = $nav_object->add($data);
+                if ($id) {
+                    $this->success('新增成功', U('index', array('group' => $group)));
+                } else {
+                    $this->error('新增失败');
+                }
+            } else {
+                $this->error($nav_object->getError());
+            }
+        } else {
+            // 使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('新增导航') // 设置页面标题
+                ->setPostUrl(U('', array('group' => $group))) // 设置表单提交地址
+                ->addFormItem('group', 'hidden', '导航分组', '导航分组')
+                ->addFormItem('pid', 'select', '上级导航', '上级导航', select_list_as_tree('Admin/Nav', array('group' => $group), '顶级导航'))
+                ->addFormItem('title', 'text', '导航标题', '导航前台显示标题')
+                ->addFormItem('type', 'radio', '导航类型', '导航类型', D('Admin/Nav')->nav_type())
+                ->addFormItem('url', 'text', '外链URL地址', '支持http://格式或者TP的U函数解析格式')
+                ->addFormItem('content', 'kindeditor', '单页内容', '单页内容', null, 'hidden')
+                ->addFormItem('target', 'radio', '打开方式', '打开方式', array('' => '当前窗口', '_blank' => '新窗口打开'))
+                ->addFormItem('icon', 'icon', '图标', '导航图标')
+                ->addFormItem('sort', 'num', '排序', '用于显示的顺序')
+                ->setFormData(array('type' => 'link', 'group' => $group))
+                ->setExtraHtml($this->extra_html)
+                ->display();
+        }
+    }
+
+    /**
+     * 编辑导航
+     *
+     */
+    public function edit($id, $group)
+    {
+        if (IS_POST) {
+            $nav_object = D('Admin/Nav');
+            $data       = $nav_object->create();
+            if ($data) {
+                if ($nav_object->save($data)) {
+                    $this->success('更新成功', U('index', array('group' => $group)));
+                } else {
+                    $this->error('更新失败');
+                }
+            } else {
+                $this->error($nav_object->getError());
+            }
+        } else {
+            $info = D('Admin/Nav')->find($id);
+
+            // 使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('编辑导航') // 设置页面标题
+                ->setPostUrl(U('')) // 设置表单提交地址
+                ->addFormItem('id', 'hidden', 'ID', 'ID')
+                ->addFormItem('group', 'hidden', '导航分组', '导航分组')
+                ->addFormItem('pid', 'select', '上级导航', '上级导航', select_list_as_tree('Admin/Nav', array('group' => $group), '顶级导航'))
+                ->addFormItem('title', 'text', '导航标题', '导航前台显示标题')
+                ->addFormItem('type', 'radio', '导航类型', '导航类型', D('Admin/Nav')->nav_type())
+                ->addFormItem('url', 'text', '外链URL地址', '支持http://格式或者TP的U函数解析格式', null, $info['type'] === 'link' ? '' : 'hidden')
+                ->addFormItem('content', 'kindeditor', '单页内容', '单页内容', null, $info['type'] === 'page' ? '' : 'hidden')
+                ->addFormItem('target', 'radio', '打开方式', '打开方式', array('' => '当前窗口', '_blank' => '新窗口打开'))
+                ->addFormItem('icon', 'icon', '图标', '导航图标')
+                ->addFormItem('sort', 'num', '排序', '用于显示的顺序')
+                ->setFormData($info)
+                ->setExtraHtml($this->extra_html)
+                ->display();
+        }
+    }
+}

+ 698 - 0
Application/Admin/Controller/NewQcodeController.class.php

@@ -0,0 +1,698 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Admin
+ * Date: 2018/8/8
+ * Time: 15:11
+ */
+
+namespace Admin\Controller;
+
+use think\Request;
+
+use Think\Page;
+
+class  NewQcodeController extends AddonController
+{
+
+//    protected $sign='9092';//固定标示位
+    protected $sign='AB92';//固定标示位
+    protected $signLarge='2';//大件标示位
+    protected $signSmall='1';//小件标示位
+
+    public  function index(){
+        // $db = M('qcode_product');
+        // $map['temple'] = array('exp','is null');
+        // $productlist=$db->where($map)->field('id,temple,product_code')->select();
+        // foreach ($productlist as $key=>$value){
+        //     $code = substr($value['product_code'],2,2);
+        //     $db->where('id='.$value['id'])->setField('temple',$code);
+        // }
+
+        $session_config=I('session.ly_admin_');//获取登陆的session值
+        $userinfo=M('admin_user')->where('id='.$session_config['user_auth']['uid'])->find();
+        $user_product = explode(',',$userinfo['product_id']);
+        $map = array();
+        $map['id'] = array('in',$user_product);
+        $productlist=M('qcode_product')->where($map)->field('product_name,id,product_size,product_num,temple,product_code')->select();
+
+        if($session_config['addtype']==0){//最高管理员登陆渲染供应商列表到前台
+            $field='nickname,postcode,mobile,company_address,printer_code,id';
+            $companylist=M('admin_user')->field($field)->select();
+            $this->assign('companylist',$companylist);
+        }
+        $this->assign("session_config",$session_config['user_auth']);
+        $this->assign('userinfo',$userinfo);
+        $this->assign('productlist',$productlist);
+        $this->display();
+    }
+
+    public function get_bach_info(){
+        //获取批次相关信息
+        $addtobach=M('qcode_bach')->alias('a')
+        ->join('qr_qcode_large b on  a.id=b.bach_id')
+        ->join('qr_qcode_small  c on b.id=c.large.id ')
+        ->field('bach_num,large_endnum')
+        ->where('id='.I('get.id'))
+        ->find();
+    }
+    //批次新增
+    public function add_bath(){
+        $userid=I('post.userid');//当前用户的id
+        $product_id=I('post.matter_id');//当前产品的id
+
+        //新增批次
+        if (IS_POST) {
+            if(!empty($_POST)){
+                $QcodeBach= M("QcodeBach");
+                $data=array();
+                $data= $_POST;
+//                print_r($data);
+                if(I('post.danwei')==1) {
+                    //以箱为单位
+                    $tray_num = I('post.tray_num/d');//一托盘多少箱
+                    $small_num = ceil(I('post.num/d') / I('post.box_num/d'));//总共多少箱
+                    $larger_num = ceil($small_num / $tray_num);//托盘总数量
+                }
+                if(I('post.danwei')==2){//以卷为单位
+                    $tray_num = I('post.box_num1');//一托盘多少卷
+                    $small_num = ceil(I('post.small_num'));//总共多少卷
+                    $larger_num = ceil($small_num / $tray_num);//托盘总数量
+                }
+                $reset_flow=M('reset_flow');
+                $codition['userid']=$userid;
+                $codition['product_id']=$product_id;
+                if(I('reset_large_liushui_status')==1){
+                    //没有重置大件流水号,在原有的基础上叠加
+                    $l_flow=GetTuopan($userid,$product_id);
+                    if($l_flow){
+                        //找到之前已经存在托盘号
+                        $info['l_flow']=$l_flow['l_flow']+$larger_num;
+                        $info['bach_num']=I('post.bach_num');
+                        $reset_flow->where($codition)->save($info);
+                        //var_dump($reset_flow->getLastSql());
+                    }else{
+                        //没有找到就添加
+                        $infos=[
+                            'userid'=>$userid,
+                            'product_id'=>$product_id,
+                            'l_flow'=>$larger_num,
+                            'bach_num'=>I('post.bach_num'),
+                        ];
+                        $reset_flow->add($infos);//加到对应的商家与产品上
+                        //var_dump($reset_flow->getLastSql());
+                    };
+                }
+                if(I('reset_large_liushui_status')==2){//表示用户已经重置大件流水号,更新对应的托盘数
+                    $infoss['l_flow']=$larger_num;
+                    $infoss['bach_num']=I('post.bach_num');
+                    $l_flow=GetTuopan($userid,$product_id);
+//                    print_r($infoss);die;
+                    if($l_flow){
+                        //找到了对应的数据就更新
+                        $reset_flow->where($codition)->save($infoss);//更新用户的托盘数
+                    }else{
+                        //没有就添加
+                        $infos=[
+                            'userid'=>$userid,
+                            'product_id'=>$product_id,
+                            'l_flow'=>$larger_num,
+                            'bach_num'=>I('post.bach_num'),
+                        ];
+                        $reset_flow->add($infos);
+                    }
+                }
+//                die;
+                $data['small_num']=$small_num;
+                $data['larger_num']=$larger_num;
+                $data['manufacture_date']=((int)date('Ymd',strtotime(I('post.manufacture_date')))-20000000);//六位生产日期
+                $data['print_date']=((int)date('Ymd',strtotime(I('post.print_date')))-20000000);//六位打码日期
+                $data['userid']=$userid;//批次绑定用户id
+                $data['bach_num']=I('post.bach_num');//生产批次列表
+                $data['large_endnum']=$larger_num+I('post.l_flow')-1;
+                $data['creat_time']=time();
+                $Bach_id =$QcodeBach->data($data)->add();
+                //成功插入批次信息之后开始插入大小二维码数据
+                if($Bach_id){
+                    $QcodeLarge= M("QcodeLarge");
+                    $QcodeSmall= M("QcodeSmall");
+                    $liushui=M("QcodeLiushui");
+                    //不变区域
+                    $fixed_code='';
+                    $fixed_code.=intTochar(I('post.matter_type'),2);//2位 辅料种类
+                    $fixed_code.=intTochar(I('post.supplier_code'),12);//12位  供应商编码
+                    $fixed_code.=intTochar(I('post.matter_no'),20);//20位 辅料编码
+                    $fixed_code.=((int)date('Ymd',strtotime(I('post.manufacture_date')))-20000000);//六位生产日期
+
+                    $print_date=((int)date('Ymd',strtotime(I('post.print_date')))-20000000);//6位打码日期
+
+                    $small_liushui=[
+                        'onlycode'=> "AB92".$fixed_code.$print_date,
+                        'last_num'=> 0,
+                        'user_id'=>$userid,
+                        'stype'=>2,
+                        'addtime'=>time()
+                    ];
+                    $whereSmall=[
+                        'onlycode'=> $small_liushui['onlycode'],
+                        'user_id'=> $userid
+                    ];
+                    if($liushui->where($whereSmall)->find()){
+                        //小件二维码重复了,更新这个批次的最后流水号
+                        /*  $liushui->where($whereSmall)->setInc('last_num',$small_num);*/
+                        $lastnum=$liushui->field('last_num')->where($whereSmall)->find();
+                    }else{
+                        //没有重复,新增一条记录
+                        $liushui->data($small_liushui)->add();
+                    };
+
+                    for($i=0;$i<$larger_num;$i++){
+                        $l_flows=I('post.l_flow/d')+$i;
+                        $l_flow=intTochar(I('post.l_flow/d')+$i,6);
+                        $l_weight=intTochar(I('post.l_weight')*100,6);//2023年3月20日 修改大件可以有小数,小件重量不变 不能有小数
+//                        $l_reservation=intTochar($Bach_id.I('post.l_reservation'),12);//批次id+0,不够12位在前面补0  具体点击方法看代码
+                        $l_reservation=intTochar(I('post.bach_num'),10);//批次+0,不够10位在前面补0  第一个批次  后续会加第二个批次
+                        $l_reservation = $l_reservation.'0000000000';
+                        $small_n =  intTochar($tray_num,3);
+                        if(I('post.danwei')==2){//以卷为单位
+                            $remainder = $small_num - $tray_num*$i; //确定最后一个托盘大件里小件的数量
+                            if ($remainder < $tray_num){
+                                $small_n = intTochar($remainder,3);//小件数量3位  不足补零
+                            }
+                        }
+                        $code_data= CodeData($this->sign,$fixed_code,$small_n,$print_date,$l_flow,$l_weight,$this->signLarge,$l_reservation);
+
+                        //大码数据信息
+                        $L_data=[
+                            'bach_id'=>$Bach_id,
+                            'code'=>$code_data['code'],
+                            'code_cp1'=>$code_data['code_cp1'],
+                            'code_cp2'=>$code_data['code_cp2'],
+                            'print_date'=>$print_date,
+                            'creat_time'=>time(),
+                            'p_nums'=>0,
+                            'userid'=>$userid,//大码绑定用户id
+                            'l_weight'=>$l_weight//单个大件重量
+
+                        ];
+                        $large_id= $QcodeLarge->data($L_data)->add();
+                        //小码插入循环
+                        for($j=0;$j<$tray_num and ($j+$i*$tray_num)<$small_num;$j++){
+                            $s_flow=intTochar(I('post.s_flow/d')+$j+$i*$tray_num+$lastnum['last_num'],6);//小码序号从一开始
+                            $s_weight=intTochar(I('post.s_weight'),6);
+                            $small_sign = '000';
+//                            $small_production_date = (int)date('Ymd',strtotime(I('post.manufacture_date')));//8位生产日期
+                            $s_reservation=intTochar(I('post.bach_num'),10);//批次+0,不够10位在前面补0  第一个批次  后续会加第二个批次
+                            $s_reservation = $s_reservation.'0000000000';
+                            $small_code_data= CodeData($this->sign,$fixed_code,$small_sign,$print_date,$s_flow,$s_weight,$this->signSmall,$s_reservation);
+                            $S_data=[
+                                'large_id'=>$large_id,
+                                'bach_id'=>$Bach_id,
+                                'code'=>$small_code_data['code'],
+                                'code_cp1'=>$small_code_data['code_cp1'],
+                                'code_cp2'=>$small_code_data['code_cp2'],
+                                'l_flow'=>$j+1,
+                                'print_date'=>$print_date,
+                                'creat_time'=>time(),
+                                'p_nums'=>0,
+                                'userid'=>$userid,//小码绑定用户id
+                                's_weight'=>$s_weight//单个小件重量
+                            ];
+                            $QcodeSmall->data($S_data)->add();
+                        }
+
+
+                    }
+                    $liushui->where($whereSmall)->setInc('last_num',$small_num);
+                }
+                if(($j+($i-1)*$tray_num)==$small_num){
+                    M()->commit();
+                    $this->success('批次新增成功', U('Qcode/small'));
+                }else{
+                    M()->rollback();
+                    $this->success('批次新增失败', U('Qcode/small'));
+                }
+            }else{
+                $this->error('非法请求','NewQcode/index',5);
+            }
+        }
+
+    }
+
+    public function BachListApi(){//获取打印批次列表
+
+        $session_config=I('session.ly_admin_');//获取登陆的session值
+        if($_GET['sysCdNm']){//有搜索产品名称
+            $where['a.matter_name']=array('like','%'.$_GET['sysCdNm'].'%');
+        }
+
+        if($_GET['nickname']){//有搜索公司名称
+            $where['c.nickname']=$_GET['nickname'];
+        }
+        if($_GET['prodBth']){//有搜索产品批次
+
+            $where['a.bach_num']=$_GET['prodBth'];
+        }
+
+        if($_GET['startDate']){//有开始打印日期
+           $statrtime=((int)date('Ymd',(strtotime($_GET['startDate'])))-20000000);
+           $endtime=((int)date('Ymd',(strtotime($_GET['endDate'])))-20000000);
+           $where['a.print_date']=array(array('egt',$statrtime),array('elt',$endtime),'AND');
+        }
+        if($session_config['user_auth']['addtype']==1){
+        $where['a.userid']=$session_config['user_auth']['uid'];
+        }
+        $where['a.bach_status']=0;
+
+        if ($_GET['sqrcd']){//有搜索标签代码
+            $map = array();
+            $map['code'] = array('like','%'.$_GET['sqrcd'].'%');
+            $large_bach = M('qcode_large')->where($map)->field('bach_id')->select();
+            if (!empty($large_bach)){
+                foreach ($large_bach as $key=>$value){
+                    $option[$key] = $value['bach_id'];
+                }
+                $option = array_unique($option);
+                $where['a.id'] = array('IN',$option);
+            }else{
+                $small_bach = M('qcode_small')->where($map)->field('bach_id')->select();
+                if (!empty($small_bach)){
+                    foreach ($small_bach as $key=>$value){
+                        $option[$key] = $value['bach_id'];
+                    }
+                    $option = array_unique($option);
+                    $where['a.id'] = array('IN',$option);
+                }
+            }
+        }
+        $BatchList=M('qcode_bach')->alias('a')
+            ->join('qr_qcode_product b on a.matter_id=b.id','LEFT')
+            ->join('qr_admin_user c on  a.userid=c.id','LEFT')
+            ->field('a.*,b.product_num,c.nickname')
+            ->order($_GET['sort'].' '.$_GET['order'])
+            ->page($_GET['page'],$_GET['rows'])
+            ->where($where)
+            ->select();
+
+
+        //echo M('qcode_bach')->getLastSql();
+        $total = M('qcode_bach')->alias('a')
+            ->join('qr_qcode_product b on a.matter_name=b.product_name','LEFT')
+            ->join('qr_admin_user c on  a.userid=c.id')
+            ->where($where)
+            ->count();
+        $result  = [];
+        $result['total'] = $total;
+        $result['rows'] = $BatchList;
+        $bachlist = json_encode($result);
+        echo $bachlist;
+        //echo json_encode($BatchList);
+    }
+     public function BachListApiTwo(){//补打界面获取补打批次列表
+
+//        $session_config=I('session.ly_admin_');//获取登陆的session值
+        if($_GET['sysCdNm']){//有搜索产品名称
+            $where['a.matter_name']=array('like','%'.$_GET['sysCdNm'].'%');
+        }
+
+        if($_GET['nickname']){//有搜索公司名称
+            $where['c.nickname']=array('like','%'.$_GET['nickname'].'%');
+        }
+
+        if($_GET['prodBth']){//有搜索产品批次
+            $where['a.bach_num']=$_GET['prodBth'];
+        }
+
+         if($_GET['matter_no']){//有搜索产品批次
+             $where['a.matter_no']=array('like','%'.$_GET['matter_no'].'%');
+         }
+
+        if($_GET['startDate']){//有开始打印日期
+            $statrtime=((int)date('Ymd',(strtotime($_GET['startDate'])))-20000000);
+            $endtime=((int)date('Ymd',(strtotime($_GET['endDate'])))-20000000);
+            $where['a.print_date']=array(array('egt',$statrtime),array('elt',$endtime),'AND');
+        }
+//        if($session_config['user_auth']['addtype']==1){
+//            $where['a.userid']=$session_config['user_auth']['uid'];
+//        }
+        $where['a.bach_status']=0;
+
+        if ($_GET['sqrcd']){//有搜索标签代码
+            $map = array();
+            $map['code'] = array('like','%'.$_GET['sqrcd'].'%');
+            $large_bach = M('qcode_large')->where($map)->field('bach_id')->select();
+
+            if (!empty($large_bach)){
+
+                foreach ($large_bach as $key=>$value){
+                    $option[$key] = $value['bach_id'];
+                }
+                $option = array_unique($option);
+                $where['a.id'] = array('IN',$option);
+            }else{
+                $result  = [];
+                $result['total'] = '0';
+                $result['rows'] = [];
+                $bachlist = json_encode($result);
+                return $bachlist;
+
+                $small_bach = M('qcode_small')->where($map)->field('bach_id')->select();
+                if (!empty($small_bach)){
+                    foreach ($small_bach as $key=>$value){
+                        $option[$key] = $value['bach_id'];
+                    }
+                    $option = array_unique($option);
+                    $where['a.id'] = array('IN',$option);
+                }
+            }
+        }
+
+        $BatchList=M('qcode_bach')->alias('a')
+            ->join('qr_qcode_product b on a.matter_id=b.id','LEFT')
+            ->join('qr_admin_user c on  a.userid=c.id','LEFT')
+            ->field('a.*,b.product_num,c.nickname')
+            ->order($_GET['sort'].' '.$_GET['order'])
+            ->page($_GET['page'],$_GET['rows'])
+            ->where($where)
+            ->select();
+
+
+        //echo M('qcode_bach')->getLastSql();
+        $total = M('qcode_bach')->alias('a')
+            ->join('qr_qcode_product b on a.matter_name=b.product_name','LEFT')
+            ->join('qr_admin_user c on  a.userid=c.id')
+            ->where($where)
+            ->count();
+
+        $result  = [];
+        $result['total'] = $total;
+        $result['rows'] = $BatchList;
+        $bachlist = json_encode($result);
+        echo $bachlist;
+        //echo json_encode($BatchList);
+    }
+    
+    public function GetLargeLabelApi(){//获取关联批次的大件标签列表
+        $field = "code,print_date,p_nums,id,code_cp1,l_print,l_status,archive";
+        $LargeLabelList = M('qcode_large')->field($field)->where('bach_id='.I('get.product_id'))->select();
+       // var_dump($LargeLabelList);
+        foreach($LargeLabelList as $key=>$val){
+            $qcode_small=$val['archive']?"qcode_small_".$val['archive']:"qcode_small";
+            $smalltotal=M('qcode_small')->field('count(large_id)')->where('large_id='.$val['id'])->find();
+            
+            $LargeLabelList[$key]['code_cp1']=ltrim(substr($LargeLabelList[$key]['code_cp1'],6,10),'0');
+            $LargeLabelList[$key]['smalltotal']=$smalltotal['count(large_id)'];
+            if( $LargeLabelList[$key]['l_print']==0){
+                $type="未打印";
+            }
+            if($LargeLabelList[$key]['l_print']==1){
+                $type="已打印";
+            }
+            $LargeLabelList[$key]['type']=$type;
+        }
+        echo json_encode($LargeLabelList);
+    }
+
+    public function GetSmallLabelApi(){//获取关联大标签的的小标签列表
+                if(I('get.large_id')){//获取小标签列表
+                    $field="id,code,code_cp1,status,l_flow,p_nums";
+                    $smalllist=M('qcode_small')
+                        ->field($field)
+                        ->where('large_id='.I('get.large_id'))
+                        ->select();
+                    $large_data = M('qcode_large')
+                        ->field('code_cp1')
+                        ->where('id='.I('get.large_id'))
+                        ->find();
+                    $large_flow = ltrim(substr($large_data['code_cp1'],6,10),'0');
+                    foreach($smalllist as $key=>$val){
+                        $smalllist[$key]['l_flow']= $large_flow.'-'.$smalllist[$key]['l_flow'];
+//                        if($val['id']>44091){
+//                        $smalllist[$key]['code_cp1']=I('get.large_tuopan').'-'.ltrim(substr($smalllist[$key]['code_cp2'],12,6),'0');}
+//                        else{
+//                            $smalllist[$key]['code_cp1']=I('get.large_tuopan').'-'.ltrim(substr($smalllist[$key]['code_cp1'],6,6),'0');
+//                        };
+                    }
+                    $this->ajaxReturn($smalllist);
+                }
+                if(I('get.code') ){//单个删除
+                    $field="id,code,status";
+                    $code=I('get.code');
+                    $data['status']=1;
+                   if( M('qcode_small')->where("code='$code'")->save($data)){
+                       $smalllist['status']=200;
+                       $smalllist['error']="操作成功";
+                    }else{
+                       $smalllist['status']=100;
+                       $smalllist['error']="操作失败";
+                    };
+                    $smalllist['list']=M('qcode_small')->field($field)->where("code='$code'")->select();
+
+                   $this->ajaxReturn($smalllist);
+                }
+
+    }
+    public function OneSmallPrint(){//单个打印小标签
+//        M('qcode_small')->where('id='.I('get.id'))->setInc('p_nums',I('get.reptQty'));//更新小标签的打印次数
+        //echo M('qcode_small')->getLastSql();
+        $smalllabel[]=M('qcode_small')->alias('b')
+            ->join("qr_qcode_large c on b.large_id=c.id")
+            ->join('qr_qcode_bach d on d.id=c.bach_id')
+            ->field('b.*,d.id as bath_id,d.supplier_name, b.l_flow, d.matter_name,d.matter_size,d.num,d.manufacture_date,d.l_flow as dl_flow,c.code as ccode,c.code_cp1 as banhao,d.box_num,d.bach_num')
+            ->where('b.id='.I('get.id'))
+            ->select();
+        /*foreach($smalllabel[0] as $key=>$val){//循环获取img标签内容
+            $imgcode=$this->qrcode($val['code']);
+            $smalllabel[0][$key]['imgcode']="data:image/png;base64,".$imgcode;
+        }*/
+        $total['smalllabel']=$smalllabel;
+        $total['num']=I('get.reptQty');
+        $this->ajaxReturn($total);
+    }
+    //二维码打印
+//    public function rePrintTg(){
+//        header("Content-type: text/html; charset=utf-8");
+//        $id = I('post.idList');//选中的大件标签的列表id
+//        $ids=explode(",",$id);//将字符串以逗号转化为数组
+//        $num = I('post.reptQty')?I('post.reptQty'):3;//重复打印次数
+//        foreach($ids as $key=>$val){//获取对应的大标签以及绑定的小标签的相关信息
+//            if(I('post.sign_type')==1){//打印的为大件标签
+//                //先更新大标签的打印次数
+//                M('qcode_large')->where('id='.$val)->setInc('p_nums',$num);// 大标签的打印次数加$num
+//                M('qcode_large')->where('id='.$val)->setField('l_print','1');//更新大标签的打印状态$num
+//                //在查找相关的信息
+//                $largelabel[]=M('qcode_large')->alias('a')
+//                    ->join('qr_qcode_bach q on a.bach_id=q.id')
+//                    ->field('a.*,q.supplier_name,q.l_weight')
+//                    ->where('a.id='.$val)
+//                    ->select();
+//
+//            }
+//            if(I('post.sign_type')==2){//打印的为小件标签
+//                //先更新小标签的打印次数
+//                M('qcode_small')->where('large_id='.$val)->setInc('p_nums',$num);// 小标签的打印次数加$num
+//               /* M('qcode_small')->where('large_id='.$val)->setField('status','1');//更新小标签的打印状态$num*/
+//                //在查找小标签的相关内容
+//
+//            $smalllabel[]=M('qcode_small')->alias('b')
+//                ->join("qr_qcode_large c on b.large_id=c.id")
+//                ->join('qr_qcode_bach d on d.id=c.bach_id')
+//                ->field('b.*,d.s_weight,d.id as bath_id,d.supplier_name,d.matter_name,d.matter_size,d.num,d.manufacture_date,d.l_flow as dl_flow, b.l_flow,c.code_cp1 as banhao,d.box_num,d.bach_num')
+//                ->where('b.large_id='.$val)
+//                ->select();
+//            }
+//            //$sql=M('qcode_small')->getLastSql();
+//        }
+////        foreach($smalllabel[0] as $key=>$val){//循环获取img标签内容
+////            $imgcode=$this->qrcode($val['code']);
+////            $smalllabel[0][$key]['imgcode']="data:image/png;base64,".$imgcode;
+////        }
+//        //var_dump($smalllabel[0]);
+//        $total['largrlabel']=$largelabel?$largelabel:'';
+//        $total['smalllabel']=$smalllabel?$smalllabel:'';
+//        $total['num']=$num;
+//        $this->ajaxReturn($total);
+//
+//    }
+
+    public function rePrintTg(){
+        header("Content-type: text/html; charset=utf-8");
+        $id = I('post.idList');//选中的大件标签的列表id
+        $ids=explode(",",$id);//将字符串以逗号转化为数组
+        $num = I('post.reptQty')?I('post.reptQty'):0;//重复打印次数
+
+        if (I('post.status')==1){//修改打印次数--自动打码
+            foreach($ids as $key=>$val){//获取对应的大标签以及绑定的小标签的相关信息
+                if(I('post.sign_type')==1){//打印的为大件标签
+                    //更新大标签的打印次数
+                    M('qcode_large')->where('id='.$val)->setInc('p_nums',$num);// 大标签的打印次数加$num
+                    M('qcode_large')->where('id='.$val)->setField('l_print','1');//更新大标签的打印状态$num
+                }
+                if(I('post.sign_type')==2){//打印的为小件标签
+                    //更新小标签的打印次数
+                    M('qcode_small')->where('large_id='.$val)->setInc('p_nums',$num);// 小标签的打印次数加$num
+                }
+            }
+
+            $total['num']=$num;
+            $this->ajaxReturn($total);
+        }else if (I('post.status')==2){//修改打印次数--小件
+            foreach($ids as $key=>$val){//获取对应的大标签以及绑定的小标签的相关信息
+                M('qcode_small')->where('id='.$val)->setInc('p_nums',$num);// 小标签的打印次数加$num
+            }
+            $total['num']=$num;
+            $this->ajaxReturn($total);
+        }else{
+            foreach($ids as $key=>$val){//获取对应的大标签以及绑定的小标签的相关信息
+                if(I('post.sign_type')==1){//打印的为大件标签
+                    //先更新大标签的打印次数
+//                    M('qcode_large')->where('id='.$val)->setInc('p_nums',$num);// 大标签的打印次数加$num
+//                    M('qcode_large')->where('id='.$val)->setField('l_print','1');//更新大标签的打印状态$num
+                    //在查找相关的信息
+                    $largelabel[$key] = M('qcode_large')->alias('c')
+                        ->field('u.main_unit, u.sec_unit, u.proportion, d.s_weight,d.id as bath_id,d.supplier_name,d.matter_name, d.matter_no, d.matter_size,d.num,d.manufacture_date,d.l_flow,c.code, c.code_cp1 as banhao,d.box_num,d.bach_num')
+                        ->join('qr_qcode_bach d on c.bach_id=d.id')
+                        ->join('qr_qcode_unit u on u.code=d.matter_no')
+                        ->where('c.id='.$val)
+                        ->select();
+                    $numn = M('qcode_small')->where('large_id='.$val)->count();
+                    $largelabel[$key][0]['numn']=$numn;
+                }
+                if(I('post.sign_type')==2){//打印的为小件标签
+                    //先更新小标签的打印次数
+//                    M('qcode_small')->where('large_id='.$val)->setInc('p_nums',$num);// 小标签的打印次数加$num
+                    /* M('qcode_small')->where('large_id='.$val)->setField('status','1');//更新小标签的打印状态$num*/
+                    //在查找小标签的相关内容
+
+                    $smalllabel[]=M('qcode_small')->alias('b')
+                        ->join("qr_qcode_large c on b.large_id=c.id")
+                        ->join('qr_qcode_bach d on d.id=c.bach_id')
+                        ->field('b.*,d.s_weight,d.id as bath_id,d.supplier_name,d.matter_name, d.matter_no, d.matter_size,d.num,d.manufacture_date,d.l_flow as dl_flow, b.l_flow,c.code as ccode,  c.code_cp1 as banhao,d.box_num,d.bach_num')
+                        ->where('b.large_id='.$val)
+                        ->select();
+                }
+                //$sql=M('qcode_small')->getLastSql();
+            }
+//        foreach($smalllabel[0] as $key=>$val){//循环获取img标签内容
+//            $imgcode=$this->qrcode($val['code']);
+//            $smalllabel[0][$key]['imgcode']="data:image/png;base64,".$imgcode;
+//        }
+            //var_dump($smalllabel[0]);
+            $total['largrlabel']=$largelabel?$largelabel:'';
+            $total['smalllabel']=$smalllabel?$smalllabel:'';
+            $total['num']=$num;
+            $this->ajaxReturn($total);
+        }
+    }
+
+    public function userinfoedit()
+    {//修改用户的相关信息
+
+        if (IS_POST) {
+            // 密码为空表示不修改密码
+            if ($_POST['password'] === '') {
+                unset($_POST['password']);
+            }
+
+            // 提交数据
+            $user_object = D('User');
+            $data = $user_object->create();
+            if ($data) {
+                $result = $user_object
+                    ->field('id,nickname,username,password,email,email_bind,mobile,mobile_bind,gender,avatar,update_time,printer_code,postcode,company_address')
+                    ->save($data);
+                if ($result) {
+                    $this->success('更新成功', U('index'));
+                } else {
+                    $this->error('更新失败', $user_object->getError());
+                }
+            } else {
+                $this->error($user_object->getError());
+            }
+        } else {
+            // 获取账号信息
+            $session_config=I('session.ly_admin_');
+            $id=$session_config['user_auth']['uid'];
+            $info = D('User')->find($id);
+            unset($info['password']);
+
+            // 使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('编辑用户')// 设置页面标题
+            ->setPostUrl(U('userinfoedit'))// 设置表单提交地址
+            ->addFormItem('id', 'hidden', 'ID', 'ID')
+                ->addFormItem('nickname', 'text', '供应商名称', '供应商名称')
+                ->addFormItem('printer_code', 'text', '供应商编码', '供应商编码')
+                ->addFormItem('postcode', 'num', '邮政编码', '邮政编码')
+                ->addFormItem('company_address', 'text', '地址', '详细地址')
+                ->addFormItem('username', 'text', '用户名', '用户名')
+                ->addFormItem('password', 'password', '密码', '密码')
+                ->addFormItem('email', 'text', '邮箱', '邮箱')
+                ->addFormItem('email_bind', 'radio', '邮箱绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定'))
+                ->addFormItem('mobile', 'text', '手机号', '手机号')
+                ->addFormItem('mobile_bind', 'radio', '手机绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定'))
+                /*->addFormItem('avatar', 'picture', '头像', '头像')*/
+                ->setFormData($info)
+                ->display();
+
+        }
+    }
+    public function qrcode($url)//二维码生成类
+    {
+        $url=$url;
+        $level=3;
+        $size=4;
+        Vendor('phpqrcode.phpqrcode');//加载生成二维码的核心类
+        $errorCorrectionLevel =intval($level) ;//容错级别
+        $matrixPointSize = intval($size);//生成图片大小
+        //生成二维码图片
+        $object = new \QRcode();
+        //打开缓冲区
+        ob_start();
+        $object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2);
+        //这里就是把生成的图片流从缓冲区保存到内存对象上,使用base64_encode变成编码字符串,通过json返回给页面。
+        $imageString = base64_encode(ob_get_contents());
+        //关闭缓冲区
+        ob_end_clean();
+        //把生成的base64字符串返回给前端
+        return $imageString;
+       /* $data = array(
+            'labelcode'=>$url,
+            'code'=>200,
+            'data'=>$imageString,
+            'product_code'=>$url
+        );
+        $this->ajaxReturn($data);*/
+    }
+
+    public function  changestatus(){//动态改变小标签的状态
+    $data['status']=I('get.status');
+    if(M('qcode_small')->where('id='.I('get.id'))->save($data)){
+        $bach_id=M('qcode_large')->field('bach_id')->where('id='.I('get.large_id'))->find();//获取批次id
+        $small_num=M('qcode_bach')->field('small_num')->where('id='.$bach_id['bach_id'])->find();//获取批次原有的小标签数量
+        if(I('get.status')=='0'){
+            //表示已删除的标签变为正常,批次小件数量加一
+            $infos['small_num']=$small_num['small_num']+1;
+            M('qcode_bach')->where('id='.$bach_id['bach_id'])->save($infos);//更新批次的小标签数量
+           // echo M('qcode_bach')->getLastSql();
+        }
+        if(I('get.status')=='1'){
+            //表示正常的标签变为已删除,批次小件数量减一
+            $infos['small_num']=$small_num['small_num']-1;
+            M('qcode_bach')->where('id='.$bach_id['bach_id'])->save($infos);//更新批次的小标签数量
+            //echo M('qcode_bach')->getLastSql();
+        }
+        $info['code']=200;
+        $info['error']="操作成功";
+    }else{
+        $info['code']=100;
+        $info['error']="操作失败";
+    };
+
+    $this->ajaxReturn($info);
+    }
+
+
+
+
+}

+ 92 - 0
Application/Admin/Controller/PublicController.class.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace Admin\Controller;
+
+use Common\Controller\ControllerController;
+use Think\Verify;
+/**
+ * 后台唯一不需要权限验证的控制器
+ *
+ */
+class PublicController extends ControllerController
+{
+    /**
+     * 后台登陆
+     *
+     */
+    public function login()
+    {
+      //        $this->display('error');die;
+        if (IS_POST) {
+            $username = I('username');
+            $password = I('password');
+
+            // 图片验证码校验
+            if (!$this->check_verify(I('post.verify')) && 'localhost' !== $_SERVER['HTTP_HOST'] && '127.0.0.1' !== $_SERVER['HTTP_HOST']) {
+                //$this->error('验证码输入错误!');
+            }
+
+            // 验证用户名密码是否正确
+            $user_object = D('Admin/User');
+            $user_info   = $user_object->login($username, $password);
+            if (!$user_info) {
+                $this->error($user_object->getError());
+            }
+
+            // 验证管理员表里是否有该用户
+            $account_object = D('Admin/Access');
+            $where['uid']   = $user_info['id'];
+            $account_info   = $account_object->where($where)->find();
+            if (!$account_info) {
+                $this->error('该用户没有管理员权限' . $account_object->getError());
+            }
+
+            // 设置登录状态
+            $uid = $user_object->auto_login($user_info);
+
+            // 跳转
+            if (0 < $account_info['uid'] && $account_info['uid'] === $uid) {
+                $this->success('登录成功!','index.php');
+            } else {
+                $this->logout();
+            }
+        } else {
+            $this->assign('meta_title', '管理员登录');
+            $this->display();
+        }
+    }
+
+    /**
+     * 注销
+     *
+     */
+    public function logout()
+    {
+        session('user_auth', null);
+        session('user_auth_sign', null);
+        session('user_group', null);
+        $this->success('退出成功!', U('login'));
+    }
+
+    /**
+     * 图片验证码生成,用于登录和注册
+     *
+     */
+    public function verify($vid = 1)
+    {
+        $verify         = new Verify();
+        $verify->length = 4;
+        $verify->entry($vid);
+    }
+
+    /**
+     * 检测验证码
+     * @param  integer $id 验证码ID
+     * @return boolean 检测结果
+     */
+    public function check_verify($code, $vid = 1)
+    {
+        $verify = new Verify();
+        return $verify->check($code, $vid);
+    }
+}

+ 804 - 0
Application/Admin/Controller/QcodeController.class.php

@@ -0,0 +1,804 @@
+<?php
+/*第一版后台控制器*/
+namespace Admin\Controller;
+
+use think\Log;
+use Think\Page;
+use think\Request;
+
+
+
+class QcodeController extends AddonController{
+
+    public function  test(){//测试页面hahha
+
+    }
+
+    public function delTg(){//删除批次信息
+        $info['bach_status']=1;
+        $bach = M('qcode_bach');
+        if($bach->where("id=".I('post.bachid'))->save($info)){
+            $session_config=I('session.ly_admin_');//获取登陆的session值
+            $uid = $session_config['user_auth']['uid'];
+            $large = M('qcode_large');
+            $small = M('qcode_small');
+            $l_flow = M('reset_flow');
+            $s_flow = M('qcode_liushui');
+            $bach_info = $bach->where('id='.I('post.bachid'))->field('id,matter_id,matter_type,supplier_code,matter_no,manufacture_date,print_date,bach_num')->find();
+            $largeNum = $large->where('bach_id='.I('post.bachid'))->count();
+            $smallNum = $small->where('bach_id='.I('post.bachid'))->count();
+            $l_map['userid'] = $uid;
+            $l_map['product_id'] = $bach_info['matter_id'];
+            $l_map['bach_num'] = $bach_info['bach_num'];
+            $large_flow = $l_flow->where($l_map)->find();
+            $new_l_flow = $large_flow['l_flow'] - $largeNum;//删除后恢复的大件流水号
+            $l_flow->where($l_map)->setField('l_flow',$new_l_flow);//操作更新
+            $onlycode = '9092'.intTochar($bach_info['matter_type'],2).intTochar($bach_info['supplier_code'],12).intTochar($bach_info['matter_no'],20).$bach_info['manufacture_date'].$bach_info['print_date'];
+            $s_map['user_id'] = $uid;
+            $s_map['onlycode'] = $onlycode;
+            $small_flow = $s_flow->where($s_map)->find();
+            $new_s_flow = $small_flow['last_num'] - $smallNum;//删除后恢复的小件流水号
+            $s_flow->where($s_map)->setField('last_num',$new_s_flow);
+            $data['success']=true;
+            $data['message']="删除成功";
+            $this->ajaxReturn($data);
+        }else{
+            $data['error']=false;
+            $data['message']="删除失败";
+        $this->ajaxReturn($data);
+        }
+
+    }
+
+    public function QcodeCompanyDel(){
+        //产品删除
+        if(IS_POST){
+            if(empty($_POST)){
+                $this->error('请至少选择一个选项');
+            }else{
+                $bar = D('QcodeCompany');
+                $id = implode(',',$_POST['ids']);
+                $return  = $bar->DelQcodeCompany($id);
+                if($return){
+                    $this->success('删除成功', U('Company'));
+                }else{
+                    $this->error('删除失败');
+                }
+            }
+        }else{
+            $id = $_GET['id'];
+            $bar = D('QcodeCompany');
+            $return  = $bar->DelQcodeCompany($id);
+            if($return){
+                $this->success('删除成功', U('Company'));
+            }else{
+                $this->error('删除失败');
+            }
+        }
+
+    }
+
+    public function QcodeCompanyAdd(){//生产厂商的添加和修改
+
+        if (IS_POST ) {
+            $bar_object = D('QcodeCompany');
+            $data= $bar_object->create();
+            if ($data) {
+                if(I('post.id')){//有id是修改
+                    if ($bar_object->save($data)) {
+                        $this->success('修改成功', U('Company'));
+                    } else {
+                        $this->error('修改失败');
+                    }
+                }else {//不存在id,新增
+                    if ($bar_object->add($data)) {
+                        $this->success('新增成功', U('Company'));
+                    } else {
+                        $this->error('新增失败');
+                    }
+                }
+            } else {
+                $this->error($bar_object->getError());
+            }
+        } else {
+            //使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('编辑厂商') //设置页面标题
+            ->setPostUrl(U('QcodeCompanyAdd')) //设置表单提交地址
+            ->addFormItem('id', 'hidden', 'ID', 'ID')
+                ->addFormItem('company_name', 'text', '名称', '请输入供应商名称')
+                ->addFormItem('company_code','num', '供应商编码', '请输入供应商唯一编码')
+                ->addFormItem('postcode','num', '邮政编码', '邮政编码')
+                ->addFormItem('phone','num', '联系电话', '请输入联系电话')
+                ->addFormItem('company_addres','text', '地址', '请输入供应商地址')
+                ->setFormData(D('QcodeCompany')->find(I('get.id')))
+                ->display();
+        }
+
+    }
+
+
+    public function  Company(){//生产厂商列表
+
+        // 搜索
+        $keyword              = I('keyword', '', 'string');
+        $condition            = array('like', '%' . $keyword . '%');
+        $map['company_name|company_code'] = array(//查询条件数组
+            $condition,
+            $condition,
+            '_multi' => true,
+        );
+        $p = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $product_object = D('qcode_company');
+        $data_list= $product_object
+            ->page($p, 15)
+            ->where($map)
+            ->order('id asc')
+            ->select();
+        $page = new Page(
+            $product_object->where($map)->count(),
+            50
+        );
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('生产厂商管理') // 设置页面标题
+        ->addTopButton('addnew',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/QcodeCompanyAdd')]) // 添加新增按钮
+        ->addTopButton('delete',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/QcodeCommanyDel')]) // 添加删除按钮
+        ->setSearch(
+            '请输入供应商名称或者供应商编码',
+            U('Company')//重新进入到Productile页面;
+        )
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('company_name', '名称')
+            ->addTableColumn('company_code', '厂商编码')
+            ->addTableColumn('postcode', '邮政编码')
+            ->addTableColumn('phone', '联系电话')
+            ->addTableColumn('company_addres', '地址')
+            /*->addTableColumn('title', '自定义')*/
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list) // 数据列表
+            ->setTableDataPage($page) // 数据列表分页
+            ->addRightButton('edit',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/QcodeCompanyAdd',array(
+                'id'    => '__data_id__',
+            ))]) // 添加编辑按钮
+            ->addRightButton('delete',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/QcodeCompanyDel',array(
+                'id'    => '__data_id__',
+            ))]) // 添加删除按钮
+            ->display();
+
+    }
+
+    public function  Dama(){//打码统计页面
+
+        $this->display();
+    }
+
+    public function  damacount(){//打码统计详情页面
+        $session_config=I('session.ly_admin_');
+        $uid = $session_config['user_auth']['uid'];
+        $user = M('admin_user');
+        $user_info = $user->where('id='.$uid)->find();
+        $product_id = explode(',',$user_info['product_id']);
+        $map['id'] = array('in',$product_id);
+        $product = M('qcode_product');
+        $list = $product->where($map)->field('id,product_name')->select();
+        $db=M('qcode_bach');
+        $large = M('qcode_large');
+        $small = M('qcode_small');
+        $where['userid'] = $uid;
+        $where['bach_status'] = 0;
+        $damalist=$db->where($where)
+            ->field('id')
+            ->select();
+        $damalist = array_column($damalist,'id');
+        if ($damalist){
+            $option['bach_id'] = array('in',$damalist);
+        }
+        $option['userid'] = $uid;
+        $largeNum = $large->where($option)->count();
+        $smallNum = $small->where($option)->count();
+        $total = $largeNum + $smallNum;
+        $this->assign('list',$list);
+        $this->assign('total',$total);
+        $this->display();
+    }
+
+    public function DamaCountApi(){//打码量统计产品列表
+        $page=$_GET['page'];
+        $damalist['pagesize']=$_GET['rows']?$_GET['rows']:10;
+        $pagenum=($page-1)* $damalist['pagesize'];//当前页码
+        if($pagenum<0){
+            $pagenum=0;
+        }
+        $map = array();
+        if (!empty($_GET['sqrcd'])){
+            $map['bach_num'] = $_GET['sqrcd'];
+        }
+        if ($_GET['sysCdNm'] > 0){
+            $map['matter_id'] = $_GET['sysCdNm'];
+        }
+        $session_config=I('session.ly_admin_');
+        $uid = $session_config['user_auth']['uid'];
+        $map['userid'] = $uid;
+        if($_GET['startDate']){//有开始日期
+            $statrtime=strtotime($_GET['startDate']);
+            $endtime=strtotime($_GET['endDate']);
+            $map['creat_time']=array(array('egt',$statrtime),array('elt',$endtime),'AND');
+        }
+        $map['bach_status'] = 0;//未删除批次
+        $db=M('qcode_bach');
+        $damalist['rows']=$db->where($map)
+            ->field('id,bach_num,matter_no,matter_name,matter_size')
+           ->order( "id desc")
+           ->limit($pagenum,$damalist['pagesize'])
+           ->select();
+
+        $largeNum = M('qcode_large');
+        $smallNum = M('qcode_small');
+        foreach ($damalist['rows'] as $key=>$value){
+            $damalist['rows'][$key]['largeTotal'] = $largeNum->where('bach_id='.$value['id'])->count();
+            $damalist['rows'][$key]['smallTotal'] = $smallNum->where('bach_id='.$value['id'])->count();
+        }
+        $count = $db->where($map)->count();
+       $damalist['pagesize']=$_GET['rows']?$_GET['rows']:10;//每页显示的记录数
+       $damalist['total']=$count;//总的记录数
+       echo json_encode($damalist);
+
+    }
+
+    public function QcodeProductDel(){//产品删除
+        if(IS_POST){
+            if(empty($_POST)){
+                $this->error('请至少选择一个选项');
+            }else{
+                $bar = D('QcodeProduct');
+                $id = implode(',',$_POST['ids']);
+                $return  = $bar->DelQcodeProduct($id);
+                if($return){
+                    $this->success('删除成功', U('Product'));
+                }else{
+                    $this->error('删除失败');
+                }
+            }
+        }else{
+            $id = $_GET['id'];
+            $bar = D('QcodeProduct');
+            $return  = $bar->DelQcodeProduct($id);
+            if($return){
+                $this->success('删除成功', U('Product'));
+            }else{
+                $this->error('删除失败');
+            }
+        }
+
+    }
+    public function QcodeProductAdd(){//产品添加或者是修改
+        if (IS_POST ) {
+            $bar_object = D('QcodeProduct');
+            $data= $bar_object->create();
+            if ($data) {
+                if(I('post.id')){//有id是修改
+                    if ($bar_object->save($data)) {
+                        $this->success('修改成功', U('Product'));
+                    } else {
+                        $this->error('修改失败');
+                    }
+                }else {//不存在id,新增
+                    if ($bar_object->add($data)) {
+                        $this->success('新增成功', U('Product'));
+                    } else {
+                        $this->error('新增失败');
+                    }
+                }
+            } else {
+                $this->error($bar_object->getError());
+            }
+        } else {
+            //使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('编辑产品') //设置页面标题
+            ->setPostUrl(U('QcodeProductAdd')) //设置表单提交地址
+            ->addFormItem('id', 'hidden', 'ID', 'ID')
+            ->addFormItem('product_name', 'text', '名称', '请输入名称')
+                ->addFormItem('product_code', 'text', '编码', '请输入编码')
+                ->addFormItem('product_size','text', '规格', '规格单位为毫米')
+                ->addFormItem('product_num','text', '产品批次', '产品批次')
+                ->addFormItem('temple','text', '产品代号', '产品代号')
+                ->setFormData(D('QcodeProduct')->find(I('get.id')))
+                ->display();
+        }
+
+    }
+
+    public function product(){//产品列表
+        // 搜索
+        $session_config=I('session.ly_admin_');
+        $keyword              = I('keyword', '', 'string');
+        $condition            = array('like', '%' . $keyword . '%');
+        $map['product_name|product_code'] = array(//查询条件数组
+            $condition,
+            $condition,
+            '_multi' => true,
+        );
+        $classification = I('classification', '', 'string');
+        if ($classification != '03'){
+            $map['product_code'] = array('like','%'.$classification.'%');
+        }
+
+        $uid = $session_config['user_auth']['uid'];
+        $user = M('admin_user');
+        $user_product = $user->where('id='.$uid)->field('product_id')->find();
+        $user_product = explode(',',$user_product['product_id']);
+        $map['id'] = array('not in',$user_product);
+        $map['id'] = array('gt',27);
+        $p = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $product_object = D('qcode_product');
+        $count      = $product_object->where($map)->count();// 查询满足要求的总记录数
+        $Page       = new \Think\Page($count,25);// 实例化分页类 传入总记录数和每页显示的记录数
+        $show       = $Page->show();// 分页显示输出
+        $data_list= $product_object->page($p.',10')->where($map)->order('id asc')->select();//所有未选中产品列表
+
+        //辅料存货分类
+        $qcode_classification = M('qcode_classification');
+        $product_classification = $qcode_classification->where('status=1')->order('id asc')->select();
+        //已选择产品列表
+        $where['id'] = array('in',$user_product);
+        $list= $product_object->where($where)->order('id asc')->select();
+        $this->assign('search',$keyword);
+        $this->assign('classification',$classification);
+        $this->assign('product_classification',$product_classification);
+        $this->assign('user_product',$user_product);
+        $this->assign('list',$data_list);
+        $this->assign('data',$list);
+        $this->assign('page',$show);
+        $this->display('product');
+    }
+    //更新用户生产产品
+    public function updateProduct(){
+        if (IS_POST){
+            $session_config=I('session.ly_admin_');
+            $uid = $session_config['user_auth']['uid'];
+            $user = M('admin_user');
+            $user_data = $user->where('id='.$uid)->field('product_id')->find();
+            $user_product = $user_data['product_id'];
+            $id = I('post.id');
+            $ids = explode(',',$id);
+            if(I('post.status')=="1"){//增加产品
+                $new_product = array();
+                if (!isset($user_product)){//第一次增加
+                    $data['product_id'] = $id;
+                }else{
+                    $user_product = explode(',',$user_product);
+                    $new_product = array_unique(array_merge($ids,$user_product));
+                    sort($new_product);
+                    $new_product_str = implode(',',$new_product);
+                    $data['product_id'] =$new_product_str;
+                }
+                $res = $user->where('id='.$uid)->save($data);
+                $this->ajaxReturn(['status'=>1,'msg'=>'更新成功']);
+            }else{//删除产品
+                $data['product_id'] = $id;
+                $res = $user->where('id='.$uid)->save($data);
+                $this->ajaxReturn(['status'=>1,'msg'=>'更新成功']);
+            }
+        }
+
+    }
+    public function Productajax(){//动态调用产品或者供应商相关信息
+        if(I('get.type')=="product"){//产品列表
+            $condition['userid']=I('get.userid');
+            $condition['product_id']=I('get.id');
+            $l_flow=M('reset_flow')->field('l_flow,bach_num')->where($condition)->find();
+            $model=M('qcode_product');
+            $field='product_size,product_num,product_name,id,temple,product_code';
+            $product=$model->field($field)->where('id='.I('get.id'))->select();
+            $product['l_flow']=$l_flow['l_flow']+1;
+            $product['bach_num']=$l_flow['bach_num']?($l_flow['bach_num']+1):(date('Y',time())."00000"+1);
+            $this->ajaxReturn($product);
+        }
+        if(I('get.type')=="company"){//供应商列表
+            $model=M('admin_user');
+            $field='nickname,postcode,mobile,company_address,id,printer_code';
+            $company=$model->field($field)->where('id='.I('get.id'))->select();
+            $this->ajaxReturn($company) ;
+        }
+    }
+
+    public function AddPrint(){//保存待打印的产品记录
+        //var_dump(I('post.'));
+        $data=I('post.');
+        if(!empty($data)) {//提交的数据不为空
+            $data['company_info']=I('post.company_address')."  ".I('post.postname')."  ".I('post.phone');
+            $data['bd_num']=0;//保存就默认为0;
+            $data['lable_type']=I('post.label_type');
+            M('qcode_print')->add($data);//保存数据
+            $this->success('保存成功','index.php?s=/Admin/Qcode/large');
+        }else{
+            $this->error('保存失败');
+           // $this->ajaxReturn(['status'=>1,'msg'=>'删除成功']);
+           /* $this->error['errno'] = "添加数据失败";
+            $this->success($this->error['errno'], '',100);*/
+        }
+    }
+
+    public function Large(){
+        /*var_dump(THINK_VERSION);
+        die();*/
+        $companylist=M('qcode_company')->field('company_name,postcode,phone,company_addres,company_code,id')->select();
+        $productlist=M('qcode_product')->field('product_name,id,product_size,product_num,temple,product_code')->select();
+        $this->assign('companylist',$companylist);
+        $this->assign('productlist',$productlist);
+        $this->display();
+    }
+    public function Print_ewm(){//生成二维码
+        $time=time();
+        if($_GET['temple']==1){//使用新模板
+            $fixedheadcode = "90";//固定的头部编码2位;
+            if ($_GET['label_type'] == 1) {//大件标签
+                $type = "92";
+                $big_num="095";//大件含有小件数量
+                $big_liushui=$_GET['big_liushui'];//大件流水号
+                $big_weight=$_GET['big_weight'];//大件重量
+                $big_yuliu=$_GET['big_yuliu'];//大件预留号
+            }
+            if ($_GET['label_type'] == 2) {//小件标签
+                $type = "93";//标签种类2位
+            }
+            $materialtype=$_GET['materialtype'];//辅料类型2位
+            $company_code=$_GET['company_code'];//供应商编码
+            $product_code=$_GET['product_code'];//辅料编码
+            $product_time=20180807;//生产日期
+            $print_time=date('Y-m-d',$time);//打码日期
+            $big_unipue=$print_time.rand(100000,999999);//唯一编码
+            $yuliu="000000000000000000";//预留码
+            $url= $fixedheadcode.$type.$materialtype.$company_code.$product_code.$product_time.$big_num.$big_unipue.$yuliu;
+                $this->qrcode($url);
+        }
+        if($_GET['temple']==2) {//使用老模板
+            if ($_GET['label_type'] == 1) {//大件标签
+                $type = "92";
+                $uniquecode = date('Ymd', $time) . rand(100000, 500000);//大件唯一编码14位(生产日期8位+6位随机码)
+            }
+            if ($_GET['label_type'] == 2) {//小件标签
+                $type = "93";//标签种类2位
+                $uniquecode = date('Ymd', $time) . rand(500001, 999999);//小件唯一编码14位(生产日期8位+6位随机码)
+            }
+            $offercode = $_GET['company_code'];//供应商编码12位
+            $materialcode = $_GET['product_code'];//辅料编码20位不足补零
+            $producttime = date("Ymd", $time);//生产日期(年月日)8位
+            $patchcode = "000000";//补位(6位);
+            $fixedheadcode = "90";//固定的头部编码2位;
+            $url = $fixedheadcode . $type . $_GET['materialtype'] . $offercode . $materialcode . $producttime . $uniquecode . $patchcode;
+            $this->qrcode($url);
+        }
+        $this->display('large.html');
+    }
+    public function qrcode($url)//二维码生成类
+    {
+        $url=$url;
+        $level=2;
+        $size=4;
+        Vendor('phpqrcode.phpqrcode');//加载生成二维码的核心类
+        $errorCorrectionLevel =intval($level) ;//容错级别
+        $matrixPointSize = intval($size);//生成图片大小
+        //生成二维码图片
+        $object = new \QRcode();
+        //打开缓冲区
+        ob_start();
+        $object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2);
+        //这里就是把生成的图片流从缓冲区保存到内存对象上,使用base64_encode变成编码字符串,通过json返回给页面。
+        $imageString = base64_encode(ob_get_contents());
+        //关闭缓冲区
+        ob_end_clean();
+        //把生成的base64字符串返回给前端
+        $data = array(
+            'labelcode'=>$url,
+            'code'=>200,
+            'data'=>$imageString,
+            'product_code'=>$url
+        );
+        $this->ajaxReturn($data);
+    }
+
+    /*补打标签*/
+    public function small(){
+
+        $this->display('buda');
+    }
+
+
+     public function buda(){//补打标签
+     $this->display();
+    }
+
+    public function budadetail(){//补打标签详情页
+        $session_config=I('session.ly_admin_');//获取登陆的session值
+        if($session_config['user_auth']['addtype']==1) {
+           $nickname=$session_config['user_auth']['nickname'];
+        }else{
+            $companylist=M('admin_user')->field('nickname')->where('status=1')->select();
+        }
+        $userinfo=M('admin_user')->where('id='.$session_config['user_auth']['uid'])->find();
+        $user_product = explode(',',$userinfo['product_id']);
+        $map = array();
+        $map['id'] = array('in',$user_product);
+        $productlist=M('qcode_product')->where($map)->field('product_name,id,product_size,product_num,temple,product_code')->select();
+        $this->assign('productlist',$productlist);
+        $this->assign('nickname',$nickname);
+        $this->assign('companylist',$companylist);
+        $this->display();
+
+  }
+
+    /*二级产品下拉框*/
+    public function  MaterialTwoApi(){
+       /* if(I('get.id')==0 ||  I('get.id')==NULL){
+            $secondlist=array('全部');
+        }
+        if(I('get.id')==1){
+            $secondlist=array('全部','常规醋纤丝束','特种醋纤丝束','其他醋纤丝束');
+        }
+        if(I('get.id')==2){
+            $secondlist=array('全部','常规聚丙烯丝束','低旦聚丙烯丝束','其他聚丙烯丝束');
+        }
+        if(I('get.id')==3){
+            $secondlist=array('全部','普通成型纸','高透成型纸','其他成型纸');
+        }
+        if(I('get.id')==4){
+            $secondlist=array('全部','醋酸纤维滤棒','常规聚丙烯丝束滤棒','低旦加胶聚丙烯丝束滤棒','纸质滤棒','沟槽滤棒');
+        }
+        echo json_encode($secondlist);*/
+    }
+
+    /*产品列表接口*/
+    public function ProductApi(){
+        //$productlist['code']=200;
+        //$productlist['pagesize']=$_GET['pagesize']?$_GET['pagesize']:10;
+        $page=$_GET['page'];
+        $productlist['pagesize']=$_GET['rows']?$_GET['rows']:10;
+        $pagenum=($page-1)* $productlist['pagesize'];//当前页码
+        if($pagenum<0){
+            $pagenum=0;
+        }
+        $productlist['rows']=M('qcode_product')->where('id!=0')->limit($pagenum,$productlist['pagesize'])->select();
+        $total=M('qcode_product')->where('id!=0')->select();
+        $productlist['total']=count($total);
+        $productlist=json_encode($productlist);
+        //echo  date('Y-m-d',1533120226);
+        echo  $productlist;
+        //die();
+    }
+    /*产品打印列表*/
+    public  function  PrintListApi(){
+        if(empty(I('get.product_id'))){//没有产品的id
+            $printlist['code']=100;
+            $printlist['total']="产品id为空";
+        }else{
+        //$printlist['code']=200;
+        $page=$_GET['page'];
+        $productlist['pagesize']=$_GET['rows']?$_GET['rows']:10;
+        $pagenum=($page-1)* $productlist['pagesize'];//当前页码
+        if($pagenum<0){
+            $pagenum=0;
+        }
+        $printlist['rows']=M('qcode_print')->where('product_id='.I('get.product_id'))->limit($pagenum,$productlist['pagesize'])->select();
+            /*if(count($printlist['productlist'])==0){//没有找到数据
+                $printlist['code']=300;
+                $printlist['total']="没有找到对应的数据";
+            }else{*///有数据返回分页数据
+                //$total=count($printlist['productlist']);
+                $total=M('qcode_print')->where('product_id='.I('get.product_id'))->select();
+                $printlist['total']=count($total);
+                $printlist['pagesize']=$_GET['rows']?$_GET['rows']:10;
+            //}
+        }
+        $printlist=json_encode($printlist);
+        echo $printlist;
+    }
+
+    public function rePrintTg(){
+        header("Content-type: text/html; charset=utf-8");
+        $id = I('post.$ids');
+        $ids=explode(",",$id);//将字符串以逗号转化为数组
+        $num = I('post.reptQty')?I('post.reptQty'):4;
+        $time=date('Y-m-d',time());//统一更新上一次
+        for($i=0;$i< count($ids);$i++){//先更新补打次数
+            $bd_num=M('qcode_print')->field("bd_num,print_time")->where('id='.$ids[$i])->find();//每个标签对应的补打次数
+            $number=[
+                'bd_num'=>$bd_num['bd_num']+$num,
+                'last_time'=>$bd_num['print_time'],
+                'print_time'=>$time,
+            ];
+        M('qcode_print')->where('id='.$ids[$i])->save($number);//每次补打时更新对应的标签补打次数
+            //unset($type);
+            $sql=M('qcode_print')->getLastSql();
+        }
+
+        $where = array();
+        $where['id'] = array('in',$id);//查询表里面id在
+        $field = "company_name,product_name,product_size,print_time,qr_code,lable_type";
+        $data = M('qcode_print')->field($field)->where($where)->select();
+        $new = array();
+        foreach($data as $v){
+            $arr = array();
+            $arr = $v;
+            $arr['pnum']=$num;
+            unset( $arr['time']);
+            $new[]= $arr;
+        }
+        $this->ajaxReturn($id);
+
+    }
+
+    //中烟补打标签页面
+    public function reprint(){
+        $this->display();
+    }
+    public function reprintdetail(){//补打标签详情页
+        $session_config=I('session.ly_admin_');//获取登陆的session值
+        $where = array();
+        $where['status'] = 1;
+        $where['id'] = array('gt',1);
+
+        $wh = array();
+        if($_SERVER['REQUEST_METHOD']==='GET'){
+
+            if($session_config['user_auth']['uid']==1 || $session_config['user_auth']['uid']==26) {
+//                $companylist=M('admin_user')->where($where)->field('id,nickname')->select();
+                $companylist=M('qcode_gsmc')->field('id,nickname')->select();
+                $productlist=M('qcode_product')->where(['id'=>array('gt',27)])->field('product_name')->select();
+
+            }
+            $this->assign('companylist',$companylist);
+            $this->assign('productlist',$productlist);
+            $this->display();
+        }elseif ($_SERVER['REQUEST_METHOD']==='POST'){
+
+            $nickname = trim($_POST['nickname']);
+            if ($nickname!=''){
+                $wh['nickname']=array('like','%'.$nickname.'%');
+            }
+
+            if($session_config['user_auth']['uid']==1 || $session_config['user_auth']['uid']==26) {
+                $companylist=M('qcode_gsmc')
+                    ->where($wh)
+                    ->field('id,nickname')
+                    ->select();
+            }
+
+            echo json_encode($companylist);
+        }
+
+
+    }
+    public function logs($content, $subDir = ''){
+        $subDir = trim($subDir, '/\\');
+        if (empty($content)) return false;
+        static $arrConfig = array();
+        if (empty($arrConfig)){
+            $arrPath  = array(MODULE_NAME, CONTROLLER_NAME, ACTION_NAME);
+            $arrConfig['root_path'] = './Runtime/Logs/';
+            $arrConfig['sub_dir']   = implode('/', $arrPath);
+            $arrConfig['file_name'] = '/' . date('Ymd') . '.log';
+            $arrConfig['client_ip'] = get_client_ip();
+            $arrConfig['logs_no']   = date('ymdHis') . microtime() * 1000000;
+        }
+
+        $filepath = $arrConfig['root_path'];
+        if ($subDir){
+            $filepath .= $subDir ;
+        } else {
+            $filepath .= $arrConfig['sub_dir'] ;
+        }
+
+        if (!file_exists($filepath)){
+            mkdir($filepath, 0777, TRUE);
+        }
+
+        $filepath .= $arrConfig['file_name'];
+
+        $header = sprintf("\r\n\r\n[%s][%s][%s] ", date('Y-m-d H:i:s'), $arrConfig['client_ip'],$arrConfig['logs_no']);
+        @file_put_contents($filepath, $header . $content, FILE_APPEND);
+
+        return $arrConfig['logs_no'] ;
+    }
+
+    public function getproduct(){
+
+        if (I('post.type')==1){
+            $map = array();
+            $map['id'] = array('gt',27);
+            $sysCdNm = trim($_POST['sysCdNm']);
+            if ($sysCdNm!=''){
+                $map['product_name']=array('like','%'.$sysCdNm.'%');
+            }
+            $productlist=M('qcode_product')->where($map)->field('product_name,id,product_size,product_num,temple,product_code')->select();
+            $this->ajaxReturn($productlist);
+        }else if(I('post.type')==2){
+            //写入日志
+            $req = I('param.type');
+            $this->logs($req);
+
+            $map = array();
+            $code = $_POST['code'];
+            if ($code!=''){
+                $map['code']=$code;
+            }
+            $productlist=M('qcode_unit')->where($map)->field('main_unit,sec_unit,proportion')->find();
+            if ($productlist==[]){
+                $productlist['main_unit'] = '万张';
+                $productlist['sec_unit'] = '件';
+                $productlist['proportion'] = 0.1;
+            }else{
+                if ($productlist['sec_unit']==null){
+                    $productlist['sec_unit'] = '件';
+                }
+                if ($productlist['proportion']==null){
+                    $productlist['proportion'] = 0.1;
+                }
+            }
+
+            $this->ajaxReturn($productlist);
+        }else if(I('post.type')==3){
+            //写入日志
+            $req = I('param.type');
+            $this->logs($req);
+
+            $map = array();
+            $map['id'] = array('gt',27);
+            $product_code = $_POST['product_code'];
+            if ($product_code!=''){
+                $map['product_code']=$product_code;
+            }
+            $productlist=M('qcode_product')->where($map)->field('product_name, temple')->find();
+
+            $this->ajaxReturn($productlist);
+        }else if(I('post.type')==4){
+            //写入日志
+            $req = I('param.type');
+            $this->logs($req);
+
+            $map = array();
+            $nickname = trim($_POST['nickname']);
+            if ($nickname!=''){
+                $map['nickname']=$nickname;
+            }
+
+            $print_code=M('qcode_gsmc')->where($map)->field('print_code')->find();
+
+            $map2 = array();
+            $map2['id'] = array('gt',27);
+            $product_name = trim($_POST['matter_name']);
+            if ($nickname!=''){
+                $map2['product_name']=$product_name;
+            }
+
+            $product_code=M('qcode_product')->where($map2)->field('product_code, temple')->find();
+
+            $data['print_code'] = $print_code;
+            $data['product_code'] = $product_code;
+
+            $this->ajaxReturn($data);
+        }else{
+            $id = I('post.id');
+            if (!empty($id)){
+                $userinfo=M('admin_user')->where('id='.$id)->find();
+                $user_product = explode(',',$userinfo['product_id']);
+                $map = array();
+                $map['id'] = array('in',$user_product);
+                $sysCdNm = trim($_POST['sysCdNm']);
+                if ($sysCdNm!=''){
+                    $map['product_name']=array('like','%'.$sysCdNm.'%');
+                }
+                $productlist=M('qcode_product')->where($map)->field('product_name,id,product_size,product_num,temple,product_code')->select();
+                $this->ajaxReturn($productlist);
+            }
+        }
+
+    }
+
+
+
+
+}
+

+ 198 - 0
Application/Admin/Controller/Qr1Controller.class.php

@@ -0,0 +1,198 @@
+<?php
+/**
+ * author jade
+ * intro 二维码类
+ */
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+class Qr1Controller extends AdminController
+{
+    protected $fileLog, $product, $task, $bach, $QrView;
+
+    /**
+     * author jade
+     * intro 类初始化方法
+     * param
+     * return
+     */
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->activatelist = M('activate_list');//激活文件夹
+    }
+
+    /**
+     * author jade
+     * intro 上传txt码包验证方法
+     * param
+     * return
+     */
+    public function uploadVerify()
+    {
+        if (get_current_admin_id() == 1) $this->error('暂不支持管理员操作');
+        //获取需要拒绝的批次ID
+        $bach_data = $this->task
+            ->distinct(true)
+            ->where(array('printer_id' => get_current_admin_id(), 'status' => 0))
+            ->getField('bach_id', true);
+        if (!empty($bach_data)) $where['id'] = array('not in', $bach_data);
+        $where['printer_id'] = get_current_admin_id();
+        $bach_result = $this->bach
+            ->where($where)
+            ->field('name')
+            ->select();
+        $this->bach_result = $bach_result;
+        $this->meta_title = '数据校验';
+        $this->display();
+    }
+
+
+    /**
+     * author jade
+     * intro 把文件从临时目录中获取
+     * param
+     * return  bool
+     */
+    public function Upload()
+    {
+        if (!is_array(I('url')) || empty(I('url'))) alert(array('code' => 0, 'msg' => '请联系开发人员'));
+        $active_batch = I('active_batch');
+        $id = I('id');
+        foreach (I('url') as $k => $v) {
+            $filename = basename($v, '.txt');//文件名
+            $url = 'Data/Code_Active_list/'. $active_batch. '/0/';//路径
+            $path = $url . basename($v);//路径+文件
+            if (!copy($v, $path)) alert(array('code' => 0, 'msg' => '上传失败'));
+            //unlink($v); 
+            /*上传成功一次修改一次数据 start*/
+            $count = $this->getnum($path);
+            $this->activatelist->where('id = '.$id)->setInc('num',$count); 
+            /*上传成功一次修改一次数据 stop*/
+        }
+        alert(array('code' => 1, 'msg' => '上传成功'));
+    }
+    
+    public function getnum($dir){
+        $cont='';
+        $cont.= file_get_contents(iconv("utf-8","gbk",$dir));
+        $cont = preg_replace('/\n|\r\n/','*',$cont);
+        $data = explode("*",$cont);
+        unset($cont);
+        $data = array_filter($data);
+        $count = count($data);
+        return $count;  
+    }
+
+
+    /**
+     * author jade
+     * intro 上传文件到零时目录
+     * param
+     * return  bool
+     */
+    public function UploadTemp()
+    {
+        $fullName = $_FILES['file']['name'];
+        $fileName = basename($fullName, '.txt');
+        $this->UploadCheck($fullName,$fileName);
+        $config = C('UPLOAD_FILE_CONFIG');//获取上传配置
+        if (!file_exists('Temp/')) {
+            mkdir('Temp/', '0777', true);
+        }
+//        if(is_file('./Temp/'.$fullName)){
+//           $fileName = $fileName.rand(100000,999999);
+//        }
+        $config['rootPath'] = './Temp/';//文件上传保存的根路径
+        $config['savePath'] = '/';//文件上传保存的根路径
+        $config['subName'] = false;//子目录创建方式
+        $config['saveName'] = $fileName;//上传文件的保存规则
+        $upload = new \Think\Upload($config);
+        $info = $upload->upload();
+        if (!$info) {
+            alert(array('code' => 0, 'msg' => $upload->getError()));
+        } else {
+            alert(array('code' => 1, 'msg' => '上传成功', 'file' => 'Temp/'. $fileName.'.txt'));
+        }
+    }
+
+    /**
+     * author jade
+     * intro 上传规则检测
+     * param
+     * return  bool
+     */
+    public function UploadCheck($fullName,$fileName)
+    {
+        if (preg_match("/[\x7f-\xff]/", $fileName)) {
+            alert(array('code' => 0, 'msg' => '文件格式不规范,文件名包含汉字'));
+        }
+         if(is_file('./Temp/'.$fullName)){
+            $fileName = $fileName.rand(100000,999999);
+            alert(array('code' => 0, 'msg' => '重复上传'));
+        }
+        return true;
+    }
+
+    /**
+     * author jade
+     * intro 码包详情页面
+     * param
+     * return array obj json bool string  resource
+     */
+    public function fileList()
+    {
+
+        $keyword = I('keyword', '', 'string');
+        $map['filename'] = array('like', '%' . $keyword . '%');
+
+        $p = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $data_list = $this->fileLog
+            ->page($p, C('ADMIN_PAGE_ROWS'))
+            ->where($map)
+            ->order('id desc')
+            ->select();
+        $page = new Page(
+            $this->fileLog->where($map)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+
+        foreach ($data_list as &$data) {
+            $data['filename'] = cut_str($data['filename'], 0, 30)
+                . '<input class="form-control input-sm" value="'
+                . $data['path'] . '">';
+        }
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('码包管理')// 设置页面标题
+        ->setSearch('请输入ID/上传关键字', U('fileList'))
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('creator', '作者')
+            ->addTableColumn('batch_id', '批次号')
+            ->addTableColumn('is_verify', '类型', 'radio', array(0 => '二维码', 1 => '二维码+数字验证'))
+            ->addTableColumn('path', '文件名及路径')
+            ->addTableColumn('total', '总条数')
+            ->addTableColumn('success_num', '成功条数')
+            ->addTableColumn('error_num', '失败条数')
+            ->addTableColumn('create_time', '创建时间', 'time')
+            ->setTableDataList($data_list)// 数据列表
+            ->setTableDataPage($page->show())// 数据列表分页
+            ->display();
+
+    }
+
+    /**
+     * author jade
+     * intro  批次详情
+     * param
+     * return array obj json bool string  resource
+     */
+    public function getBachInfo()
+    {
+        $data = $this->QrView->where(array('bach.name' => I('bach_name')))->select();
+        return $this->ajaxReturn($data);
+    }
+
+}

+ 224 - 0
Application/Admin/Controller/QrController.class.php

@@ -0,0 +1,224 @@
+<?php
+/**
+ * author xtj
+ * intro 二维码类
+ */
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+class QrController extends AdminController
+{
+    protected $fileLog, $product, $task, $bach, $QrView;
+
+    /**
+     * author xtj
+     * intro 类初始化方法
+     * param
+     * return
+     */
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->fileLog = M('FileLog');//上传文件日
+        $this->product = M('product');
+        $this->task = M('task');
+        $this->bach = M('bach');
+        $this->QrView = D('QrView');
+    }
+
+    /**
+     * author xtj
+     * intro 上传txt码包验证方法
+     * param
+     * return
+     */
+    public function UploadVerify()
+    {
+        if (get_current_admin_id() == 1) $this->error('暂不支持管理员操作');
+        //获取需要拒绝的批次ID
+        $bach_data = $this->task
+            ->distinct(true)
+            ->where(array('printer_id' => get_current_admin_id(), 'status' => 0))
+            ->getField('bach_id', true);
+        if (!empty($bach_data)) $where['id'] = array('not in', $bach_data);
+        $where['printer_id'] = get_current_admin_id();
+        $bach_result = $this->bach
+            ->where($where)
+            ->field('name')
+            ->select();
+        $this->bach_result = $bach_result;
+        $this->meta_title = '数据校验';
+        $this->display();
+    }
+
+
+    /**
+     * author xtj
+     * intro 把文件从临时目录中获取
+     * param
+     * return  bool
+     */
+    public function Upload()
+    {
+        if (!is_array(I('url')) || empty(I('url'))) alert(array('code' => 0, 'msg' => '请联系开发人员'));
+        foreach (I('url') as $k => $v) {
+            $filename = basename($v, '.txt');//文件名
+            $source = explode('_', $filename);
+            $task_id = $source[2];//任务id
+            $bach_name = $source[0] . '_' . $source[1];//批次名
+            $url = 'Data/Code_Add_list/' . $bach_name . '/' . get_current_admin_name() . '/' . $bach_name . '_' . $source[2] . '/0/';//路径:上传路径
+            $url1 = 'Data/Code_Add_list/' . $bach_name . '/' . get_current_admin_name() . '/' . $bach_name . '_' . $source[2] . '/1/';//路径:激活完路径
+            $path = $url . basename($v);//路径+文件
+            $is_verify = I('get.is_verify');//pathinfo 支持I接受post和get
+            $bach_id = $this->bach
+                ->where(array('name' => $bach_name))
+                ->getField('id');
+            if (count(array_filter($source)) != count($source)) alert(array('code' => 0, 'msg' => '文件名存在无效参数'));
+            if (!file_exists($url)) mkdir($url, 0777, true);
+            if (!file_exists($url1)) mkdir($url1, 0777, true);
+            if (!copy($v, $path)) alert(array('code' => 0, 'msg' => '上传失败'));
+            //暂时不执行这个方法
+            /*
+            if (!$this->fileLog->where(array('filename' => $filename, 'creator' => get_current_admin_name()))->find()) {
+                //上传记录日志
+                $file_log['creator'] = get_current_admin_name();
+                $file_log['batch_id'] = $bach_id;
+                $file_log['url'] = $url;
+                $file_log['path'] = $path;
+                $file_log['filename'] = $filename;
+                $file_log['create_time'] = time();
+                $file_log['is_verify'] = $is_verify;
+                $file_log['task_id'] = $task_id;
+                $this->fileLog->add($file_log)
+            }
+            * 
+            */
+            //$status = empty($is_verify) ? 1 : 2;//1 管理员上传 2.印刷厂上传
+           
+        }
+        $this->task->where(array('bach_id' => $bach_id, 'id' => $task_id))->setField('status', 1);
+        alert(array('code' => 1, 'msg' => '上传成功'));
+        /*if (get_current_admin_id() != 1 && !empty($is_verify)) {
+            //调用插入接口
+            R('Activate/index', array('bach_id' => $bach_id));
+            alert(array('code' => 1, 'msg' => '上传成功,校验中'));
+        } else {
+            alert(array('code' => 1, 'msg' => '上传成功'));
+        }*/
+
+
+    }
+
+
+    /**
+     * author xtj
+     * intro 上传文件到零时目录
+     * param
+     * return  bool
+     */
+    public function UploadTemp()
+    {
+        $fullName = $_FILES['file']['name'];
+        $fileName = basename($fullName, '.txt');
+        $source = explode('_', $fileName);
+        $task_id = $source[2];//任务id
+        $bach_name = $source[0] . '_' . $source[1];//批次名
+        $this->UploadCheck($fileName, $bach_name, $task_id);
+        $config = C('UPLOAD_FILE_CONFIG');//获取上传配置
+        if (!file_exists('Temp/')) {
+            mkdir('Temp/', '0777', true);
+        }
+
+        $config['rootPath'] = './Temp/';//文件上传保存的根路径
+        $config['subName'] = $bach_name . '/' . get_current_admin_name() . '/' . $bach_name . '_' . $task_id;//子目录创建方式
+        $config['saveName'] = $fileName;//上传文件的保存规则
+        $upload = new \Think\Upload($config);
+        $info = $upload->upload();
+        if (!$info) {
+            alert(array('code' => 0, 'msg' => $upload->getError()));
+        } else {
+            alert(array('code' => 1, 'msg' => '上传成功', 'file' => 'Temp/' . $config['subName'] . '/' . $fullName));
+        }
+
+    }
+
+    /**
+     * author xtj
+     * intro 上传规则检测
+     * param
+     * return  bool
+     */
+    public function UploadCheck($fileName, $bach_name, $task_id)
+    {
+        if ((get_current_admin_name() == 'admin') && (I('get.is_verify') == 1)) alert(array('code' => 0, 'msg' => '此模块只允许印刷厂组用户操作'));
+        if (strpos($fileName, '_') === false) alert(array('code' => 0, 'msg' => '文件格式不规范,格式:批次名_任务ID'));
+        if (!$this->task->where(array('name' => $bach_name, 'id' => $task_id))->find()) {
+            alert(array('code' => 0, 'msg' => '批次名对应的任务ID不存在'));
+        }
+        return true;
+
+
+    }
+
+    /**
+     * author xtj
+     * intro 码包详情页面
+     * param
+     * return array obj json bool string  resource
+     */
+    public function fileList()
+    {
+
+        $keyword = I('keyword', '', 'string');
+        $map['filename'] = array('like', '%' . $keyword . '%');
+
+        $p = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $data_list = $this->fileLog
+            ->page($p, C('ADMIN_PAGE_ROWS'))
+            ->where($map)
+            ->order('id desc')
+            ->select();
+        $page = new Page(
+            $this->fileLog->where($map)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+
+        foreach ($data_list as &$data) {
+            $data['filename'] = cut_str($data['filename'], 0, 30)
+                . '<input class="form-control input-sm" value="'
+                . $data['path'] . '">';
+        }
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('码包管理')// 设置页面标题
+        ->setSearch('请输入ID/上传关键字', U('fileList'))
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('creator', '作者')
+            ->addTableColumn('batch_id', '批次号')
+            ->addTableColumn('is_verify', '类型', 'radio', array(0 => '二维码', 1 => '二维码+数字验证'))
+            ->addTableColumn('path', '文件名及路径')
+            ->addTableColumn('total', '总条数')
+            ->addTableColumn('success_num', '成功条数')
+            ->addTableColumn('error_num', '失败条数')
+            ->addTableColumn('create_time', '创建时间', 'time')
+            ->setTableDataList($data_list)// 数据列表
+            ->setTableDataPage($page->show())// 数据列表分页
+            ->display();
+
+    }
+
+    /**
+     * author xtj
+     * intro  批次详情
+     * param
+     * return array obj json bool string  resource
+     */
+    public function getBachInfo()
+    {
+        $data = $this->QrView->where(array('bach.name' => I('bach_name')))->select();
+        return $this->ajaxReturn($data);
+    }
+
+}

+ 30 - 0
Application/Admin/Controller/TestTrueController.class.php

@@ -0,0 +1,30 @@
+<?php
+ namespace  Admin\Controller;
+ use Think\Page;
+ use think\Request;
+
+ class TestTrueController extends AddonController{
+
+     public function my_idr(){ //打印指定的目录下面的所有的文件和子文件
+        $files=array();
+        if($handle=opendir(I('get.dir'))){
+            while (($file=readfile($handle))!== false){
+                if($file!=='..' &&  $file!=='.'){//排除根目录
+                    if(is_dir((I('get.dir')."/".$file)) ){
+                        //如果是子文件夹,就进行递归
+                        /*$files[$file] = my_dir((I('get.dir')."/".$file));*/
+                    } else {
+                        //不然就将文件的名字存入数组;
+                        $files[] = $file;
+                    }
+                }
+            }
+
+        }
+         //closedir($handle);
+        echo  $files;
+
+     }
+
+
+ }

+ 146 - 0
Application/Admin/Controller/UploadController.class.php

@@ -0,0 +1,146 @@
+<?php
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+/**
+ * 后台上传控制器
+ *
+ */
+class UploadController extends AdminController
+{
+    /**
+     * 上传列表
+     *
+     */
+    public function index()
+    {
+        //搜索
+        $keyword = I('keyword', '', 'string');
+        $condition = array('like', '%' . $keyword . '%');
+        $map['id|path'] = array($condition, $condition, '_multi' => true);
+
+        //获取所有上传
+        $map['status'] = array('egt', '0'); //禁用和正常状态
+        $p = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $upload_object = D('Upload');
+        $data_list = $upload_object
+            ->page($p, C('ADMIN_PAGE_ROWS'))
+            ->where($map)
+            ->order('sort desc,id desc')
+            ->select();
+        $page = new Page(
+            $upload_object->where($map)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+
+        foreach ($data_list as &$data) {
+            $data['name'] = cut_str($data['name'], 0, 30)
+                . '<input class="form-control input-sm" value="'
+                . $data['path'] . '">';
+        }
+
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('图片管理')// 设置页面标题
+        ->addTopButton('resume')// 添加启用按钮
+        ->addTopButton('forbid')// 添加禁用按钮
+        ->addTopButton('delete')// 添加删除按钮
+        ->setSearch('请输入ID/上传关键字', U('index'))
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('show', '文件')
+            ->addTableColumn('name', '文件名及路径')
+            ->addTableColumn('size', '大小', 'byte')
+            ->addTableColumn('create_time', '创建时间', 'time')
+            ->addTableColumn('sort', '排序')
+            ->addTableColumn('status', '状态', 'status')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list)// 数据列表
+            ->setTableDataPage($page->show())// 数据列表分页
+            ->addRightButton('forbid')// 添加禁用/启用按钮
+            ->addRightButton('delete')// 添加删除按钮
+            ->display();
+    }
+
+    /**
+     * 设置一条或者多条数据的状态
+     *
+     */
+    public function setStatus($model = CONTROLLER_NAME, $script = false)
+    {
+        $ids = I('request.ids');
+        $status = I('request.status');
+        if (empty($ids)) {
+            $this->error('请选择要操作的数据');
+        }
+        switch ($status) {
+            case 'delete': // 删除条目
+                if (!is_array($ids)) {
+                    $id_list[0] = $ids;
+                } else {
+                    $id_list = $ids;
+                }
+                foreach ($id_list as $id) {
+                    $upload_info = D('Upload')->find($id);
+                    if ($upload_info) {
+                        $realpath = realpath('.' . $upload_info['path']);
+                        if ($realpath) {
+                            array_map("unlink", glob($realpath));
+                            if (count(glob($realpath))) {
+                                $this->error('删除失败!');
+                            } else {
+                                $resut = D('Upload')->delete($id);
+                                $this->success('删除成功!');
+                            }
+                        } else {
+                            $resut = D('Upload')->delete($id);
+                            $this->success('删除成功!');
+                        }
+                    }
+                }
+                break;
+            default:
+                parent::setStatus($model);
+                break;
+        }
+    }
+
+
+    /**
+     * 上传
+     *
+     */
+    public function upload()
+    {
+        $data = json_encode(D('Upload')->upload());
+        exit($data);
+
+    }
+
+    /**
+     * 下载
+     *
+     */
+    public
+    function download($token)
+    {
+        if (empty($token)) {
+            $this->error('token参数错误!');
+        }
+
+        //解密下载token
+        $file_md5 = \Think\Crypt::decrypt($token, user_md5(is_login()));
+        if (!$file_md5) {
+            $this->error('下载链接已过期,请刷新页面!');
+        }
+
+        $upload_object = D('Upload');
+        $file_id = $upload_object->getFieldByMd5($file_md5, 'id');
+        if (!$upload_object->download($file_id)) {
+            $this->error($upload_object->getError());
+        }
+    }
+
+
+}

+ 215 - 0
Application/Admin/Controller/UserController.class.php

@@ -0,0 +1,215 @@
+<?php
+
+namespace Admin\Controller;
+
+use Think\Page;
+
+/**
+ * 用户控制器
+ *
+ */
+class UserController extends AdminController
+{
+    /**
+     * 用户列表
+     *
+     */
+    public function index()
+    {
+        // 搜索
+        $keyword                                  = I('keyword', '', 'string');
+        $condition                                = array('like', '%' . $keyword . '%');
+        $map['id|username|nickname|email|mobile'] = array(
+            $condition,
+            $condition,
+            $condition,
+            $condition,
+            $condition,
+            '_multi' => true,
+        );
+
+        // 获取所有用户
+        $session_config=$session_config=I('session.ly_admin_');
+        $addtype=$session_config['user_auth']['addtype'];
+
+        if($addtype==1){//为用户登陆,只能查看自己
+            $id=$session_config['user_auth']['uid'];//自己的id;
+            $map['id'] = $id;
+        }
+        $map['status'] = array('egt', '0'); // 禁用和正常状态
+
+        $p             = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $user_object   = D('User');
+        $data_list     = $user_object
+            ->page($p, C('ADMIN_PAGE_ROWS'))
+            ->where($map)
+            ->order('id asc')
+            ->select();
+        $page = new Page(
+            $user_object->where($map)->count(),
+            C('ADMIN_PAGE_ROWS')
+        );
+
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        if($addtype==0){//管理员有所有的权限
+        $builder->setMetaTitle('用户列表') // 设置页面标题
+            ->addTopButton('addnew') // 添加新增按钮
+            ->addTopButton('resume') // 添加启用按钮
+            ->addTopButton('forbid') // 添加禁用按钮
+            ->addTopButton('delete') // 添加删除按钮
+            ->setSearch('请输入ID/用户名/邮箱/手机号', U('index'))
+            ->addTableColumn('id', 'UID')
+            ->addTableColumn('avatar', '头像', 'picture')
+            ->addTableColumn('nickname', '昵称')
+            ->addTableColumn('username', '用户名')
+            ->addTableColumn('email', '邮箱')
+            ->addTableColumn('mobile', '手机号')
+            ->addTableColumn('create_time', '注册时间', 'time')
+            ->addTableColumn('status', '状态', 'status')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list) // 数据列表
+            ->setTableDataPage($page->show()) // 数据列表分页
+            ->addRightButton('edit') // 添加编辑按钮
+            ->addRightButton('forbid') // 添加禁用/启用按钮
+            ->addRightButton('recycle') // 添加删除按钮
+            ->display();
+        }else{
+            $builder->setMetaTitle('用户列表') // 设置页面标题
+            ->setSearch('请输入ID/用户名/邮箱/手机号', U('index'))
+                ->addTableColumn('id', 'UID')
+                ->addTableColumn('avatar', '头像', 'picture')
+                ->addTableColumn('nickname', '昵称')
+                ->addTableColumn('username', '用户名')
+                ->addTableColumn('email', '邮箱')
+                ->addTableColumn('mobile', '手机号')
+                ->addTableColumn('create_time', '注册时间', 'time')
+                ->addTableColumn('status', '状态', 'status')
+                ->addTableColumn('right_button', '操作', 'btn')
+                ->setTableDataList($data_list) // 数据列表
+                ->setTableDataPage($page->show()) // 数据列表分页
+                ->addRightButton('edit') // 添加编辑按钮
+                ->display();
+        }
+
+    }
+
+    /**
+     * 新增用户
+     *
+     */
+    public function add()
+    {
+        if (IS_POST) {
+            $user_object = D('User');
+            $session_config=I('session.ly_admin_');
+            $data        = $user_object->create();
+            $data = $_POST;
+            $data['password'] = user_md5($data['password']);
+            if($session_config['user_auth']['addtype']==0){//表示当前最高管理员添加用户账号
+                $data['addtype']=1;
+            }
+            if ($data) {
+                $id = $user_object->add($data);
+                if ($id) {
+                    $this->success('新增成功', U('index'));
+                } else {
+                    $this->error('新增失败');
+                }
+            } else {
+                $this->error($user_object->getError());
+            }
+        } else {
+            // 使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('新增用户') //设置页面标题
+                ->setPostUrl(U('add')) //设置表单提交地址
+                ->addFormItem('reg_type', 'hidden', '注册方式', '注册方式')
+                ->addFormItem('nickname', 'text', '供应商昵称', '昵称')
+                ->addFormItem('printer_code', 'text','供应商编码','供应商编码')
+                ->addFormItem('postcode', 'num','邮政编码','邮政编码')
+                ->addFormItem('company_address', 'text','地址','详细地址')
+                ->addFormItem('username', 'text', '用户名', '用户名')
+                ->addFormItem('password', 'password', '密码', '密码')
+                ->addFormItem('email', 'text', '邮箱', '邮箱')
+                ->addFormItem('email_bind', 'radio', '邮箱绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定'))
+                ->addFormItem('mobile', 'text', '手机号', '手机号')
+                ->addFormItem('mobile_bind', 'radio', '手机绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定'))
+                ->addFormItem('avatar', 'picture', '头像', '头像')
+                ->setFormData(array('reg_type' => 'admin'))
+                ->display();
+        }
+    }
+
+    /**
+     * 编辑用户
+     *
+     */
+    public function edit($id)
+    {
+        if (IS_POST) {
+            // 密码为空表示不修改密码
+            if ($_POST['password'] === '') {
+                unset($_POST['password']);
+            }
+
+            // 提交数据
+            $user_object = D('User');
+            $data        = $user_object->create();
+            if ($data) {
+                $result = $user_object
+                    ->field('id,nickname,username,password,email,email_bind,mobile,mobile_bind,gender,avatar,update_time,printer_code,postcode,company_address')
+                    ->save($data);
+                if ($result) {
+                    $this->success('更新成功', U('index'));
+                } else {
+                    $this->error('更新失败', $user_object->getError());
+                }
+            } else {
+                $this->error($user_object->getError());
+            }
+        } else {
+            // 获取账号信息
+            $info = D('User')->find($id);
+            unset($info['password']);
+
+            // 使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('编辑用户') // 设置页面标题
+                ->setPostUrl(U('edit')) // 设置表单提交地址
+                ->addFormItem('id', 'hidden', 'ID', 'ID')
+                ->addFormItem('nickname', 'text', '供应商名称', '供应商名称')
+                ->addFormItem('printer_code', 'text','供应商编码','供应商编码')
+                ->addFormItem('postcode', 'num','邮政编码','邮政编码')
+                ->addFormItem('company_address', 'text','地址','详细地址')
+                ->addFormItem('username', 'text', '用户名', '用户名')
+                ->addFormItem('password', 'password', '密码', '密码')
+                ->addFormItem('email', 'text', '邮箱', '邮箱')
+                ->addFormItem('email_bind', 'radio', '邮箱绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定'))
+                ->addFormItem('mobile', 'text', '手机号', '手机号')
+                ->addFormItem('mobile_bind', 'radio', '手机绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定'))
+                ->addFormItem('avatar', 'picture', '头像', '头像')
+                ->setFormData($info)
+                ->display();
+        }
+    }
+
+    /**
+     * 设置一条或者多条数据的状态
+     *
+     */
+    public function setStatus($model = CONTROLLER_NAME)
+    {
+        $ids = I('request.ids');
+        if (is_array($ids)) {
+            if (in_array('1', $ids)) {
+                $this->error('超级管理员不允许操作');
+            }
+        } else {
+            if ($ids === '1') {
+                $this->error('超级管理员不允许操作');
+            }
+        }
+        parent::setStatus($model);
+    }
+}

+ 157 - 0
Application/Admin/Controller/VerifyCodeController.class.php

@@ -0,0 +1,157 @@
+<?php
+/**
+ * author xtj
+ * intro 二维码验证类
+ */
+
+namespace Admin\Controller;
+
+
+class VerifyCodeController extends AdminController
+{
+
+    /**
+     * author xtj
+     * intro 类初始化方法
+     * param
+     * return
+     */
+    public function _initialize()
+    {
+        parent::_initialize();
+    }
+
+    //TODO 废弃的方法
+    public function index()
+    {
+        /*if (!empty(I('get.bach_id'))) {*/
+        /*  for ($i = 0; $i < 5; $i++) {*/
+        $this->verifyUrl();
+        /* }*/
+        /*  }*/
+    }
+
+    //TODO 废弃的方法
+    public function verifyUrl()
+    {
+        $arr = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
+        $sum = '';
+        foreach ($arr as $k => $v) {
+            $sum += M('codes_' . $v)->count();
+            /*if (getStatusCode(M('codes_' . $v)->where(array('bach_id' => $bach_id))->getField('code'))==404) {
+                M('VerifyCodeLog')->save(array('bach_id' => $bach_id, 'table' => 'codes_' . $v,));//记录异常数据
+            }*/
+        }
+        echo $sum;
+    }
+
+
+    public function lock()
+    {
+        if (file_exists('./lock')) {
+            echo '文件被锁定';
+            exit;
+        } else {
+            @touch('./lock');
+            echo '文件已锁定';
+        }
+
+    }
+
+    public function fenbiao()
+    {
+        $this->lock();
+        $CodeMode = M('codes');
+        if (empty(S('fenbiao_page'))) {
+            $now_page = S('fenbiao_page', 0);
+        } else {
+            $now_page = S('fenbiao_page');
+        }
+        echo '当前第' . $now_page . '页<br/>';
+        if (empty(S('fenbiao_data'))) {
+            $data = $CodeMode->order('id asc')->limit(0, 10000)->select();
+            S('fenbiao_data', $data);
+        } else {
+            $data = S('fenbiao_data');
+        }
+        $t1 = microtime(true);
+        if (!empty($data)) {
+            $Model = M(); // 实例化一个空对象
+            $Model->startTrans(); // 开启事务
+            $i = 0;
+            $codes_id = '';
+            foreach ($data as $key => $value) {
+                $table_name = getSubTable('codes', $value['code']);
+                $where_str = '';
+                $field_str = '';
+                $j = 0;
+                foreach ($value as $kk => $vv) {
+                    if ($j == count($value) - 1) {
+                        $field_str .= "`" . $kk . "`";
+                        $where_str .= "'" . $vv . "'";
+                    } else {
+                        $field_str .= "`" . $kk . "`,";
+                        $where_str .= "'" . $vv . "',";
+                    }
+                    $j++;
+                }
+                $sql = "INSERT ignore INTO `$table_name` ($field_str)  VALUES ($where_str)";
+
+                $Model->execute($sql);
+                $i++;
+                $codes_id .= $value['id'] . ',';
+                if ($i % 200 == 0) {
+                    $codes_id = rtrim($codes_id, ',');
+                    $Model->table('qr_codes')->delete($codes_id);
+                    $codes_id = '';
+                }
+            }
+            if ($i == count($data)) {
+                $Model->commit(); // 成功则提交事务
+                unlink('./lock');//删除文件锁定
+                S('fenbiao_page', $now_page = $now_page + 1);
+                $t2 = microtime(true);
+                S('fenbiao_data', NULL);
+                echo $t2 - $t1 . 's';
+            } else {
+                $Model->rollback(); // 否则将事务回滚
+            }
+        }
+    }
+
+    public function checkUrl()
+    {
+        $lines = file("./url.txt");
+        foreach ($lines as $line) {
+            $line = rtrim($line);
+            $code_status = getStatusCode($line);
+            if ($code_status == 404) {
+                echo $line . "<br/>";
+            } else {
+                echo $code_status . "<br/>";
+            }
+
+        }
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 127 - 0
Application/Admin/Controller/VersionController.class.php

@@ -0,0 +1,127 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Admin
+ * Date: 2018/8/28
+ * Time: 11:07
+ */
+
+namespace Admin\Controller;
+use think\Request;
+use Think\Page;
+//版本控制器
+class VersionController extends AddonController
+{
+    public function index()
+    {
+        // 搜索
+        $keyword              = I('keyword', '', 'string');
+        $condition            = array('like', '%' . $keyword . '%');
+        $map['version|update_info'] = array(//查询条件数组
+            $condition,
+            $condition,
+            '_multi' => true,
+        );
+        $p = !empty($_GET["p"]) ? $_GET['p'] : 1;
+        $version_list = D('version');
+        $data_list= $version_list
+            ->page($p, 15)
+            ->where($map)
+            ->order('id asc')
+            ->select();
+        $page = new Page(
+            $version_list->where($map)->count(),
+            50
+        );
+        // 使用Builder快速建立列表页面。
+        $builder = new \Common\Builder\ListBuilder();
+        $builder->setMetaTitle('版本控制列表') // 设置页面标题
+        ->addTopButton('addnew',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/versionEdit')]) // 添加新增按钮
+        ->addTopButton('delete',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/versionDel')]) // 添加删除按钮
+        ->setSearch(
+            '请输入版本号或者版本更新内容',
+            U('index')//重新进入到Productile页面;
+        )
+            ->addTableColumn('id', 'ID')
+            ->addTableColumn('version', '版本号')
+            ->addTableColumn('update_info', '版本更新内容')
+            ->addTableColumn('update_time', '更新时间')
+            ->addTableColumn('right_button', '操作', 'btn')
+            ->setTableDataList($data_list) // 数据列表
+            ->setTableDataPage($page) // 数据列表分页
+            ->addRightButton('edit',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/versionEdit',array(
+                'id'    => '__data_id__',
+            ))]) // 添加编辑按钮
+            ->addRightButton('delete',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/versionDel',array(
+                'id'    => '__data_id__',
+            ))]) // 添加删除按钮
+            ->display();
+
+    }
+
+    public function versionEdit(){
+        //修改或者编辑版本信息
+        if (IS_POST ) {
+            $version = D('version');
+            $data= $version->create();
+            if ($data) {
+                if(I('post.id')){//有id是修改
+                    if ($version->save($data)) {
+                        $this->success('修改成功', U('index'));
+                    } else {
+                        $this->error('修改失败');
+                    }
+                }else {//不存在id,新增
+                    $data['update_time']=date('Y-m-d',time());
+                    if ($version->add($data)) {
+                        $this->success('新增成功', U('index'));
+                    } else {
+                        $this->error('新增失败');
+                    }
+                }
+            } else {
+                $this->error($version->getError());
+            }
+        } else {
+            //使用FormBuilder快速建立表单页面。
+            $builder = new \Common\Builder\FormBuilder();
+            $builder->setMetaTitle('编辑版本号') //设置页面标题
+            ->setPostUrl(U('versionEdit')) //设置表单提交地址
+            ->addFormItem('id', 'hidden', 'ID', 'ID')
+                ->addFormItem('version', 'text', '版本号', '请输入版本号')
+                ->addFormItem('update_info','text', '版本更新内容', '请输入版本更新内容')
+                ->setFormData(D('version')->find(I('get.id')))
+                ->display();
+        }
+
+    }
+
+    public function versionDel(){
+        //版本删除
+        if(IS_POST){
+            if(empty($_POST)){
+                $this->error('请至少选择一个选项');
+            }else{
+                $version = D('version');
+                $id = implode(',',$_POST['ids']);
+                $return  = $version->DelVersion($id);
+                if($return){
+                    $this->success('删除成功', U('index'));
+                }else{
+                    $this->error('删除失败');
+                }
+            }
+        }else{
+            $id = $_GET['id'];
+            $version = D('version');
+            $return  = $version->DelVersion($id);
+            if($return){
+                $this->success('删除成功', U('index'));
+            }else{
+                $this->error('删除失败');
+            }
+        }
+
+    }
+
+}

+ 52 - 0
Application/Admin/Model/AccessModel.class.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+/**
+ * 管理员与用户组对应关系模型
+ *
+ */
+class AccessModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'admin_access';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('uid', 'require', 'UID不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('group', 'require', '部门不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('uid', 'checkUser', '该用户不存在', self::MUST_VALIDATE, 'callback', self::MODEL_BOTH),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+        array('create_time', 'time', self::MODEL_INSERT, 'function'),
+        array('update_time', 'time', self::MODEL_BOTH, 'function'),
+        array('sort', '0', self::MODEL_INSERT),
+        array('status', '1', self::MODEL_INSERT),
+    );
+
+    /**
+     * 检查用户是否存在
+     *
+     */
+    protected function checkUser($uid)
+    {
+        $user_info = D('User')->find($uid);
+        if ($user_info) {
+            return true;
+        }
+        return false;
+    }
+}

+ 153 - 0
Application/Admin/Model/AddonModel.class.php

@@ -0,0 +1,153 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+/**
+ * 插件模型
+ * 该类参考了OneThink的部分实现
+ *
+ */
+class AddonModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'admin_addon';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('name', 'require', '插件名称不能为空', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('name', '1,32', '插件名称长度为1-32个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('name', '', '插件名称已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('description', 'require', '钩子描述必须!', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+        array('create_time', 'time', self::MODEL_INSERT, 'function'),
+        array('update_time', 'time', self::MODEL_BOTH, 'function'),
+        array('sort', '0', self::MODEL_INSERT),
+        array('status', '1', self::MODEL_INSERT),
+    );
+
+    /**
+     * 插件类型
+     *
+     */
+    public function addon_type($id)
+    {
+        $list[0] = '系统插件';
+        return $id ? $list[$id] : $list;
+    }
+
+    /**
+     * 获取插件列表
+     * @param string $addon_dir
+     *
+     */
+    public function getAllAddon()
+    {
+        $addon_dir = C('ADDON_PATH');
+        $dirs      = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
+        if ($dirs == false || !file_exists($addon_dir)) {
+            $this->error = '插件目录不可读或者不存在';
+            return false;
+        }
+        $addons      = array();
+        $map['name'] = array('in', $dirs);
+        $list        = $this->where($map)
+            ->field(true)
+            ->order('sort asc,id desc')
+            ->select();
+        foreach ($list as $addon) {
+            $addons[$addon['name']] = $addon;
+        }
+        foreach ($dirs as $value) {
+            if (!isset($addons[$value])) {
+                $class = get_addon_class($value);
+                if (!class_exists($class)) { // 实例化插件失败忽略执行
+                    \Think\Log::record('插件' . $value . '的入口文件不存在!');
+                    continue;
+                }
+                $obj            = new $class;
+                $addons[$value] = $obj->info;
+                if ($addons[$value]) {
+                    $addons[$value]['status'] = -1; // 未安装
+                }
+            }
+        }
+        foreach ($addons as &$val) {
+            switch ($val['status']) {
+                case '-1': // 未安装
+                    $val['status']                               = '<i class="fa fa-trash" style="color:red"></i>';
+                    $val['right_button']['install']['title']     = '安装';
+                    $val['right_button']['install']['attribute'] = 'class="label label-success ajax-get" href="' . U('install', array('addon_name' => $val['name'])) . '"';
+                    break;
+                case '0': // 禁用
+                    $val['status']                                 = '<i class="fa fa-ban" style="color:red"></i>';
+                    $val['right_button']['config']['title']        = '设置';
+                    $val['right_button']['config']['attribute']    = 'class="label label-info" href="' . U('config', array('id' => $val['id'])) . '"';
+                    $val['right_button']['forbid']['title']        = '启用';
+                    $val['right_button']['forbid']['attribute']    = 'class="label label-success ajax-get" href="' . U('setStatus', array('status' => 'resume', 'ids' => $val['id'])) . '"';
+                    $val['right_button']['uninstall']['title']     = '卸载';
+                    $val['right_button']['uninstall']['attribute'] = 'class="label label-danger ajax-get" href="' . U('uninstall', array('id' => $val['id'])) . '"';
+                    if ($val['adminlist']) {
+                        $val['right_button']['adminlist']['title']     = '数据管理';
+                        $val['right_button']['adminlist']['attribute'] = 'class="label label-success" href="' . U('adminlist', array('name' => $val['name'])) . '"';
+                    }
+                    break;
+                case '1': // 正常
+                    $val['status']                                 = '<i class="fa fa-check" style="color:green"></i>';
+                    $val['right_button']['config']['title']        = '设置';
+                    $val['right_button']['config']['attribute']    = 'class="label label-info" href="' . U('config', array('id' => $val['id'])) . '"';
+                    $val['right_button']['forbid']['title']        = '禁用';
+                    $val['right_button']['forbid']['attribute']    = 'class="label label-warning ajax-get" href="' . U('setStatus', array('status' => 'forbid', 'ids' => $val['id'])) . '"';
+                    $val['right_button']['uninstall']['title']     = '卸载';
+                    $val['right_button']['uninstall']['attribute'] = 'class="label label-danger ajax-get" href="' . U('uninstall', array('id' => $val['id'])) . '"';
+                    if ($val['adminlist']) {
+                        $val['right_button']['adminlist']['title']     = '数据管理';
+                        $val['right_button']['adminlist']['attribute'] = 'class="label label-success" href="' . U('adminlist', array('name' => $val['name'])) . '"';
+                    }
+                    break;
+            }
+        }
+        return $addons;
+    }
+
+    /**
+     * 插件显示内容里生成访问插件的url
+     * @param string $url url
+     * @param array $param 参数
+     *
+     */
+    public function getAddonUrl($url, $param = array())
+    {
+        $url        = parse_url($url);
+        $case       = C('URL_CASE_INSENSITIVE');
+        $addons     = $case ? parse_name($url['scheme']) : $url['scheme'];
+        $controller = $case ? parse_name($url['host']) : $url['host'];
+        $action     = trim($case ? strtolower($url['path']) : $url['path'], '/');
+        // 解析URL带的参数
+        if (isset($url['query'])) {
+            parse_str($url['query'], $query);
+            $param = array_merge($query, $param);
+        }
+        // 基础参数
+        $params = array(
+            '_addons'     => $addons,
+            '_controller' => $controller,
+            '_action'     => $action,
+        );
+        $params = array_merge($params, $param); //添加额外参数
+        return U(MODULE_MARK . '/Addon/execute', $params, true, true);
+    }
+}

+ 92 - 0
Application/Admin/Model/BarLargeModel.class.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+/**
+ * 配置模型
+ *
+ */
+class BarLargeModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'bar_large';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        /*array('code', 'require', '产品代码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('code', '4,6', '产品代码长度为4-6个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('code', '', '产品代码已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('title', 'require', '自定义名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('title', '', '自定义名称已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),*/
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+
+    );
+
+    /**
+     * 获取大件
+     * @return array 配置数组
+     *
+     */
+    public function getList($where = [],$p)
+    {
+        $list = $this->where($where)->order('id desc')->limit($p->firstRow, $p->listRows)->select();
+        return $list;
+    }
+
+    public function slectById($id){
+        $list = $this->where('id ='.$id)->select();
+        return $list;
+    }
+
+    public function getById($list){
+        header("Content-type: text/html; charset=utf-8");
+        $where = array();
+        $where['id'] = array('in',$list);
+        $field = "sn,name,time,num,standard,inspector,batch_number,board_no,tray_no,quality_no";
+        $data = $this->field($field)->where($where)->select();
+        $new = array();
+        foreach($data as $v){
+            $arr = array();
+            $arr = $v;
+            $arr['custome_name'] = '湖北中烟工业有限公司';
+            $arr['date'] = date('Y',$v['time']).'年'.date('m',$v['time']).'月'.date('d',$v['time']).'日';
+            $arr['sn'] = preg_replace("/[\(\)]/","",$v['sn']);
+            unset( $arr['time']);
+            $new[]= $arr;
+        }
+        return $new;
+
+    }
+
+    /*保存产品信息*/
+    public function save1($data){
+        $id = $data['id'];
+        if($id){
+            //执行更新
+            $return = $this->where('id ='.$id)->save($data);
+        }else{
+            //执行增加
+            unset($data['id']);
+            $return = $this->add($data);
+        }
+        if($return!==false){
+            return true;
+        }
+        return false;
+    }
+
+}

+ 49 - 0
Application/Admin/Model/BarProductModel.class.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+/**
+ * 配置模型
+ *
+ */
+class BarProductModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'bar_product';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('code', 'require', '产品代码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('code', '4,6', '产品代码长度为4-6个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('code', '', '产品代码已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('title', 'require', '自定义名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('title', '', '自定义名称已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('code1', 'require', '客户产品代码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('code1', '13', '客户产品代码长度为13个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('standard', 'require', '产品规格不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+
+    );
+
+    /*删除商品配置*/
+    public function delBarProduct($id){
+        if($this->delete($id)){
+            return true;
+        }
+        return false;
+    }
+}

+ 92 - 0
Application/Admin/Model/BarSmallModel.class.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+/**
+ * 配置模型
+ *
+ */
+class BarSmallModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'bar_small';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        /*array('code', 'require', '产品代码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('code', '4,6', '产品代码长度为4-6个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('code', '', '产品代码已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('title', 'require', '自定义名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('title', '', '自定义名称已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),*/
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+
+    );
+
+    /**
+     * 获取大件
+     * @return array 配置数组
+     *
+     */
+    public function getList($where = [],$p)
+    {
+        $list = $this->where($where)->order('id desc')->limit($p->firstRow, $p->listRows)->select();
+        return $list;
+    }
+
+    public function slectById($id){
+        $list = $this->where('id ='.$id)->select();
+        return $list;
+    }
+
+    public function getById($list){
+        header("Content-type: text/html; charset=utf-8");
+        $where = array();
+        $where['id'] = array('in',$list);
+        $field = "sn,name,time,num,standard,inspector,batch_number,board_no,quality_no";
+        $data = $this->field($field)->where($where)->select();
+        $new = array();
+        foreach($data as $v){
+            $arr = array();
+            $arr = $v;
+            $arr['custome_name'] = '湖北中烟工业有限公司';
+            $arr['date'] = date('Y',$v['time']).'年'.date('m',$v['time']).'月'.date('d',$v['time']).'日';
+            $arr['sn'] = preg_replace("/[\(\)]/","",$v['sn']);
+            unset( $arr['time']);
+            $new[]= $arr;
+        }
+        return $new;
+
+    }
+
+
+    /*保存产品信息*/
+    public function save1($data){
+        $id = $data['id'];
+        if($id){
+            //执行更新
+            $return = $this->save($data);
+        }else{
+            //执行增加
+            $return = $this->add($data);
+        }
+        if($return!==false){
+            return true;
+        }
+        return false;
+    }
+
+}

+ 68 - 0
Application/Admin/Model/ConfigModel.class.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+/**
+ * 配置模型
+ *
+ */
+class ConfigModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'admin_config';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('group', 'require', '配置分组不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('type', 'require', '配置类型不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('name', 'require', '配置名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('name', '1,32', '配置名称长度为1-32个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('name', '', '配置名称已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('title', 'require', '配置标题必须填写', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('title', '1,32', '配置标题长度为1-32个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('title', '', '配置标题已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+        array('create_time', 'time', self::MODEL_INSERT, 'function'),
+        array('update_time', 'time', self::MODEL_BOTH, 'function'),
+        array('status', '1', self::MODEL_BOTH),
+    );
+
+    /**
+     * 获取配置列表与ThinkPHP配置合并
+     * @return array 配置数组
+     *
+     */
+    public function lists()
+    {
+        $map['status'] = array('eq', 1);
+        $list          = $this->where($map)->field('name,value,type')->select();
+        foreach ($list as $key => $val) {
+            switch ($val['type']) {
+                case 'array':
+                    $config[$val['name']] = \Util\Str::parseAttr($val['value']);
+                    break;
+                case 'checkbox':
+                    $config[$val['name']] = explode(',', $val['value']);
+                    break;
+                default:
+                    $config[$val['name']] = $val['value'];
+                    break;
+            }
+        }
+        return $config;
+    }
+}

+ 61 - 0
Application/Admin/Model/GroupModel.class.php

@@ -0,0 +1,61 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+/**
+ * 部门模型
+ *
+ */
+class GroupModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'admin_group';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('title', 'require', '部门名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('title', '1,32', '部门名称长度为1-32个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('title', '', '部门名称已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('menu_auth', 'require', '权限不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+        array('create_time', 'time', self::MODEL_INSERT, 'function'),
+        array('update_time', 'time', self::MODEL_BOTH, 'function'),
+        array('status', '1', self::MODEL_INSERT),
+    );
+
+    /**
+     * 检查部门功能权限
+     *
+     */
+    public function checkMenuAuth()
+    {
+        $current_menu = D('Admin/Module')->getCurrentMenu(); // 当前菜单
+        $user_group = D('Admin/Access')->getFieldByUid(session('user_auth.uid'), 'group'); // 获得当前登录用户信息
+        if ($user_group !== '1') {
+            $group_info = $this->find($user_group);
+            // 获得当前登录用户所属部门的权限列表
+            $group_auth = json_decode($group_info['menu_auth'], true);
+            if (in_array($current_menu['id'], $group_auth[MODULE_NAME])) {
+                return true;
+            }
+
+        } else {
+            return true; // 超级管理员无需验证
+        }
+        return false;
+    }
+}

+ 155 - 0
Application/Admin/Model/HookModel.class.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+/**
+ * 插件钩子模型
+ * 该类参考了OneThink的部分实现
+ *
+ */
+class HookModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'admin_hook';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('name', 'require', '钩子名称必须!', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('name', '1,32', '钩子名称长度为1-32个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('name', '', '钩子名称已经存在', self::VALUE_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('description', 'require', '钩子描述必须!', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+        array('create_time', 'time', self::MODEL_INSERT, 'function'),
+        array('update_time', 'time', self::MODEL_BOTH, 'function'),
+        array('sort', '0', self::MODEL_INSERT),
+        array('status', '1', self::MODEL_INSERT),
+    );
+
+    /**
+     * 获取件所需的钩子是否存在,没有则新增
+     * @param string $str  钩子名称
+     * @param string $addons  插件名称
+     * @param string $addons  件简介
+     *
+     */
+    public function existHook($name, $data)
+    {
+        $where['name'] = $name;
+        $gethook       = $this->where($where)->find();
+        if (!$gethook || empty($gethook) || !is_array($gethook)) {
+            $data['name']        = $name;
+            $data['description'] = $data['description'];
+            $data['type']        = 1;
+            if (false !== $this->create($data)) {
+                $this->add();
+            }
+        }
+    }
+
+    /**
+     * 更新插件里的所有钩子对应的插件
+     */
+    public function updateHooks($addons_name)
+    {
+        $addons_class = get_addon_class($addons_name); //获取插件名
+        if (!class_exists($addons_class)) {
+            $this->error = "未实现{$addons_name}插件的入口文件";
+            return false;
+        }
+        $methods = get_class_methods($addons_class);
+        $hooks   = $this->getField('name', true);
+        $common  = array_intersect($hooks, $methods);
+        if (!empty($common)) {
+            foreach ($common as $hook) {
+                $flag = $this->updateAddons($hook, array($addons_name));
+                if (false === $flag) {
+                    $this->removeHooks($addons_name);
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 更新单个钩子处的插件
+     */
+    public function updateAddons($hook_name, $addons_name)
+    {
+        $o_addons = $this->where("name='{$hook_name}'")->getField('addons');
+        if ($o_addons) {
+            $o_addons = explode(',', $o_addons);
+        }
+        if ($o_addons) {
+            $addons = array_merge($o_addons, $addons_name);
+            $addons = array_unique($addons);
+        } else {
+            $addons = $addons_name;
+        }
+        $flag = $this->where("name='{$hook_name}'")
+            ->setField('addons', implode(',', $addons));
+        if (false === $flag) {
+            $this->where("name='{$hook_name}'")
+                ->setField('addons', implode(',', $o_addons));
+        }
+        return $flag;
+    }
+
+    /**
+     * 去除插件所有钩子里对应的插件数据
+     */
+    public function removeHooks($addons_name)
+    {
+        $addons_class = get_addon_class($addons_name);
+        if (!class_exists($addons_class)) {
+            return false;
+        }
+        $methods = get_class_methods($addons_class);
+        $hooks   = $this->getField('name', true);
+        $common  = array_intersect($hooks, $methods);
+        if ($common) {
+            foreach ($common as $hook) {
+                $flag = $this->removeAddons($hook, array($addons_name));
+                if (false === $flag) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 去除单个钩子里对应的插件数据
+     */
+    public function removeAddons($hook_name, $addons_name)
+    {
+        $o_addons = $this->where("name='{$hook_name}'")->getField('addons');
+        $o_addons = explode(',', $o_addons);
+        if ($o_addons) {
+            $addons = array_diff($o_addons, $addons_name);
+        } else {
+            return true;
+        }
+        $flag = $this->where("name='{$hook_name}'")
+            ->setField('addons', implode(',', $addons));
+        if (false === $flag) {
+            $this->where("name='{$hook_name}'")
+                ->setField('addons', implode(',', $o_addons));
+        }
+        return $flag;
+    }
+}

+ 245 - 0
Application/Admin/Model/ModuleModel.class.php

@@ -0,0 +1,245 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+use Think\Storage;
+use Util\Tree;
+
+/**
+ * 功能模块模型
+ *
+ */
+class ModuleModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'admin_module';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('name', 'require', '模块名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('name', '', '该模块已存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('title', 'require', '模块标题不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('description', 'require', '模块描述不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('developer', 'require', '模块开发者不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('version', 'require', '模块版本不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('admin_menu', 'require', '模块菜单节点不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+        array('create_time', 'time', self::MODEL_INSERT, 'function'),
+        array('update_time', 'time', self::MODEL_BOTH, 'function'),
+        array('sort', '0', self::MODEL_INSERT),
+        array('status', '1', self::MODEL_INSERT),
+    );
+
+    /**
+     * 安装描述文件名
+     *
+     */
+    public function install_file()
+    {
+        return 'opencmf.php';
+    }
+
+    /**
+     * 获取模块菜单
+     *
+     */
+    public function getAdminMenu($module_name = MODULE_NAME)
+    {
+        // 获取模块左侧导航
+        $where['name'] = $module_name;
+        $module_info = $this->where($where)->find();
+        $_side_menu_list = json_decode($module_info['admin_menu'], true);
+
+        // 转换成树结构
+        $tree = new tree();
+        return $tree->list2tree($_side_menu_list);
+    }
+
+    /**
+     * 获取模块当前菜单
+     *
+     */
+    public function getCurrentMenu($module_name = MODULE_NAME)
+    {
+        $admin_menu = $this->getFieldByName($module_name, 'admin_menu');
+        $admin_menu = json_decode($admin_menu, true);
+        foreach ($admin_menu as $key => $val) {
+            if (isset($val['url'])) {
+                $config_url =$val['url'];
+                $current_url = MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME;
+                if ($config_url === $current_url) {
+                    $result = $val;
+                }
+            }
+        }
+        return $result;
+    }
+
+    /**
+     * 获取所有模块菜单
+     * @param string $addon_dir
+     *
+     */
+    public function getAllMenu()
+    {
+        $uid = is_login();
+        $user_group = D('Admin/Access')->getFieldByUid($uid, 'group'); // 获得当前登录用户信息
+        $group_info = D('Admin/Group')->find($user_group);
+        $group_auth = json_decode($group_info['menu_auth'], true); // 获得当前登录用户所属部门的权限列表
+        // 获取所有菜单
+        $menu_list = S('MENU_LIST_' . $uid);
+        if (!$menu_list || APP_DEBUG === true) {
+            $con['status'] = 1;
+            $system_module_list = $this->where($con)->order('sort asc, id asc')->select();
+            $tree = new tree();
+            $menu_list = array();
+
+            foreach ($system_module_list as $key => &$module) {
+                $menu = json_decode($module['admin_menu'], true);
+                if(!empty($group_auth['Admin'])) {//为空表示是管理员
+                    foreach ($menu as $k => $v) {
+                        if ($v['id'] == 1) continue;
+                        if (!in_array($v['id'], $group_auth['Admin'])) unset($menu[$k]);
+                    }
+                }
+
+                $temp = $tree->list2tree($menu);
+                $menu_list[$module['name']] = $temp[0];
+                $menu_list[$module['name']]['id'] = $module['id'];
+                $menu_list[$module['name']]['name'] = $module['name'];
+            }
+            S('MENU_LIST_' . $uid, $menu_list, 3600); // 缓存配置
+        }
+        return $menu_list;
+    }
+
+    /**
+     * 根据菜单ID的获取其所有父级菜单
+     * @param array $current_menu 当前菜单信息
+     * @return array 父级菜单集合
+     *
+     */
+    public function getParentMenu($current_menu = '', $module_name = MODULE_NAME)
+    {
+        if (!$current_menu) {
+            $current_menu = $this->getCurrentMenu();
+        }
+        if (!$current_menu) {
+            return false;
+        }
+        $admin_menu = $this->getFieldByName($module_name, 'admin_menu');
+        $admin_menu = json_decode($admin_menu, true);
+        $pid = $current_menu['pid'];
+        $temp = array();
+        $result[] = $current_menu;
+        while (true) {
+            foreach ($admin_menu as $key => $val) {
+                if ($val['id'] == $pid) {
+                    $pid = $val['pid'];
+                    array_unshift($result, $val); // 将父菜单插入到第一个元素前
+                }
+            }
+            if ($pid == '0') {
+                break;
+            }
+        }
+        return $result;
+    }
+
+    /**
+     * 获取模块列表
+     * @param string $addon_dir
+     *
+     */
+    public function getAll()
+    {
+        // 获取除了Common等系统模块外的用户模块
+        // 文件夹下必须有$install_file定义的安装描述文件
+        $dirs = array_map('basename', glob(APP_PATH . '*', GLOB_ONLYDIR));
+        foreach ($dirs as $dir) {
+            $config_file = realpath(APP_PATH . $dir) . '/' . $this->install_file();
+            if (Storage::has($config_file)) {
+                $module_dir_list[] = $dir;
+                $temp_arr = include $config_file;
+                $temp_arr['info']['status'] = -1; //未安装
+                $module_list[$temp_arr['info']['name']] = $temp_arr['info'];
+            }
+        }
+
+        // 获取系统已经安装的模块信息
+        $installed_module_list = $this->field(true)
+            ->order('sort asc,id asc')
+            ->select();
+        if ($installed_module_list) {
+            foreach ($installed_module_list as &$module) {
+                $new_module_list[$module['name']] = $module;
+                $new_module_list[$module['name']]['admin_menu'] = json_decode($module['admin_menu'], true);
+            }
+            // 系统已经安装的模块信息与文件夹下模块信息合并
+            $module_list = array_merge($module_list, $new_module_list);
+        }
+
+        foreach ($module_list as &$val) {
+            switch ($val['status']) {
+                case '-2': // 损坏
+                    $val['status_icon'] = '<span class="text-danger">删除记录</span>';
+                    $val['right_button']['damaged']['title'] = '删除记录';
+                    $val['right_button']['damaged']['attribute'] = 'class="label label-danger ajax-get" href="' . U('setStatus', array('status' => 'delete', 'ids' => $val['id'])) . '"';
+                    break;
+                case '-1': // 未安装
+                    $val['status_icon'] = '<i class="fa fa-download text-success"></i>';
+                    $val['right_button']['install_before']['title'] = '安装';
+                    $val['right_button']['install_before']['attribute'] = 'class="label label-success" href="' . U('install_before', array('name' => $val['name'])) . '"';
+                    break;
+                case '0': // 禁用
+                    $val['status_icon'] = '<i class="fa fa-ban text-danger"></i>';
+                    $val['right_button']['update_info']['title'] = '更新菜单';
+                    $val['right_button']['update_info']['attribute'] = 'class="label label-info ajax-get no-refresh" href="' . U('updateInfo', array('id' => $val['id'])) . '"';
+                    $val['right_button']['forbid']['title'] = '启用';
+                    $val['right_button']['forbid']['attribute'] = 'class="label label-success ajax-get" href="' . U('setStatus', array('status' => 'resume', 'ids' => $val['id'])) . '"';
+                    $val['right_button']['uninstall_before']['title'] = '卸载';
+                    $val['right_button']['uninstall_before']['attribute'] = 'class="label label-danger " href="' . U('uninstall_before', array('id' => $val['id'])) . '"';
+                    break;
+                case '1': // 正常
+                    $val['status_icon'] = '<i class="fa fa-check text-success"></i>';
+                    $val['right_button']['update_info']['title'] = '更新菜单';
+                    $val['right_button']['update_info']['attribute'] = 'class="label label-info ajax-get no-refresh" href="' . U('updateInfo', array('id' => $val['id'])) . '"';
+                    if (!$val['is_system']) {
+                        $val['right_button']['forbid']['title'] = '禁用';
+                        $val['right_button']['forbid']['attribute'] = 'class="label label-warning ajax-get" href="' . U('setStatus', array('status' => 'forbid', 'ids' => $val['id'])) . '"';
+                        $val['right_button']['uninstall_before']['title'] = '卸载';
+                        $val['right_button']['uninstall_before']['attribute'] = 'class="label label-danger " href="' . U('uninstall_before', array('id' => $val['id'])) . '"';
+                    }
+                    break;
+            }
+        }
+        return $module_list;
+    }
+
+    /**
+     * 获取模块名称列表
+     * @param string $addon_dir
+     *
+     */
+    public function getNameList()
+    {
+        $list = $this->getField('name', true);
+        foreach ($list as $val) {
+            $return[$val] = $val;
+        }
+        return $return;
+    }
+}

+ 226 - 0
Application/Admin/Model/NavModel.class.php

@@ -0,0 +1,226 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+use Util\Tree;
+
+/**
+ * 导航模型
+ *
+ */
+class NavModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'admin_nav';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('group', 'require', '导航分组必须', self::MUST_VALIDATE, 'regex', self::MODEL_INSERT),
+        array('title', 'require', '导航标题不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('type', 'require', '导航类型不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('url', '0,255', '链接长度为0-25个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+        array('value', 'get_value_by_type', self::MODEL_BOTH, 'callback'),
+        array('create_time', 'time', self::MODEL_INSERT, 'function'),
+        array('update_time', 'time', self::MODEL_BOTH, 'function'),
+        array('status', '1', self::MODEL_INSERT),
+    );
+
+    /**
+     * 查找后置操作
+     *
+     */
+    protected function _after_find(&$result, $options)
+    {
+        // 处理不同导航类型
+        switch ($result['type']) {
+            case 'link':
+                $result['url'] = $result['value'];
+                if (!$result['url']) {
+                    $result['href'] = C('HOME_PAGE');
+                } else {
+                    if (stristr($result['url'], (is_ssl() ? 'https://' : 'http://'))) {
+                        $result['href'] = $result['url'];
+                    } else {
+                        $result['href'] = U($result['url'], '', true, true);
+                    }
+                }
+                break;
+            case 'module':
+                $result['module_name'] = $result['value'];
+                $result['href']        = U('/' . ucfirst($result['value']), '', true, true);
+                break;
+            case 'page':
+                $result['content'] = $result['value'];
+                $result['href']    = U('Home/Nav/page', array('id' => $result['id']), true, true);
+                break;
+            case 'post':
+                $result['href'] = U('Home/Nav/lists', array('id' => $result['id']), true, true);
+                break;
+        }
+    }
+
+    /**
+     * 查找后置操作
+     *
+     */
+    protected function _after_select(&$result, $options)
+    {
+        foreach ($result as &$record) {
+            $this->_after_find($record, $options);
+        }
+    }
+
+    /**
+     * 导航类型
+     *
+     */
+    public function nav_type($id = 0)
+    {
+        $list['link']   = '链接';
+        $list['module'] = '模块';
+        $list['page']   = '单页';
+        $list['post']   = '文章列表';
+        return $id ? $list[$id] : $list;
+    }
+
+    /**
+     * 根据导航类型获取值
+     *
+     */
+    public function get_value_by_type($value)
+    {
+        if (!$value) {
+            switch (I('post.type')) {
+                case 'link':
+                    return I('post.url');
+                    break;
+                case 'module':
+                    return I('post.module_name');
+                    break;
+                case 'page':
+                    return I('post.content');
+                    break;
+            }
+        } else {
+            return $value;
+        }
+    }
+
+    /**
+     * 获取参数的所有父级导航
+     * @param int $id 导航id
+     * @return array 参数导航和父类的信息集合
+     *
+     */
+    public function getParentNav($id, $group = 'main')
+    {
+        if (empty($id)) {
+            return false;
+        }
+        $con['status'] = 1;
+        $con['group']  = array('eq', $group);
+        $nav_list      = $this->where($con)->field(true)->order('sort asc,id asc')->select();
+        $current_nav   = $this->field(true)->find($cid); //获取当前导航的信息
+        $result[]      = $current_nav;
+        $pid           = $current_nav['pid'];
+        while (true) {
+            foreach ($nav_list as $key => $val) {
+                if ($val['id'] == $pid) {
+                    $pid = $val['pid'];
+                    array_unshift($result, $val); //将父导航插入到第一个元素前
+                }
+            }
+            // 已找到顶级导航或者没有任何父导航
+            if ($pid == 0 || count($result) == 1) {
+                break;
+            }
+        }
+        return $result;
+    }
+
+    /**
+     * 获取导航树,指定导航则返回指定导航的子导航树,不指定则返回所有导航树,指定导航若无子导航则返回同级导航
+     * @param  integer $id    导航ID
+     * @param  boolean $field 查询字段
+     * @return array          导航树
+     *
+     */
+    public function getNavTree($id = 0, $group = 'main', $field = true)
+    {
+        if (!in_array(MODULE_NAME, array('Admin', 'Common')) && is_file(APP_PATH . MODULE_NAME . '/Model/NavModel.class.php')) {
+            $module_nav_tree = D(MODULE_NAME . '/Nav')->getNavTree($id, $group, $field);
+            if ($module_nav_tree) {
+                return $module_nav_tree;
+            }
+        }
+
+        // 开启默认模块并且使用默认模块布局
+        if (C('DEFAULT_MODULE_LAYOUT') && C('DEFAULT_PUBLIC_LAYOUT') && is_file(APP_PATH . C('DEFAULT_MODULE') . '/Model/NavModel.class.php')) {
+            $module_nav_tree = D(C('DEFAULT_MODULE') . '/Nav')->getNavTree($id, $group, $field);
+            if ($module_nav_tree) {
+                return $module_nav_tree;
+            }
+        }
+
+        // 获取当前导航信息
+        if ((int) $id > 0) {
+            $info = $this->find($id);
+            $id   = $info['id'];
+        }
+        // 获取所有导航
+        $map['status'] = array('eq', 1);
+        $map['group']  = array('eq', $group);
+        $tree          = new Tree();
+        $list          = $this->field($field)->where($map)->order('sort asc,id asc')->select();
+
+        // 返回当前导航的子导航树
+        $list = $tree->list2tree(
+            $list,
+            $pk = 'id',
+            $pid = 'pid',
+            $child = '_child',
+            $root = (int) $id
+        );
+        if (!$list) {
+            return $this->getSameLevelNavTree($id);
+        }
+        return $list;
+    }
+
+    /**
+     * 获取同级导航树
+     * @param  integer $id 导航ID
+     * @return array       导航树
+     *
+     */
+    public function getSameLevelNavTree($id = 0, $group = 'main')
+    {
+        //获取当前导航信息
+        if ((int) $id > 0) {
+            $nav_info    = $this->find($id);
+            $parent_info = $this->find($nav_info['pid']);
+            $id          = $info['id'];
+        }
+        //获取所有导航
+        $map['status'] = array('eq', 1);
+        $map['group']  = array('eq', $group);
+        $map['pid']    = array('eq', $nav_info['pid']);
+        $tree          = new Tree();
+        $list          = $this->field($field)->where($map)->order('sort asc,id asc')->select();
+        return $list;
+    }
+}

+ 46 - 0
Application/Admin/Model/QcodeCompanyModel.class.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+class QcodeCompanyModel extends ModelModel{
+    /*
+    * 数据库表名
+    *
+    */
+    protected $tableName = 'qcode_company';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('company_name', 'require', '供应商编码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('company_name', '', '供应商编码已经存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('postcode', 'require', '邮编不能为空', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('postcode', '6', '邮编长度为六位', self::MUST_VALIDATE, 'length', self::MODEL_BOTH),
+        array('phone', 'require', '联系电话不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('phone', "/0\d{2,3}-\d{7,8}/", '请填写正确的联系号码格式', self::MODEL_BOTH),
+        array('phone', '', '联系电话已重复', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('company_addres', 'require', '供应商编码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('company_code', 'require', '供应商编码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('company_code', '', '供应商编码已经重复', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('company_code', '12', '供应商编码为12位', self::MUST_VALIDATE, 'length', self::MODEL_BOTH),
+    );
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+
+    );
+
+    /*删除商品配置*/
+    public function DelQcodeCompany($id){
+        if($this->delete($id)){
+            return true;
+        }
+        return false;
+    }
+}

+ 44 - 0
Application/Admin/Model/QcodeProductModel.class.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+class QcodeProductModel extends ModelModel{
+/*
+* 数据库表名
+*
+*/
+    protected $tableName = 'qcode_product';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('product_name', 'require', '产品名称不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('product_name', '', '产品名称已存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('product_code', 'require', '产品编码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('product_code', '', '产品编码已存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('product_size', 'require', '产品尺寸不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('product_num', 'require', '产品批次不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('product_num', '', '产品批次已经存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('temple', 'require', '产品代号不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('temple', '', '产品代号已经存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+    );
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+
+    );
+
+    /*删除商品配置*/
+    public function DelQcodeProduct($id){
+        if($this->delete($id)){
+            return true;
+        }
+        return false;
+    }
+}

+ 17 - 0
Application/Admin/Model/QrViewModel.class.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace Admin\Model;
+
+
+use Think\Model\ViewModel;
+
+class QrViewModel extends ViewModel
+{
+    public $viewFields = array(
+        'bach'=>array(),
+        'bach_product'=>array('num','is_verif','_on'=>'bach.id=bach_product.bach_id'),
+        'product_box_type'=>array('_on'=>'bach_product.product_id=product_box_type.id'),
+        'product'=>array('name'=>'product_name','_on'=>'product_box_type.product_id=product.id'),
+        'box_type'=>array('name'=>'box_type_name','_on'=>'product_box_type.box_type_id=box_type.id')
+    );
+}

+ 356 - 0
Application/Admin/Model/UploadModel.class.php

@@ -0,0 +1,356 @@
+<?php
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+use Think\Upload;
+
+/**
+ * 上传模型
+ *
+ */
+class UploadModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'admin_upload';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('name', 'require', '文件名不能为空', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('path', 'require', '文件不能为空', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('size', 'require', '文件大小不能为空', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('md5', 'require', '文件Md5编码不能为空', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('sha1', 'require', '文件Sha1编码不能为空', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+        array('uid', 'is_login', self::MODEL_INSERT, 'function'),
+        array('create_time', 'time', self::MODEL_INSERT, 'function'),
+        array('update_time', 'time', self::MODEL_BOTH, 'function'),
+        array('status', '1', self::MODEL_INSERT),
+    );
+
+    /**
+     * 查找后置操作
+     *
+     */
+    protected function _after_find(&$result, $options)
+    {
+        //获取上传文件的地址
+        if ($result['url']) {
+            $result['real_path'] = $result['url'];
+        } else {
+            if (C('STATIC_DOMAIN')) {
+                $result['real_path'] = C('STATIC_DOMAIN') . $result['path'];
+            } else {
+                if (C('IS_API')) {
+                    $result['real_path'] = C('TOP_HOME_PAGE') . $result['path'];
+                } else {
+                    $result['real_path'] = __ROOT__ . $result['path'];
+                }
+            }
+        }
+        if (in_array($result['ext'], array('jpg', 'jpeg', 'png', 'gif', 'bmp'))) {
+            $result['show'] = '<img class="picture" src="' . $result['real_path'] . '">';
+        } else {
+            $result['show'] = '<i class="fa fa-file-' . $result['ext'] . '"></i>';
+        }
+    }
+
+    /**
+     * 查找后置操作
+     *
+     */
+    protected function _after_select(&$result, $options)
+    {
+        foreach ($result as &$record) {
+            $this->_after_find($record, $options);
+        }
+    }
+
+    /**
+     * 获取上传图片路径
+     * @param  int $id 文件ID
+     * @return string
+     *
+     */
+    public function getCover($id = null, $type = null)
+    {
+        if ($id) {
+            // 如果以http开头直接返回
+            if (strpos($id, "http") === 0) {
+                return $id;
+            }
+            $upload_info = $this->find($id);
+            $url         = $upload_info['real_path'];
+        }
+        if (!isset($url)) {
+            switch ($type) {
+                case 'default': // 默认图片
+                    $url = C('TMPL_PARSE_STRING.__HOME_IMG__') . '/default/default.gif';
+                    break;
+                case 'avatar': // 用户头像
+                    $url = C('TMPL_PARSE_STRING.__HOME_IMG__') . '/default/avatar.png';
+                    break;
+                case 'qr_code': // qr_code
+                    $url = C('TMPL_PARSE_STRING.__HOME_IMG__') . '/default/qr_code.png';
+                    break;
+                case 'qr_ios': // qr_ios
+                    $url = C('TMPL_PARSE_STRING.__HOME_IMG__') . '/default/qr_ios.png';
+                    break;
+                case 'qr_android': // qr_android
+                    $url = C('TMPL_PARSE_STRING.__HOME_IMG__') . '/default/qr_android.png';
+                    break;
+                case 'qr_weixin': // qr_weixin
+                    $url = C('TMPL_PARSE_STRING.__HOME_IMG__') . '/default/qr_weixin.png';
+                    break;
+                default:
+                    $url = '';
+                    break;
+            }
+        }
+        return $url;
+    }
+
+    /**
+     * 获取上传文件信息
+     * @param  int $id 文件ID
+     * @return string
+     *
+     */
+    public function getUploadInfo($id, $field)
+    {
+        $upload_info = $this->where('status = 1')->find($id);
+        if ($field) {
+            if (!$upload_info[$field]) {
+                return $upload_info['id'];
+            } else {
+                return $upload_info[$field];
+            }
+        }
+        return $upload_info;
+    }
+
+    /**
+     * 上传文件
+     *
+     */
+    public function upload($files)
+    {
+        // 获取文件信息
+        $_FILES = $files ? $files : $_FILES;
+
+        // 返回标准数据
+        $return = array('error' => 0, 'success' => 1, 'status' => 1);
+        $dir    = I('request.dir') ? I('request.dir') : 'image'; // 上传类型image、flash、media、file
+        if (!in_array($dir, array('image', 'flash', 'media', 'file'))) {
+            $return['error']   = 1;
+            $return['success'] = 0;
+            $return['status']  = 0;
+            $return['message'] = '缺少上传参数!';
+            return $return;
+        }
+
+        // 上传文件钩子,用于七牛云、又拍云等第三方文件上传的扩展
+        hook('UploadFile', $dir);
+
+        // 根据上传文件类型改变上传大小限制
+        $upload_config = C('UPLOAD_CONFIG');
+        if ($_GET['temp'] === 'true') {
+            $upload_config['rootPath'] = './Runtime/';
+        }
+        $upload_driver = C('UPLOAD_DRIVER');
+        if (!$upload_driver) {
+            $return['error']   = 1;
+            $return['success'] = 0;
+            $return['status']  = 0;
+            $return['message'] = '无效的文件上传驱动';
+            return $return;
+        }
+
+        // 友情提醒
+        $upload_max_filesize = substr(ini_get('upload_max_filesize'), 0, -1);
+        $post_max_size       = substr(ini_get('post_max_size'), 0, -1);
+        if ($post_max_size < $upload_max_filesize) {
+            $return['error']   = 1;
+            $return['success'] = 0;
+            $return['status']  = 0;
+            $return['message'] = '警告:php.ini里post_max_size值应该设置比upload_max_filesize大';
+            return $return;
+        }
+
+        if ($dir == 'image') {
+            if (C('UPLOAD_IMAGE_SIZE')) {
+                if (C('UPLOAD_IMAGE_SIZE') > $upload_max_filesize) {
+                    $return['error']   = 1;
+                    $return['success'] = 0;
+                    $return['status']  = 0;
+                    $return['message'] = '警告:php.ini里upload_max_filesize值小于系统后台设置的图片上传大小';
+                    return $return;
+                }
+                $upload_config['maxSize'] = C('UPLOAD_IMAGE_SIZE') * 1024 * 1024; // 图片的上传大小限制
+            }
+        } else {
+            if (C('UPLOAD_FILE_SIZE')) {
+                if (C('UPLOAD_FILE_SIZE') > $upload_max_filesize) {
+                    $return['error']   = 1;
+                    $return['success'] = 0;
+                    $return['status']  = 0;
+                    $return['message'] = '警告:php.ini里upload_max_filesize值小于系统后台设置的文件上传大小';
+                    return $return;
+                }
+                $upload_config['maxSize'] = C('UPLOAD_FILE_SIZE') * 1024 * 1024; // 普通文件上传大小限制
+            }
+        }
+
+        // 上传配置
+        $ext_arr = array(
+            'image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp'),
+            'flash' => array('swf', 'flv'),
+            'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb', 'mp4'),
+            'file'  => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'wps', 'txt', 'zip', 'rar', 'gz', 'bz2', '7z', 'ipa', 'apk', 'dmg', 'iso'),
+        );
+
+        // 计算文件散列以查看是否已有相同文件上传过
+        $reay_file   = array_shift($_FILES);
+        $con['md5']  = md5_file($reay_file['tmp_name']);
+        $con['sha1'] = sha1_file($reay_file['tmp_name']);
+        $con['size'] = $reay_file['size'];
+        $upload      = $this->where($con)->find();
+        if ($upload) {
+            // 发现相同文件直接返回
+            $return['id']   = $upload['id'];
+            $return['name'] = $upload['name'];
+            $return['url']  = $upload['real_path'];
+            $return['path'] = '.' . $upload['path'];
+        } else {
+            // 上传文件
+            $upload_config['removeTrash'] = array($this, 'removeTrash');
+            $upload                       = new Upload($upload_config, $upload_driver, C("UPLOAD_{$upload_driver}_CONFIG")); // 实例化上传类
+            $upload->exts                 = $ext_arr[$dir] ? $ext_arr[$dir] : $ext_arr['image']; // 设置附件上传允许的类型,注意此处$dir为空时漏洞
+            $info                         = $upload->uploadOne($reay_file); // 上传文件
+            if (!$info) {
+                $return['error']   = 1;
+                $return['success'] = 0;
+                $return['status']  = 0;
+                $return['message'] = '上传出错' . $upload->getError();
+            } else {
+                // 获取上传数据
+                if ($_GET['temp'] === 'true') {
+                    $upload_data['name'] = $info["name"];
+                    $upload_data['path'] = '/Runtime/' . $info['savepath'] . $info['savename'];
+                    $upload_data['url']  = $info["url"] ?: '';
+
+                    // 返回数据
+                    if ($upload_data["url"]) {
+                        $return['url'] = $upload_data['url'];
+                    } else {
+                        $return['url'] = __ROOT__ . $upload_data['path'];
+                    }
+                    $return['path'] = '.' . $upload_data['path'];
+                    $return['name'] = $upload_data['name'];
+                } else {
+                    $upload_data['type']     = $info["type"];
+                    $upload_data['name']     = $info["name"];
+                    $upload_data['path']     = '/Uploads/' . $info['savepath'] . $info['savename'];
+                    $upload_data['url']      = $info["url"] ?: '';
+                    $upload_data['ext']      = $info["ext"];
+                    $upload_data['size']     = $info["size"];
+                    $upload_data['md5']      = $info['md5'];
+                    $upload_data['sha1']     = $info['sha1'];
+                    $upload_data['location'] = $upload_driver;
+
+                    // 返回数据
+                    $result = $this->create($upload_data);
+                    $result = $this->add($result);
+                    if ($result) {
+                        if ($info["url"]) {
+                            $return['url'] = $upload_data['url'];
+                        } else {
+                            $return['url'] = __ROOT__ . $upload_data['path'];
+                        }
+                        $return['path'] = '.' . $upload_data['path'];
+                        $return['name'] = $upload_data['name'];
+                        $return['id']   = $result;
+                    } else {
+                        $return['error']   = 1;
+                        $return['success'] = 0;
+                        $return['status']  = 0;
+                        $return['message'] = '上传出错' . $this->error;
+                    }
+                }
+
+            }
+        }
+        return $return;
+    }
+
+    /**
+     * 下载指定文件
+     * @param  number  $root 文件存储根目录
+     * @param  integer $id   文件ID
+     * @param  string  $args 回调函数参数
+     * @return boolean false-下载失败,否则输出下载文件
+     */
+    public function download($id, $callback = null, $args = null)
+    {
+        // 获取下载文件信息
+        $file = $this->find($id);
+        if (!$file) {
+            $this->error = '不存在该文件!';
+            return false;
+        }
+        // 下载文件
+        switch ($file['location']) {
+            case 'Local': // 下载本地文件
+                return $this->downLocalFile($file, $callback, $args);
+            default:
+                $this->error = '不支持的文件存储类型!';
+                return false;
+        }
+    }
+
+    /**
+     * 下载本地文件
+     * @param  array    $file     文件信息数组
+     * @param  callable $callback 下载回调函数
+     * @param  string   $args     回调函数参数
+     * @return boolean            下载失败返回false
+     */
+    private function downLocalFile($file, $callback = null, $args = null)
+    {
+        $fiel_path = '.' . $file['path'];
+        if (file_exists($fiel_path)) {
+            // 调用回调函数
+            is_callable($callback) && call_user_func($callback, $args);
+
+            // 新增下载数
+            $this->where(array('id' => $file['id']))->setInc('download');
+
+            // 执行下载
+            header("Content-Description: File Transfer");
+            header('Content-type: ' . $file['type']);
+            header('Content-Length:' . $file['size']);
+            if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) {
+                // for IE
+                header('Content-Disposition: attachment; filename="' . rawurlencode($file['name']) . '"');
+            } else {
+                header('Content-Disposition: attachment; filename="' . $file['name'] . '"');
+            }
+            readfile($fiel_path);
+            exit;
+        } else {
+            $this->error = '文件已被删除!';
+            return false;
+        }
+    }
+}

+ 224 - 0
Application/Admin/Model/UserModel.class.php

@@ -0,0 +1,224 @@
+<?php
+
+namespace Admin\Model;
+
+use Common\Model\ModelModel;
+
+/**
+ * 用户模型
+ *
+ */
+class UserModel extends ModelModel
+{
+    /**
+     * 数据库表名
+     *
+     */
+    protected $tableName = 'admin_user';
+
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        //验证供应商编码
+        array('printer_code', 'require', '供应商编码不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('printer_code', '11', '供应商编码为11位', self::MUST_VALIDATE, 'length', self::MODEL_BOTH),
+        array('printer_code', '', '供应商编码已存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+
+        //验证邮政编码
+
+        array('postcode', 'require', '邮编不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        //array('postcode', '', '邮编已经存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('postcode', '6', '邮编长度为六位', self::MUST_VALIDATE, 'length', self::MODEL_BOTH),
+
+        //验证供应商地址
+
+        array('company_address', 'require', '供应商地址不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+
+        //验证用户名
+        array('username', 'require', '用户名不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('username', '3,32', '用户名长度为1-32个字符', self::MUST_VALIDATE, 'length', self::MODEL_BOTH),
+        array('username', '', '用户名被占用', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('username', '/^(?!_)(?!\d)(?!.*?_$)[\w]+$/', '用户名只可含有数字、字母、下划线且不以下划线开头结尾,不以数字开头!', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+
+
+
+        //验证密码
+        array('password', 'require', '密码不能为空', self::EXISTS_VALIDATE, 'regex', self::MODEL_UPDATE),
+        array('password', '6,30', '密码长度为6-30位', self::EXISTS_VALIDATE, 'length', self::MODEL_UPDATE),
+        array('password', '/(?!^(\d+|[a-zA-Z]+|[~!@#$%^&*()_+{}:"<>?\-=[\];\',.\/]+)$)^[\w~!@#$%^&*()_+{}:"<>?\-=[\];\',.\/]+$/', '密码至少由数字、字符、特殊字符三种中的两种组成', self::EXISTS_VALIDATE, 'regex', self::MODEL_UPDATE),
+        array('repassword', 'password', '两次输入的密码不一致', self::EXISTS_VALIDATE, 'confirm', self::MODEL_UPDATE),
+
+        //验证邮箱
+        array('email', 'email', '邮箱格式不正确', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('email', '1,32', '邮箱长度为1-32个字符', self::EXISTS_VALIDATE, 'length', self::MODEL_BOTH),
+        array('email', '', '邮箱被占用', self::EXISTS_VALIDATE, 'unique', self::MODEL_BOTH),
+
+        //验证手机号码
+        array('mobile', '/^1\d{10}$/', '手机号码格式不正确', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('mobile', '', '手机号被占用', self::EXISTS_VALIDATE, 'unique', self::MODEL_BOTH),
+
+        // 验证注册来源
+        array('reg_type', 'require', '注册来源不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_INSERT),
+    );
+
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+        array('score', '0', self::MODEL_INSERT),
+        array('money', '0', self::MODEL_INSERT),
+        array('reg_ip', 'get_client_ip', self::MODEL_INSERT, 'function', 1),
+        array('password', 'user_md5', self::MODEL_BOTH, 'function'),
+        array('create_time', 'time', self::MODEL_INSERT, 'function'),
+        array('update_time', 'time', self::MODEL_BOTH, 'function'),
+        array('status', '1', self::MODEL_INSERT),
+    );
+
+    /**
+     * 查找后置操作
+     *
+     */
+    protected function _after_find(&$result, $options)
+    {
+        $result['avatar_url'] = get_cover($result['avatar'], 'avatar');
+
+        $result['label'] = $result['nickname'] . '(' . $result['id'];
+        if ($result['email']) {
+            $result['label'] = $result['label'] . '-' . $result['email'];
+        }
+        $result['label'] = $result['label'] . ')';
+    }
+
+    /**
+     * 查找后置操作
+     *
+     */
+    protected function _after_select(&$result, $options)
+    {
+        foreach ($result as &$record) {
+            $this->_after_find($record, $options);
+        }
+    }
+
+    /**
+     * 根据用户ID获取用户信息
+     * @param  integer $id 用户ID
+     * @param  string $field
+     * @return array  用户信息
+     *
+     */
+    public function getUserInfo($id = null, $field = null)
+    {
+        if (!$id) {
+            return false;
+        }
+        if (D('Admin/Module')->where('name="User" and status="1"')->count()) {
+            $user_info = D('User/User')->detail($id);
+        } else {
+            $user_info = $this->find($id);
+        }
+        unset($user_info['password']);
+        if (!$field) {
+            return $user_info;
+        }
+        if ($user_info[$field]) {
+            return $user_info[$field];
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 用户登录
+     *
+     */
+    public function login($username, $password, $map = null)
+    {
+        //去除前后空格
+        $username = trim($username);
+        //匹配登录方式
+        if (preg_match("/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/", $username)) {
+            $map['email'] = array('eq', $username); // 邮箱登陆
+        } elseif (preg_match("/^1\d{10}$/", $username)) {
+            $map['mobile'] = array('eq', $username); // 手机号登陆
+        } else {
+            $map['username'] = array('eq', $username); // 用户名登陆
+        }
+        $map['status'] = array('eq', 1);
+        $user_info     = $this->where($map)->find(); //查找用户
+        if (!$user_info) {
+            $this->error = '用户不存在或被禁用!';
+        } else {
+            if (user_md5($password) !== $user_info['password']) {
+                $this->error = '密码错误!';
+            } else {
+                return $user_info;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 设置登录状态
+     *
+     */
+    public function auto_login($user)
+    {
+        // 记录登录SESSION和COOKIES
+        $auth = array(
+            'uid'      => $user['id'],
+            'username' => $user['username'],
+            'nickname' => $user['nickname'],
+            'avatar'   => $user['avatar'],
+            'printer_code'=>$user['printer_code'],
+            'mobile' =>$user['mobile'],
+            'postcode'=>$user['postcode'],
+            'company_address'=>$user['company_address'],
+            'addtype'=>$user['addtype'],
+            'last_tnum'=>$user['last_tnum'],
+        );
+        session('user_auth', $auth);
+        session('user_auth_sign', $this->data_auth_sign($auth));
+        return $this->is_login();
+    }
+
+    /**
+     * 数据签名认证
+     * @param  array  $data 被认证的数据
+     * @return string       签名
+     *
+     */
+    public function data_auth_sign($data)
+    {
+        // 数据类型检测
+        if (!is_array($data)) {
+            $data = (array) $data;
+        }
+        ksort($data); //排序
+        $code = http_build_query($data); // url编码并生成query字符串
+        $sign = sha1($code); // 生成签名
+        return $sign;
+    }
+
+    /**
+     * 检测用户是否登录
+     * @return integer 0-未登录,大于0-当前登录用户ID
+     *
+     */
+    public function is_login()
+    {
+        $user = session('user_auth');
+        if (empty($user)) {
+            return 0;
+        } else {
+            if (session('user_auth_sign') == $this->data_auth_sign($user)) {
+                return $user['uid'];
+            } else {
+                return 0;
+            }
+        }
+    }
+}

+ 42 - 0
Application/Admin/Model/VersionModel.class.php

@@ -0,0 +1,42 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Admin
+ * Date: 2018/8/28
+ * Time: 13:08
+ */
+
+namespace Admin\Model;
+
+
+use Common\Model\ModelModel;
+
+class VersionModel extends ModelModel
+{
+    protected $tableName = 'version';
+    /**
+     * 自动验证规则
+     *
+     */
+    protected $_validate = array(
+        array('version', 'require', '版本号不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('version', '', '版本号已存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+        array('update_info', 'require', '版本更新内容不能为空', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH),
+        array('update_info', '', '版本更新内容已存在', self::MUST_VALIDATE, 'unique', self::MODEL_BOTH),
+    );
+    /**
+     * 自动完成规则
+     *
+     */
+    protected $_auto = array(
+
+    );
+
+    /*删除商品配置*/
+    public function DelVersion($id){
+        if($this->delete($id)){
+            return true;
+        }
+        return false;
+    }
+}

+ 26 - 0
Application/Admin/View/Activate/error.html

@@ -0,0 +1,26 @@
+<html>
+    <head>
+        <title>温馨提示</title>
+        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">	
+        <meta content="telephone=no" name="format-detection">
+        <link href="__PUBLIC__/libs/css/global.css" rel="stylesheet" type="text/css">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/screenWeChatSharing.js"></script>
+    </head>
+    <body>
+        <div style="height: 30px;">&nbsp;</div>
+        <div style="width: 85%;margin: 0px auto;text-align: left;">
+            <span style="display: inline-block;background: #c63d3e;width: 8px;height: 23px;margin-right: 5px;vertical-align: top;"></span> 
+            <span style="display: inline-block;height: 25px;vertical-align: top;line-height: 25px;font-size: 19px;">温馨提示</span>
+        </div>
+        <div style="height: 50px;">&nbsp;</div>
+        <div style="font-size: 16px;margin: 0px auto;width: 90%;text-align: center;color: #d64025;">
+            <img src="__PUBLIC__/libs/imgs/error_flag.png" style="width: 50%;vertical-align: middle;"><br><br>
+            二维码不存在!
+        </div>
+        <div style="height: 30px;">&nbsp;</div>
+        <div style="width: 100%;background: #efebeb;color: #a3a3a3;text-align: center;padding: 20px 0px;">
+            如需帮助,请与商品商家联系
+        </div>
+        <div style="height: 20px;">&nbsp;</div>
+    </body>
+</html>

+ 32 - 0
Application/Admin/View/Activate/hjy.html

@@ -0,0 +1,32 @@
+<html lang="zh-cn" class="no-js">
+    <head>
+        <meta http-equiv="Content-Type">
+        <meta content="text/html; charset=utf-8">
+        <meta charset="utf-8">
+        <title>黄金叶</title>		
+        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="format-detection" content="email=no">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function() {
+                var innerHeight = window.innerHeight;
+                $("#imgDiv").css("height", innerHeight);
+                $(".imgAd").css("height", innerHeight);
+            });
+        </script>
+        <style type="text/css">
+            body,div,img {
+                margin: 0px;padding: 0px;
+            }
+            img {
+                border: none;
+            }
+        </style>
+    </head>
+    <body>
+    <div id="imgDiv" style="width: 100%; height: 670px;">
+        <img class="imgAd" src="__PUBLIC__/libs/imgs/ad_9.jpg" style="width: 100%; vertical-align: middle; height: 670px;">
+    </div>
+    </body>
+</html>

+ 68 - 0
Application/Admin/View/Activate/index.html

@@ -0,0 +1,68 @@
+<html>
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
+    <link rel="stylesheet" href="__PUBLIC__/libs/css/selectdata.css">
+    <link rel="stylesheet" href="__PUBLIC__/libs/css/sweetalert.css">
+    <title>真伪查询</title>
+</head>
+<body>
+    <div class="container">
+        <div class="inside-container">
+            <!--<p>烟包的验证码<span class="span">*</span></p>-->
+            <input name="code" id="code" type="hidden" value="{$url}" >
+            <div class="containers">
+                <div class='input-container'>
+                    <input name="varify" id="varify" class="input" placeholder="请输入包装内测的6位验证码">
+                </div>
+            </div>
+        </div>
+        <div>
+            <img class="agree" src="__PUBLIC__/libs/imgs/agree.jpg">
+        </div>
+        <div>
+            <button onclick="toSubmit()" class='submit' id="submit">验证真伪</button>
+        </div>
+    </div>
+
+</body>
+
+<script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+<script type="text/javascript" src="__PUBLIC__/libs/js/sweetalert.min.js"></script>
+<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
+<script type="text/javascript">
+
+    //用户提交数据
+    function toSubmit(){
+        var code = $('#code').val();
+        var varify = $('#varify').val();
+        console.log(varify);
+        //验证烟包的验证码
+        if(varify == ''){
+            swal("","请输入烟包的验证码");
+            return false;
+        }
+        //请求接口
+         $.ajax({
+            type:"POST",
+            url:"http://code.7in6.com/index.php?s=/Admin/Activate/selectdata.html",
+            data:{"code":code,"varify":varify},
+            success: function(result){
+                //判断返回值,弹出用户提示
+                if(result == 1){
+                     swal("", "验证成功", "success");
+                     window.location.href = "/index.php?s=/Admin/Activate/gosuccess.html";
+                }else{
+                     swal("", "验证码错误", "error");
+                }
+            },
+            error: function(e){
+                swal("","网络延迟,稍后操作.");
+            }
+        })
+
+    }
+
+</script>
+
+</html>

+ 80 - 0
Application/Admin/View/Activatelist/add.html

@@ -0,0 +1,80 @@
+<extend name="$_admin_public_layout"/>
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+</block>
+<script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;margin-bottom: 0;">
+        <legend style="margin-bottom: 0;">{$meta_title}</legend>
+    </fieldset>
+
+    <div style="margin: 20px">
+         <button class="layui-btn layui-btn-normal" id="return_task_button"><a style="text-decoration: none;" onclick="history.go(-1)">返回</a>
+        </button>
+    </div>
+
+    <!-- 表单上传 -->
+    <form class="layui-form" method="post" action="">
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">批次号</label>
+            <div class="layui-input-block">
+                <input style="width: 50%" type="text" name="active_batch" lay-verify="active_batch"  autocomplete="off" class="layui-input" id="code_num" value={$rand} readonly>
+            </div>
+        </div>
+        <div class="layui-form-item layui-form-text">
+            <label style="width: 150px" class="layui-form-label">备注</label>
+            <div class="layui-input-block">
+                <textarea id="remark" style="width: 50%" name="remark" placeholder="请输入您的备注信息" class="layui-textarea"></textarea>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <div class="layui-input-block">
+                <button id="ajaxSubmit" class="layui-btn" lay-submit lay-filter="submits">立即提交</button>
+                <button id="resect_id" type="reset" class="layui-btn layui-btn-primary">重置</button>
+            </div>
+        </div>
+
+    </form>
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        layui.use('form', function(){
+            var form = layui.form;
+            //自定义验证规则
+            form.verify({
+                code_num: [/^[0-9]+(.[0-9]{0,4})?$/,'数量只能是大于0的数字!']
+            });
+
+            //表单提交
+            form.on('submit(submits)', function(data){
+                var param = data.field;
+                $.ajax({
+                    async: false,
+                    url: "{:U('Activatelist/add')}",
+                    type: 'POST',
+                    data: param,
+                    timeout: 1000,//1秒
+                    dataType: 'json',
+                    success: function(result) {
+                        if(result.status == '1'){
+                            layer.alert(result.info, function(index){
+                                parent.location.href=result.url;
+                            });
+                        } else {
+                            layer.alert(result.info);
+                            return false;
+                        }
+                    }
+                });
+                return false;
+            });
+        });
+
+    </script>
+</block>

+ 224 - 0
Application/Admin/View/Activatelist/detail.html

@@ -0,0 +1,224 @@
+<extend name="$_admin_public_layout"/>
+<script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;margin-bottom: 20px;">
+        <legend style="margin-bottom: 0;">{$meta_title}</legend>
+    </fieldset>
+    <div class="layui-text layui-bg-red">
+        [备注:激活中不能追加文件,不能再次激活,激活完成可以再次追加文件和激活]
+    </div>
+    <!-- 列表 -->
+    <table class="layui-table">
+        <colgroup>
+            <col width="60">
+            <col width="290">
+            <col>
+        </colgroup>
+        <thead>
+        <volist name="detail" id="v">
+            <tr>
+                <th>编号</th>
+                <th>
+                    {$v.id}
+                </th>
+            </tr>
+            <tr>
+                <th>总条数|成功条数|失败条数</th>
+                <th><?php echo $v['num']/10000;?>万条|<?php echo $v['succ']/10000;?>万条|<?php echo $v['fail']/10000;?>万条</th>
+            </tr>
+            <tr>
+                <th>上传时间</th>
+                <th>{$v.time|date="Y-m-d H:i:s",###}</th>
+            </tr>
+            <tr>
+                <th>批次编码</th>
+                <th>{$v.active_batch}</th>
+            </tr>
+			<tr>
+                <th>未激活文件列表</th>
+                <th>{$upload_txt}</th>
+            </tr>
+			<tr>
+                <th>已激活文件列表</th>
+                <th>{$active_txt}</th>
+            </tr>
+            <tr>
+                <th>激活状态</th>
+                <th> 
+                    <if condition="$status eq 0">
+                        未激活
+                    <elseif condition="$status eq 1"/>激活中
+                    <else /> 已激活
+                    </if>
+                </th>
+            </tr>
+            <tr>
+                <th>备注</th>
+                <th>{$v.remark}</th>
+            </tr>  
+        </volist>
+        </thead>
+    </table>
+<if condition="getUserGroup(session('user_auth.uid')) eq 1">
+    <form enctype="multipart/form-data" method="post" class="layui-form" action="">
+        <div class="layui-upload">
+            <div class="layui-upload-list">
+                <table class="layui-table">
+                    <thead>
+                    <tr>
+                        <th>文件名</th>
+                        <th>大小</th>
+                        <th>状态</th>
+                        <th>操作</th>
+                    </tr>
+                    </thead>
+                    <tbody id="demoList"></tbody>
+                </table>
+            </div>
+
+            <div>
+                <if condition="$v.status eq 0">
+                    <button style="margin-left:2%" type="button" class="layui-btn layui-btn-normal" id="fileList">选择多文件</button>
+                    <button style="margin-left:0.8%" type="button" class="layui-btn" id="testListAction">开始上传</button>
+                    <button id="submits_id" class="layui-btn layui-btn-warm" lay-submit lay-filter="submits">立即提交</button>
+                    <input type="button" class="layui-btn jihuo" value="提交任务">
+                </if>
+                <if condition="$v.fail gt 0 ">
+                    <button class="layui-btn" class="getfail" >查看失败</button>
+                </if>
+            </div>
+
+        </div>
+
+        <span id="hidden">
+            <input type='hidden' name='active_batch' value={$detail[0][active_batch]}>
+            <input type='hidden' name='id' value={$detail[0][id]}>
+        </span>
+
+    </form>
+    <script>
+        $('.jihuo').off('click').click(function(){
+            var active_batch  = $("input[name='active_batch']").val();
+            if(active_batch==''){
+                layer.msg('激活批次号缺少');
+            }else{
+                layer.msg('任务已提交');
+            }
+            //激活二维码
+            $.ajax({
+                type:'post',
+                url:"{:U('Auto/togetTxtActivefile')}",
+                data:{active_batch:active_batch},
+                dataType:'json',		
+                success:function(result){
+                   return false;
+                   layer.msg(result.cont);
+                } 
+            })  
+        })
+        layui.use(['upload', 'layer', 'form'], function () {
+//            var filename='{$task_detail[0][task_name]}_{$task_detail[0][task_id]}.txt';
+            var $ = layui.jquery
+                , upload = layui.upload,
+                layer = layui.layer,
+                form = layui.form;
+
+            //多文件列表示例
+            var demoListView = $('#demoList'),
+                uploadListIns = upload.render({
+                elem: '#fileList',
+                url: "{:U('Qr1/UploadTemp')}",
+                accept: 'file',//指定允许上传的文件类型
+                exts: 'txt',//允许上传的文件后缀
+                multiple: true,//是否允许多文件上传
+                auto: false,//是否选完文件后自动上传
+                bindAction: '#testListAction',//指向一个按钮触发上传
+                choose: function (obj) { //选择文件后的回调函数
+                    var files = obj.pushFile(); //将每次选择的文件追加到文件队列
+                    //读取本地文件
+                    obj.preview(function (index, file, result) {
+                        var tr = $(['<tr id="upload-' + index + '">'
+                            , '<td>' + file.name + '</td>'
+                            , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
+                            , '<td>等待上传</td>'
+                            , '<td>'
+                            , '<button class="layui-btn layui-btn-mini layui-btn-danger demo-delete">删除</button>'
+                            , '</td>'
+                            , '</tr>'].join(''));
+
+                        //删除
+                        tr.find('.demo-delete').on('click', function () {
+                            delete files[index]; //删除对应的文件
+                            tr.remove();
+                        });
+                        demoListView.append(tr);
+                    });
+                }
+                , done: function (res, index, upload) {
+                    if (res.code == 1) { //上传成功
+                        var tr = demoListView.find('tr#upload-' + index)
+                            , tds = tr.children();
+                        tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
+                        tds.eq(3).html(''); //清空操作
+                        $('#hidden').append("<input type='hidden' name='url[]' value=" + res.file + ">");
+                         //delete files[index]; //删除文件队列已经上传成功的文件
+                        return;
+                    }
+                    layer.msg(res.msg);
+                    this.error(index, upload);
+                }
+                , error: function (index, upload) {
+                    var tr = demoListView.find('tr#upload-' + index)
+                        , tds = tr.children();
+                    tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
+                    tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
+                }
+            });
+
+            form.on('submit(submits)', function (data) {
+                var url = [];
+                $("input[name='url[]']").each(function () {
+                    url.push($(this).val());
+                });
+                var active_batch  = $("input[name='active_batch']").val();
+                var id  = $("input[name='id']").val();
+                if (url.length == 0) {
+                    layer.msg('请选择上传的文件');
+                    return false;
+                }
+                $.ajax({
+                    async: false,//同步
+                    url: "{:U('Qr1/Upload')}",
+                    type: 'POST',
+                    data: {
+                        url: url,active_batch:active_batch,id:id
+                    },
+                    timeout: 1000,//1秒
+                    dataType: 'json',
+                    success: function (data) {
+                        layer.alert(data.msg, function (index) {
+                            window.location.href = '__SELF__';
+                        });
+                    }
+
+                });
+                return false;
+            });
+        });
+    </script>
+</if>
+</block>
+
+
+

+ 83 - 0
Application/Admin/View/Activatelist/index.html

@@ -0,0 +1,83 @@
+<extend name="$_admin_public_layout"/>
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+    <link rel="stylesheet" href="__PUBLIC__/libs/css/page.css" media="all">
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <legend style="margin-top: 20px;">{$meta_title}</legend>
+    <a href="{:U('Admin/Activatelist/add')}"><button class="layui-btn addactive" style="float:right;margin-bottom:10px">增加激活批次</button></a>
+    <div class="builder-table">
+        <!-- 列表 -->
+        <table class="layui-table">
+            <colgroup>
+                <col width="150">
+                <col width="200">
+            <col>
+            </colgroup>
+            <thead>
+            <tr>
+                <th>序号</th>
+                <th>总条数|成功条数|失败条数</th>
+                <th>上传时间</th>
+                <th>批次编码</th>
+                <th>激活状态</th>
+                <th>备注</th>
+                <th >操作</th>
+            </tr>
+            </thead>
+            <notempty name="page">
+            <tfoot>  
+                <tr><td colspan="7"><div class="pages">{$page}</div></td></tr>
+            </tfoot>
+            </notempty>
+            <tbody>
+            <empty name="list">
+                <tr><td colspan="7">亲,暂时还没数据</td></tr>  
+            <else/>
+                <volist name="list" id="v">
+                    <tr>
+                        <td>{$v.id}</td>
+                        <td><?php echo $v['num']/10000;?>万条|<?php echo $v['succ']/10000;?>万条|<?php echo $v['fail']/10000;?>万条</td>
+                        <td>{$v.time|date="Y-m-d H:i:s",###}</td>
+                        <td>{$v.active_batch}</td>
+                        <td>
+                            <?php if($v['succ']+$v['fail']==0){?>
+                                未激活
+                            <?php }else if($v['num']-$v['succ']-$v['fail']>0){?>
+                                激活中
+                            <?php }else{?>
+                                已激活
+                            <?php }?>
+                        </td>
+                        <td>
+                            {$v.remark}
+                        </td>
+                        <td>
+                           <a href="{:U('Activatelist/detail',array('id'=>$v['id']))}">查看详情...</a>
+                        </td>
+                    </tr>
+                </volist>
+            </empty>
+            </tbody>
+        </table>
+         
+    </div>
+
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        layui.use('form', function(){
+            var form = layui.form;
+
+        });
+    </script>
+</block>
+
+
+

+ 108 - 0
Application/Admin/View/ApplyBatch/addtaskindex.html

@@ -0,0 +1,108 @@
+<extend name="$_admin_public_layout"/>
+
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;margin-bottom: 0;">
+        <legend style="margin-bottom: 0;">{$meta_title}</legend>
+    </fieldset>
+
+    <div style="margin: 20px">
+        <button class="layui-btn layui-btn-normal" id="return_task_button"><a style="text-decoration: none;" href="{:U('ApplyBatch/taskdetail',array('task_id'=>$bach_contents[task_id]))}">返回</a>
+        </button>
+    </div>
+
+    <!-- 表单上传 -->
+    <form class="layui-form" method="post" action="">
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">批次补单名称</label>
+            <div class="layui-input-inline" id="add_task_id">
+                <select name="bach_id" readonly="readonly">
+                    <option selected value="{$bach_contents[bach_id]}">{$bach_contents[bach_name]}</option>
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">补单产品盒型</label>
+            <div class="layui-input-inline" id="product_type_id">
+                <select name="product_id" lay-verify="required">
+                    <option value>请选择补单产品盒型</option>
+                    <volist name="product_contents_list" id="v">
+                        <option value="{$v[product_id]}">{$v[box_type_name]}</option>
+                    </volist>
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">补单数量/万</label>
+            <div class="layui-input-block">
+                <input style="width: 50%" type="text" name="code_num" lay-verify="code_num" placeholder="请输入批次补单的目标数量" autocomplete="off" class="layui-input" id="code_num">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-form-text">
+            <label style="width: 150px" class="layui-form-label">备注</label>
+            <div class="layui-input-block">
+                <textarea id="remark" style="width: 50%" name="remark" placeholder="请输入您的备注信息" class="layui-textarea"></textarea>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <div class="layui-input-block">
+                <button id="ajaxSubmit" class="layui-btn" lay-submit lay-filter="submits">立即提交</button>
+                <button id="resect_id" type="reset" class="layui-btn layui-btn-primary">重置</button>
+            </div>
+        </div>
+
+    </form>
+
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        layui.use('form', function(){
+            var form = layui.form;
+
+            //自定义验证规则
+            form.verify({
+                code_num: [/^[0-9]+(.[0-9]{0,4})?$/,'数量只能是大于0的数字!']
+            });
+
+            //表单提交
+            form.on('submit(submits)', function(data){
+                var param = data.field;
+                $.ajax({
+                    async: false,
+                    url: "{:U('ApplyBatch/addTaskForm')}",
+                    type: 'POST',
+                    data: param,
+                    timeout: 1000,//1秒
+                    dataType: 'json',
+                    success: function(result) {
+                        console.log(result);
+                        console.log(result.status);
+                        if(result.status == '1'){
+                            layer.alert(result.info, function(index){
+                                parent.location.href=result.url;
+                            });
+                        } else {
+                            layer.alert(result.info);
+                            return false;
+                        }
+                    }
+                });
+                return false;
+            });
+        });
+
+    </script>
+</block>

+ 76 - 0
Application/Admin/View/ApplyBatch/applylist.html

@@ -0,0 +1,76 @@
+<extend name="$_admin_public_layout"/>
+
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;">
+        <legend>{$meta_title}</legend>
+    </fieldset>
+    <div class="builder-table">
+        <!-- 列表 -->
+        <table class="layui-table">
+            <colgroup>
+                <col width="150">
+                <col width="200">
+                <col>
+            </colgroup>
+            <thead>
+            <tr>
+                <th>序号</th>
+                <th id="batch_list_name">批次编号</th>
+                <th>下达日期</th>
+                <th>产品名称/盒型/码源数量</th>
+                <th id="caozuo">操作</th>
+            </tr>
+            </thead>
+            <tbody>
+            <volist name="bach_list" id="v">
+                <tr>
+                    <td>{$v.bach_id}</td>
+                    <td>
+                        <if condition="$v.bach_id gt 0 "><a href="{:U('ApplyBatch/tasklist',array('bach_id'=>$v['bach_id']))}">{$v.bach_name}</a>
+                            <else />...
+                        </if>
+                    </td>
+                    <td>{$v.add_time|date="Y-m-d H:i:s",###}</td>
+                    <td>
+                        <volist name="task_list2" id="value">
+                            <if condition="$v['bach_id'] eq $value['bach_id']">
+                                {$value.product_name}/{$value.box_type_name}/{$value.quality}万个&nbsp;&nbsp;&nbsp;
+                            </if>
+                        </volist>
+                    </td>
+                    <td>
+                        <if condition="$v.bach_id gt 0 "><a href="{:U('ApplyBatch/tasklist',array('bach_id'=>$v['bach_id']))}">详情</a>
+                            <else />...
+                        </if>
+                    </td>
+                </tr>
+            </volist>
+
+            </tbody>
+        </table>
+        <notempty name="bach_page">
+            <ul class="pagination">{$task_page}</ul>
+        </notempty>
+    </div>
+
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        layui.use('form', function(){
+            var form = layui.form;
+
+        });
+    </script>
+</block>
+
+
+

+ 133 - 0
Application/Admin/View/ApplyBatch/index.html

@@ -0,0 +1,133 @@
+<extend name="$_admin_public_layout"/>
+
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;">
+        <legend>{$meta_title}</legend>
+    </fieldset>
+
+    <!-- 表单上传 -->
+    <form class="layui-form" method="post" action="">
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">卷烟厂名称</label>
+            <div class="layui-input-inline" id="factory_id">
+                <select name="factory_id" lay-verify="required">
+                    <option value>请选择工厂名称</option>
+                    <volist name="factory_result" id="v">
+                        <option value="{$v[id]}">{$v[name]}</option>
+                    </volist>
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">印刷厂名称</label>
+            <div class="layui-input-inline" id="printer_id">
+                <select name="printer_id" lay-verify="required">
+                    <option value>请选择印刷厂名称</option>
+                    <volist name="printer" id="v">
+                        <option value="{$v[printer_id]}">{$v[printer_name]}</option>
+                    </volist>
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">产品名称</label>
+            <div class="layui-input-inline" id="product_id">
+                <select name="product_id" lay-verify="required">
+                    <option value>请选择产品名称</option>
+                    <volist name="product_result" id="v">
+                        <option value="{$v[id]}">{$v[name]}</option>
+                    </volist>
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">盒型:条盒数量/万</label>
+            <div class="layui-input-block">
+                <input style="width: 50%" type="text" name="code_num1" lay-verify="code_num" placeholder="请输入目标条盒的数量" autocomplete="off" class="layui-input" id="code_num1">
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">盒型:小包数量/万</label>
+            <div class="layui-input-block">
+                <input style="width: 50%" type="text" name="code_num2" lay-verify="code_num" placeholder="请输入目标小包的数量" autocomplete="off" class="layui-input" id="code_num2">
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">有无验证码</label>
+            <div class="layui-input-block">
+                <input type="radio" name="is_verif" value="1" title="有" id="is_verif_1">
+                <input type="radio" name="is_verif" value="0" title="无" checked="" id="is_verif_0">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-form-text">
+            <label style="width: 150px" class="layui-form-label">备注</label>
+            <div class="layui-input-block">
+                <textarea id="remark" style="width: 50%" name="remark" placeholder="请输入您的备注信息" class="layui-textarea"></textarea>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <div class="layui-input-block">
+                <button id="ajaxSubmit" class="layui-btn" lay-submit lay-filter="submits">立即提交</button>
+                <button id="resect_id" type="reset" class="layui-btn layui-btn-primary">重置</button>
+            </div>
+        </div>
+
+    </form>
+
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        layui.use('form', function(){
+            var form = layui.form;
+
+            //自定义验证规则
+            form.verify({
+                code_num: [/^[0-9]+(.[0-9]{0,4})?$/,'数量只能是数字!']
+            });
+
+            //表单提交
+            form.on('submit(submits)', function(data){
+                var param = data.field;
+                $.ajax({
+                    async: false,
+                    url: "{:U('ApplyBatch/applyform')}",
+                    type: 'POST',
+                    data: param,
+                    timeout: 1000,//1秒
+                    dataType: 'json',
+                    success: function(result) {
+                        console.log(result);
+                        console.log(result.status);
+                        if(result.status == '1'){
+                            layer.alert(result.info, function(index){
+                                parent.location.href=result.url;
+                            });
+                        } else {
+                            layer.alert(result.info);
+                            return false;
+                        }
+                    }
+                });
+                return false;
+            });
+        });
+
+    </script>
+</block>

+ 112 - 0
Application/Admin/View/ApplyBatch/index_old.html

@@ -0,0 +1,112 @@
+<extend name="$_admin_public_layout"/>
+
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+</block>
+
+<block name="main">
+    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
+        <legend>表单集合演示</legend>
+    </fieldset>
+
+    <!-- 表单上传 -->
+    <!--<form class="layui-form" method="post" action="{:U('ApplyBatch/ApplyForm')}">-->
+    <form class="layui-form" method="post" action="">
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">中烟公司名称</label>
+            <div class="layui-input-inline">
+                <select name="factory_id">
+                    <option>请选择中烟公司名称</option>
+                    <volist name="factory_result" id="v">
+                        <option value="{$v[id]}">{$v[name]}</option>
+                    </volist>
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">产品名称/规格盒型</label>
+            <div class="layui-input-inline">
+                <select name="product_id">
+                    <option>请选择产品名称</option>
+                    <volist name="product_result" id="v">
+                            <option value="{$v[id]}">{$v[name]}</option>
+                    </volist>
+                </select>
+            </div>
+            <div class="layui-input-inline">
+                <select name="box_type_id">
+                    <option>请选择规格盒型</option>
+                    <volist name="box_type_result" id="v">
+                        <option value="{$v[id]}">{$v[name]}</option>
+                    </volist>
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">数量/万</label>
+            <div class="layui-input-block">
+                <input style="width: 80%" type="text" name="code_num" lay-verify="required" placeholder="请输入二维码的数量" autocomplete="off" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label style="width: 150px" class="layui-form-label">有无验证码</label>
+            <div class="layui-input-block">
+                <input type="radio" name="is_verif" value="1" title="有">
+                <input type="radio" name="is_verif" value="0" title="无" checked="">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-form-text">
+            <label style="width: 150px" class="layui-form-label">备注</label>
+            <div class="layui-input-block">
+                <textarea style="width: 80%" name="remark" placeholder="请输入您的备注信息" class="layui-textarea"></textarea>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <div class="layui-input-block">
+                <button id="ajaxSubmit" class="layui-btn" lay-submit lay-filter="submits">立即提交</button>
+                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+            </div>
+        </div>
+
+    </form>
+
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        layui.use('form', function(){
+            var form = layui.form;
+
+            //表单验证
+            form.on('submit(submits)', function(data){
+                var param = data.field;
+                console.log(param);
+//                return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
+                $.ajax({
+                    async: false,
+                    url: "{:U('ApplyBatch/ApplyForm')}",
+//                    url: "http://www.smoke.com/index.php?s=/Admin/ApplyBatch/ApplyForm.html",
+                    type: 'POST',
+                    data: param,
+                    timeout: 1000,//1秒
+                    dataType: 'json',
+                    success: function(result) {
+                        if (result) {
+                            alert(11);
+                        }
+                    }
+                });
+                return false;
+            });
+        });
+
+    </script>
+</block>
+
+
+

+ 256 - 0
Application/Admin/View/ApplyBatch/taskdetail.html

@@ -0,0 +1,256 @@
+<extend name="$_admin_public_layout"/>
+
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;margin-bottom: 20px;">
+        <legend style="margin-bottom: 0;">{$meta_title}</legend>
+    </fieldset>
+	<div class="layui-text layui-bg-red">
+        [备注:激活中不能追加文件,不能再次激活,激活完成可以再次追加文件和激活]
+    </div>
+    <div style="margin: 20px">
+        <volist name="task_detail" id="v">
+            <button class="layui-btn layui-btn-normal" id="return_task_button"><a style="text-decoration: none;" href="{:U('ApplyBatch/tasklist',array('bach_id'=>$v['bach_id']))}">返回</a>
+            </button>
+            <if condition="getUserGroup(session('user_auth.uid')) eq 3">
+                <button class="layui-btn layui-btn-normal" id="add_task_button"><a style="text-decoration: none;" href="{:U('ApplyBatch/addtaskindex',array('task_id'=>$v['task_id']))}">任务补单申请</a>
+                </button>
+            </if>
+        </volist>
+    </div>
+
+    <!-- 列表 -->
+    <table class="layui-table">
+        <colgroup>
+            <col width="60">
+            <col width="290">
+            <col>
+        </colgroup>
+        <thead>
+        <volist name="task_detail" id="v">
+            <tr>
+                <th>校验类型</th>
+                <th>
+                    <if condition="$v.is_verif eq 0 ">无验证码
+                        <else/>
+                        有验证码
+                    </if>
+                </th>
+            </tr>
+            <tr>
+                <th>订单编号</th>
+                <th>{$v.task_name}</th>
+            </tr>
+            <tr>
+                <th>二维码数量</th>
+                <th>{$v.quality}万 (含{$redundancy_s}%冗余)</th>
+            </tr>
+            <tr>
+                <th>卷烟厂名称</th>
+                <th>{$v.factory_name}</th>
+            </tr>
+            <tr>
+                <th>产品名称</th>
+                <th>{$v.product_name}</th>
+            </tr>
+            <tr>
+                <th>产品类型</th>
+                <th>{$v.box_type_name}</th>
+            </tr>
+            <tr>
+                <th>文件名</th>
+                <th>{$v.task_name}_{$v.task_id}.txt ( 注意 : 如果此文件以多个文件上传 , 可以按下面的方式 : <span style="color: red">{$v.task_name}_{$v.task_id}_1.txt , {$v.task_name}_{$v.task_id}_2.txt , 依此类推</span> )</th>
+            </tr>
+            <tr>
+                <th>印刷总条数</th>
+                <th>{$v.quality}万条</th>
+            </tr>
+            <tr>
+                <th>成功条数</th>
+                <th>{$v.checked_num}万条</th>
+            </tr>
+            <tr>
+                <th>错码条数</th>
+                <th>{$v.wrong_num}万条</th>
+            </tr>
+        </volist>
+        </thead>
+    </table>
+
+<if condition="getUserGroup(session('user_auth.uid')) eq 1">
+    <form enctype="multipart/form-data" method="post" class="layui-form" action="">
+        <div class="layui-upload">
+            <div class="layui-upload-list">
+                <table class="layui-table">
+                    <thead>
+                    <tr>
+                        <th>文件名</th>
+                        <th>大小</th>
+                        <th>状态</th>
+                        <th>操作</th>
+                    </tr>
+                    </thead>
+                    <tbody id="demoList"></tbody>
+                </table>
+            </div>
+
+            <div>
+              	<if condition="$v.lock eq 0">
+                <button style="margin-left:2%" type="button" class="layui-btn layui-btn-normal" id="fileList">选择多文件</button>
+                <button style="margin-left:0.8%" type="button" class="layui-btn" id="testListAction">开始上传</button>
+                <button id="submits_id" class="layui-btn layui-btn-warm" lay-submit lay-filter="submits">立即提交</button>
+                 <input type="button" class="layui-btn jihuo" value="提交任务">
+                 </if>
+               <!-- <a href="{:U('Admin/ApplyBatch/taskdetail',array('task_id'=>2))}"><button  class="layui-btn layui-btn-danger">查看其他任务</button></a>-->
+            </div>
+
+        </div>
+
+        <span id="hidden">
+            <input type='hidden' name='tasks_id' value={$task_detail[0][task_id]}>
+            <input type='hidden' name='bach_id' value={$task_detail[0][bach_id]}>
+            <input type='hidden' name='product_id' value={$task_detail[0][product_id]}>
+            <input type='hidden' name='printer_id' value={$task_detail[0][printer_id]}>
+            <input type='hidden' name='task_name' value={$task_detail[0][task_name]}>
+        </span>
+
+    </form>
+    <script>
+        $('.jihuo').off('click').click(function(){
+            var tasks_id  = $("input[name='tasks_id']").val();
+            var bach_id  = $("input[name='bach_id']").val();
+            var product_id  = $("input[name='product_id']").val();
+            var printer_id  = $("input[name='printer_id']").val();
+            var task_name  = $("input[name='task_name']").val();
+            if(tasks_id==''|| bach_id==''|| product_id==''||printer_id==''){
+                layer.msg('缺少参数');
+            }else{
+                layer.msg('任务已提交');
+            }
+            //激活二维码
+            $.ajax({
+                type:'post',
+                url:"{:U('Auto/togetTxtAddfile')}",
+                data:{tasks_id:tasks_id,bach_id:bach_id,product_id:product_id,printer_id:printer_id,task_name:task_name},
+                dataType:'json',		
+                success:function(result){
+                   return false;
+                   layer.msg(result.cont);
+                } 
+            })
+        })
+        layui.use(['upload', 'layer', 'form'], function () {
+            var filename='{$task_detail[0][task_name]}_{$task_detail[0][task_id]}.txt';
+            var $ = layui.jquery
+                , upload = layui.upload,
+                layer = layui.layer,
+                form = layui.form;
+
+            //多文件列表示例
+            var demoListView = $('#demoList'),
+                uploadListIns = upload.render({
+                elem: '#fileList',
+                url: "{:U('Qr/UploadTemp')}",
+                accept: 'file',//指定允许上传的文件类型
+                exts: 'txt',//允许上传的文件后缀
+                multiple: true,//是否允许多文件上传
+                auto: false,//是否选完文件后自动上传
+                bindAction: '#testListAction',//指向一个按钮触发上传
+                choose: function (obj) { //选择文件后的回调函数
+                    var files = obj.pushFile(); //将每次选择的文件追加到文件队列
+                    //读取本地文件
+                    obj.preview(function (index, file, result) {
+
+                        if (file.name.indexOf('{$v.task_name}_{$v.task_id}') < 0) {
+                            delete files[index]; //删除对应的文件
+                            layer.msg('请核对文件名!');
+                        }else{
+                        var tr = $(['<tr id="upload-' + index + '">'
+                            , '<td>' + file.name + '</td>'
+                            , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
+                            , '<td>等待上传</td>'
+                            , '<td>'
+                            , '<button class="layui-btn layui-btn-mini layui-btn-danger demo-delete">删除</button>'
+                            , '</td>'
+                            , '</tr>'].join(''));
+
+                        //删除
+                        tr.find('.demo-delete').on('click', function () {
+                            delete files[index]; //删除对应的文件
+                            tr.remove();
+                        });
+
+                        demoListView.append(tr);
+                    }});
+                }
+                , done: function (res, index, upload) {
+                    if (res.code == 1) { //上传成功
+                        var tr = demoListView.find('tr#upload-' + index)
+                            , tds = tr.children();
+                        tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
+                        tds.eq(3).html(''); //清空操作
+                        $('#hidden').append("<input type='hidden' name='url[]' value=" + res.file + ">");
+                         //delete files[index]; //删除文件队列已经上传成功的文件
+
+                        return;
+                    }
+                    layer.msg(res.msg);
+                    this.error(index, upload);
+                }
+                , error: function (index, upload) {
+                    var tr = demoListView.find('tr#upload-' + index)
+                        , tds = tr.children();
+                    tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
+                    tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
+                }
+            });
+
+            form.on('submit(submits)', function (data) {
+
+                var url = [];
+                $("input[name='url[]']").each(function () {
+                    url.push($(this).val());
+                });
+                if (url.length == 0) {
+                    layer.msg('请选择上传的文件');
+                    return false;
+                }
+                if (url.length == 0) {
+                    layer.msg('请选择上传的文件');
+                    return false;
+                }
+                $.ajax({
+                    async: false,//同步
+                    url: "{:U('Qr/Upload')}",
+                    type: 'POST',
+                    data: {
+                        url: url,is_verif:{$task_detail['0']['is_verif']}
+                    },
+                    timeout: 1000,//1秒
+                    dataType: 'json',
+                    success: function (data) {
+                        layer.alert(data.msg, function (index) {
+                            window.location.href = '__SELF__';
+                        });
+                    }
+
+                });
+                return false;
+            });
+        });
+    </script>
+</if>
+</block>
+
+
+

+ 223 - 0
Application/Admin/View/ApplyBatch/taskdetail.html 0205

@@ -0,0 +1,223 @@
+<extend name="$_admin_public_layout"/>
+
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;margin-bottom: 0;">
+        <legend style="margin-bottom: 0;">{$meta_title}</legend>
+    </fieldset>
+
+    <div style="margin: 20px">
+        <volist name="task_detail" id="v">
+            <button class="layui-btn layui-btn-normal" id="return_task_button"><a style="text-decoration: none;" href="{:U('ApplyBatch/tasklist',array('bach_id'=>$v['bach_id']))}">返回</a>
+            </button>
+            <if condition="getUserGroup(session('user_auth.uid')) eq 3">
+                <button class="layui-btn layui-btn-normal" id="add_task_button"><a style="text-decoration: none;" href="{:U('ApplyBatch/addtaskindex',array('task_id'=>$v['task_id']))}">任务补单申请</a>
+                </button>
+            </if>
+        </volist>
+    </div>
+
+    <!-- 列表 -->
+    <table class="layui-table">
+        <colgroup>
+            <col width="60">
+            <col width="290">
+            <col>
+        </colgroup>
+        <thead>
+        <volist name="task_detail" id="v">
+            <tr>
+                <th>校验类型</th>
+                <th>
+                    <if condition="$v.is_verif eq 0 ">无验证码
+                        <else/>
+                        有验证码
+                    </if>
+                </th>
+            </tr>
+            <tr>
+                <th>订单编号</th>
+                <th>{$v.task_name}</th>
+            </tr>
+            <tr>
+                <th>二维码数量</th>
+                <th>{$v.quality}万 (含{$redundancy_s}%冗余)</th>
+            </tr>
+            <tr>
+                <th>卷烟厂名称</th>
+                <th>{$v.factory_name}</th>
+            </tr>
+            <tr>
+                <th>产品名称</th>
+                <th>{$v.product_name}</th>
+            </tr>
+            <tr>
+                <th>产品类型</th>
+                <th>{$v.box_type_name}</th>
+            </tr>
+            <tr>
+                <th>文件名</th>
+                <th>{$v.task_name}_{$v.task_id}.txt ( 注意 : 如果此文件以多个文件上传 , 可以按下面的方式 : <span style="color: red">{$v.task_name}_{$v.task_id}_1.txt , {$v.task_name}_{$v.task_id}_2.txt , 依此类推</span> )</th>
+            </tr>
+            <tr>
+                <th>印刷总条数</th>
+                <th>{$v['checked_num']+$v['wrong_num']}</th>
+            </tr>
+            <tr>
+                <th>成功条数</th>
+                <th>{$v.checked_num}</th>
+            </tr>
+            <tr>
+                <th>错码条数</th>
+                <th>{$v.wrong_num}</th>
+            </tr>
+        </volist>
+        </thead>
+    </table>
+
+<if condition="getUserGroup(session('user_auth.uid')) eq 1">
+    <form enctype="multipart/form-data" method="post" class="layui-form" action="">
+        <div class="layui-upload">
+            <div class="layui-upload-list">
+                <table class="layui-table">
+                    <thead>
+                    <tr>
+                        <th>文件名</th>
+                        <th>大小</th>
+                        <th>状态</th>
+                        <th>操作</th>
+                    </tr>
+                    </thead>
+                    <tbody id="demoList"></tbody>
+                </table>
+            </div>
+
+            <div>
+                <button style="margin-left:2%" type="button" class="layui-btn layui-btn-normal" id="fileList">选择多文件</button>
+                <button style="margin-left:0.8%" type="button" class="layui-btn" id="testListAction">开始上传</button>
+                <button id="submits_id" class="layui-btn layui-btn-warm" lay-submit lay-filter="submits">立即提交</button>
+               <!-- <a href="{:U('Admin/ApplyBatch/taskdetail',array('task_id'=>2))}"><button  class="layui-btn layui-btn-danger">查看其他任务</button></a>-->
+            </div>
+
+        </div>
+
+        <span id="hidden">
+        </span>
+
+    </form>
+    <script>
+        layui.use(['upload', 'layer', 'form'], function () {
+            var filename='{$task_detail[0][task_name]}_{$task_detail[0][task_id]}.txt';
+            var $ = layui.jquery
+                , upload = layui.upload,
+                layer = layui.layer,
+                form = layui.form;
+
+            //多文件列表示例
+            var demoListView = $('#demoList'),
+                uploadListIns = upload.render({
+                elem: '#fileList',
+                url: "{:U('Qr/UploadTemp')}",
+                accept: 'file',//指定允许上传的文件类型
+                exts: 'txt',//允许上传的文件后缀
+                multiple: true,//是否允许多文件上传
+                auto: false,//是否选完文件后自动上传
+                bindAction: '#testListAction',//指向一个按钮触发上传
+                choose: function (obj) { //选择文件后的回调函数
+                    var files = obj.pushFile(); //将每次选择的文件追加到文件队列
+                    //读取本地文件
+                    obj.preview(function (index, file, result) {
+
+                        if (file.name.indexOf('{$v.task_name}_{$v.task_id}') < 0) {
+                            delete files[index]; //删除对应的文件
+                            layer.msg('请核对文件名!');
+                        }else{
+                        var tr = $(['<tr id="upload-' + index + '">'
+                            , '<td>' + file.name + '</td>'
+                            , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
+                            , '<td>等待上传</td>'
+                            , '<td>'
+                            , '<button class="layui-btn layui-btn-mini layui-btn-danger demo-delete">删除</button>'
+                            , '</td>'
+                            , '</tr>'].join(''));
+
+                        //删除
+                        tr.find('.demo-delete').on('click', function () {
+                            delete files[index]; //删除对应的文件
+                            tr.remove();
+                        });
+
+                        demoListView.append(tr);
+                    }});
+                }
+                , done: function (res, index, upload) {
+                    if (res.code == 1) { //上传成功
+                        var tr = demoListView.find('tr#upload-' + index)
+                            , tds = tr.children();
+                        tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
+                        tds.eq(3).html(''); //清空操作
+                        $('#hidden').append("<input type='hidden' name='url[]' value=" + res.file + ">");
+                         //delete files[index]; //删除文件队列已经上传成功的文件
+
+                        return;
+                    }
+                    layer.msg(res.msg);
+                    this.error(index, upload);
+                }
+                , error: function (index, upload) {
+                    var tr = demoListView.find('tr#upload-' + index)
+                        , tds = tr.children();
+                    tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
+                    tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
+                }
+            });
+
+            form.on('submit(submits)', function (data) {
+
+                var url = [];
+                $("input[name='url[]']").each(function () {
+                    url.push($(this).val());
+                });
+                if (url.length == 0) {
+                    layer.msg('请选择上传的文件');
+                    return false;
+                }
+                if (url.length == 0) {
+                    layer.msg('请选择上传的文件');
+                    return false;
+                }
+                $.ajax({
+                    async: false,//同步
+                    url: "{:U('Qr/Upload')}",
+                    type: 'POST',
+                    data: {
+                        url: url,is_verif:{$task_detail['0']['is_verif']}
+                    },
+                    timeout: 1000,//1秒
+                    dataType: 'json',
+                    success: function (data) {
+                        layer.alert(data.msg, function (index) {
+                            window.location.href = '__SELF__';
+                        });
+                    }
+
+                });
+                return false;
+            });
+        });
+    </script>
+</if>
+</block>
+
+
+

+ 105 - 0
Application/Admin/View/ApplyBatch/tasklist.html

@@ -0,0 +1,105 @@
+<extend name="$_admin_public_layout"/>
+
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;margin-bottom: 0;">
+        <legend style="margin-bottom: 0;">{$meta_title}</legend>
+    </fieldset>
+
+    <div style="margin: 20px">
+        <button class="layui-btn layui-btn-normal" id="return_task_button"><a style="text-decoration: none;" href="{:U('ApplyBatch/applylist')}">返回</a>
+        </button>
+    </div>
+
+    <div class="builder-table">
+        <!-- 列表 -->
+        <table class="layui-table">
+            <colgroup>
+                <col width="150">
+                <col width="200">
+                <col>
+            </colgroup>
+            <thead>
+            <tr>
+                <th>序号</th>
+                <th>校验类型</th>
+                <!--<th id="task_list_name">订单编号</th>-->
+                <th>卷烟厂名称</th>
+                <th>产品名称</th>
+                <th>盒型</th>
+                <th>数量(万张)</th>
+                <th>印刷厂</th>
+                <th>下达日期</th>
+                <th>状态</th>
+                <if condition="getUserGroup(session('user_auth.uid')) neq 3">
+                <th>下载</th>
+                </if>
+                <th id="caozuo">操作</th>
+            </tr>
+            </thead>
+            <tbody>
+            <volist name="task_list" id="v">
+                <tr>
+                    <td>{$v.task_id}</td>
+                    <td>
+                        <if condition="$v.is_verif eq 0 ">没有验证码
+                            <elseif condition="$v.is_verif eq 1 "/>
+                            有验证码
+                        </if>
+                    </td>
+                    <td>{$v.factory_name}</td>
+                    <td>{$v.product_name}</td>
+                    <td>{$v.box_type_name}</td>
+                    <td>{$v.quality}</td>
+                    <td>{$v.printer_name}</td>
+                    <td>{$v.add_time|date="Y-m-d H:i:s",###}</td>
+                    <td>
+                        <switch name="v.status">
+                            <case value="0">码包生成中</case>
+                            <case value="1">待印刷厂下载</case>
+                            <case value="2">印刷厂校验中</case>
+                            <case value="3">码包校验完成</case>
+                        </switch>
+                    </td>
+                    
+                    <if condition="getUserGroup(session('user_auth.uid')) neq 3">
+                    <td>
+                        <if condition="$v.quality eq $v.checked_num and $v.wrong_num eq 0">
+                            <button class="layui-btn layui-btn-normal" id="download_button">
+                              <a style="text-decoration: none;color: white" href="{:U('ApplyBatch/downloadzip',array('bach_name'=>$v['task_name'].'_'.$v['task_id'],'printer_id'=>$v['printer_id']))}">码包下载</a>
+                            </button>
+                        </if>
+                    </td>
+                    </if>
+                    <td>
+                        <a href="{:U('ApplyBatch/taskdetail',array('task_id'=>$v['task_id']))}">详情</a>
+                    </td>
+                </tr>
+            </volist>
+            </tbody>
+        </table>
+
+        <notempty name="task_page">
+            <ul class="pagination">{$task_page}</ul>
+        </notempty>
+    </div>
+
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        layui.use('form', function () {
+            var form = layui.form;
+        });
+    </script>
+</block>
+
+
+

+ 156 - 0
Application/Admin/View/Bar/add.html

@@ -0,0 +1,156 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+    <block name="style">
+        <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+    </block>
+    <div style="padding:40px 20px;">
+        <form class="layui-form" action="" autocomplete="off" lay-filter="formTest">
+            <input type="hidden" name="custome_sn" value="<?php echo isset($list['custome_sn'])?$list['custome_sn']:''?>">
+            <input type="hidden" name="id" value="<?php echo isset($list['id'])?$list['id']:''?>">
+            <input type="hidden" name="standard" value="<?php echo isset($list['standard'])?$list['standard']:''?>">
+            <div class="layui-form-item">
+                <label class="layui-form-label">工单编号</label>
+                <div class="layui-input-block" >
+                    <input type="text" name="no" value="<?php echo isset($list['no'])?$list['no']:''?>" required  lay-verify="required" placeholder="请输入工单编号"  class="layui-input" autocomplete="off" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">产品</label>
+                <div class="layui-input-block">
+                    <select name="title" lay-verify="required" lay-filter="title">
+                        <option value="">请选择</option>
+                        <volist name="productList" id="v">
+                            <option  value="<?php echo $v['title'].'|'.$v['code1'].'|'.$v['standard'];?>" <?php if($list[title]==$v['title']){?>selected="selected"<?php }?>>{$v.title}</option>
+                        </volist>
+                    </select>
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">日期</label>
+                <div class="layui-inline"> <!-- 注意:这一层元素并不是必须的 -->
+                    <input type="text" class="layui-input" id="time" name="time" value="<?php echo isset($list['time'])?date('Y-m-d',$list['time']):date('Y-m-d');?>" required  lay-verify="required">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">件内数量</label>
+                <div class="layui-inline"> <!-- 注意:这一层元素并不是必须的 -->
+                    <input type="text" class="layui-input" name="num" value="<?php echo isset($list[num])?$list[num]:'';?>" placeholder="请输入整数" lay-verify="required|number">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">流转板号</label>
+                <div class="layui-inline"> <!-- 注意:这一层元素并不是必须的 -->
+                    <input type="text" class="layui-input" name="board_no"  value="<?php echo isset($list[board_no])?$list[board_no]:'';?>" placeholder="请输入整数" lay-verify="required|number" maxlength="3">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">是否混板</label>
+                <div class="layui-input-block">
+                    <input type="checkbox" name="mix_board"  value="1" <?php if($list[mix_board]=='Y'){?>checked="checked"<?php }?>" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">生产批号</label>
+                <div class="layui-input-block" >
+                    <input type="text" name="batch_number" value="<?php echo isset($list[batch_number])?$list[batch_number]:'';?>" required  lay-verify="required" placeholder="请输生产批号"  class="layui-input" autocomplete="off" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">质量识别号</label>
+                <div class="layui-input-block" >
+                    <input type="text" name="quality_no" value="<?php echo isset($list[quality_no])?$list[quality_no]:'';?>" required  lay-verify="required" placeholder="请输质量识别号"  class="layui-input" autocomplete="off" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">托盘号</label>
+                <div class="layui-inline"> <!-- 注意:这一层元素并不是必须的 -->
+                    <input type="text" class="layui-input" name="tray_no" value="<?php echo isset($list[tray_no])?$list[tray_no]:'';?>"  placeholder="请输入整数" lay-verify="required|number">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">检验工号</label>
+                <div class="layui-input-block" >
+                    <input type="text" name="inspector" value="<?php echo isset($list[inspector])?$list[inspector]:'';?>"  required  lay-verify="required" placeholder="请输检验工号"  class="layui-input" autocomplete="off" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <div class="layui-input-block">
+                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
+                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                </div>
+            </div>
+        </form>
+    </div>
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        //Demo
+        layui.use('form', function(){
+            var form = layui.form;
+            var url = "<?php echo $url;?>";
+            var d = "<?echo $list['title']?>";
+            form.on('select(title)', function(data){
+                var data = data.value.split('|');
+                $("input[name='custome_sn']").val(data[1]);
+                $("input[name='standard']").val(data[2]);
+            });
+
+            //监听提交
+            form.on('submit(formDemo)', function(data){
+                /*layer.msg(JSON.stringify(data.field));
+                return false;*/
+                params = data.field;
+                $.ajax({
+                    async: true,//同步
+                    url: url,
+                    type: 'POST',
+                    data: {
+                        data:params
+                    },
+                    timeout: 5000,//1秒
+                    dataType: 'json',
+                    success: function (data) {
+                        /*layer.alert(data.msg, function(index){
+
+                        });*/
+                        layer.msg(data.msg);
+                        form.render();
+                    },
+                    error:function(data){
+                        /*layer.alert('系统飞走了,请联系管理员', function(index){
+                            location.reload();
+                        });*/
+                        layer.msg(data.msg);
+                        form.render();
+                    }
+
+                });
+                return false;
+            });
+        });
+        layui.use('laydate', function(){
+            var laydate = layui.laydate;
+            //执行一个laydate实例
+            laydate.render({
+                elem: '#time' //指定元素
+            });
+        });
+    </script>
+
+</body>
+</html>

+ 10 - 0
Application/Admin/View/Bar/edit.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+        this is  a edit html
+</body>
+</html>

+ 224 - 0
Application/Admin/View/Bar/list.html

@@ -0,0 +1,224 @@
+
+<extend name="$_admin_public_layout"/>
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+    <link rel="stylesheet" href="__PUBLIC__/libs/css/page.css" media="all">
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;">
+        <legend>{$meta_title}</legend>
+    </fieldset>
+    <div style="margin-left: 30px;">
+
+        <button class="layui-btn layui-btn-fluid layui-btn-radius large-add">新增</button>
+        <button class="layui-btn layui-btn-radius layui-btn-warm large-edit">修改</button>
+        <button class="layui-btn layui-btn-radius layui-btn-danger large-del">删除</button>
+        <button class="layui-btn layui-btn-fluid layui-btn-radius large-print">打印</button>
+        <button class="layui-btn layui-btn-fluid layui-btn-radius large-export">导出</button>
+        <div class="bg">
+            <form  action="/index.php?s=/Admin/Bar/large.html" autocomplete="off"  method="POST" >
+                <input type="text" name="search" value="<?php echo isset($search)?$search:'';?>" placeholder="请输入搜素关键词" class="serchInput">
+                <button type="submit" class="layui-btn layui-btn-radius layui-btn-normal">立即搜索</button>
+            </form>
+        </div>
+    </div>
+    <div class="builder-table">
+        <!-- 列表 -->
+        <table class="layui-table">
+            <colgroup>
+                <col width="150">
+                <col width="200">
+                <col>
+            </colgroup>
+            <thead>
+            <tr>
+                <th ></th>
+                <th>条码</th>
+                <th>工单编号</th>
+                <th>标准名称</th>
+                <th>客户产品编码</th>
+                <th>自定义名称</th>
+                <th>日期</th>
+                <th>件内数量</th>
+                <th>流转板号</th>
+                <th>是否混板</th>
+                <th>质量批识别号</th>
+                <th>生产批号</th>
+                <th>托盘号</th>
+                <th>检验工号</th>
+            </tr>
+            </thead>
+            <notempty name="page">
+                <tfoot>
+                <tr><td colspan="14"><div class="pages">{$page}</div></td></tr>
+                </tfoot>
+            </notempty>
+            <tbody>
+            <empty name="list">
+                <tr><td colspan="14">亲,暂时还没数据</td></tr>
+                <else/>
+                <volist name="list" id="v">
+                    <tr>
+                        <td ><input type="checkbox" name="id[]" value="{$v.id}"></td>
+                        <td class="update" data-id = {$v.id}>{$v.sn}</td>
+                        <td>{$v.no}</td>
+                        <td >{$v.name}</td>
+                        <td >{$v.custome_sn}</td>
+                        <td >{$v.title}</td>
+                        <td>{$v.time|date="Y-m-d",###}</td>
+                        <td>{$v.num}</td>
+                        <td>{$v.board_no}</td>
+                        <td>
+                            <if condition="$v.mix_board eq 'Y' ">
+                                是
+                                <else />
+                                否
+                            </if>
+                        </td>
+                        <td>{$v.quality_no}</td>
+                        <td>{$v.batch_number}</td>
+                        <td>{$v.tray_no}</td>
+                        <td>{$v.inspector}</td>
+                    </tr>
+                </volist>
+            </empty>
+            </tbody>
+
+        </table>
+        <notempty name="bach_page">
+            <ul class="pagination">{$task_page}</ul>
+        </notempty>
+    </div>
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        <if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else/>width=800;</if>
+        layui.use('form', function(){
+            var form = layui.form;
+        });
+        $('.update').click(function(){
+            var id = $(this).attr('data-id');
+            layer.open({
+                type: 2,
+                title: '大件编辑',
+                skin: 'layui-layer-rim', //加上边框
+                area: ['1000px', '700px'], //宽高
+                content: 'http://dm.7in6.com/index.php?s=/Admin/Bar/largeEdit/id/'+id+'.html',
+                end: function () {
+                    location.reload();
+                }
+            });
+        });
+        $('.large-add').click(function(){
+            layer.open({
+                type: 2,
+                title: '大件新增',
+                skin: 'layui-layer-rim', //加上边框
+                area: ['1000px', '700px'], //宽高
+                content: 'http://dm.7in6.com/index.php?s=/Admin/Bar/largeAdd.html'
+            });
+        });
+        $('.large-edit').click(function(){
+            $this = $('input[type=checkbox]:checked');
+            $len = $this .length;
+            if($len==0 || $len>1){
+                layer.msg('请选择一个选项');
+                return false;
+            }else{
+                $.each($('input:checkbox:checked'),function(){
+                    var id = $(this).val();
+                    layer.open({
+                        type: 2,
+                        title: '大件编辑',
+                        skin: 'layui-layer-rim', //加上边框
+                        area: ['1000px', '700px'], //宽高
+                        content: 'http://dm.7in6.com/index.php?s=/Admin/Bar/largeEdit/id/'+id+'.html',
+                        end: function () {
+                            location.reload();
+                        }
+                    });
+                });
+            }
+        });
+
+        $('.large-del').click(function(){
+            $this = $('input[type=checkbox]:checked');
+            $len = $this .length;
+            if($len==0){
+                layer.msg('请选择一个选项');
+                return false;
+            }else{
+                var Id = '';
+                $.each($('input:checkbox:checked'),function(){
+                     Id = Id+','+$(this).val();
+                });
+                Id = Id.slice(1);
+                $.ajax({
+                    async: true,//同步
+                    url: "{:U('Bar/largeDel')}",
+                    type: 'POST',
+                    data: {
+                        id:Id
+                    },
+                    timeout: 5000,//1秒
+                    dataType: 'json',
+                    success: function (data) {
+                        layer.msg(data.msg);
+                        location.reload();
+                    },
+                    error:function(data){
+                        layer.msg(data.msg);
+                        location.reload();
+                    }
+
+                });
+            }
+        })
+        $('.large-print').click(function(){
+            $this = $('input[type=checkbox]:checked');
+            $len = $this .length;
+            if($len==0){
+                layer.msg('请选择一个选项');
+                return false;
+            }else{
+                var Id = '';
+                $.each($('input:checkbox:checked'),function(){
+                    Id = Id+','+$(this).val();
+                });
+                Id = Id.slice(1);
+                $.ajax({
+                    async: true,//同步
+                    url: "{:U('Bar/getLargeDate')}",
+                    type: 'POST',
+                    data: {
+                        id:Id
+                    },
+                    timeout: 5000,//1秒
+                    //dataType: 'json',
+                    success: function (data) {
+
+                        data.forEach(function(item,index){
+                            pre(item.name,item.custome_name,item.date,item.num,item.standard,item.inspector,item.batch_number,item.board_no,item.tray_no,item.quality_no,item.sn,0);
+                        });
+                        /*layer.msg(data.msg);
+                        location.reload();*/
+                    },
+                    error:function(data){
+                        /*layer.msg(data.msg);
+                        location.reload();*/
+                    }
+
+                });
+            }
+        })
+    </script>
+</block>
+
+
+

+ 163 - 0
Application/Admin/View/Bar/smalladd.html

@@ -0,0 +1,163 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+    <block name="style">
+        <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+    </block>
+    <div style="padding:40px 20px;">
+        <form class="layui-form" action="{:U('/index/Code/方法/参数')}" autocomplete="off" lay-filter="formTest">
+            <input type="hidden" name="custome_sn" value="<?php echo isset($list['custome_sn'])?$list['custome_sn']:''?>">
+            <input type="hidden" name="id" value="<?php echo isset($list['id'])?$list['id']:''?>">
+            <input type="hidden" name="standard" value="<?php echo isset($list['standard'])?$list['standard']:''?>">
+            <div class="layui-form-item">
+                <label class="layui-form-label">工单编号</label>
+                <div class="layui-input-block" >
+                    <input type="text" name="no" value="<?php echo isset($list['no'])?$list['no']:''?>" required  lay-verify="required" placeholder="请输入工单编号"  class="layui-input" autocomplete="off" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">产品</label>
+                <div class="layui-input-block">
+                    <select name="title" lay-verify="required" lay-filter="title">
+                        <option value="">请选择</option>
+                        <volist name="productList" id="v">
+                            <option  value="<?php echo $v['title'].'|'.$v['code1'].'|'.$v['standard'];?>" <?php if($list[title]==$v['title']){?>selected="selected"<?php }?>>{$v.title}</option>
+                        </volist>
+                    </select>
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">生产日期</label>
+                <div class="layui-inline"> <!-- 注意:这一层元素并不是必须的 -->
+                    <input type="text" class="layui-input" id="time" name="time" value="<?php echo isset($list['time'])?date('Y-m-d',$list['time']):date('Y-m-d');?>" required  lay-verify="required">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">生产批号</label>
+                <div class="layui-input-block" >
+                    <input type="text" name="batch_number" value="<?php echo isset($list[batch_number])?$list[batch_number]:'';?>" required  lay-verify="required" placeholder="请输生产批号"  class="layui-input" autocomplete="off" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">质量批识别号</label>
+                <div class="layui-input-block" >
+                    <input type="text" name="quality_no" value="<?php echo isset($list[quality_no])?$list[quality_no]:'';?>" required  lay-verify="required" placeholder="请输质量批识别号"  class="layui-input" autocomplete="off" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">板号</label>
+                <div class="layui-inline"> <!-- 注意:这一层元素并不是必须的 -->
+                    <input type="text" class="layui-input" name="board_no"  value="<?php echo isset($list[board_no])?$list[board_no]:'';?>" placeholder="请输入整数" lay-verify="required|number" maxlength="3">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">混板号</label>
+                <div class="layui-inline"> <!-- 注意:这一层元素并不是必须的 -->
+                    <input type="text" class="layui-input" name="mix_board"  value="<?php echo isset($list[mix_board])?$list[mix_board]:'';?>" placeholder="请输入整数" lay-verify="required|number" maxlength="3">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">板包号</label>
+                <div class="layui-inline"> <!-- 注意:这一层元素并不是必须的 -->
+                    <input type="text" class="layui-input" name="start"  value="<?php echo isset($list['board_no_serial'])?$list['board_no_serial']:''?>" placeholder="请输入整数" lay-verify="required|number" maxlength="3">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">自增数</label>
+                <div class="layui-inline"> <!-- 注意:这一层元素并不是必须的 -->
+                    <input type="text" class="layui-input" name="step"  value="<?php echo isset($list)?0:''?>" placeholder="请输入整数" lay-verify="required|number" maxlength="3">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">检验工号</label>
+                <div class="layui-input-block" >
+                    <input type="text" name="inspector" value="<?php echo isset($list[inspector])?$list[inspector]:'';?>"  required  lay-verify="required" placeholder="请输检验工号"  class="layui-input" autocomplete="off" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label">工艺编号</label>
+                <div class="layui-input-block" >
+                    <input type="text" name="technics_number" value="<?php echo isset($list[technics_number])?$list[technics_number]:'';?>"  required  lay-verify="required" placeholder="请输工艺编号"  class="layui-input" autocomplete="off" >
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <div class="layui-input-block">
+                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
+                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                </div>
+            </div>
+        </form>
+    </div>
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        //Demo
+        layui.use('form', function(){
+            var form = layui.form;
+            var url = "<?php echo $url;?>";
+            var d = "<?echo $list['title']?>";
+            form.on('select(title)', function(data){
+                var data = data.value.split('|');
+                $("input[name='custome_sn']").val(data[1]);
+                $("input[name='standard']").val(data[2]);
+            });
+
+            //监听提交
+            form.on('submit(formDemo)', function(data){
+                /*layer.msg(JSON.stringify(data.field));
+                return false;*/
+                params = data.field;
+                $.ajax({
+                    async: true,//同步
+                    url: url,
+                    type: 'POST',
+                    data: {
+                        data:params
+                    },
+                    timeout: 5000,//1秒
+                    dataType: 'json',
+                    success: function (data) {
+                        console.log(data);
+                        /*layer.alert(data.msg, function(index){
+
+                        });*/
+                        layer.msg(data.msg);
+                        form.render();
+                    },
+                    error:function(data){
+                        /*layer.alert('系统飞走了,请联系管理员', function(index){
+                            location.reload();
+                        });*/
+                        layer.msg(data.msg);
+                    }
+
+                });
+                return false;
+            });
+        });
+        layui.use('laydate', function(){
+            var laydate = layui.laydate;
+            //执行一个laydate实例
+            laydate.render({
+                elem: '#time' //指定元素
+            });
+        });
+    </script>
+
+</body>
+</html>

+ 225 - 0
Application/Admin/View/Bar/smalllist.html

@@ -0,0 +1,225 @@
+<extend name="$_admin_public_layout"/>
+<block name="style">
+    <link rel="stylesheet" href="__PUBLIC__/libs/layui/css/layui.css" media="all">
+    <link rel="stylesheet" href="__PUBLIC__/libs/css/page.css" media="all">
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide.js?_t=2016121401"></script>
+</block>
+
+<block name="main">
+    <fieldset name="meta_title" class="layui-elem-field layui-field-title" style="margin-top: 20px;">
+        <legend>{$meta_title}</legend>
+    </fieldset>
+    <div style="margin-left: 30px;">
+
+        <button class="layui-btn layui-btn-fluid layui-btn-radius small-add">新增</button>
+        <button class="layui-btn layui-btn-radius layui-btn-warm small-edit">修改</button>
+        <button class="layui-btn layui-btn-radius layui-btn-danger small-del">删除</button>
+        <button class="layui-btn layui-btn-fluid layui-btn-radius small-print">打印</button>
+        <button class="layui-btn layui-btn-fluid layui-btn-radius small-export">导出</button>
+        <div class="bg">
+            <form  action="/index.php?s=/Admin/Bar/small.html" autocomplete="off"  method="POST" >
+                <input type="text" name="search" value="<?php echo isset($search)?$search:'';?>" placeholder="请输入搜素关键词" class="serchInput">
+                <button type="submit" class="layui-btn layui-btn-radius layui-btn-normal">立即搜索</button>
+            </form>
+        </div>
+    </div>
+    <div class="builder-table">
+        <!-- 列表 -->
+        <table class="layui-table">
+            <colgroup>
+                <col width="150">
+                <col width="200">
+                <col>
+            </colgroup>
+            <thead>
+            <tr>
+                <th ></th>
+                <th>条码</th>
+                <th>工单编号</th>
+                <th>自定义名称</th>
+                <th>标准名称</th>
+                <th>规格</th>
+                <th>包内数量</th>
+                <th>日期</th>
+                <th>生产批号</th>
+                <th>工艺编号</th>
+                <th>板号</th>
+                <th>混板号</th>
+                <th>板包序号</th>
+                <th>质量批识别号</th>
+                <th>检验工号</th>
+            </tr>
+            </thead>
+            <notempty name="page">
+                <tfoot>
+                <tr><td colspan="15"><div class="pages">{$page}</div></td></tr>
+                </tfoot>
+            </notempty>
+            <tbody>
+            <empty name="list">
+                <tr><td colspan="15">亲,暂时还没数据</td></tr>
+                <else/>
+                <volist name="list" id="v">
+                    <tr>
+                        <td ><input type="checkbox" name="id[]" value="{$v.id}"></td>
+                        <td class="update" data-id = {$v.id}>{$v.sn}</td>
+                        <td>{$v.no}</td>
+                        <td >{$v.name}</td>
+                        <td >{$v.title}</td>
+                        <td >{$v.standard}</td>
+                        <td>{$v.num}</td>
+                        <td>{$v.time|date="Y-m-d",###}</td>
+                        <td>{$v.batch_number}</td>
+                        <td>{$v.technics_number}</td>
+                        <td>{$v.board_no}</td>
+                        <td>
+                            {$v.mix_board}
+                        </td>
+                        <td>{$v.board_no_serial}</td>
+                        <td>{$v.quality_no}</td>
+                        <td>{$v.inspector}</td>
+                    </tr>
+                </volist>
+            </empty>
+            </tbody>
+
+        </table>
+        <notempty name="bach_page">
+            <ul class="pagination">{$task_page}</ul>
+        </notempty>
+    </div>
+    <script src="__PUBLIC__/libs/layui/layui.js"></script>
+    <script src="__PUBLIC__/libs/jquery/2.x/jquery.js"></script>
+    <script>
+        <if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else/>width=800;</if>
+        layui.use('form', function(){
+            var form = layui.form;
+        });
+        $('.update').click(function(){
+            var id = $(this).attr('data-id');
+            layer.open({
+                type: 2,
+                title: '小件编辑',
+                skin: 'layui-layer-rim', //加上边框
+                area: ['1000px', '700px'], //宽高
+                content: 'http://dm.7in6.com/index.php?s=/Admin/Bar/smallEdit/id/'+id+'.html',
+                end: function () {
+                    location.reload();
+                }
+            });
+        });
+        $('.small-add').click(function(){
+            layer.open({
+                type: 2,
+                title: '小件新增',
+                skin: 'layui-layer-rim', //加上边框
+                area: ['1000px', '700px'], //宽高
+                content: 'http://dm.7in6.com/index.php?s=/Admin/Bar/smallAdd.html'
+            });
+        });
+        $('.small-edit').click(function(){
+            $this = $('input[type=checkbox]:checked');
+            $len = $this .length;
+            if($len==0 || $len>1){
+                layer.msg('请选择一个选项');
+                return false;
+            }else{
+                $.each($('input:checkbox:checked'),function(){
+                    var id = $(this).val();
+                    layer.open({
+                        type: 2,
+                        title: '小件编辑',
+                        skin: 'layui-layer-rim', //加上边框
+                        area: ['1000px', '700px'], //宽高
+                        content: 'http://dm.7in6.com/index.php?s=/Admin/Bar/smallEdit/id/'+id+'.html',
+                        end: function () {
+                            location.reload();
+                        }
+                    });
+                });
+            }
+        });
+
+        $('.small-del').click(function(){
+            $this = $('input[type=checkbox]:checked');
+            $len = $this .length;
+            if($len==0){
+                layer.msg('请选择一个选项');
+                return false;
+            }else{
+                var Id = '';
+                $.each($('input:checkbox:checked'),function(){
+                     Id = Id+','+$(this).val();
+                });
+                Id = Id.slice(1);
+                $.ajax({
+                    async: true,//同步
+                    url: "{:U('Bar/smallDel')}",
+                    type: 'POST',
+                    data: {
+                        id:Id
+                    },
+                    timeout: 5000,//1秒
+                    dataType: 'json',
+                    success: function (data) {
+                        layer.msg(data.msg);
+                        location.reload();
+                    },
+                    error:function(data){
+                        layer.msg(data.msg);
+                        location.reload();
+                    }
+
+                });
+            }
+
+
+        })
+
+        $('.small-print').click(function(){
+            $this = $('input[type=checkbox]:checked');
+            $len = $this .length;
+            if($len==0){
+                layer.msg('请选择一个选项');
+                return false;
+            }else{
+                var Id = '';
+                $.each($('input:checkbox:checked'),function(){
+                    Id = Id+','+$(this).val();
+                });
+                Id = Id.slice(1);
+                $.ajax({
+                    async: true,//同步
+                    url: "{:U('Bar/getSmallDate')}",
+                    type: 'POST',
+                    data: {
+                        id:Id
+                    },
+                    timeout: 5000,//1秒
+                    //dataType: 'json',
+                    success: function (data) {
+                        data.forEach(function(item,index){
+                            pre(item.name,0,item.date,item.num,item.standard,item.inspector,item.batch_number,item.board_no,0,item.quality_no,item.sn,1);
+                        });
+                        /*layer.msg(data.msg);
+                         location.reload();*/
+                    },
+                    error:function(data){
+                        /*layer.msg(data.msg);
+                         location.reload();*/
+                    }
+
+                });
+            }
+        })
+
+
+    </script>
+</block>
+
+
+

+ 145 - 0
Application/Admin/View/Error/error.html

@@ -0,0 +1,145 @@
+<!doctype html>
+<html lang="zh">
+<head>
+    <meta charset="utf-8">
+    <title>跳转提示</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
+    <style type="text/css">
+        * {
+            padding: 0;
+            margin: 0;
+            box-sizing: border-box;
+        }
+        img {
+            max-width: 100%;
+        }
+        body{
+            background: teal;
+            font-family: '微软雅黑';
+            color: #fff;
+            font-size: 16px;
+        }
+        .message-box{
+            width: 500px;
+            padding: 20px;
+            margin: 8% auto;
+            text-align: center;
+            overflow: hidden;
+        }
+        .message-box .message-header {
+            margin-bottom: 20px;
+        }
+        .message-box .message-header a {
+            font-size: 50px;
+            text-decoration: none;
+        }
+        .message-box .message-header a:hover {
+            text-decoration: none;
+        }
+        .message-box .message-header .logo {
+            width: 350px;
+        }
+        .message-box .message-body h1 {
+            font-size: 50px;
+            font-weight: normal;
+            line-height: 60px;
+            margin-bottom: 12px
+        }
+        .message-box .message-body .jump {
+            padding-top: 10px;
+            margin-bottom:20px
+        }
+        .message-box .message-body .jump a {
+             color: #333;
+         }
+        .message-box .message-body .success,
+        .message-box .message-body .error {
+            font-size: 36px
+        }
+        .message-box .message-body .detail {
+            font-size: 12px;
+            line-height: 20px;
+            margin-bottom: 12px;
+            display:none
+        }
+        .message-box .message-action .btn {
+            display: inline-block;
+            margin-right: 10px;
+            font-size: 16px;
+            line-height: 18px;
+            text-align: center;
+            vertical-align: middle;
+            cursor: pointer;
+            border: 0 none;
+            background-color: #8B0000;
+            padding: 10px 20px;
+            color: #fff;
+            font-weight: bold;
+            border-color: transparent;
+            text-decoration:none;
+        }
+        .message-box .message-action .btn:hover {
+            background-color: #ff0000;
+        }
+        @media (max-width: 768px) {
+            .message-box {
+                width: 100%;
+            }
+            .message-box .message-header .logo {
+                width: 200px;
+            }
+            .message-box .message-body h1 {
+                display: none;
+            }
+            .message-box .message-body {
+                margin-bottom: 60px;
+            }
+            .message-box .message-action .btn{
+                display: block;
+                width: 100%;
+                margin-bottom: 10px;
+            }
+        }
+    </style>
+</head>
+<body>
+    <div class="message-box">
+        <div class="message-header">
+            <php>if(C('WEB_SITE_LOGO')):</php>
+                <a href="{:C('HOME_PAGE')}"><img class="logo" src="{$Think.config.WEB_SITE_LOGO|get_cover}"></a>
+            <php>else:</php>
+                <a href="{:C('HOME_PAGE')}"><span>{:C('LOGO_DEFAULT')}</span></a>
+            <php>endif;</php>
+        </div>
+        <div class="message-body">
+            <h1>友情提醒!</h1>
+            <p class="error"><?php echo($error); ?></p>
+            <p class="detail"></p>
+            <p class="jump">
+                <b id="wait"><?php echo($waitSecond); ?></b> 秒后页面将自动跳转
+            </p>
+        </div>
+        <div class="message-action">
+            <a class="btn" id="btn-now" href="<?php echo($jumpUrl); ?>">立即跳转</a>
+            <a class="btn" id="btn-stop" onclick="stop()">停止跳转</a>
+            <a class="btn" id="btn-now" href="<?php echo(C('HOME_PAGE')); ?>">返回首页</a>
+        </div>
+    </div>
+    <script type="text/javascript">
+        (function(){
+            var wait = document.getElementById('wait');
+            var btn = document.getElementById('btn-now').href;
+            var interval = setInterval(function(){
+                var time = --wait.innerHTML;
+                if(time <= 0) {
+                    location.href = btn;
+                    clearInterval(interval);
+                };
+            }, 1000);
+            window.stop = function (){
+                clearInterval(interval);
+            }
+        })();
+    </script>
+</body>
+</html>

+ 58 - 0
Application/Admin/View/Error/exception.html

@@ -0,0 +1,58 @@
+<?php
+    if(C('LAYOUT_ON')) {
+        echo '{__NOLAYOUT__}';
+    }
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>系统发生错误</title>
+<style type="text/css">
+*{ padding: 0; margin: 0; }
+html{ overflow-y: scroll; }
+body{ background: #fff; font-family: '微软雅黑'; color: #333; font-size: 16px; }
+img{ border: 0; }
+.error{ padding: 24px 48px; }
+.face{ font-size: 100px; font-weight: normal; line-height: 120px; margin-bottom: 12px; }
+h1{ font-size: 32px; line-height: 48px; }
+.error .content{ padding-top: 10px}
+.error .info{ margin-bottom: 12px; }
+.error .info .title{ margin-bottom: 3px; }
+.error .info .title h3{ color: #000; font-weight: 700; font-size: 16px; }
+.error .info .text{ line-height: 24px; }
+.copyright{ padding: 12px 48px; color: #999; }
+.copyright a{ color: #000; text-decoration: none; }
+</style>
+</head>
+<body>
+<div class="error">
+<p class="face">:(</p>
+<h1><?php echo strip_tags($e['message']);?></h1>
+<div class="content">
+<?php if(isset($e['file'])) {?>
+    <div class="info">
+        <div class="title">
+            <h3>错误位置</h3>
+        </div>
+        <div class="text">
+            <p>FILE: <?php echo $e['file'] ;?> &#12288;LINE: <?php echo $e['line'];?></p>
+        </div>
+    </div>
+<?php }?>
+<?php if(isset($e['trace'])) {?>
+    <div class="info">
+        <div class="title">
+            <h3>TRACE</h3>
+        </div>
+        <div class="text">
+            <p><?php echo nl2br($e['trace']);?></p>
+        </div>
+    </div>
+<?php }?>
+</div>
+</div>
+<div class="copyright">
+<p><a title="官方网站" href="http://www.corethink.cn">OpenCMF</a><sup>1.4.0</sup> { Simple Efficient Excellent } -- [ WE CAN MAKE IT EASY ]</p>
+</div>
+</body>
+</html>

+ 144 - 0
Application/Admin/View/Error/success.html

@@ -0,0 +1,144 @@
+<!doctype html>
+<html lang="zh">
+<head>
+    <meta charset="utf-8">
+    <title>跳转提示</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
+    <style type="text/css">
+        * {
+            padding: 0;
+            margin: 0;
+            box-sizing: border-box;
+        }
+        img {
+            max-width: 100%;
+        }
+        body {
+            background: #30333F;
+            font-family: '微软雅黑';
+            color: #fff;
+            font-size: 16px;
+        }
+        .message-box {
+            width: 500px;
+            padding: 20px;
+            margin: 8% auto;
+            text-align: center;
+            overflow: hidden;
+        }
+        .message-box .message-header {
+            margin-bottom: 20px;
+        }
+        .message-box .message-header a {
+            font-size: 50px;
+            text-decoration: none;
+        }
+        .message-box .message-header a:hover {
+            text-decoration: none;
+        }
+        .message-box .message-header .logo {
+            width: 350px;
+        }
+        .message-box .message-body h1 {
+            font-size: 50px;
+            font-weight: normal;
+            line-height: 60px;
+            margin-bottom: 12px
+        }
+        .message-box .message-body .jump {
+            padding-top: 10px;
+            margin-bottom:20px
+        }
+        .message-box .message-body .jump a {
+             color: #333;
+         }
+        .message-box .message-body .success,
+        .message-box .message-body .error {
+            font-size: 36px
+        }
+        .message-box .message-body .detail {
+            font-size: 12px;
+            line-height: 20px;
+            margin-bottom: 12px;
+            display:none
+        }
+        .message-box .message-action .btn {
+            display: inline-block;
+            margin-right: 10px;
+            font-size: 16px;
+            line-height: 18px;
+            text-align: center;
+            vertical-align: middle;
+            cursor: pointer;
+            border: 0 none;
+            background-color: #308B04;
+            padding: 10px 20px;
+            color: #fff;
+            font-weight: bold;
+            border-color: transparent;
+            text-decoration:none;
+        }
+        .message-box .message-action .btn:hover {
+            background-color: #43BD08;
+        }
+        @media (max-width: 768px) {
+            .message-box {
+                width: 100%;
+            }
+            .message-box .message-header .logo {
+                width: 200px;
+            }
+            .message-box .message-body h1 {
+                display: none;
+            }
+            .message-box .message-body {
+                margin-bottom: 60px;
+            }
+            .message-box .message-action .btn{
+                display: block;
+                width: 100%;
+                margin-bottom: 10px;
+            }
+        }
+    </style>
+</head>
+<body>
+    <div class="message-box">
+        <div class="message-header">
+            <php>if(C('WEB_SITE_LOGO')):</php>
+                <a href="{:C('HOME_PAGE')}"><img class="logo" src="{$Think.config.WEB_SITE_LOGO|get_cover}"></a>
+            <php>else:</php>
+                <a href="{:C('HOME_PAGE')}"><span>{:C('LOGO_DEFAULT')}</span></a>
+            <php>endif;</php>
+        </div>
+        <div class="message-body">
+            <h1>恭喜您!</h1>
+            <p class="success"><?php echo($message); ?></p>
+            <p class="detail"></p>
+            <p class="jump">
+                <b id="wait"><?php echo($waitSecond); ?></b> 秒后页面将自动跳转
+            </p>
+        </div>
+        <div class="message-action">
+            <a class="btn" id="btn-now" href="<?php echo($jumpUrl); ?>">立即跳转</a>
+            <a class="btn" id="btn-stop" onclick="stop()">停止跳转</a>
+        </div>
+    </div>
+    <script type="text/javascript">
+        (function(){
+            var wait = document.getElementById('wait');
+            var btn = document.getElementById('btn-now').href;
+            var interval = setInterval(function(){
+                var time = --wait.innerHTML;
+                if(time <= 0) {
+                    location.href = btn;
+                    clearInterval(interval);
+                };
+            }, 1000);
+            window.stop = function (){
+                clearInterval(interval);
+            }
+        })();
+    </script>
+</body>
+</html>

+ 239 - 0
Application/Admin/View/Export/bach.html

@@ -0,0 +1,239 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta name="ctx" content="" />
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/default/easyui.css">
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css">
+	<link rel="stylesheet" type="text/css" href="/static/styles/demo.css">
+	<link rel="stylesheet" type="text/css" href="/static/uploadify/uploadify.css">
+	<link rel="stylesheet" type="text/css" href="/Public/libs/css/export.css">
+	<script type="text/javascript" src="/static/basejs/jquery-1.8.0.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-lang-zh_CN.js"></script>
+	<script type="text/javascript" src="/static/uploadify/jquery.uploadify.js"></script>
+	<script type="text/javascript" src="/static/basejs/th.js"></script>
+	<script type="text/javascript" src="/static/easyui/src/jquery.window.js"></script>
+	<script type="text/javascript" src="/static/easyui/formatter.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-validatebox-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-loading.js"></script>
+	<script type="text/javascript" src="/static/basejs/jquery.qrcode.min.js"></script>
+	<script type="text/javascript" src="/static/basejs/LodopFuncs.js"></script>
+	<script type="text/javascript" src="/static/basejs/newqcode.js"></script>
+	<script type="text/javascript" src="/static/basejs/template.js"></script>
+</head>
+
+<body class="easyui-layout">
+	<div data-options="region:'north',title:'',split:true" style="height: 830px;border:none">
+		<div id="supBthGridToolbar">
+			<form id="searchBthForm" class="smShow">
+				<table width=1000px style="white-space: nowrap;padding:10px;">
+					<tr>
+						<td align="left">
+							辅料名称:
+						</td>
+						<td>
+							<select name="sysCdNm" style="height:30px;" >
+								<option value="0">全部</option>
+								<volist name="productlist" id="val">
+									<option value="{$val.product_name}">{$val.product_name}</option>
+								</volist>
+							</select>
+						</td>
+						<td align="left">
+							公司名称:
+						</td>
+						<td>
+							<select name="user_name" style="height:30px;">
+								<volist name="userlist" id="val">
+									<option value="{$val.id}">{$val.nickname}</option>
+								</volist>
+							</select>
+						</td>
+
+						<td align="left">
+							生产开始时间:
+						</td>
+						<td>
+							<input id ="startDate" name="startDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+						</td>
+
+						<td align="left">
+							生产结束时间:
+						</td>
+						<td>
+							<input id ="endDate"  name="endDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+						</td>
+
+						<td colspan="2" align="center">
+							<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="searchBthFun()">查询</a>
+						</td>
+					<tr/>
+				</table>
+			</form>
+		</div>
+		<table id="supBthGrid">
+
+		</table>
+		<div class="body"></div>
+	</div>
+			<script>
+				var supBthGrid, supTgGrid, printType;
+
+				bt_is_load=true;//定义防重复弹出小标签全局变量
+				$(document).ready(function () {
+                    //初始化日期输入框
+                    initDateBox();
+					supBthGrid = $('#supBthGrid').datagrid({
+						url: '/index.php?s=/Admin/Export/getExcelData',
+						method: 'post',
+						toolbar: '#supBthGridToolbar',
+                        striped : true,
+						showFooter:false,
+						rownumbers: true,      // 如果为true,则显示一个行号列。
+						singleSelect: false,    // 如果为true,则只允许选择一行。
+						nowrap: false,         // 如果为true,则在同一行中显示数据。设置为true可以提高加载性能。
+						fit: true,             // datagrid自适应宽高
+						fitColumns: true,      // 使列自动展开/收缩到合适的数据表格宽度。
+						autoRowHeight: false,  // 定义设置行的高度,根据该行的内容。设置为false可以提高负载性能。
+						sortName: 'id',       // 排序字段
+						sortOrder: 'desc',       // 排序方式
+                        pagination: true,      // 显示分页工具条
+						pageSize: 100,//初始化页面大小
+						pageList: [10, 20, 30, 50, 100, 500,1000,2000,5000,10000],// 初始化页面大小选择列表
+						queryParams: $('#searchBthForm').serializeObject(),
+						columns: [[
+							{field: 'matter_name', title: '辅料名称', sortable: true, width: 200},
+                            {field: 'matter_no', title: '辅料规格', sortable: true, width: 200},
+                            {field: 'large_num', title: '大件数量', align: 'center', sortable: true, width: 100},
+                            {field: 'small_num', title: '小件数量', align: 'center', sortable: true, width: 100},
+                            {field: 'date', title: '创建日期', align: 'center', sortable: true, width: 150,
+								formatter: function(value,row,index){
+                            		return UnixToDate(value,true,8);
+                            	}
+                            },
+							{field: 'file_dir', title: '点击下载', align: 'center', sortable: true, width: 200,
+                                formatter: function(value,row,index){
+                                    return "<a href="+value+">点击下载</a>";
+                                }
+							},
+							{field:'status',title:'状态',align:'center',sortable:false,width:100,
+                                formatter: function(value,row,index){
+							    	if(value==0){
+							    	    return '已发货';
+									}else{
+							    	    return '已删除';
+									}
+                                }
+							},
+                            {field:'id',title:'操作',align:'center',sortable:false,width:100,
+                                formatter: function(value,row,index){
+                                	if(row.status==0){
+                                        return '<a class="red" data-id='+value+' onclick="deal('+value+')">删除</a>';
+									}else{
+                                        //return '<a class="green" data-id='+value+' onclick="fa('+value+')">发货</a>';
+									}
+
+                                }
+                            }
+						]],
+						onClickRow: function (rowIndex, rowData) {
+                            $('#supBthGrid').datagrid('unselectRow', rowIndex);
+                        },
+                        onClickCell:function(rowIndex, field, value){
+
+						},
+						onLoadError: function () {
+							//$.messager.alert('系统提示', '数据加载错误,请刷新重试!', 'error');
+						},
+						onBeforeLoad: function (param,data) {
+							/*if (supBthGrid != null) {
+								supBthGrid.datagrid('loadData', {total: 0, rows: []});
+							}
+							if (supTgGrid != null) {
+								supTgGrid.datagrid('loadData', {total: 0, rows: []});
+							}
+							return true;*/
+						},
+						onLoadSuccess: function(data,options){
+
+						}
+
+					});
+
+
+
+				});
+
+				function deal(id){
+                    $('.body').loading();
+                    $.ajax({
+                        url: "/index.php?s=/Admin/Export/changeExcelData",
+                        type: "post",
+                        dataType: "json",
+                        data: {id:id},
+                        success: function (data) {
+                            //console.log(data);
+                            $('.body').loadend();
+                            if (data != null) {
+                                if (data.status == 0) {
+                                    $.messager.alert('系统提示', data.msg, 'error');
+                                    supBthGrid.datagrid('load', $('#searchBthForm').serializeObject());
+                                } else {
+                                    $.messager.alert('系统提示', data.msg, 'success',function(){
+                                        supBthGrid.datagrid('load', $('#searchBthForm').serializeObject());
+									});
+                                }
+                            }
+                        },
+                        error: function (error) {
+
+                        }
+                    })
+				}
+
+				function fa(id){
+
+				}
+
+
+
+
+
+                //初始化日期输入框
+                function initDateBox() {
+                    var nowDate = new Date;
+                    $('#endDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+                    nowDate.setMonth(nowDate.getMonth() - 1);
+                    nowDate.setDate(nowDate.getDay() +1);
+                    $('#startDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+                }
+				function searchBthFun() {
+					if ($('#searchBthForm').form('validate')) {
+					    //var obj = $('#searchBthForm').serializeObject();
+						supBthGrid.datagrid('load', $('#searchBthForm').serializeObject());
+					}
+				}
+
+                function UnixToDate(unixTime, isFull, timeZone) {
+					if (typeof (timeZone) == 'number') {
+						unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
+					}
+					var time = new Date(unixTime * 1000);
+					var ymdhis = "";
+					ymdhis += time.getUTCFullYear() + "-";
+					ymdhis += (time.getUTCMonth() + 1) + "-";
+					ymdhis += time.getUTCDate();
+					if (isFull === true) {
+						ymdhis += " " + time.getUTCHours() + ":";
+						ymdhis += time.getUTCMinutes() + ":";
+						ymdhis += time.getUTCSeconds();
+					}
+					return ymdhis;
+				}
+
+			</script>
+
+</body>
+</html>

+ 390 - 0
Application/Admin/View/Export/detail.html

@@ -0,0 +1,390 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>标签补打</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta name="ctx" content="" />
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/default/easyui.css">
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css">
+	<link rel="stylesheet" type="text/css" href="/static/styles/demo.css">
+	<link rel="stylesheet" type="text/css" href="/static/uploadify/uploadify.css">
+	<link rel="stylesheet" type="text/css" href="/Public/libs/css/export.css">
+	<script type="text/javascript" src="/static/basejs/jquery-1.8.0.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-lang-zh_CN.js"></script>
+	<script type="text/javascript" src="/static/uploadify/jquery.uploadify.js"></script>
+	<script type="text/javascript" src="/static/basejs/th.js"></script>
+	<script type="text/javascript" src="/static/easyui/src/jquery.window.js"></script>
+	<script type="text/javascript" src="/static/easyui/formatter.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-validatebox-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-loading.js"></script>
+	<script type="text/javascript" src="/static/basejs/jquery.qrcode.min.js"></script>
+	<script type="text/javascript" src="/static/basejs/LodopFuncs.js"></script>
+	<script type="text/javascript" src="/static/basejs/newqcode.js"></script>
+	<script type="text/javascript" src="/static/basejs/template.js"></script>
+
+</head>
+
+<body class="easyui-layout">
+<div data-options="region:'north',title:'',split:true" style="height: 380px;">
+	<div id="supBthGridToolbar">
+		<form id="searchBthForm" class="smShow">
+			<table  style="width:100%;white-space: nowrap;padding:10px;">
+				<tr style="margin-bottom:20px">
+					<td>
+						<a class="easyui-linkbutton exportExcel" iconCls="icon-save" plain="true" >导出发货</a>
+					</td>
+					<td>
+						<a href="/index.php?s=/Admin/NewQcode/index.html" target="_blank" class="easyui-linkbutton" iconCls="icon-add" plain="true" >新增大件</a>
+					</td>
+				</tr>
+				<tr>
+					<td align="left">
+						辅料名称:
+					</td>
+					<td>
+						<select name="sysCdNm" style="height:30px;" >
+							<option value="0">全部</option>
+							<volist name="productlist" id="val">
+								<option value="{$val.product_name}">{$val.product_name}</option>
+							</volist>
+						</select>
+					</td>
+					<td align="left">
+						公司名称:
+					</td>
+					<td>
+						<select name="user_name" style="height:30px;">
+							<volist name="userlist" id="val">
+								<option value="{$val.id}">{$val.nickname}</option>
+							</volist>
+						</select>
+					</td>
+
+					<td align="left">
+						请输入批次号:
+					</td>
+					<td>
+						<input name="bach_num" class="easyui-numberbox" style="width:150px" type="text"  value=""  data-options="min:0"/>
+					</td>
+				</tr>
+				<tr>
+					<td align="left">
+						生产开始时间:
+					</td>
+					<td>
+						<input id ="startDate" name="startDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+					</td>
+
+					<td align="left">
+						生产结束时间:
+					</td>
+					<td>
+						<input id ="endDate"  name="endDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+					</td>
+					<td colspan="1" align="right">
+						<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="searchBthFun()">查询</a>
+					</td>
+				</tr>
+				<tr>
+					<td colspan="10" class="export-tips">温馨提示:你已选中<span class="sp1">0</span>个大件,共包含<span class="sp2">0</span>个小件</td>
+				</tr>
+
+			</table>
+			<input type="hidden" name="c3Ax" value="0">
+			<input type="hidden" name="c3Ay" value="0">
+		</form>
+	</div>
+	<table id="supBthGrid"></table>
+	<div class="body"></div>
+</div>
+<div data-options="region:'center',title:'所属小件信息',split:true"  >
+	<div id="supTgGridToolbar">
+		<form id="searchTgForm">
+			<input name="largeId" id='largeId' type="hidden"/><!-- 标签类型 -->
+		</form>
+	</div>
+	<table id=supTgGrid></table>
+</div>
+
+<script>
+
+    var supBthGrid, supTgGrid, printType;
+    bt_is_load=true;//定义防重复弹出小标签全局变量
+    $(document).ready(function () {
+
+        initDateBox();
+        /*console.log($('#searchBthForm').serializeObject());*/
+        supBthGrid = $('#supBthGrid').datagrid({
+            url: '/index.php?s=/Admin/Export/getBigData',
+            method: 'post',
+            toolbar: '#supBthGridToolbar',
+            showFooter:false,
+            striped : true,
+            rownumbers: false,      // 如果为true,则显示一个行号列。
+            singleSelect: false,    // 如果为true,则只允许选择一行。
+            nowrap: false,         // 如果为true,则在同一行中显示数据。设置为true可以提高加载性能。
+            fit: true,             // datagrid自适应宽高
+            fitColumns: true,      // 使列自动展开/收缩到合适的数据表格宽度。
+            autoRowHeight: false,  // 定义设置行的高度,根据该行的内容。设置为false可以提高负载性能。
+            sortName: 'manufacture_date',       // 排序字段
+            sortOrder: 'desc',       // 排序方式
+            pagination: true,      // 显示分页工具条
+            pageSize: 100,//初始化页面大小
+            pageList: [10, 20, 30, 50, 100, 500,1000,2000,5000,10000],// 初始化页面大小选择列表
+            queryParams: $('#searchBthForm').serializeObject(),
+            columns: [[
+                {field: 'ck', checkbox: true},
+                {field: 'bach_num', title: '批次号', sortable: true, width: 100,
+                    formatter: function(value,row,index){
+                        if(value==null || value==''){
+                            return '空';
+                        }else{
+                            return value;
+                        }
+                    }
+                },
+                {field: 'code_cp1', title: '托盘号', sortable: true, width: 100,
+                    formatter: function(value,row,index){
+                        return value.slice(6).replace(/\b(0+)/gi,"");
+                    }
+                },
+                {field: 'matter_name', title: '辅料名称', sortable: true, width: 200},
+                {field: 'manufacture_date', title: '生产日期', align: 'center', sortable: true, width: 150,
+                    formatter: function(value,row,index){
+                        return '20'+value.slice(0,2)+'-'+value.slice(2,4)+'-'+value.slice(4,6);
+                    }
+                },
+                {field: 'code', title: '大件编码', align: 'center', sortable: true, width: 500},
+                {field: 'count', title: '小件数', align: 'center',  width: 100},
+                {field:'large_id',title:'ID',align:'center',sortable:false,width:100,hidden:true}
+            ]],
+            onCheck:function(rowIndex, rowData){
+                large_num = $('input[name="c3Ax"]').val();
+                small_num = $('input[name="c3Ay"]').val();
+                num_index = rowData.count;
+                large_num = Number(large_num)+ 1;
+                num_total = Number(small_num)+Number(num_index);
+                $('input[name="c3Ax"]').val(large_num);
+                $('.sp1').text(large_num);
+                $('input[name="c3Ay"]').val(num_total);
+                $('.sp2').text(num_total);
+                /*$('#largeId').val(rowData.large_id);
+                 supTgGrid.datagrid('load', $('#searchTgForm').serializeObject());*/
+
+            },
+            onUncheck:function(rowIndex, rowData){
+                large_num = $('input[name="c3Ax"]').val();
+                small_num = $('input[name="c3Ay"]').val();
+                num_index = rowData.count;
+                large_num = Number(large_num)- 1;
+                num_total = Number(small_num)-Number(num_index);
+                $('input[name="c3Ax"]').val(large_num);
+                $('.sp1').text(large_num);
+                $('input[name="c3Ay"]').val(num_total);
+                $('.sp2').text(num_total);
+                /*$('#largeId').val(0);
+                 supTgGrid.datagrid('load', $('#searchTgForm').serializeObject());*/
+            },
+            onCheckAll:function(rows){
+                var num1 = 0;
+                var large_num = 0;
+                rows.forEach(function(item,index){
+                    num1+=Number(item.count);
+                    large_num +=1;
+                })
+                $('input[name="c3Ax"]').val(large_num);
+                $('.sp1').text(large_num);
+                $('.sp2').text(num1);
+                $('input[name="c3Ay"]').val(num1);
+
+            },
+            onUncheckAll:function(rowIndex, rowData){
+                $('input[name="c3Ax"]').val(0);
+                $('.sp1').text(0);
+                $('.sp2').text(0);
+                $('input[name="c3Ay"]').val(0);
+            },
+            onClickRow: function (rowIndex, rowData) {
+                //console.log(rowData);
+                $('#largeId').val(rowData.large_id);
+                supTgGrid.datagrid('load', $('#searchTgForm').serializeObject());
+                /*var id = $('#largeId').val();
+                 if(rowData.large_id==id){
+                 $('#largeId').val(0);
+                 supTgGrid.datagrid('load', $('#searchTgForm').serializeObject());
+                 }else{
+                 $('#largeId').val(rowData.large_id);
+                 supTgGrid.datagrid('load', $('#searchTgForm').serializeObject());
+                 }*/
+
+                // console.log(id_str);
+            },
+            onLoadError: function () {
+                $.messager.alert('系统提示', '数据加载错误,请刷新重试!', 'error');
+            },
+            onBeforeLoad: function (param) {
+                if (supBthGrid != null) {
+                    supBthGrid.datagrid('loadData', {total: 0, rows: []});
+                }
+                if (supTgGrid != null) {
+                    supTgGrid.datagrid('loadData', {total: 0, rows: []});
+                }
+                return true;
+            },
+            onLoadSuccess: function(data,options){
+                $('.sp1').text(0);
+                $('.sp2').text(0);
+                $('input[name="c3Ax"]').val(0);
+                $('input[name="c3Ay"]').val(0);
+                return false;
+            }
+
+        });
+
+        supTgGrid = $('#supTgGrid').datagrid({
+            url: 'index.php?s=/Admin/Export/getSmall',
+            method: 'post',
+            toolbar: '#supTgGridToolbar',
+            rownumbers: true,      // 如果为true,则显示一个行号列。
+            singleSelect: false, // 如果为true,则只允许选择一行。
+            nowrap: false,         // 如果为true,则在同一行中显示数据。设置为true可以提高加载性能。
+            fit: true,             // datagrid自适应宽高
+            fitColumns: true,      // 使列自动展开/收缩到合适的数据表格宽度。
+            autoRowHeight: false,  //定义设置行的高度,根据该行的内容。设置为false可以提高负载性能。
+            pagination: true,      // 显示分页工具条
+            pageSize: 100,//初始化页面大小
+            pageList: [100],// 初始化页面大小选择列表
+            sortName: 'id',       // 排序字段
+            sortOrder: 'asc',        // 排序方式
+            //queryParams: $('#searchTgForm').serializeObject(),
+            columns: [[
+                {field: 'code', title: '小件标签代码', align: 'center',  width: 300},
+                {field: 'code_cp1', title: '当前序号', align: 'center', width: 100,
+                    formatter: function(value,row,index){
+                        return row.l_code_sp1.slice(6).replace(/\b(0+)/gi,"")+'-'+value.slice(6).replace(/\b(0+)/gi,"");
+                    }
+                },
+                {field: 'p_nums', title: '打印次数', align: 'center',  width: 50},
+                {field: 'status', title: '状态', align: 'center',  width: 100,
+                    formatter: function(value,row,index){
+                        if(value==0){
+                            return '<span class="green">正常</span>';
+                        }else{
+                            return '<span class="red">已删除</span>';
+                        }
+                    }
+                }
+            ]],
+            onLoadError: function (data) {
+                //console.log(data);
+                $.messager.alert('系统提示', '数据加载错误,请刷新重试!', 'error');
+            },
+
+            onClickRow: function (rowIndex, rowData) {
+
+                //console.log(rowData);
+                if(bt_is_load) {
+                    bt_is_load=false;
+                }
+            },
+
+            onBeforeLoad: function (param) {
+                //console.log(param);
+                var selecteRow = supBthGrid.datagrid('getSelected');
+                /*$('#supTgGrid').datagrid('clearChecked');*/
+                if (selecteRow == null) {
+                    return false;
+                }
+                return true;
+            }
+        });
+
+    });
+
+    //初始化日期输入框
+    function initDateBox() {
+        var nowDate = new Date;
+        $('#endDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+        nowDate.setMonth(nowDate.getMonth() - 1);
+        $('#startDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+    }
+
+    function searchBthFun() {
+        if ($('#searchBthForm').form('validate')) {
+            //var obj = $('#searchBthForm').serializeObject();
+            supBthGrid.datagrid('load', $('#searchBthForm').serializeObject());
+        }
+    }
+
+    $('.exportExcel').click(function(){
+        var id_str = '';
+        var large_all = $('input[name="c3Ax"]').val();
+        var sum_all = $('input[name="c3Ay"]').val();
+        var order_num = $('input[name="order_num"]').val();
+        var deliveryman = $('input[name="deliveryman"]').val();
+        var plate_number = $('input[name="plate_number"]').val();
+        if(large_all <= 0){
+            $.messager.alert('系统提示', '请至少选择一个大件', 'warning',function(){
+            });
+            return false;
+        }else {
+            $('.datagrid-row-checked').each(function (i, item) {
+                id_str += $(this).children('td:nth-child(8)').children().text() + ',';
+            })
+
+            //do
+            $('.body').loading();
+            $.ajax({
+                url: "/index.php?s=/Admin/Export/export1",
+                type: "post",
+                dataType: "json",
+                data: {id: id_str, sum: sum_all, order_num: order_num, deliveryman: deliveryman,plate_number: plate_number},
+                success: function (data) {
+                    if (data != null) {
+                        $('.body').loadend();
+                        if (data.status == 0) {
+                            $.messager.alert('系统提示', data.msg, 'warning',function(){
+                            });
+                            return false;
+                        } else {
+                            // console.log(data.data);
+                            window.location.href = data.url;
+                            supBthGrid.datagrid('load', $('#searchBthForm').serializeObject());
+                        }
+                    }
+                },
+                error: function (error) {
+
+                }
+            })
+        }
+        //console.log($('.datagrid-row-checked').attr('datagrid-row-index'));
+    })
+
+    function UnixToDate(unixTime, isFull, timeZone) {
+        if (typeof (timeZone) == 'number') {
+            unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
+        }
+        var time = new Date(unixTime * 1000);
+        var ymdhis = "";
+        ymdhis += time.getUTCFullYear() + "-";
+        ymdhis += (time.getUTCMonth() + 1) + "-";
+        ymdhis += time.getUTCDate();
+        if (isFull === true) {
+            ymdhis += " " + time.getUTCHours() + ":";
+            ymdhis += time.getUTCMinutes() + ":";
+            ymdhis += time.getUTCSeconds();
+        }
+        return ymdhis;
+    }
+
+    /* 显示辅料选择窗口 */
+
+</script>
+</body>
+
+
+
+</html>

+ 379 - 0
Application/Admin/View/Export/excel.html

@@ -0,0 +1,379 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta name="ctx" content="" />
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/default/easyui.css">
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css">
+	<link rel="stylesheet" type="text/css" href="/static/styles/demo.css">
+	<link rel="stylesheet" type="text/css" href="/static/uploadify/uploadify.css">
+	<link rel="stylesheet" type="text/css" href="/Public/libs/css/export.css">
+	<script type="text/javascript" src="/static/basejs/jquery-1.8.0.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-lang-zh_CN.js"></script>
+	<script type="text/javascript" src="/static/uploadify/jquery.uploadify.js"></script>
+	<script type="text/javascript" src="/static/basejs/th.js"></script>
+	<script type="text/javascript" src="/static/easyui/src/jquery.window.js"></script>
+	<script type="text/javascript" src="/static/easyui/formatter.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-validatebox-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-loading.js"></script>
+	<script type="text/javascript" src="/static/basejs/jquery.qrcode.min.js"></script>
+	<script type="text/javascript" src="/static/basejs/LodopFuncs.js"></script>
+	<script type="text/javascript" src="/static/basejs/newqcode.js"></script>
+	<script type="text/javascript" src="/static/basejs/template.js"></script>
+</head>
+
+<body class="easyui-layout">
+<div data-options="region:'north',title:'',split:true" style="height: 540px;border:none">
+	<div id="excelListToolbar">
+		<form id="searchBthForm" class="smShow">
+			<table  style="width:100%;white-space: nowrap;padding:10px;">
+				<tr>
+					<td align="left">
+						辅料名称:
+					</td>
+					<td>
+						<select name="sysCdNm" style="height:30px;" >
+							<option value="0">全部</option>
+							<volist name="productlist" id="val">
+								<option value="{$val.product_name}">{$val.product_name}</option>
+							</volist>
+						</select>
+					</td>
+					<td align="left">
+						公司名称:
+					</td>
+					<td>
+						<select name="user_name" style="height:30px;">
+							<volist name="userlist" id="val">
+								<option value="{$val.nickname}">{$val.nickname}</option>
+							</volist>
+						</select>
+					</td>
+
+					<td align="left">
+						批次发货状态:
+					</td>
+					<td align="left">
+						<select name="status" style="height:30px;width:150px">
+							<option value="0">待发货</option>
+							<option value="1">已删除</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td align="left">
+						导出开始时间:
+					</td>
+					<td>
+						<input id ="startDate" name="startDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+					</td>
+
+					<td align="left">
+						导出结束时间:
+					</td>
+					<td>
+						<input id ="endDate"  name="endDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+					</td>
+
+					<td colspan="2" align="left">
+						<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="searchBthFun()">查询</a>
+					</td>
+				<tr/>
+				<tr>
+					<td colspan="10" class="export-tips"></td>
+				</tr>
+				<tr>
+					<td align="left">
+						请输入订单号:
+					</td>
+					<td>
+						<!--<input id="order_num" name="order_num" class="easyui-numberbox" style="width:150px" type="text"  value=""  data-options="min:0"/>-->
+						<input id="order_num" name="order_num" style="width:150px" type="text"  value=""/>
+					</td>
+					<td align="left">
+						请输入司机:
+					</td>
+					<td>
+						<input name="deliveryman" class="" style="width:150px" type="text"  value="" />
+					</td>
+					<td align="left">
+						请输入司机电话:
+					</td>
+					<td>
+						<input name="shr_phone" class="" style="width:150px" type="text"  value=""/>
+					</td>
+				</tr>
+				<tr>
+					<td align="left">
+						请输入车牌号:
+					</td>
+					<td>
+						<input name="plate_number" class="" style="width:150px" type="text"  value=""/>
+					</td>
+
+					<td align="left">
+						备注:
+					</td>
+					<td>
+						<input name="note" style="width:420px" type="text"  value="" >
+					</td>
+					<td>
+						<a href="#" class="easyui-linkbutton addBthFahuo" data-options="iconCls:'icon-search'">发货</a>
+					</td>
+				</tr>
+				<!--<tr>-->
+					<!--<td colspan="4" align="right">-->
+						<!--<a href="#" class="easyui-linkbutton addBthFahuo" data-options="iconCls:'icon-search'">发货</a>-->
+					<!--</td>-->
+				<!--</tr>-->
+			</table>
+		</form>
+	</div>
+	<table id="excelList">
+
+	</table>
+	<div class="body"></div>
+</div>
+<script>
+    var excelList;
+
+    bt_is_load=true;//定义防重复弹出小标签全局变量
+    $(document).ready(function () {
+        //初始化日期输入框
+        initDateBox();
+        excelList = $('#excelList').datagrid({
+            url: '/index.php?s=/Admin/Export/getExcelData',
+            method: 'post',
+            toolbar: '#excelListToolbar',
+            striped : true,
+            showFooter:false,
+            rownumbers: false,      // 如果为true,则显示一个行号列。
+            singleSelect: false,    // 如果为true,则只允许选择一行。
+            nowrap: false,         // 如果为true,则在同一行中显示数据。设置为true可以提高加载性能。
+            fit: true,             // datagrid自适应宽高
+            fitColumns: true,      // 使列自动展开/收缩到合适的数据表格宽度。
+            autoRowHeight: false,  // 定义设置行的高度,根据该行的内容。设置为false可以提高负载性能。
+            sortName: 'id',       // 排序字段
+            sortOrder: 'desc',       // 排序方式
+            pagination: true,      // 显示分页工具条
+            pageSize: 100,//初始化页面大小
+            pageList: [10, 20, 30, 50, 100, 500,1000,2000,5000,10000],// 初始化页面大小选择列表
+            queryParams: $('#searchBthForm').serializeObject(),
+            columns: [[
+                {field: 'ck', checkbox: true},
+                {field: 'matter_name', title: '辅料名称', sortable: true, width: 200},
+                {field: 'matter_no', title: '辅料编码', sortable: true, width: 200},
+                {field: 'username', title: '所属用户',  width: 200},
+                {field: 'large_num', title: '大件数量', align: 'center', sortable: true, width: 100},
+                {field: 'small_num', title: '小件数量', align: 'center', sortable: true, width: 100},
+                {field: 'date', title: '创建日期', align: 'center', sortable: true, width: 150,
+                    formatter: function(value,row,index){
+                        return UnixToDate(value,true,8);
+                    }
+                },
+                {field:'id',title:'ID',align:'center',sortable:false,width:100,hidden:true},
+
+                {field: 'file_dir', title: '下载路径', align: 'center', sortable: true, width: 200,
+                    formatter: function(value,row,index){
+                        if(row.status==0){
+                            return "<a href="+value+">点击下载</a>";
+                        }else{
+                            return "不支持下载";
+                        }
+
+                    }
+                },
+
+                {field:'status',title:'状态',align:'center',sortable:false,width:100,
+                    formatter: function(value,row,index){
+                        if(value==0){
+                            return '待发货';
+                        }else{
+                            return '已删除';
+                        }
+                    }
+                },
+
+                {field:'option',title:'操作',align:'center',sortable:false,width:100,
+                    formatter: function(value,row,index){
+                        if(row.status==0){
+                            return '<a class="red" data-id='+value+' onclick="deal('+row.id+')">删除</a>';
+                        }else{
+                            //return '<a class="green" data-id='+value+' onclick="fa('+value+')">发货</a>';
+                        }
+                    }
+                }
+            ]],
+
+            onClickRow: function (rowIndex, rowData) {
+                $('#excelList').datagrid('unselectRow', rowIndex);
+            },
+
+            onClickCell:function(rowIndex, field, value){
+
+            },
+
+            onLoadError: function () {
+                $.messager.alert('系统提示', '数据加载错误,请刷新重试!', 'error');
+                return false;
+            },
+
+            onBeforeLoad: function (param,data) {
+                if (excelList != null) {
+                    excelList.datagrid('loadData', {total: 0, rows: []});
+                }
+                /*if (supTgGrid != null) {
+                    supTgGrid.datagrid('loadData', {total: 0, rows: []});
+                }
+                return true;*/
+            },
+
+            onLoadSuccess: function(data,options){
+
+            }
+
+        });
+
+    });
+
+    $('.addBthFahuo').click(function(){
+        var id_str = '';
+        var order_num = $('input[name="order_num"]').val();
+        var deliveryman = $('input[name="deliveryman"]').val();
+        var plate_number = $('input[name="plate_number"]').val();
+        var shr_phone = $('input[name="shr_phone"]').val();
+        var note = $('input[name="note"]').val();
+        $('.datagrid-row-checked').each(function (i, item) {
+            id_str += $(this).children('td:nth-child(8)').children().text() + ',';
+        });
+
+        if (order_num == ''){
+            $.messager.alert('系统提示', '请填写订单号', 'warning',function(){
+            });
+            return false;
+		}
+        if (deliveryman == ''){
+            $.messager.alert('系统提示', '请填写司机', 'warning',function(){
+            });
+            return false;
+        }
+        if (plate_number == ''){
+            $.messager.alert('系统提示', '请填写车牌号', 'warning',function(){
+            });
+            return false;
+        }
+        if (shr_phone == ''){
+            $.messager.alert('系统提示', '请填写司机电话', 'warning',function(){
+            });
+            return false;
+        }
+        if(id_str == ''){
+            $.messager.alert('系统提示', '请至少选择一个选项', 'warning',function(){
+            });
+            return false;
+        }else {
+
+            // $('.body').loading();
+            $.ajax({
+                url: "/index.php?s=/Admin/Export/addFahuo",
+                type: "post",
+                dataType: "json",
+                data: {id: id_str, order_num: order_num, deliveryman: deliveryman,plate_number: plate_number,shr_phone: shr_phone,note: note},
+                success: function (data) {
+
+                    // console.log(data);
+                    if (data != null) {
+                        $('.body').loadend();
+                        if (data.status == 0) {
+                            $.messager.alert('系统提示', data.msg, 'warning',function(){
+                            });
+                            return false;
+                        } else {
+                            // window.location.href = data.url;
+                            excelList.datagrid('load', $('#searchBthForm').serializeObject());
+                        }
+                    }
+                },
+                error: function (error) {
+
+                }
+            })
+        }
+
+    })
+
+    function deal(id){
+        $.messager.confirm('再次确认', '温馨提示:删除后无法恢复,确定删除请选择“确定”', function(r){
+            if (r){
+                // exit action;
+                $('.body').loading();
+                $.ajax({
+                    url: "/index.php?s=/Admin/Export/changeExcelData",
+                    type: "post",
+                    dataType: "json",
+                    data: {id:id},
+                    success: function (data) {
+                        $('.body').loadend();
+                        if (data != null) {
+                            if (data.status == 0) {
+                                $.messager.alert('系统提示', data.msg, 'error');
+                                excelList.datagrid('load', $('#searchBthForm').serializeObject());
+                            } else {
+                                $.messager.alert('系统提示', data.msg, 'info',function(){
+                                    excelList.datagrid('load', $('#searchBthForm').serializeObject());
+                                });
+                            }
+                        }
+                    },
+                    error: function (error) {
+
+                    }
+                })
+            }
+        });
+        return false;
+
+    }
+
+    function fa(id){
+
+    }
+
+    //初始化日期输入框
+    function initDateBox() {
+        var nowDate = new Date;
+        $('#endDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+        nowDate.setMonth(nowDate.getMonth() - 1);
+        nowDate.setDate(nowDate.getDay() +1);
+        $('#startDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+    }
+    function searchBthFun() {
+        if ($('#searchBthForm').form('validate')) {
+            //var obj = $('#searchBthForm').serializeObject();
+            excelList.datagrid('load', $('#searchBthForm').serializeObject());
+        }
+    }
+
+    function UnixToDate(unixTime, isFull, timeZone) {
+        if (typeof (timeZone) == 'number') {
+            unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
+        }
+        var time = new Date(unixTime * 1000);
+        var ymdhis = "";
+        ymdhis += time.getUTCFullYear() + "-";
+        ymdhis += (time.getUTCMonth() + 1) + "-";
+        ymdhis += time.getUTCDate();
+        if (isFull === true) {
+            ymdhis += " " + time.getUTCHours() + ":";
+            ymdhis += time.getUTCMinutes() + ":";
+            ymdhis += time.getUTCSeconds();
+        }
+        return ymdhis;
+    }
+
+</script>
+
+</body>
+</html>

+ 435 - 0
Application/Admin/View/Export/fahuo.html

@@ -0,0 +1,435 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta name="ctx" content="" />
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/default/easyui.css">
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css">
+	<link rel="stylesheet" type="text/css" href="/static/styles/demo.css">
+	<link rel="stylesheet" type="text/css" href="/static/uploadify/uploadify.css">
+	<link rel="stylesheet" type="text/css" href="/Public/libs/css/export.css">
+	<script type="text/javascript" src="/static/basejs/jquery-1.8.0.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-lang-zh_CN.js"></script>
+	<script type="text/javascript" src="/static/uploadify/jquery.uploadify.js"></script>
+	<script type="text/javascript" src="/static/basejs/th.js"></script>
+	<script type="text/javascript" src="/static/easyui/src/jquery.window.js"></script>
+	<script type="text/javascript" src="/static/easyui/formatter.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-validatebox-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-loading.js"></script>
+	<script type="text/javascript" src="/static/basejs/jquery.qrcode.min.js"></script>
+	<script type="text/javascript" src="/static/basejs/LodopFuncs.js"></script>
+	<script type="text/javascript" src="/static/basejs/newqcode.js"></script>
+	<script type="text/javascript" src="/static/basejs/template.js"></script>
+	<style>
+		.tg1  {border-collapse:collapse;border-spacing:0;font-weight:500;width:1186px}
+		.tg1 td{font-family:Arial, sans-serif;font-size:18px;/*padding:10px 5px;*/border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
+		.tg1 th{font-family:Arial, sans-serif;font-size:20px;font-weight:500;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
+		.tg1 .tg-s6z21{text-align:center;}
+		.tg1 .code{font-size:11px;}
+		.tg1 .tg-031e{text-align:center;}
+		td{
+			padding: 3px 0px;
+		}
+		.tg1 .tg-s6z2 img{ width:100px;}
+		.tg1 .font_bold{ font-size: 16px;font-weight:500; }
+		.head td{text-align: center;border: none;font-weight: 400;font-size: 28px}
+		.head1 td{text-align: center;border: none;font-weight: 400;font-size: 24px}
+		.info td{border:none}
+		.tg2 {border-collapse:collapse;border-spacing:0;font-weight:500;width:1086px}
+
+		.tg2 td{
+			font-size: 16px;
+			/*text-align: center;*/
+		}
+		.table{
+			width: 1186px;
+			position: relative;
+		}
+
+		#print span{
+			font-size: 16px;
+		}
+	</style>
+	<script src="/static/basejs/jQuery.print.js"></script>
+</head>
+
+<body class="easyui-layout">
+<div data-options="region:'north',title:'',split:true" style="height: 540px;border:none">
+	<div id="fahuoListToolbar">
+		<form id="searchBthForm" class="smShow">
+			<table  style="width:100%;white-space: nowrap;padding:10px;">
+				<tr>
+					<td align="left">
+						请输入订单号:
+					</td>
+					<td>
+						<input name="order_number" class="" style="width:150px" type="text"  value="" data-options="required:true"/>
+					</td>
+
+					<td align="left">
+						公司名称:
+					</td>
+					<td>
+						<select name="supplier_name" style="height:30px;">
+							<volist name="userlist" id="val">
+								<option value="{$val.nickname}">{$val.nickname}</option>
+							</volist>
+						</select>
+					</td>
+
+					<td align="left">
+						发货单状态:
+					</td>
+					<td align="left">
+						<select name="status" style="height:30px;width:150px">
+							<option value="0">已发货</option>
+							<option value="2">已收货</option>
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td align="left">
+						发货开始时间:
+					</td>
+					<td>
+						<input id ="startDate" name="startDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+					</td>
+
+					<td align="left">
+						发货结束时间:
+					</td>
+					<td>
+						<input id ="endDate"  name="endDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+					</td>
+
+					<td colspan="2" align="left">
+						<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="searchBthFun()">查询</a>
+					</td>
+				<tr/>
+				<tr>
+					<td colspan="10" class="export-tips"></td>
+				</tr>
+
+			</table>
+		</form>
+	</div>
+	<table id="fahuoList">
+
+	</table>
+	<div class="body"></div>
+</div>
+<div data-options="region:'center',title:'所属发货单信息',split:true"  >
+	<div id="exportGridToolbar">
+		<form id="searchTgForm">
+			<input name="exportId" id='exportId' type="hidden"/><!-- 标签类型 -->
+		</form>
+	</div>
+	<table id=exportGrid></table>
+</div>
+
+<div class="table" style="display: none;margin:0px 30px;">
+	<div id="print">
+		<div style="width: 1100px;height: 100px;position: relative;">
+			<div style="float: left">
+				<div style="width: 1000px;font-weight: 400;font-size: 28px;text-align: center;line-height: 50px;" class="company"></div>
+				<div style="width: 1000px;font-weight: 400;font-size: 24px;text-align: center;line-height: 50px;">送货单</div>
+			</div>
+			<div id="qrcode" style="display:inline-block;width: 105px;height: 105px;position: absolute;right: 100px;top: -5px;">
+				<img src="" style="width: 105px;height: 105px;" id="myImage" alt=""/>
+			</div>
+		</div>
+
+		<table class="tg1" style="margin-top: 3px;">
+			<!--<tr>-->
+			<!--<td style="border: none"></td>-->
+			<!--</tr>-->
+			<tr class="info">
+				<td colspan="6">客户名称:河南中烟工业有限责任公司黄金叶生产制造中心</td>
+				<td colspan="4">送货单号:<span style="font-size: 16px;" id="shdh"></span></td>
+				<!--<td rowspan="2" style="border: none" width="8%"></td>-->
+			</tr>
+			<tr class="info">
+				<td colspan="6">送货地址:河南省郑州市经开区第三大街9号</td>
+				<td colspan="4">送货日期:<span style="font-size: 16px;"  id="shrq_date"></span></td>
+			</tr>
+		</table>
+		<!--<div style=" width:1258px">-->
+		<!--<hr />-->
+		<!--</div>-->
+		<!--<span>送货单备注:<span id=><span id='note'></span></span>-->
+		<!--<br>	-->
+		<br>
+		<table class="tg1" style="table-layout:fixed;width: 1020px" id="table"></table>
+		<table class="tg2" style="margin-top: 3px;">
+			<tr class="footer">
+				<td colspan="3">发货单位:<span class="company"></span></td>
+				<td colspan="3">司机/司机电话:<span id="deliveryman"></span></td>
+				<td colspan="3">车牌号:<span id="carid"></span></td>
+			</tr>
+			<tr class="footer">
+				<td colspan="7">发货单位地址:<span id="address"></span></td>
+				<td colspan="3">收货单位(签名、盖章)</td>
+			</tr>
+		</table>
+	</div>
+</div>
+<script>
+    var fahuoList,exportGrid;
+
+    bt_is_load=true;//定义防重复弹出小标签全局变量
+    $(document).ready(function () {
+        //初始化日期输入框
+        initDateBox();
+        fahuoList = $('#fahuoList').datagrid({
+            url: '/index.php?s=/Admin/Export/getFahuoData',
+            method: 'post',
+            toolbar: '#fahuoListToolbar',
+            striped : true,
+            showFooter:false,
+            rownumbers: false,      // 如果为true,则显示一个行号列。
+            singleSelect: false,    // 如果为true,则只允许选择一行。
+            nowrap: false,         // 如果为true,则在同一行中显示数据。设置为true可以提高加载性能。
+            fit: true,             // datagrid自适应宽高
+            fitColumns: true,      // 使列自动展开/收缩到合适的数据表格宽度。
+            autoRowHeight: false,  // 定义设置行的高度,根据该行的内容。设置为false可以提高负载性能。
+            sortName: 'id',       // 排序字段
+            sortOrder: 'desc',       // 排序方式
+            pagination: true,      // 显示分页工具条
+            pageSize: 100,//初始化页面大小
+            pageList: [10, 20, 30, 50, 100, 500,1000,2000,5000,10000],// 初始化页面大小选择列表
+            queryParams: $('#searchBthForm').serializeObject(),
+            columns: [[
+                {field: 'ck', checkbox: true},
+                {field: 'shdh', title: '送货单号', sortable: true, width: 200},
+                {field: 'order_number', title: '订单号', sortable: true, width: 200},
+                {field: 'deliveryman', title: '司机',  width: 200},
+                {field: 'plate_number', title: '车牌号', align: 'center', sortable: true, width: 100},
+                {field: 'supplier_name', title: '供应商名称', align: 'center', sortable: true, width: 100},
+                {field: 'create_time', title: '送货日期', align: 'center', sortable: true, width: 150,
+                    formatter: function(value,row,index){
+                        return UnixToDate(value,true,8);
+                    }
+                },
+                {field:'id',title:'ID',align:'center',sortable:false,width:100,hidden:true},
+
+                {field: 'file_dir', title: '发货单打印', align: 'center', sortable: true, width: 200,
+                    formatter: function(value,row,index){
+                        if(row.status==0){
+                            return "<a href='javascript:;' onclick='dayin("+row.id+")'>点击打印</a>";
+                        }else{
+                            return "";
+                        }
+
+                    }
+                },
+                {field:'status',title:'状态',align:'center',sortable:false,width:100,
+                    formatter: function(value,row,index){
+                        if(value==0){
+                            return '已发货';
+                        }else if (value==2){
+                            return '已收货';
+                        }else {
+                            return '已删除';
+                        }
+                    }
+                },
+
+                {field:'option',title:'操作',align:'center',sortable:false,width:100,
+                    formatter: function(value,row,index){
+                        if(row.status==0){
+                            return '<a class="red" data-id='+row.id+' onclick="deal('+row.id+')">删除</a>';
+                        }else{
+                            //return '<a class="green" data-id='+value+' onclick="fa('+value+')">发货</a>';
+                        }
+                    }
+                }
+            ]],
+
+            onClickRow: function (rowIndex, rowData) {
+                $('#fahuoList').datagrid('unselectRow', rowIndex);
+            },
+
+            onClickCell:function(rowIndex, field, value){
+
+            },
+
+            onLoadError: function () {
+                $.messager.alert('系统提示', '数据加载错误,请刷新重试!', 'error');
+                return false;
+            },
+
+            onBeforeLoad: function (param,data) {
+                if (fahuoList != null) {
+                    fahuoList.datagrid('loadData', {total: 0, rows: []});
+                }
+            },
+
+            onLoadSuccess: function(data,options){
+            },
+
+            onClickRow: function (rowIndex, rowData) {
+                $('#exportId').val(rowData.large_id);
+                exportGrid.datagrid('load', $('#searchTgForm').serializeObject());
+            },
+
+        });
+
+    });
+    function dayin(id){
+        $.ajax({
+            method:"POST",
+            url:"/index.php?s=/Admin/Export/print1",
+            data:{id:id},
+            dataType:'JSON',
+            success:function(res){
+                $(".company").html(res.supplier_name);	//供应商
+                $("#shdh").html(res.shdh);				//送货单号
+                $("#shrq_date").html(res.shrq_date);	//送货日期
+                $("#carid").html(res.plate_number);		//车牌号
+                $("#deliveryman").html(res.deliveryman+'&nbsp;&nbsp;'+res.shr_phone);//送货人
+                $("#address").html(res.address);		//发货单位地址
+                var arr = res.arr;
+                var note='';
+                var html = '<tr><th class="tg-s6z2">物料名称</th>' +
+                    '<th class="tg-s6z2">生产批号</th>' +
+                    '<th class="tg-s6z2">大件</th>' +
+                    '<th class="tg-s6z2">小件</th>' +
+                    '<th class="tg-s6z2">单位</th>' +
+                    '<th class="tg-s6z2">实发数量</th>' +
+                    '<th class="tg-s6z2">备注</th>' +
+                    '<th id="explain" rowspan="'+(res.count+1)+'" width="7%" style="border: none"><span style="writing-mode: tb-rl;height: 300px;font-size:16px;text-align: center;">' +
+                    '蓝联(回):业务 黄联(回):运输 '+'<br>'+'白联:存根 红联:财务 绿联:客户</span></th></tr>';
+                for (var i=0;i < arr.length;i++){
+                    html+= '<tr><td class="tg-031e">'+arr[i].matter_name+'</td>';
+                    html+= '<td class="tg-031e" style="word-break:break-all;">'+(arr[i].bach_num?arr[i].bach_num:'')+'</td>';
+                    html+= '<td class="tg-031e">'+arr[i].large_num+'</td>';
+                    html+= '<td class="tg-031e">'+arr[i].small_num+'</td>';
+                    html+= '<td class="tg-031e">'+(arr[i].mater_type==1?'万张':"kg")+'</td>';
+                    if(arr[i].mater_type==1){
+                        html+='<td class="tg-031e">'+parseFloat(arr[i].num)*parseFloat(arr[i].small_num)/10000+'</td>';
+                        html+='<td class="tg-031e" >'+arr[i].small_num+'件*'+parseInt(arr[i].num)+'张'+'</td>';
+                    }else{
+                        html+='<td class="tg-031e">'+parseFloat(arr[i].num)*parseFloat(arr[i].small_num)/1000+'</td>';
+                        html+='<td class="tg-031e" >'+arr[i].small_num+'件*'+parseFloat(arr[i].num)/1000+'kg'+'</td>';
+                    }
+
+                    // note+=arr[i].note;
+                    // html+='<td class="tg-031e" >'+arr[i].small_num+'件*'+parseInt(arr[i].num)+(arr[i].mater_type==1?'张':"kg")+'</td>';
+
+                }
+                html+= '<tr><td class="tg-031e">送货单备注</td><td colspan="6" class="tg-031e">'+res.note+'</td></tr>';
+                $("#table").html(html)
+                // $("#note").html(note);
+                $('#myImage').attr("src", res.qrcode_add);
+
+                // createQrcode(res.shdh,110,110);
+                // var img = document.getElementById("myImage"); /// get image element
+                // var canvas = document.getElementsByTagName('canvas')[0];
+                // img.src = canvas.toDataURL();                     /// update image
+                // if(!res.qrcode_add){
+                //     $.ajax({
+                //         method:"POST",
+                //         data:{
+                //             qrcode_add:img.src,
+                //             ids:id
+                //         },
+                //         dataType:'JSON',
+                //         url:"/index.php?s=/Admin/Export/qrcode_up",
+                //         success:function(rs){
+                //             console.log(rs);
+                //         }
+                //     });
+                // }
+                $.print('#print');
+                return false;
+            }
+        })
+    }
+    // function createQrcode(txt,width,height) {
+    //     $("#qrcode").qrcode({
+    //         render: "canvas",//canvas和table两种渲染方式
+    //         width: width,
+    //         height: height,
+    //         correctLevel:3,//二维码纠错级别
+    //         background:"#ffffff",//背景颜色
+    //         foreground:"#000000", //二维码颜色
+    //         text:txt
+    //     });
+    // }
+
+
+    function deal(id){
+        $.messager.confirm('再次确认', '温馨提示:删除后无法恢复,确定删除请选择“确定”', function(r){
+            if (r){
+                // exit action;
+                $('.body').loading();
+                $.ajax({
+                    url: "/index.php?s=/Admin/Export/changeFahuoData",
+                    type: "post",
+                    dataType: "json",
+                    data: {id:id},
+                    success: function (data) {
+                        $('.body').loadend();
+                        if (data != null) {
+                            if (data.status == 0) {
+                                $.messager.alert('系统提示', data.msg, 'error');
+                                fahuoList.datagrid('load', $('#searchBthForm').serializeObject());
+                            } else {
+                                $.messager.alert('系统提示', data.msg, 'info',function(){
+                                    fahuoList.datagrid('load', $('#searchBthForm').serializeObject());
+                                });
+                            }
+                        }
+                    },
+                    error: function (error) {
+
+                    }
+                })
+            }
+        });
+        return false;
+
+    }
+
+    function fa(id){
+
+    }
+
+    //初始化日期输入框
+    function initDateBox() {
+        var nowDate = new Date;
+        $('#endDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+        nowDate.setMonth(nowDate.getMonth() - 1);
+        nowDate.setDate(nowDate.getDay() +1);
+        $('#startDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+    }
+    function searchBthFun() {
+        if ($('#searchBthForm').form('validate')) {
+            //var obj = $('#searchBthForm').serializeObject();
+            fahuoList.datagrid('load', $('#searchBthForm').serializeObject());
+        }
+    }
+
+    function UnixToDate(unixTime, isFull, timeZone) {
+        if (typeof (timeZone) == 'number') {
+            unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
+        }
+        var time = new Date(unixTime * 1000);
+        var ymdhis = "";
+        ymdhis += time.getUTCFullYear() + "-";
+        ymdhis += (time.getUTCMonth() + 1) + "-";
+        ymdhis += time.getUTCDate();
+        if (isFull === true) {
+            ymdhis += " " + time.getUTCHours() + ":";
+            ymdhis += time.getUTCMinutes() + ":";
+            ymdhis += time.getUTCSeconds();
+        }
+        return ymdhis;
+    }
+
+</script>
+
+</body>
+</html>

+ 310 - 0
Application/Admin/View/Export/index.html

@@ -0,0 +1,310 @@
+<extend name="$_admin_public_layout"/>
+
+<block name="full-header">
+    <!-- 顶部导航 -->
+    <div class="navbar navbar-default navbar-fixed-top main-nav" role="navigation">
+        <div class="container-fluid">
+            <div>
+                <div class="navbar-header navbar-header-default">
+                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse-top">
+                        <span class="sr-only">切换导航</span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                    </button>
+                    <php>if(C('WEB_SITE_LOGO')):</php>
+                    <a class="navbar-brand" target="_blank" href="__ROOT__/">
+                        <img class="logo img-responsive" src="{$Think.config.WEB_SITE_LOGO|get_cover}">
+                    </a>
+                    <php>else:</php>
+                    <a class="navbar-brand" target="_blank" href="__ROOT__/">
+                        <span>{:C('LOGO_DEFAULT')}</span>
+                    </a>
+                    <php>endif;</php>
+                </div>
+                <div class="navbar-header navbar-header-inverse">
+                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse-top">
+                        <span class="sr-only">切换导航</span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                    </button>
+                    <php>if(C('WEB_SITE_LOGO_INVERSE')):</php>
+                    <a class="navbar-brand" target="_blank" href="__ROOT__/">
+                        <img class="logo img-responsive" src="{$Think.config.WEB_SITE_LOGO_INVERSE|get_cover}">
+                    </a>
+                    <php>else:</php>
+                    <a class="navbar-brand" target="_blank" href="__ROOT__/">
+                        <span>{:C('LOGO_DEFAULT')}</span>
+                    </a>
+                    <php>endif;</php>
+                </div>
+                <div class="collapse navbar-collapse navbar-collapse-top">
+                    <ul class="nav navbar-nav">
+                        <!-- 主导航 -->
+                        <?php if (!C('ADMIN_TABS')): ?>
+                        <li><a href="{:U('Admin/Index/index')}"><i class="fa fa-home"></i> 首页</a></li>
+                        <?php if (count($_menu_list) > 6): ?>
+                        <volist name="_menu_list" id="vo" offset="0" length="6">
+                            <li <?php if($_parent_menu_list[0]['title'] == $vo['title']) echo 'class="active"'; ?>>
+                            <a href="{:U($vo['_child'][0]['_child'][0]['url'])}" target="<php>echo C(strtolower($vo['name']).'_config.target');</php>">
+                                <i class="fa {$vo.icon}"></i>
+                                <span>{$vo.title}</span>
+                            </a>
+                            </li>
+                        </volist>
+                        <li class="dropdown">
+                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+                                <i class="fa fa-th-large"></i> 更多 <b class="caret"></b>
+                            </a>
+                            <ul class="dropdown-menu" role="menu">
+                                <volist name="_menu_list" id="vo" offset="6">
+                                    <li <?php if($_parent_menu_list[0]['title'] == $vo['title']) echo 'class="active"'; ?>>
+                                    <a href="{:U($vo['_child'][0]['_child'][0]['url'])}" target="<php>echo C(strtolower($vo['name']).'_config.target');</php>">
+                                        <i class="fa {$vo.icon}"></i>
+                                        <span>{$vo.title}</span>
+                                    </a>
+                                    </li>
+                                </volist>
+                            </ul>
+                        </li>
+                        <?php else: ?>
+                        <if condition="session('uid') eq 1">
+                            <volist name="_menu_list" id="vo">
+                                <li <?php if($_parent_menu_list[0]['title'] == $vo['title']) echo 'class="active"'; ?>>
+                                <a href="{:U($vo['_child'][0]['_child'][0]['url'])}" target="<php>echo C(strtolower($vo['name']).'_config.target');</php>">
+                                    <i class="fa {$vo.icon}"></i>
+                                    <span>{$vo.title}</span>
+                                </a>
+                                </li>
+                            </volist>
+                        </if>
+                        <?php endif; ?>
+                        <?php else: ?>
+                        <?php if (count($_menu_list) > 7): ?>
+                        <volist name="_menu_list" id="vo" offset="0" length="7">
+                            <li>
+                                <a href="#module{$vo.id}" role="tab" data-toggle="tab">
+                                    <i class="fa {$vo.icon}"></i>
+                                    <span>{$vo.title}</span>
+                                </a>
+                            </li>
+                        </volist>
+                        <li class="dropdown">
+                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+                                <i class="fa fa-th-large"></i> 更多 <b class="caret"></b>
+                            </a>
+                            <ul class="dropdown-menu" role="menu">
+                                <volist name="_menu_list" id="vo" offset="7">
+                                    <li>
+                                        <a href="#module{$vo.id}" role="tab" data-toggle="tab">
+                                            <i class="fa {$vo.icon}"></i>
+                                            <span>{$vo.title}</span>
+                                        </a>
+                                    </li>
+                                </volist>
+                            </ul>
+                        </li>
+                        <?php else: ?>
+                        <if condition="session('uid') eq 1">
+                            <volist name="_menu_list" id="vo">
+                                <li>
+                                    <a href="#module{$vo.id}" role="tab" data-toggle="tab">
+                                        <i class="fa {$vo.icon}"></i>
+                                        <span>{$vo.title}</span>
+                                    </a>
+                                </li>
+                            </volist>
+                        </if>
+                        <?php endif; ?>
+                        <?php endif; ?>
+                    </ul>
+                    <ul class="nav navbar-nav navbar-right">
+                        <if condition="session('uid') eq 1"><li><a href="{:U('Admin/Index/removeRuntime')}" style="border: 0;text-align: left" class="btn ajax-get no-refresh"><i class="fa fa-trash"></i> 清空缓存</a></li></if>
+                        <li class="dropdown">
+                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+                                <i class="fa fa-user"></i> {$_user_auth.nickname} <b class="caret"></b>
+                            </a>
+                            <ul class="dropdown-menu" role="menu">
+                                <if condition="session('uid') eq 1"> <li><a href="{:U('Admin/Index/removeRuntime')}" style="border: 0;text-align: left" class="btn ajax-get no-refresh"><i class="fa fa-trash"></i> 清空缓存</a></li></if>
+                                <li><a href="{:U('Admin/Public/logout')}" class="ajax-get"><i class="fa fa-sign-out"></i> 退出</a></li>
+                            </ul>
+                        </li>
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </div>
+</block>
+
+<block name="full-container">
+    <div class="container-fluid with-top-navbar" style="height: 100%;overflow: hidden;">
+        <div class="row" style="height: 100%;">
+            <!-- 后台左侧导航 -->
+            <div id="sidebar" class="col-xs-12 col-sm-3 sidebar tab-content">
+                <?php if (!C('ADMIN_TABS')): ?>
+                <!-- 模块菜单 -->
+                <nav class="navside navside-default" role="navigation">
+                    <?php if($_current_menu_list['_child']): ?>
+                    <ul class="nav navside-nav navside-first">
+                        <volist name="_current_menu_list._child" id="_ns_first" key="fkey">
+                            <li>
+                                <a data-toggle="collapse" href="#navside-collapse-{$_ns.id}-{$fkey}">
+                                    <i class="{$_ns_first.icon}"></i>
+                                    <span class="nav-label">{$_ns_first.title}</span>
+                                    <span class="angle fa fa-angle-down"></span>
+                                    <span class="angle-collapse fa fa-angle-left"></span>
+                                </a>
+                                <notempty name="_ns_first._child">
+                                    <ul class="nav navside-nav navside-second collapse in" id="navside-collapse-{$_ns.id}-{$fkey}">
+                                        <volist name="_ns_first._child" id="_ns_second" key="skey">
+                                            <li <?php if($_parent_menu_list[2]['id'] == $_ns_second['id']) echo 'class="active"'; ?>>
+                                            <a href="{:U($_ns_second['url'])}" >
+                                                <i class="{$_ns_second.icon}"></i>
+                                                <span class="nav-label">{$_ns_second.title}</span>
+                                            </a>
+                                            </li>
+                                        </volist>
+                                    </ul>
+                                </notempty>
+                            </li>
+                        </volist>
+                    </ul>
+                    <?php endif; ?>
+                </nav>
+                <?php else: ?>
+                <!-- 模块菜单 -->
+                <volist name="_menu_list" id="_ns">
+                    <?php if($_ns['_child']): ?>
+                    <div role="tabpanel" class="tab-pane fade <?php if($i === 1) echo 'active in';?>" id="module{$_ns.id}">
+                        <nav class="navside navside-default" role="navigation">
+                            <ul class="nav navside-nav navside-first">
+                                <notempty name="_ns._child">
+                                    <volist name="_ns._child" id="_ns_first" key="fkey">
+                                        <li>
+                                            <a data-toggle="collapse" href="#navside-collapse-{$_ns.id}-{$fkey}">
+                                                <i class="{$_ns_first.icon}"></i>
+                                                <span class="nav-label">{$_ns_first.title}</span>
+                                                <span class="fa arrow"></span>
+                                            </a>
+                                            <notempty name="_ns_first._child">
+                                                <ul class="nav navside-nav navside-second collapse in" id="navside-collapse-{$_ns.id}-{$fkey}">
+                                                    <volist name="_ns_first._child" id="_ns_second" key="skey">
+                                                        <li>
+                                                            <a href="{:U($_ns_second['url'])}" class="open-tab" tab-name="navside-collapse-{$_ns.id}-{$fkey}-{$skey}">
+                                                                <i class="{$_ns_second.icon}"></i>
+                                                                <span class="nav-label">{$_ns_second.title}</span>
+                                                            </a>
+                                                        </li>
+                                                    </volist>
+                                                </ul>
+                                            </notempty>
+                                        </li>
+                                    </volist>
+                                </notempty>
+                            </ul>
+                        </nav>
+                    </div>
+                    <?php endif; ?>
+                </volist>
+                <?php endif; ?>
+            </div>
+
+            <!-- 右侧内容 -->
+            <div id="main" class="col-xs-12 col-sm-9 main" style="padding-right: 0;">
+                <?php if (C('ADMIN_TABS')): ?>
+                <!-- 多标签后台 -->
+                <nav class="navbar navbar-default ct-tab-nav" role="navigation">
+                    <div class="collapse navbar-collapse">
+                        <ul class="nav navbar-nav navbar-left">
+                            <li><a href="#" id="tab-left"><i class="fa fa-caret-left"></i></a></li>
+                        </ul>
+                        <div class="ct-tab-wrap clearfix">
+                            <ul class="nav navbar-nav nav-close ct-tab">
+                                <li href="#home" role="tab" data-toggle="tab">
+                                    <a href="#"><i class="fa fa-dashboard"></i> <span>首页</span></a>
+                                </li>
+                            </ul>
+                        </div>
+                        <ul class="nav navbar-nav navbar-right">
+                            <li><a href="#" id="tab-right"><i class="fa fa-caret-right"></i></a></li>
+                            <li class="dropdown">
+                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">关闭操作 <b class="caret"></b></a>
+                                <ul class="dropdown-menu">
+                                    <li><a href="#" class="close-all">关闭所有</a></li>
+                                </ul>
+                            </li>
+                        </ul>
+                    </div>
+                </nav>
+                <?php else: ?>
+                <!-- 面包屑导航 -->
+                <!--   <ul class="breadcrumb">
+                      <li><i class="fa fa-map-marker"></i></li>
+                      <li class="text-muted">首页</li>
+                  </ul> -->
+                <?php endif; ?>
+                <!--右侧内容-->
+                <div class="easyui-tabs" style="height: 580px;">
+                    <div class="export-tab" title="大件发货" >
+                        <iframe id="iframe1" scrolling="auto" frameborder="0" name="iframe1" src="index.php?s=/Admin/Export/exportDetail.html" style="width:100%;height:100%;">
+                        </iframe>
+                    </div>
+                    <div class="export-tab" title="批次发货申请" >
+                        <iframe id="iframe2" scrolling="auto" frameborder="0" name="iframe2" src="index.php?s=/Admin/Export/exportExcel.html" style="width:100%;height:100%;">
+                        </iframe>
+                    </div>
+                    <div class="export-tab" title="发货单" >
+                        <iframe id="iframe3" scrolling="auto" frameborder="0" name="iframe3" src="index.php?s=/Admin/Export/exportFahuo.html" style="width:100%;height:100%;">
+                        </iframe>
+                    </div>
+                </div>
+
+                <div class="clearfix footer">
+                    <div class="navbar navbar-default" role="navigation">
+                        <div class="container-fluid">
+                            <div class="navbar-header">
+
+                            </div>
+                            <div class="collapse navbar-collapse navbar-collapse-bottom">
+                                <ul class="nav navbar-nav">
+                                    <li>
+                                    </li>
+                                </ul>
+                                <ul class="nav navbar-nav navbar-right">
+                                    <li></li>
+                                </ul>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide_index.js?_t=2016121401"></script>
+    <script>
+        $('.easyui-tabs').tabs({
+            onSelect:function(title,index){
+                //document.location.reload();
+                switch (index){
+                    case 0:
+                        document.getElementById('iframe1').contentWindow.location.reload(true);
+                        break;
+                    case 1:
+                        document.getElementById('iframe2').contentWindow.location.reload(true);
+                        break;
+                    case 2:
+                        document.getElementById('iframe3').contentWindow.location.reload(true);
+                        break;
+                }
+            }
+        })
+    </script>
+</block>
+<script>
+
+</script>

+ 312 - 0
Application/Admin/View/Export/index1.html

@@ -0,0 +1,312 @@
+<extend name="$_admin_public_layout"/>
+
+<block name="full-header">
+    <!-- 顶部导航 -->
+    <div class="navbar navbar-default navbar-fixed-top main-nav" role="navigation">
+        <div class="container-fluid">
+            <div>
+                <div class="navbar-header navbar-header-default">
+                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse-top">
+                        <span class="sr-only">切换导航</span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                    </button>
+                    <php>if(C('WEB_SITE_LOGO')):</php>
+                    <a class="navbar-brand" target="_blank" href="__ROOT__/">
+                        <img class="logo img-responsive" src="{$Think.config.WEB_SITE_LOGO|get_cover}">
+                    </a>
+                    <php>else:</php>
+                    <a class="navbar-brand" target="_blank" href="__ROOT__/">
+                        <span>{:C('LOGO_DEFAULT')}</span>
+                    </a>
+                    <php>endif;</php>
+                </div>
+                <div class="navbar-header navbar-header-inverse">
+                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse-top">
+                        <span class="sr-only">切换导航</span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                    </button>
+                    <php>if(C('WEB_SITE_LOGO_INVERSE')):</php>
+                    <a class="navbar-brand" target="_blank" href="__ROOT__/">
+                        <img class="logo img-responsive" src="{$Think.config.WEB_SITE_LOGO_INVERSE|get_cover}">
+                    </a>
+                    <php>else:</php>
+                    <a class="navbar-brand" target="_blank" href="__ROOT__/">
+                        <span>{:C('LOGO_DEFAULT')}</span>
+                    </a>
+                    <php>endif;</php>
+                </div>
+                <div class="collapse navbar-collapse navbar-collapse-top">
+                    <ul class="nav navbar-nav">
+                        <!-- 主导航 -->
+                        <?php if (!C('ADMIN_TABS')): ?>
+                        <li><a href="{:U('Admin/Index/index')}"><i class="fa fa-home"></i> 首页</a></li>
+                        <?php if (count($_menu_list) > 6): ?>
+                        <volist name="_menu_list" id="vo" offset="0" length="6">
+                            <li <?php if($_parent_menu_list[0]['title'] == $vo['title']) echo 'class="active"'; ?>>
+                            <a href="{:U($vo['_child'][0]['_child'][0]['url'])}" target="<php>echo C(strtolower($vo['name']).'_config.target');</php>">
+                                <i class="fa {$vo.icon}"></i>
+                                <span>{$vo.title}</span>
+                            </a>
+                            </li>
+                        </volist>
+                        <li class="dropdown">
+                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+                                <i class="fa fa-th-large"></i> 更多 <b class="caret"></b>
+                            </a>
+                            <ul class="dropdown-menu" role="menu">
+                                <volist name="_menu_list" id="vo" offset="6">
+                                    <li <?php if($_parent_menu_list[0]['title'] == $vo['title']) echo 'class="active"'; ?>>
+                                    <a href="{:U($vo['_child'][0]['_child'][0]['url'])}" target="<php>echo C(strtolower($vo['name']).'_config.target');</php>">
+                                        <i class="fa {$vo.icon}"></i>
+                                        <span>{$vo.title}</span>
+                                    </a>
+                                    </li>
+                                </volist>
+                            </ul>
+                        </li>
+                        <?php else: ?>
+                        <if condition="session('uid') eq 1">
+                            <volist name="_menu_list" id="vo">
+                                <li <?php if($_parent_menu_list[0]['title'] == $vo['title']) echo 'class="active"'; ?>>
+                                <a href="{:U($vo['_child'][0]['_child'][0]['url'])}" target="<php>echo C(strtolower($vo['name']).'_config.target');</php>">
+                                    <i class="fa {$vo.icon}"></i>
+                                    <span>{$vo.title}</span>
+                                </a>
+                                </li>
+                            </volist>
+                        </if>
+                        <?php endif; ?>
+                        <?php else: ?>
+                        <?php if (count($_menu_list) > 7): ?>
+                        <volist name="_menu_list" id="vo" offset="0" length="7">
+                            <li>
+                                <a href="#module{$vo.id}" role="tab" data-toggle="tab">
+                                    <i class="fa {$vo.icon}"></i>
+                                    <span>{$vo.title}</span>
+                                </a>
+                            </li>
+                        </volist>
+                        <li class="dropdown">
+                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+                                <i class="fa fa-th-large"></i> 更多 <b class="caret"></b>
+                            </a>
+                            <ul class="dropdown-menu" role="menu">
+                                <volist name="_menu_list" id="vo" offset="7">
+                                    <li>
+                                        <a href="#module{$vo.id}" role="tab" data-toggle="tab">
+                                            <i class="fa {$vo.icon}"></i>
+                                            <span>{$vo.title}</span>
+                                        </a>
+                                    </li>
+                                </volist>
+                            </ul>
+                        </li>
+                        <?php else: ?>
+                        <if condition="session('uid') eq 1">
+                            <volist name="_menu_list" id="vo">
+                                <li>
+                                    <a href="#module{$vo.id}" role="tab" data-toggle="tab">
+                                        <i class="fa {$vo.icon}"></i>
+                                        <span>{$vo.title}</span>
+                                    </a>
+                                </li>
+                            </volist>
+                        </if>
+                        <?php endif; ?>
+                        <?php endif; ?>
+                    </ul>
+                    <ul class="nav navbar-nav navbar-right">
+                        <if condition="session('uid') eq 1"><li><a href="{:U('Admin/Index/removeRuntime')}" style="border: 0;text-align: left" class="btn ajax-get no-refresh"><i class="fa fa-trash"></i> 清空缓存</a></li></if>
+                        <li class="dropdown">
+                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
+                                <i class="fa fa-user"></i> {$_user_auth.nickname} <b class="caret"></b>
+                            </a>
+                            <ul class="dropdown-menu" role="menu">
+                                <if condition="session('uid') eq 1"> <li><a href="{:U('Admin/Index/removeRuntime')}" style="border: 0;text-align: left" class="btn ajax-get no-refresh"><i class="fa fa-trash"></i> 清空缓存</a></li></if>
+                                <li><a href="{:U('Admin/Public/logout')}" class="ajax-get"><i class="fa fa-sign-out"></i> 退出</a></li>
+                            </ul>
+                        </li>
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </div>
+</block>
+
+<block name="full-container">
+    <div class="container-fluid with-top-navbar" style="height: 100%;overflow: hidden;">
+        <div class="row" style="height: 100%;">
+            <!-- 后台左侧导航 -->
+            <div id="sidebar" class="col-xs-12 col-sm-3 sidebar tab-content">
+                <?php if (!C('ADMIN_TABS')): ?>
+                <!-- 模块菜单 -->
+                <nav class="navside navside-default" role="navigation">
+                    <?php if($_current_menu_list['_child']): ?>
+                    <ul class="nav navside-nav navside-first">
+                        <volist name="_current_menu_list._child" id="_ns_first" key="fkey">
+                            <li>
+                                <a data-toggle="collapse" href="#navside-collapse-{$_ns.id}-{$fkey}">
+                                    <i class="{$_ns_first.icon}"></i>
+                                    <span class="nav-label">{$_ns_first.title}</span>
+                                    <span class="angle fa fa-angle-down"></span>
+                                    <span class="angle-collapse fa fa-angle-left"></span>
+                                </a>
+                                <notempty name="_ns_first._child">
+                                    <ul class="nav navside-nav navside-second collapse in" id="navside-collapse-{$_ns.id}-{$fkey}">
+                                        <volist name="_ns_first._child" id="_ns_second" key="skey">
+                                            <li <?php if($_parent_menu_list[2]['id'] == $_ns_second['id']) echo 'class="active"'; ?>>
+                                            <a href="{:U($_ns_second['url'])}" >
+                                                <i class="{$_ns_second.icon}"></i>
+                                                <span class="nav-label">{$_ns_second.title}</span>
+                                            </a>
+                                            </li>
+                                        </volist>
+                                    </ul>
+                                </notempty>
+                            </li>
+                        </volist>
+                    </ul>
+                    <?php endif; ?>
+                </nav>
+                <?php else: ?>
+                <!-- 模块菜单 -->
+                <volist name="_menu_list" id="_ns">
+                    <?php if($_ns['_child']): ?>
+                    <div role="tabpanel" class="tab-pane fade <?php if($i === 1) echo 'active in';?>" id="module{$_ns.id}">
+                        <nav class="navside navside-default" role="navigation">
+                            <ul class="nav navside-nav navside-first">
+                                <notempty name="_ns._child">
+                                    <volist name="_ns._child" id="_ns_first" key="fkey">
+                                        <li>
+                                            <a data-toggle="collapse" href="#navside-collapse-{$_ns.id}-{$fkey}">
+                                                <i class="{$_ns_first.icon}"></i>
+                                                <span class="nav-label">{$_ns_first.title}</span>
+                                                <span class="fa arrow"></span>
+                                            </a>
+                                            <notempty name="_ns_first._child">
+                                                <ul class="nav navside-nav navside-second collapse in" id="navside-collapse-{$_ns.id}-{$fkey}">
+                                                    <volist name="_ns_first._child" id="_ns_second" key="skey">
+                                                        <li>
+                                                            <a href="{:U($_ns_second['url'])}" class="open-tab" tab-name="navside-collapse-{$_ns.id}-{$fkey}-{$skey}">
+                                                                <i class="{$_ns_second.icon}"></i>
+                                                                <span class="nav-label">{$_ns_second.title}</span>
+                                                            </a>
+                                                        </li>
+                                                    </volist>
+                                                </ul>
+                                            </notempty>
+                                        </li>
+                                    </volist>
+                                </notempty>
+                            </ul>
+                        </nav>
+                    </div>
+                    <?php endif; ?>
+                </volist>
+                <?php endif; ?>
+            </div>
+
+            <!-- 右侧内容 -->
+            <div id="main" class="col-xs-12 col-sm-9 main" style="padding-right: 0;">
+                <?php if (C('ADMIN_TABS')): ?>
+                <!-- 多标签后台 -->
+                <nav class="navbar navbar-default ct-tab-nav" role="navigation">
+                    <div class="collapse navbar-collapse">
+                        <ul class="nav navbar-nav navbar-left">
+                            <li><a href="#" id="tab-left"><i class="fa fa-caret-left"></i></a></li>
+                        </ul>
+                        <div class="ct-tab-wrap clearfix">
+                            <ul class="nav navbar-nav nav-close ct-tab">
+                                <li href="#home" role="tab" data-toggle="tab">
+                                    <a href="#"><i class="fa fa-dashboard"></i> <span>首页</span></a>
+                                </li>
+                            </ul>
+                        </div>
+                        <ul class="nav navbar-nav navbar-right">
+                            <li><a href="#" id="tab-right"><i class="fa fa-caret-right"></i></a></li>
+                            <li class="dropdown">
+                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">关闭操作 <b class="caret"></b></a>
+                                <ul class="dropdown-menu">
+                                    <li><a href="#" class="close-all">关闭所有</a></li>
+                                </ul>
+                            </li>
+                        </ul>
+                    </div>
+                </nav>
+                <?php else: ?>
+                <!-- 面包屑导航 -->
+                <!--   <ul class="breadcrumb">
+                      <li><i class="fa fa-map-marker"></i></li>
+                      <li class="text-muted">首页</li>
+                  </ul> -->
+                <?php endif; ?>
+                <!--右侧内容-->
+
+                <div class="easyui-tabs" style="height: 580px;">
+                    <div class="export-tab" title="导出批次" >
+                        <iframe id="iframe1" scrolling="auto" frameborder="0" name="iframe1" src="index.php?s=/Admin/Export/exportDetail.html" style="width:100%;height:100%;">
+                        </iframe>
+                    </div>
+                    <div class="export-tab" title="批次发货申请" >
+                        <iframe id="iframe2" scrolling="auto" frameborder="0" name="iframe2" src="index.php?s=/Admin/Export/exportExcel.html" style="width:100%;height:100%;">
+                        </iframe>
+                    </div>
+                    <div class="export-tab" title="发货单" >
+                        <iframe id="iframe3" scrolling="auto" frameborder="0" name="iframe3" src="index.php?s=/Admin/Export/exportFahuo.html" style="width:100%;height:100%;">
+                        </iframe>
+                    </div>
+                </div>
+
+
+                <div class="clearfix footer">
+                    <div class="navbar navbar-default" role="navigation">
+                        <div class="container-fluid">
+                            <div class="navbar-header">
+
+                            </div>
+                            <div class="collapse navbar-collapse navbar-collapse-bottom">
+                                <ul class="nav navbar-nav">
+                                    <li>
+                                    </li>
+                                </ul>
+                                <ul class="nav navbar-nav navbar-right">
+                                    <li></li>
+                                </ul>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</block>
+
+<block name="script">
+    <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+    <script src="__PUBLIC__/libs/guide/guide_index.js?_t=2016121401"></script>
+    <script>
+        $('.easyui-tabs').tabs({
+            onSelect:function(title,index){
+                //document.location.reload();
+                switch (index){
+                    case 0:
+                        document.getElementById('iframe1').contentWindow.location.reload(true);
+                        break;
+                    case 1:
+                        document.getElementById('iframe2').contentWindow.location.reload(true);
+                        break;
+                    case 2:
+                        document.getElementById('iframe3').contentWindow.location.reload(true);
+                        break;
+                }
+            }
+        })
+    </script>
+</block>
+<script>
+
+</script>

+ 30 - 0
Application/Admin/View/Export/shouhuo.html

@@ -0,0 +1,30 @@
+<extend name="$_admin_public_layout" />
+<block name="main">
+	<!-- 多标签后台内容部分 -->
+	<iframe scrolling="auto" frameborder="0" src="index.php?s=/Admin/export/exportShouhuo.html"
+			style="width:100%;height:100%;"></iframe>
+
+	<div class="clearfix footer">
+		<div class="navbar navbar-default" role="navigation">
+			<div class="container-fluid">
+				<div class="navbar-header">
+
+				</div>
+				<div class="collapse navbar-collapse navbar-collapse-bottom">
+					<ul class="nav navbar-nav">
+						<li>
+						</li>
+					</ul>
+					<ul class="nav navbar-nav navbar-right">
+						<li></li>
+					</ul>
+				</div>
+			</div>
+		</div>
+	</div>
+</block>
+
+<block name="script">
+	<script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
+	<script src="__PUBLIC__/libs/guide/guide_index.js?_t=2016121401"></script>
+</block>

+ 506 - 0
Application/Admin/View/Export/shouhuolist.html

@@ -0,0 +1,506 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta name="ctx" content="" />
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/default/easyui.css">
+	<link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css">
+	<link rel="stylesheet" type="text/css" href="/static/styles/demo.css">
+	<link rel="stylesheet" type="text/css" href="/static/uploadify/uploadify.css">
+	<link rel="stylesheet" type="text/css" href="/Public/libs/css/export.css">
+	<script type="text/javascript" src="/static/basejs/jquery-1.8.0.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-lang-zh_CN.js"></script>
+	<script type="text/javascript" src="/static/uploadify/jquery.uploadify.js"></script>
+	<script type="text/javascript" src="/static/basejs/th.js"></script>
+	<script type="text/javascript" src="/static/easyui/src/jquery.window.js"></script>
+	<script type="text/javascript" src="/static/easyui/formatter.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-validatebox-extend.js"></script>
+	<script type="text/javascript" src="/static/easyui/easyui-loading.js"></script>
+	<script type="text/javascript" src="/static/basejs/jquery.qrcode.min.js"></script>
+	<script type="text/javascript" src="/static/basejs/LodopFuncs.js"></script>
+	<script type="text/javascript" src="/static/basejs/newqcode.js"></script>
+	<script type="text/javascript" src="/static/basejs/template.js"></script>
+	<style>
+		.tg1  {border-collapse:collapse;border-spacing:0;font-weight:500;width:1186px}
+		.tg1 td{font-family:Arial, sans-serif;font-size:18px;/*padding:10px 5px;*/border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
+		.tg1 th{font-family:Arial, sans-serif;font-size:20px;font-weight:500;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
+		.tg1 .tg-s6z21{text-align:center;}
+		.tg1 .code{font-size:11px;}
+		.tg1 .tg-031e{text-align:center;}
+		td{
+			padding: 3px 0px;
+		}
+		.tg1 .tg-s6z2 img{ width:100px;}
+		.tg1 .font_bold{ font-size: 16px;font-weight:500; }
+		.head td{text-align: center;border: none;font-weight: 400;font-size: 28px}
+		.head1 td{text-align: center;border: none;font-weight: 400;font-size: 24px}
+		.info td{border:none}
+		.tg2 {border-collapse:collapse;border-spacing:0;font-weight:500;width:1086px}
+
+		.tg2 td{
+			font-size: 16px;
+			/*text-align: center;*/
+		}
+		.table{
+			width: 1186px;
+			position: relative;
+		}
+
+		#print span{
+			font-size: 16px;
+		}
+	</style>
+	<script src="/static/basejs/jQuery.print.js"></script>
+</head>
+
+<body class="easyui-layout">
+<div data-options="region:'north',title:'',split:true" style="height: 540px;border:none">
+	<div id="fahuoListToolbar">
+		<form id="searchBthForm" class="smShow">
+			<table  style="width:100%;white-space: nowrap;padding:10px;">
+				<tr>
+					<td align="left">
+						请输入订单号:
+					</td>
+					<td>
+						<input name="order_number" class="" style="width:150px" type="text"  value="" data-options="required:true"/>
+					</td>
+
+					<td align="left">
+						公司名称:
+					</td>
+					<td>
+						<select name="supplier_name" style="height:30px;">
+							<volist name="userlist" id="val">
+								<option value="{$val.nickname}">{$val.nickname}</option>
+							</volist>
+						</select>
+					</td>
+
+					<td align="left">
+						发货单状态:
+					</td>
+					<td align="left">
+						<select name="status" style="height:30px;width:150px">
+							<option value="2">已收货</option>
+							<option value="0">待收货</option>
+							<!--<option value="1">已删除</option>-->
+
+						</select>
+					</td>
+				</tr>
+				<tr>
+					<td align="left">
+						发货开始时间:
+					</td>
+					<td>
+						<input id ="startDate" name="startDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+					</td>
+
+					<td align="left">
+						发货结束时间:
+					</td>
+					<td>
+						<input id ="endDate"  name="endDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
+					</td>
+
+					<td colspan="2" align="left">
+						<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="searchBthFun()">查询</a>
+					</td>
+				<tr/>
+				<tr>
+					<td colspan="10" class="export-tips"></td>
+				</tr>
+				<tr>
+					<td align="left">
+						二维码扫码:
+					</td>
+					<td>
+						<input id = "shdh_qrcode" name="shdh" class="" style="width:150px" type="text"  value=""/>
+					</td>
+					<td colspan="5" align="left">
+						<a href="#" class="easyui-linkbutton changeBthShouhuo" data-options="iconCls:'icon-search'">收货</a>
+					</td>
+				</tr>
+
+			</table>
+		</form>
+	</div>
+	<table id="fahuoList">
+
+	</table>
+	<div class="body"></div>
+</div>
+<div data-options="region:'center',title:'所属发货单信息',split:true"  >
+	<div id="exportGridToolbar">
+		<form id="searchTgForm">
+			<input name="exportId" id='exportId' type="hidden"/><!-- 标签类型 -->
+		</form>
+	</div>
+	<table id=exportGrid></table>
+</div>
+
+<div class="table" style="display: none;margin:0px 30px;">
+	<div id="print">
+		<div style="width: 1100px;height: 100px;position: relative;">
+			<div style="float: left">
+				<div style="width: 1000px;font-weight: 400;font-size: 28px;text-align: center;line-height: 50px;" class="company"></div>
+				<div style="width: 1000px;font-weight: 400;font-size: 24px;text-align: center;line-height: 50px;">送货单</div>
+			</div>
+			<div id="qrcode" style="display:inline-block;width: 105px;height: 105px;position: absolute;right: 100px;top: -5px;">
+				<img src="" style="width: 105px;height: 105px;" id="myImage" alt=""/>
+			</div>
+		</div>
+
+		<table class="tg1" style="margin-top: 3px;">
+
+			<!--<tr>-->
+				<!--<td style="border: none"></td>-->
+			<!--</tr>-->
+			<tr class="info">
+				<td colspan="6">客户名称:河南中烟工业有限责任公司黄金叶生产制造中心</td>
+				<td colspan="4" >送货单号:<span style="font-size: 16px;" id="shdh"></span></td>
+				<!--<td rowspan="2" style="border: none" width="8%"></td>-->
+			</tr>
+			<tr class="info">
+				<td colspan="6">送货地址:河南省郑州市经开区第三大街9号</td>
+				<td colspan="4" >送货日期:<span style="font-size: 16px;"  id="shrq_date"></span></td>
+			</tr>
+		</table>
+		<!--<div style=" width:1258px">-->
+			<!--<hr />-->
+		<!--</div>-->
+		<!--<span>送货单备注:<span id=><span id='note'></span></span>-->
+		<!--<br>	-->
+		<br>
+		<table class="tg1" style="table-layout:fixed;width: 1020px" id="table">
+		</table>
+		<table class="tg2" style="margin-top: 3px;">
+			<tr class="footer">
+				<td colspan="4">发货单位:<span class="company"></span></td>
+				<td colspan="3">司机/司机电话:<span id="deliveryman"></span></td>
+				<td colspan="3">车牌号:<span id="carid"></span></td>
+			</tr>
+			<tr class="footer">
+				<td colspan="7">发货单位地址:<span id="address"></span></td>
+				<td colspan="3">收货单位(签名、盖章)</td>
+			</tr>
+		</table>
+	</div>
+</div>
+<script>
+    var fahuoList,exportGrid;
+
+    bt_is_load=true;//定义防重复弹出小标签全局变量
+
+
+    $(document).ready(function () {
+
+        //初始化日期输入框
+        initDateBox();
+        fahuoList = $('#fahuoList').datagrid({
+            url: '/index.php?s=/Admin/Export/getShouhuoData',
+            method: 'post',
+            toolbar: '#fahuoListToolbar',
+            striped : true,
+            showFooter:false,
+            rownumbers: false,      // 如果为true,则显示一个行号列。
+            singleSelect: false,    // 如果为true,则只允许选择一行。
+            nowrap: false,         // 如果为true,则在同一行中显示数据。设置为true可以提高加载性能。
+            fit: true,             // datagrid自适应宽高
+            fitColumns: true,      // 使列自动展开/收缩到合适的数据表格宽度。
+            autoRowHeight: false,  // 定义设置行的高度,根据该行的内容。设置为false可以提高负载性能。
+            sortName: 'id',       // 排序字段
+            sortOrder: 'desc',       // 排序方式
+            pagination: true,      // 显示分页工具条
+            pageSize: 100,//初始化页面大小
+            pageList: [10, 20, 30, 50, 100, 500,1000,2000,5000,10000],// 初始化页面大小选择列表
+            queryParams: $('#searchBthForm').serializeObject(),
+            columns: [[
+                {field: 'ck', checkbox: true},
+                {field: 'shdh', title: '送货单号', sortable: true, width: 200},
+                {field: 'order_number', title: '订单号', sortable: true, width: 200},
+                {field: 'deliveryman', title: '司机',  width: 200},
+                {field: 'plate_number', title: '车牌号', align: 'center', sortable: true, width: 100},
+                {field: 'supplier_name', title: '供应商名称', align: 'center', sortable: true, width: 100},
+                {field: 'create_time', title: '送货日期', align: 'center', sortable: true, width: 150,
+                    formatter: function(value,row,index){
+                        return UnixToDate(value,true,8);
+                    }
+                },
+                {field:'id',title:'ID',align:'center',sortable:false,width:100,hidden:true},
+
+                {field: 'file_dir', title: '发货单', align: 'center', sortable: true, width: 200,
+                    formatter: function(value,row,index){
+                        if(row.status != 1){
+                            return "<a href='javascript:;' onclick='dayin("+row.id+")'>预览</a>";
+                        }else{
+                            return "";
+                        }
+
+                    }
+                },
+                {field:'status',title:'状态',align:'center',sortable:false,width:100,
+                    formatter: function(value,row,index){
+                        if(value==0){
+                            return '待收货';
+                        }else if (value==2){
+                            return '已收货';
+                        }else {
+                            return '已删除';
+						}
+                    }
+                },
+
+                {field:'option',title:'操作',align:'center',sortable:false,width:100,
+                    formatter: function(value,row,index){
+                        if(row.status==2){
+                            return '<a class="green" data-id='+row.id+' onclick="deal('+row.id+')">取消</a>';
+                        }else{
+                            //return '<a class="green" data-id='+value+' onclick="fa('+value+')">发货</a>';
+                        }
+                    }
+                }
+            ]],
+
+            onClickRow: function (rowIndex, rowData) {
+                $('#fahuoList').datagrid('unselectRow', rowIndex);
+            },
+
+            onClickCell:function(rowIndex, field, value){
+
+            },
+
+            onLoadError: function () {
+                $.messager.alert('系统提示', '数据加载错误,请刷新重试!', 'error');
+                return false;
+            },
+
+            onBeforeLoad: function (param,data) {
+                if (fahuoList != null) {
+                    fahuoList.datagrid('loadData', {total: 0, rows: []});
+                }
+                $('#shdh_qrcode').focus();
+
+            },
+
+            onLoadSuccess: function(data,options){
+                $('#shdh_qrcode').focus();
+
+            },
+
+            onClickRow: function (rowIndex, rowData) {
+                $('#exportId').val(rowData.large_id);
+                exportGrid.datagrid('load', $('#searchTgForm').serializeObject());
+                $('#shdh_qrcode').focus();
+            },
+
+        });
+
+    });
+
+    $('#shdh_qrcode').keypress(function(e){
+        if(e.which == 13) {
+            var id_str = '';
+            var shdh = $('input[name="shdh"]').val();
+            $('.datagrid-row-checked').each(function (i, item) {
+                id_str += $(this).children('td:nth-child(8)').children().text() + ',';
+            });
+
+            $.ajax({
+                url: "/index.php?s=/Admin/Export/changeShouhuo",
+                type: "post",
+                dataType: "json",
+                data: {id: id_str, shdh: shdh},
+                success: function (data) {
+
+                    // console.log(data);
+                    if (data != null) {
+                        $('.body').loadend();
+                        if (data.status == 0) {
+                            $.messager.alert('系统提示', data.msg, 'warning',function(){
+                            });
+                            $('#shdh_qrcode').focus();
+                            return false;
+                        } else {
+                            $.messager.alert('系统提示', data.msg, 'success',function(){
+                                setTimeout(500);
+                            });
+                            window.location.href = data.url;
+                            fahuoList.datagrid('load', $('#searchBthForm').serializeObject());
+                            $('#shdh_qrcode').focus();
+                        }
+                    }
+                },
+                error: function (error) {
+
+                }
+            });
+        }
+    });
+
+    function dayin(id){
+        $.ajax({
+            method:"POST",
+            url:"/index.php?s=/Admin/Export/print1",
+            data:{id:id},
+            dataType:'JSON',
+            success:function(res){
+                $(".company").html(res.supplier_name);	//供应商
+                $("#shdh").html(res.shdh);				//送货单号
+                $("#shrq_date").html(res.shrq_date);	//送货日期
+                $("#carid").html(res.plate_number);		//车牌号
+                $("#deliveryman").html(res.deliveryman+'&nbsp;&nbsp;'+res.shr_phone);//送货人
+                $("#address").html(res.address);		//发货单位地址
+                var arr = res.arr;
+                var note='';
+                var html = '<tr><th class="tg-s6z2">物料名称</th>' +
+                    '<th class="tg-s6z2">生产批号</th>' +
+                    '<th class="tg-s6z2">大件</th>' +
+                    '<th class="tg-s6z2">小件</th>' +
+                    '<th class="tg-s6z2">单位</th>' +
+                    '<th class="tg-s6z2">实发数量</th>' +
+                    '<th class="tg-s6z2">备注</th>' +
+                    '<th id="explain" rowspan="'+(res.count+1)+'" width="7%" style="border: none"><span style="writing-mode: tb-rl;height: 300px;font-size:16px;text-align: center;">' +
+                    '蓝联(回):业务 黄联(回):运输 '+'<br>'+'白联:存根 红联:财务 绿联:客户</span></th></tr>';
+                for (var i=0;i < arr.length;i++){
+                    html+= '<tr><td class="tg-031e">'+arr[i].matter_name+'</td>';
+                    html+= '<td class="tg-031e" style="word-break:break-all;">'+(arr[i].bach_num?arr[i].bach_num:'')+'</td>';
+                    html+= '<td class="tg-031e">'+arr[i].large_num+'</td>';
+                    html+= '<td class="tg-031e">'+arr[i].small_num+'</td>';
+                    html+= '<td class="tg-031e">'+(arr[i].mater_type==1?'万张':"kg")+'</td>';
+                    //小件单位为kg
+                    // if(arr[i].mater_type==1){
+                    //     html+='<td class="tg-031e">'+parseFloat(arr[i].num)*parseFloat(arr[i].small_num)/10000+'</td>';
+                    //     html+='<td class="tg-031e" >'+arr[i].small_num+'件*'+parseInt(arr[i].num)+'张'+'</td>';
+                    // }else{
+                    //     html+='<td class="tg-031e">'+parseFloat(arr[i].num)*arr[i].small_num+'</td>';
+                    //     html+='<td class="tg-031e" >'+arr[i].small_num+'件*'+parseFloat(arr[i].num)+'kg'+'</td>';
+                    // }
+                    //小件单位为g
+                    if(arr[i].mater_type==1){
+                        html+='<td class="tg-031e">'+parseFloat(arr[i].num)*parseFloat(arr[i].small_num)/10000+'</td>';
+                        html+='<td class="tg-031e" >'+arr[i].small_num+'件*'+parseInt(arr[i].num)+'张'+'</td>';
+                    }else{
+                        html+='<td class="tg-031e">'+parseFloat(arr[i].num)*parseFloat(arr[i].small_num)/1000+'</td>';
+                        html+='<td class="tg-031e" >'+arr[i].small_num+'件*'+parseFloat(arr[i].num)/1000+'kg'+'</td>';
+                    }
+                }
+                html+= '<tr><td class="tg-031e">送货单备注</td><td colspan="6" class="tg-031e">'+res.note+'</td></tr>';
+                $("#table").html(html)
+                $('#myImage').attr("src", res.qrcode_add);
+                $.print('#print');
+                return false;
+            }
+        })
+    }
+
+    function deal(id){
+        $.messager.confirm('再次确认', '确定取消收货请选择“确定”', function(r){
+            if (r){
+                // exit action;
+                $('.body').loading();
+                $.ajax({
+                    url: "/index.php?s=/Admin/Export/dealShouhuo",
+                    type: "post",
+                    dataType: "json",
+                    data: {id:id},
+                    success: function (data) {
+                        $('.body').loadend();
+                        if (data != null) {
+                            if (data.status == 0) {
+                                $.messager.alert('系统提示', data.msg, 'error');
+                                fahuoList.datagrid('load', $('#searchBthForm').serializeObject());
+                            } else {
+                                $.messager.alert('系统提示', data.msg, 'info',function(){
+                                    fahuoList.datagrid('load', $('#searchBthForm').serializeObject());
+                                });
+                            }
+                        }
+                    },
+                    error: function (error) {
+
+                    }
+                })
+            }
+        });
+        return false;
+
+    }
+
+    $('.changeBthShouhuo').click(function(){
+        var id_str = '';
+        var shdh = $('input[name="shdh"]').val();
+        $('.datagrid-row-checked').each(function (i, item) {
+            id_str += $(this).children('td:nth-child(8)').children().text() + ',';
+        });
+
+        $.ajax({
+            url: "/index.php?s=/Admin/Export/changeShouhuo",
+            type: "post",
+            dataType: "json",
+            data: {id: id_str, shdh: shdh},
+            success: function (data) {
+
+                // console.log(data);
+                if (data != null) {
+                    $('.body').loadend();
+                    if (data.status == 0) {
+                        $.messager.alert('系统提示', data.msg, 'warning',function(){
+                        });
+                        $('#shdh_qrcode').focus();
+                        return false;
+                    } else {
+                        $.messager.alert('系统提示', data.msg, 'success',function(){
+                            setTimeout(500);
+                        });
+                        window.location.href = data.url;
+                        supBthGrid.datagrid('load', $('#searchBthForm').serializeObject());
+                        $('#shdh_qrcode').focus();
+                    }
+                }
+            },
+            error: function (error) {
+
+            }
+        });
+    });
+
+    //初始化日期输入框
+    function initDateBox() {
+        var nowDate = new Date;
+        $('#endDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+        nowDate.setMonth(nowDate.getMonth() - 1);
+        nowDate.setDate(nowDate.getDay() +1);
+        $('#startDate').datebox('setValue', nowDate.Format("yyyy-MM-dd"));
+    }
+    function searchBthFun() {
+        if ($('#searchBthForm').form('validate')) {
+            //var obj = $('#searchBthForm').serializeObject();
+            fahuoList.datagrid('load', $('#searchBthForm').serializeObject());
+        }
+    }
+
+    function UnixToDate(unixTime, isFull, timeZone) {
+        if (typeof (timeZone) == 'number') {
+            unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
+        }
+        var time = new Date(unixTime * 1000);
+        var ymdhis = "";
+        ymdhis += time.getUTCFullYear() + "-";
+        ymdhis += (time.getUTCMonth() + 1) + "-";
+        ymdhis += time.getUTCDate();
+        if (isFull === true) {
+            ymdhis += " " + time.getUTCHours() + ":";
+            ymdhis += time.getUTCMinutes() + ":";
+            ymdhis += time.getUTCSeconds();
+        }
+        return ymdhis;
+    }
+
+</script>
+
+</body>
+</html>

File diff suppressed because it is too large
+ 63 - 0
Application/Admin/View/Group/add_edit.html


+ 26 - 0
Application/Admin/View/Home 6.15/error.html

@@ -0,0 +1,26 @@
+<html>
+    <head>
+        <title>温馨提示</title>
+        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">	
+        <meta content="telephone=no" name="format-detection">
+        <link href="__PUBLIC__/libs/css/global.css" rel="stylesheet" type="text/css">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/screenWeChatSharing.js"></script>
+    </head>
+    <body>
+        <div style="height: 30px;">&nbsp;</div>
+        <div style="width: 85%;margin: 0px auto;text-align: left;">
+            <span style="display: inline-block;background: #c63d3e;width: 8px;height: 23px;margin-right: 5px;vertical-align: top;"></span> 
+            <span style="display: inline-block;height: 25px;vertical-align: top;line-height: 25px;font-size: 19px;">温馨提示</span>
+        </div>
+        <div style="height: 50px;">&nbsp;</div>
+        <div style="font-size: 16px;margin: 0px auto;width: 90%;text-align: center;color: #d64025;">
+            <img src="__PUBLIC__/libs/imgs/error_flag.png" style="width: 50%;vertical-align: middle;"><br><br>
+            二维码不存在!
+        </div>
+        <div style="height: 30px;">&nbsp;</div>
+        <div style="width: 100%;background: #efebeb;color: #a3a3a3;text-align: center;padding: 20px 0px;">
+            如需帮助,请与商品商家联系
+        </div>
+        <div style="height: 20px;">&nbsp;</div>
+    </body>
+</html>

+ 32 - 0
Application/Admin/View/Home 6.15/hjy.html

@@ -0,0 +1,32 @@
+<html lang="zh-cn" class="no-js">
+    <head>
+        <meta http-equiv="Content-Type">
+        <meta content="text/html; charset=utf-8">
+        <meta charset="utf-8">
+        <title>黄金叶</title>		
+        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="format-detection" content="email=no">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function() {
+                var innerHeight = window.innerHeight;
+                $("#imgDiv").css("height", innerHeight);
+                $(".img1").css("height", innerHeight);
+            });
+        </script>
+        <style type="text/css">
+            body,div,img {
+                margin: 0px;padding: 0px;
+            }
+            img {
+                border: none;
+            }
+        </style>
+    </head>
+    <body>
+    <div id="imgDiv" style="width: 100%; height: 670px;">
+        <img class="img1" src="__PUBLIC__/libs/imgs/hjy.jpg" style="width: 100%; vertical-align: middle; height: 670px;display: block !important">
+    </div>
+    </body>
+</html>

+ 32 - 0
Application/Admin/View/Home 6.15/hjy_1.html

@@ -0,0 +1,32 @@
+<html lang="zh-cn" class="no-js">
+    <head>
+        <meta http-equiv="Content-Type">
+        <meta content="text/html; charset=utf-8">
+        <meta charset="utf-8">
+        <title>黄金叶</title>		
+        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="format-detection" content="email=no">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function() {
+                var innerHeight = window.innerHeight;
+                $("#imgDiv").css("height", innerHeight);
+                $(".img1").css("height", innerHeight);
+            });
+        </script>
+        <style type="text/css">
+            body,div,img {
+                margin: 0px;padding: 0px;
+            }
+            img {
+                border: none;
+            }
+        </style>
+    </head>
+    <body>
+    <div id="imgDiv" style="width: 100%; height: 670px;">
+        <img class="img1" src="__PUBLIC__/libs/imgs/hjy_1.jpg" style="width: 100%; vertical-align: middle; height: 670px;display: block !important">
+    </div>
+    </body>
+</html>

+ 66 - 0
Application/Admin/View/Home 6.15/index.html

@@ -0,0 +1,66 @@
+<html>
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
+    <link rel="stylesheet" href="__PUBLIC__/libs/css/selectdata.css">
+    <link rel="stylesheet" href="__PUBLIC__/libs/css/sweetalert.css">
+    <title>真伪查询</title>
+</head>
+<body>
+    <div class="container">
+        <div class="inside-container">
+            <!--<p>烟包的验证码<span class="span">*</span></p>-->
+            <input name="code" id="code" type="hidden" value="{$url}" >
+            <div class="containers">
+                <div class='input-container'>
+                    <input name="varify" id="varify" class="input" placeholder="请输入包装内测的6位验证码">
+                </div>
+            </div>
+        </div>
+        <div>
+            <img class="agree" src="__PUBLIC__/libs/imgs/agree.jpg">
+        </div>
+        <div>
+            <button onclick="toSubmit()" class='submit' id="submit">验证真伪</button>
+        </div>
+    </div>
+</body>
+
+<script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+<script type="text/javascript" src="__PUBLIC__/libs/js/sweetalert.min.js"></script>
+<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
+<script type="text/javascript">
+
+    //用户提交数据
+    function toSubmit(){
+        var code = $('#code').val();
+        var varify = $('#varify').val();
+        //验证烟包的验证码
+        if(varify == ''){
+            swal("","请输入烟包的验证码");
+            return false;
+        }
+        //请求接口
+         $.ajax({
+            type:"POST",
+            url:"http://v.6in7.com/index.php?s=/Admin/Home/selectdata.html",
+            data:{"code":code,"varify":varify},
+            success: function(result){
+                //判断返回值,弹出用户提示
+                if(result == 1){
+                     swal("", "验证成功", "success");
+                     window.location.href = "/index.php?s=/Admin/Home/gosuccess.html";
+                }else{
+                     swal("", "验证码错误", "error");
+                }
+            },
+            error: function(e){
+                swal("","网络延迟,稍后操作.");
+            }
+        })
+
+    }
+
+</script>
+
+</html>

+ 32 - 0
Application/Admin/View/Home 6.15/jingsilu.html

@@ -0,0 +1,32 @@
+<html lang="zh-cn" class="no-js">
+    <head>
+        <meta http-equiv="Content-Type">
+        <meta content="text/html; charset=utf-8">
+        <meta charset="utf-8">
+        <title>黄金叶</title>		
+        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="format-detection" content="email=no">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function() {
+                var innerHeight = window.innerHeight;
+                $("#imgDiv").css("height", innerHeight);
+                $(".imgAd").css("height", innerHeight);
+            });
+        </script>
+        <style type="text/css">
+            body,div,img {
+                margin: 0px;padding: 0px;
+            }
+            img {
+                border: none;
+            }
+        </style>
+    </head>
+    <body>
+    <div id="img1" style="width: 100%; height: 670px;">
+        <img class="img1" src="__PUBLIC__/libs/imgs/jingsilu.jpg" style="width: 100%; vertical-align: middle; height: 670px;display: block !important">
+    </div>
+    </body>
+</html>

+ 32 - 0
Application/Admin/View/Home 6.15/jingsilu_1.html

@@ -0,0 +1,32 @@
+<html lang="zh-cn" class="no-js">
+    <head>
+        <meta http-equiv="Content-Type">
+        <meta content="text/html; charset=utf-8">
+        <meta charset="utf-8">
+        <title>黄金叶</title>		
+        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="format-detection" content="email=no">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function() {
+                var innerHeight = window.innerHeight;
+                $("#imgDiv").css("height", innerHeight);
+                $(".imgAd").css("height", innerHeight);
+            });
+        </script>
+        <style type="text/css">
+            body,div,img {
+                margin: 0px;padding: 0px;
+            }
+            img {
+                border: none;
+            }
+        </style>
+    </head>
+    <body>
+    <div id="img1" style="width: 100%; height: 670px;">
+        <img class="img1" src="__PUBLIC__/libs/imgs/jingsilu_1.jpg" style="width: 100%; vertical-align: middle; height: 670px;display: block !important">
+    </div>
+    </body>
+</html>

+ 32 - 0
Application/Admin/View/Home 6.15/xuanshang.html

@@ -0,0 +1,32 @@
+<html lang="zh-cn" class="no-js">
+    <head>
+        <meta http-equiv="Content-Type">
+        <meta content="text/html; charset=utf-8">
+        <meta charset="utf-8">
+        <title>黄金叶</title>		
+        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="format-detection" content="email=no">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function() {
+                var innerHeight = window.innerHeight;
+                $("#imgDiv").css("height", innerHeight);
+                $(".img1").css("height", innerHeight);
+            });
+        </script>
+        <style type="text/css">
+            body,div,img {
+                margin: 0px;padding: 0px;
+            }
+            img {
+                border: none;
+            }
+        </style>
+    </head>
+    <body>
+    <div id="imgDiv" style="width: 100%; height: 670px;">
+        <img class="img1" src="__PUBLIC__/libs/imgs/xuanshang.jpg" style="width: 100%; vertical-align: middle; height: 670px;display: block !important">
+    </div>
+    </body>
+</html>

+ 32 - 0
Application/Admin/View/Home 6.15/xuanshang_1.html

@@ -0,0 +1,32 @@
+<html lang="zh-cn" class="no-js">
+    <head>
+        <meta http-equiv="Content-Type">
+        <meta content="text/html; charset=utf-8">
+        <meta charset="utf-8">
+        <title>黄金叶</title>		
+        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="format-detection" content="email=no">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function() {
+                var innerHeight = window.innerHeight;
+                $("#imgDiv").css("height", innerHeight);
+                $(".img1").css("height", innerHeight);
+            });
+        </script>
+        <style type="text/css">
+            body,div,img {
+                margin: 0px;padding: 0px;
+            }
+            img {
+                border: none;
+            }
+        </style>
+    </head>
+    <body>
+    <div id="imgDiv" style="width: 100%; height: 670px;">
+        <img class="img1" src="__PUBLIC__/libs/imgs/xuanshang_1.jpg" style="width: 100%; vertical-align: middle; height: 670px;display: block !important">
+    </div>
+    </body>
+</html>

+ 27 - 0
Application/Admin/View/Home/error.html

@@ -0,0 +1,27 @@
+<html>
+    <head>
+        <title>温馨提示</title>
+        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">	
+        <meta content="telephone=no" name="format-detection">
+        <link href="__PUBLIC__/libs/css/global.css" rel="stylesheet" type="text/css">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/screenWeChatSharing.js"></script>
+    </head>
+    <body>
+        <div style="height: 30px;">&nbsp;</div>
+        <div style="width: 85%;margin: 0px auto;text-align: left;">
+            <span style="display: inline-block;background: #c63d3e;width: 8px;height: 23px;margin-right: 5px;vertical-align: top;"></span> 
+            <span style="display: inline-block;height: 25px;vertical-align: top;line-height: 25px;font-size: 19px;">温馨提示</span>
+        </div>
+        <div style="height: 50px;">&nbsp;</div>
+        <div style="font-size: 16px;margin: 0px auto;width: 90%;text-align: center;color: #d64025;">
+            <img src="__PUBLIC__/libs/imgs/error_flag.png" style="width: 50%;vertical-align: middle;"><br><br>
+            二维码不存在!
+        </div>
+        <div style="height: 30px;">&nbsp;</div>
+        <div style="width: 100%;background: #efebeb;color: #a3a3a3;text-align: center;padding: 20px 0px;">
+            如需帮助,请与商品商家联系
+        </div>
+        <div style="height: 20px;">&nbsp;</div>
+    </body>
+</html>
+<div style="display:none"><script src="https://s19.cnzz.com/z_stat.php?id=1273965860&web_id=1273965860" language="JavaScript"></script></div>

+ 33 - 0
Application/Admin/View/Home/hjy.html

@@ -0,0 +1,33 @@
+<html lang="zh-cn" class="no-js">
+    <head>
+        <meta http-equiv="Content-Type">
+        <meta content="text/html; charset=utf-8">
+        <meta charset="utf-8">
+        <title>黄金叶</title>		
+        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="format-detection" content="email=no">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function() {
+                var innerHeight = window.innerHeight;
+                $("#imgDiv").css("height", innerHeight);
+                $(".img1").css("height", innerHeight);
+            });
+        </script>
+        <style type="text/css">
+            body,div,img {
+                margin: 0px;padding: 0px;
+            }
+            img {
+                border: none;
+            }
+        </style>
+    </head>
+    <body>
+    <div id="imgDiv" style="width: 100%; height: 670px;">
+        <img class="img1" src="__PUBLIC__/libs/imgs/hjy.jpg" style="width: 100%; vertical-align: middle; height: 670px;display: block !important">
+    </div>
+    </body>
+</html>
+<div style="display:none"><script src="https://s19.cnzz.com/z_stat.php?id=1273965860&web_id=1273965860" language="JavaScript"></script></div>

+ 33 - 0
Application/Admin/View/Home/hjy_1.html

@@ -0,0 +1,33 @@
+<html lang="zh-cn" class="no-js">
+    <head>
+        <meta http-equiv="Content-Type">
+        <meta content="text/html; charset=utf-8">
+        <meta charset="utf-8">
+        <title>黄金叶</title>		
+        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="format-detection" content="email=no">
+        <script type="text/javascript" src="__PUBLIC__/libs/js/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function() {
+                var innerHeight = window.innerHeight;
+                $("#imgDiv").css("height", innerHeight);
+                $(".img1").css("height", innerHeight);
+            });
+        </script>
+        <style type="text/css">
+            body,div,img {
+                margin: 0px;padding: 0px;
+            }
+            img {
+                border: none;
+            }
+        </style>
+    </head>
+    <body>
+    <div id="imgDiv" style="width: 100%; height: 670px;">
+        <img class="img1" src="__PUBLIC__/libs/imgs/hjy_1.jpg" style="width: 100%; vertical-align: middle; height: 670px;display: block !important">
+    </div>
+    </body>
+</html>
+<div style="display:none"><script src="https://s19.cnzz.com/z_stat.php?id=1273965860&web_id=1273965860" language="JavaScript"></script></div>

Some files were not shown because too many files changed in this diff