Commit ffc314f179ecb9bbbd0891f6f7076ea1e2bb726f

Authored by 曹明
1 parent 611ce669
Exists in master

app-ht(build v0.0.1 build 2)

1. 后台生产日期管理功能实现。
app-ht/config/main.php
@@ -56,8 +56,8 @@ $config = [ @@ -56,8 +56,8 @@ $config = [
56 'class' => 'app\ht\modules\home\Module', 56 'class' => 'app\ht\modules\home\Module',
57 ] 57 ]
58 , 58 ,
59 - 'shop' => [  
60 - 'class' => 'app\ht\modules\shop\Module', 59 + 'production' => [
  60 + 'class' => 'app\ht\modules\production\Module',
61 ] 61 ]
62 ], 62 ],
63 'components' => [ 63 'components' => [
app-ht/config/params.php
@@ -3,5 +3,5 @@ return [ @@ -3,5 +3,5 @@ return [
3 'adminEmail' => 'tech@jiwork.com', 3 'adminEmail' => 'tech@jiwork.com',
4 'DINGTALKL_URL' => 'https://tdd.jiwork.com/', //在钉钉端用系统扫码之后跳转到钉钉对应的界面,里面要指定钉钉的网址 4 'DINGTALKL_URL' => 'https://tdd.jiwork.com/', //在钉钉端用系统扫码之后跳转到钉钉对应的界面,里面要指定钉钉的网址
5 'BAIDU_MAP_BROWSER_KEY' => 'UzLG5fpQtralY2hXO3wvVFzvlCmw6Rue', 5 'BAIDU_MAP_BROWSER_KEY' => 'UzLG5fpQtralY2hXO3wvVFzvlCmw6Rue',
6 - 'VERSION' => 'v0.0.1 build 1', 6 + 'VERSION' => 'v0.0.1 build 2',
7 ]; 7 ];
8 \ No newline at end of file 8 \ No newline at end of file
app-ht/modules/manufacturer/controllers/ManufacturerController.php
@@ -12,7 +12,7 @@ use app\ht\controllers\BaseController; @@ -12,7 +12,7 @@ use app\ht\controllers\BaseController;
12 /** 12 /**
13 * 厂商管理 13 * 厂商管理
14 * Class ManufacturerController 14 * Class ManufacturerController
15 - * @package app\ht\modules\shop\controllers 15 + * @package app\ht\modules\manufacturer\controllers
16 */ 16 */
17 class ManufacturerController extends BaseController 17 class ManufacturerController extends BaseController
18 { 18 {
@@ -134,7 +134,7 @@ class ManufacturerController extends BaseController @@ -134,7 +134,7 @@ class ManufacturerController extends BaseController
134 } 134 }
135 135
136 /** 136 /**
137 - * 创建厂商 137 + * 编辑厂商
138 * @return string 138 * @return string
139 */ 139 */
140 public function actionDoEdit() 140 public function actionDoEdit()
@@ -193,7 +193,7 @@ class ManufacturerController extends BaseController @@ -193,7 +193,7 @@ class ManufacturerController extends BaseController
193 } 193 }
194 194
195 /** 195 /**
196 - * 删除商品 196 + * 删除厂商
197 * @return string 197 * @return string
198 * @throws \Exception 198 * @throws \Exception
199 */ 199 */
@@ -203,7 +203,7 @@ class ManufacturerController extends BaseController @@ -203,7 +203,7 @@ class ManufacturerController extends BaseController
203 $itemId = $request->post("data_id"); 203 $itemId = $request->post("data_id");
204 $msg = array(); 204 $msg = array();
205 205
206 - // 删除对应的商品 206 + // 删除对应的厂商
207 if (Manufacturer::delete($itemId)) { 207 if (Manufacturer::delete($itemId)) {
208 $msg['status'] = 1; 208 $msg['status'] = 1;
209 $msg['msg'] = "操作成功"; 209 $msg['msg'] = "操作成功";
app-ht/modules/manufacturer/views/manufacturer/create.php
@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 use yii\helpers\Url; 3 use yii\helpers\Url;
4 4
5 $this->title = '添加厂商'; 5 $this->title = '添加厂商';
6 -$this->params['breadcrumbs'][] = '厂商管理';  
7 $this->params['breadcrumbs'][] = ['label' => '厂商管理', 'url' => ['/manufacturer/manufacturer/index']]; 6 $this->params['breadcrumbs'][] = ['label' => '厂商管理', 'url' => ['/manufacturer/manufacturer/index']];
8 $this->params['breadcrumbs'][] = $this->title; 7 $this->params['breadcrumbs'][] = $this->title;
9 8
@@ -45,24 +44,6 @@ $this->params['breadcrumbs'][] = $this->title; @@ -45,24 +44,6 @@ $this->params['breadcrumbs'][] = $this->title;
45 rules: { 44 rules: {
46 } 45 }
47 }); 46 });
48 -  
49 - //校验价格  
50 - $.validator.addMethod("nameRequired",  
51 - function(value, element, params) {  
52 - var a = $("input[name='name']").val();  
53 - var b = $("input[name='phone']").val();  
54 - if (a == ""){  
55 - params[0] = "用户名称不能为空";  
56 - return false;  
57 - }  
58 - if (!utils.isMobile(b)){  
59 - params[0] = "请填写正确的手机号码";  
60 - return false;  
61 - }  
62 - return true;  
63 - }, $.validator.format("{0}")  
64 - );  
65 -  
66 }); 47 });
67 48
68 $("#save").bind("click", function () { 49 $("#save").bind("click", function () {
app-ht/modules/manufacturer/views/manufacturer/edit.php
@@ -6,7 +6,6 @@ if ($isCreateSuccess) { @@ -6,7 +6,6 @@ if ($isCreateSuccess) {
6 } else { 6 } else {
7 $this->title = '编辑厂商'; 7 $this->title = '编辑厂商';
8 } 8 }
9 -$this->params['breadcrumbs'][] = '厂商管理';  
10 $this->params['breadcrumbs'][] = ['label' => '厂商管理', 'url' => ['/manufacturer/manufacturer/index']]; 9 $this->params['breadcrumbs'][] = ['label' => '厂商管理', 'url' => ['/manufacturer/manufacturer/index']];
11 $this->params['breadcrumbs'][] = $this->title; 10 $this->params['breadcrumbs'][] = $this->title;
12 11
app-ht/modules/manufacturer/views/manufacturer/index.php
@@ -5,7 +5,6 @@ use common\helpers\ImageManager; @@ -5,7 +5,6 @@ use common\helpers\ImageManager;
5 use domain\shop\ShopItemStatus; 5 use domain\shop\ShopItemStatus;
6 6
7 $this->title = '厂商管理'; 7 $this->title = '厂商管理';
8 -$this->params['breadcrumbs'][] = '厂商管理';  
9 $this->params['breadcrumbs'][] = $this->title; 8 $this->params['breadcrumbs'][] = $this->title;
10 ?> 9 ?>
11 10
@@ -124,56 +123,5 @@ $this->params['breadcrumbs'][] = $this->title; @@ -124,56 +123,5 @@ $this->params['breadcrumbs'][] = $this->title;
124 }); 123 });
125 } 124 }
126 }) ; 125 }) ;
127 -  
128 - $(".btn_auth_fail").bind("click",function () {  
129 - var data_id = $.trim($(this).attr("aid"));  
130 - if (data_id == null || data_id == ""){  
131 - alert("丢失参数,暂时无法审核,请刷新后再试");  
132 - return false;  
133 - }  
134 - var thiz = $(this);  
135 - $.ajax({  
136 - type: "post",  
137 - url: "do-auth",  
138 - dataType:"json",  
139 - data: $.csrf({"data_id":data_id, "auth_type": "auth_fail"}),  
140 - success:function(msg){  
141 - alert(msg['msg']);  
142 - if (msg['status'] == 1){  
143 - window.location.reload();  
144 - }else{  
145 - //提示确认失败  
146 - }  
147 - },  
148 - error:function(msg){  
149 - //提示确认失败  
150 - }  
151 - });  
152 - }) ;  
153 - $(".btn_auth_success").bind("click",function () {  
154 - var data_id = $.trim($(this).attr("aid"));  
155 - if (data_id == null || data_id == ""){  
156 - alert("丢失参数,暂时无法审核,请刷新后再试");  
157 - return false;  
158 - }  
159 - var thiz = $(this);  
160 - $.ajax({  
161 - type: "post",  
162 - url: "do-auth",  
163 - dataType:"json",  
164 - data: $.csrf({"data_id":data_id, "auth_type": "auth_success"}),  
165 - success:function(msg){  
166 - alert(msg['msg']);  
167 - if (msg['status'] == 1){  
168 - window.location.reload();  
169 - }else{  
170 - //提示确认失败  
171 - }  
172 - },  
173 - error:function(msg){  
174 - //提示确认失败  
175 - }  
176 - });  
177 - }) ;  
178 }); 126 });
179 </script> 127 </script>
180 \ No newline at end of file 128 \ No newline at end of file
app-ht/modules/production/Module.php 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +<?php namespace app\ht\modules\production;
  2 +
  3 +/**
  4 + * @author CM
  5 + */
  6 +class Module extends \app\ht\modules\BaseModule
  7 +{
  8 + public function init()
  9 + {
  10 + parent::init();
  11 +
  12 + $this->params['perm'] = require(__DIR__ . '/config/perm.php');
  13 + }
  14 +}
0 \ No newline at end of file 15 \ No newline at end of file
app-ht/modules/production/config/perm.php 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +<?php
  2 +
  3 +return [
  4 + 'label' => '生产日期',
  5 + 'items' => [
  6 + 'shop_city' => [
  7 + 'label' => '生产日期',
  8 + 'items' => [
  9 + 2 => '生产日期管理',
  10 + ],
  11 + 'path' => 'production/production/*'
  12 + ],
  13 + ]
  14 +];
app-ht/modules/production/controllers/ProductionController.php 0 → 100644
@@ -0,0 +1,189 @@ @@ -0,0 +1,189 @@
  1 +<?php
  2 +
  3 +namespace app\ht\modules\production\controllers;
  4 +
  5 +use Yii;
  6 +use yii\data\Pagination;
  7 +use domain\production\Production;
  8 +use domain\production\ProductionRepository;
  9 +use app\ht\controllers\BaseController;
  10 +
  11 +/**
  12 + * 生产日期管理
  13 + * Class ProductionController
  14 + * @package app\ht\modules\production\controllers
  15 + */
  16 +class ProductionController extends BaseController
  17 +{
  18 + /**
  19 + * 生产日期管理
  20 + */
  21 + public function actionIndex()
  22 + {
  23 + $params = $this->dataList(1);
  24 + /**
  25 + * 渲染模板
  26 + */
  27 + return $this->render('index', $params);
  28 + }
  29 +
  30 + /**
  31 + * 查询数据列表
  32 + */
  33 + protected function dataList($type = '')
  34 + {
  35 + $request = Yii::$app->request;
  36 + $creatTime = $request->get('creatTime');
  37 + $endTime = $request->get('endTime');
  38 + $productionCreatTime = $request->get('productionCreatTime');
  39 + $productionEndTime = $request->get('productionEndTime');
  40 +
  41 + $gets = [
  42 + 'creatTime' => $creatTime,
  43 + 'endTime' => $endTime,
  44 + 'productionCreatTime' => $productionCreatTime,
  45 + 'productionEndTime' => $productionEndTime,
  46 + ];
  47 +
  48 + $where = ['and'];
  49 + if ($creatTime) {
  50 + $creatTime = strtotime($creatTime);
  51 + $where[] = ['>=', 'p.created_at', $creatTime];
  52 + }
  53 + if ($endTime) {
  54 + $endTime = strtotime($endTime) + 86400;
  55 + $where[] = ['<=', 'p.created_at', $endTime];
  56 + }
  57 + if ($productionCreatTime) {
  58 + $productionCreatTime = strtotime($productionCreatTime);
  59 + $where[] = ['>=', 'p.name', $productionCreatTime];
  60 + }
  61 + if ($productionEndTime) {
  62 + $productionEndTime = strtotime($productionEndTime) + 86400;
  63 + $where[] = ['<=', 'p.name', $productionEndTime];
  64 + }
  65 + if ($type == 0) {
  66 + $pageList = ProductionRepository::getPageList($where);
  67 + $pages = null;
  68 + } else {
  69 + $pageSize = 20;
  70 + $pages = new Pagination(['totalCount' => ProductionRepository::getPageCount($where), 'pageSize' => $pageSize]);
  71 + $pageList = ProductionRepository::getPageList($where, $pages->offset, $pages->limit);
  72 + }
  73 +
  74 + /**
  75 + * 数据整理
  76 + */
  77 + return [
  78 + 'listdata' => $pageList,
  79 + 'pages' => $pages,
  80 + 'gets' => $gets
  81 + ];
  82 + }
  83 +
  84 + /**
  85 + * 创建生产日期
  86 + * @return string
  87 + */
  88 + public function actionCreate()
  89 + {
  90 + return $this->render('create');
  91 + }
  92 +
  93 + /**
  94 + * 创建生产日期
  95 + * @return string
  96 + */
  97 + public function actionDoAdd()
  98 + {
  99 + $request = Yii::$app->request;
  100 + $name = $request->post("name"); // 生产日期
  101 + if (empty($name)) {
  102 + Yii::$app->session->setFlash('error', '生产日期不能为空');
  103 + return $this->render('create');
  104 + }
  105 + $result = Production::create($request->post());
  106 + if ($result) {
  107 + Yii::$app->session->setFlash('success', '添加成功');
  108 + } else {
  109 + Yii::$app->session->setFlash('error', '添加失败');
  110 + }
  111 +
  112 + return $this->redirect('index');
  113 + }
  114 +
  115 + /**
  116 + * 编辑生产日期
  117 + * @return string
  118 + */
  119 + public function actionEdit()
  120 + {
  121 + $productionId = $this->request->get("pid");
  122 + $info = ProductionRepository::selectOne($productionId, true);
  123 + return $this->render('edit', ["info" => $info]);
  124 + }
  125 +
  126 + /**
  127 + * 编辑生产日期
  128 + * @return string
  129 + */
  130 + public function actionDoEdit()
  131 + {
  132 + $request = Yii::$app->request;
  133 + $name = $request->post("name");
  134 + $pid = $request->post("pid");
  135 + if (empty($pid)) {
  136 + Yii::$app->session->setFlash('error', '生产日期编号不能为空');
  137 + $params = $this->dataList(1);
  138 + return $this->render('index', $params);
  139 + }
  140 + $production = ProductionRepository::selectOne($pid,true);
  141 + if (empty($production)) {
  142 + Yii::$app->session->setFlash('error', '生产日期记录不存在');
  143 + $params = $this->dataList(1);
  144 + return $this->render('index', $params);
  145 + }
  146 + if (empty($name)) {
  147 + Yii::$app->session->setFlash('error', '生产日期不能为空');
  148 + return $this->render('edit', ["info" => $production]);
  149 + }
  150 +
  151 + $result = Production::update($pid, $request->post());
  152 +
  153 + if ($result === -1) {
  154 + Yii::$app->session->setFlash('error', '修改的生产日期' . $name . '已存在');
  155 + return $this->render('edit', ["info" => $production]);
  156 + }
  157 + if ($result) {
  158 + Yii::$app->session->setFlash('success', '编辑成功');
  159 + } else {
  160 + Yii::$app->session->setFlash('error', '编辑失败');
  161 + }
  162 + $production = ProductionRepository::selectOne($pid,true);
  163 + return $this->render('edit', ["info" => $production]);
  164 + }
  165 +
  166 + /**
  167 + * 删除生产日期
  168 + * @return string
  169 + * @throws \Exception
  170 + */
  171 + public function actionDoDel()
  172 + {
  173 + $request = Yii::$app->request;
  174 + $itemId = $request->post("data_id");
  175 + $msg = array();
  176 +
  177 + // 删除对应的生产日期
  178 + if (Production::delete($itemId)) {
  179 + $msg['status'] = 1;
  180 + $msg['msg'] = "操作成功";
  181 + } else {
  182 + $msg['status'] = 0;
  183 + $msg['msg'] = "操作失败";
  184 + }
  185 +
  186 + return $this->renderJson($msg);
  187 + }
  188 +
  189 +}
0 \ No newline at end of file 190 \ No newline at end of file
app-ht/modules/production/views/production/create.php 0 → 100644
@@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
  1 +<?php
  2 +
  3 +use yii\helpers\Url;
  4 +
  5 +$this->title = '创建生产日期';
  6 +$this->params['breadcrumbs'][] = ['label' => '生产日期管理', 'url' => ['/production/production/index']];
  7 +$this->params['breadcrumbs'][] = $this->title;
  8 +
  9 +?>
  10 +
  11 +<form action="<?php echo Url::toRoute(['/production/production/do-add']); ?>" name="myFrom" id="myFrom" method="post" enctype="multipart/form-data">
  12 + <div class="panel panel-default">
  13 + <div class="panel-body">
  14 + <div class="form-group col-sm-12" style="text-align: center">
  15 + <h3>创建生产日期</h3>
  16 + </div>
  17 + <div class="form-group col-sm-12">
  18 + <label for="skillName" class="col-sm-4 control-label text-right">生产日期:</label>
  19 + <div class="col-sm-4 text-left">
  20 + <input type="date" value="" name="name" placeholder="请输入生产日期(如:2019-10-28)" style="margin-top: -6px;" class="form-control"">
  21 + </div>
  22 + </div>
  23 + </div>
  24 +
  25 + <div class="panel-footer text-center">
  26 + <button type="button" class="btn btn-primary ladda-button" data-style="slide-up" id="save">确&nbsp;&nbsp;定</button>&nbsp;&nbsp;&nbsp;&nbsp;
  27 + <a class="btn btn-default" href="<?=Url::toRoute("/production/production/create")?>">重&nbsp;&nbsp;&nbsp;&nbsp;置</a>
  28 + </div>
  29 + </div>
  30 +
  31 +</form>
  32 +
  33 +<script>
  34 + // 表单提交验证
  35 + seajs.use("base/1.0.0/unit/validate/custom-1.0.0",function () {
  36 + var validator = $("#myFrom").validate({
  37 + //debug:true,
  38 + rules: {
  39 + }
  40 + });
  41 + });
  42 +
  43 + $("#save").bind("click", function () {
  44 + var getUrl = '<?=Url::toRoute("/production/production/do-add")?>';
  45 + $('#myFrom').attr('action', getUrl);
  46 + var a = $("input[name='name']").val();
  47 + if (a == ""){
  48 + alert("生产日期不能为空");
  49 + return false;
  50 + }
  51 + var cb = $("#myFrom").validate().form();
  52 + if (!cb){
  53 + return;
  54 + }
  55 + var submit = $('#myFrom').submit();
  56 + var l = $.ladda(this);
  57 + l.start();
  58 + return false;
  59 + });
  60 +</script>
0 \ No newline at end of file 61 \ No newline at end of file
app-ht/modules/production/views/production/edit.php 0 → 100644
@@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
  1 +<?php
  2 +
  3 +use yii\helpers\Url;
  4 +
  5 +$this->title = '编辑生产日期';
  6 +$this->params['breadcrumbs'][] = ['label' => '生产日期管理', 'url' => ['/production/production/index']];
  7 +$this->params['breadcrumbs'][] = $this->title;
  8 +
  9 +?>
  10 +
  11 +<form action="<?php echo Url::toRoute(['/production/production/do-add']); ?>" name="myFrom" id="myFrom" method="post" enctype="multipart/form-data">
  12 + <div class="panel panel-default">
  13 + <div class="panel-body">
  14 + <div style="margin-bottom: 15px;text-align: right;">
  15 + <a href="<?=Url::toRoute("/production/production/create")?>" class="btn btn-success"> + 创建生产日期</a>
  16 + </div>
  17 + <div class="form-group col-sm-12" style="text-align: center">
  18 + <h3>编辑生产日期</h3>
  19 + </div>
  20 + <div class="form-group col-sm-12">
  21 + <label for="skillName" class="col-sm-4 control-label text-right">生产日期:</label>
  22 + <div class="col-sm-4 text-left">
  23 + <input type="text" value="<?= isset($info["name"]) ? $info["name"] : "" ?>" style="margin-top: -6px;" name="name" placeholder="请填写生产日期(如:2019-10-28)" class="form-control">
  24 + </div>
  25 + </div>
  26 + </div>
  27 +
  28 + <div class="panel-footer text-center">
  29 + <input type="hidden" value="<?= isset($info["id"]) ? $info["id"] : "" ?>" name="pid" class="form-control"">
  30 + <button type="button" class="btn btn-primary ladda-button" data-style="slide-up" id="save">确&nbsp;&nbsp;定</button>&nbsp;&nbsp;&nbsp;&nbsp;
  31 + <a class="btn btn-default" href="<?=Url::toRoute("/production/production/index")?>">返&nbsp;&nbsp;&nbsp;&nbsp;回</a>
  32 + </div>
  33 + </div>
  34 +
  35 +</form>
  36 +
  37 +<script>
  38 + // 表单提交验证
  39 + seajs.use("base/1.0.0/unit/validate/custom-1.0.0",function () {
  40 + var validator = $("#myFrom").validate({
  41 + //debug:true,
  42 + rules: {
  43 + }
  44 + });
  45 + });
  46 +
  47 + $("#save").bind("click", function () {
  48 + var getUrl = '<?=Url::toRoute("/production/production/do-edit")?>';
  49 + $('#myFrom').attr('action', getUrl);
  50 + var a = $("input[name='name']").val();
  51 + if (a == ""){
  52 + alert("生产日期不能为空");
  53 + return false;
  54 + }
  55 + var cb = $("#myFrom").validate().form();
  56 + if (!cb){
  57 + return;
  58 + }
  59 + var submit = $('#myFrom').submit();
  60 + var l = $.ladda(this);
  61 + l.start();
  62 + return false;
  63 + });
  64 +</script>
0 \ No newline at end of file 65 \ No newline at end of file
app-ht/modules/production/views/production/index.php 0 → 100644
@@ -0,0 +1,122 @@ @@ -0,0 +1,122 @@
  1 +<?php
  2 +use yii\helpers\Url;
  3 +use app\ht\widgets\LinkPager;
  4 +use common\helpers\ImageManager;
  5 +use domain\shop\ShopItemStatus;
  6 +
  7 +$this->title = '生产日期管理';
  8 +$this->params['breadcrumbs'][] = $this->title;
  9 +?>
  10 +
  11 +<div class="panel panel-default">
  12 + <div class="panel-body">
  13 + <form action="" method="get" id="search-form" class="filter-form">
  14 + <table width="100%" class="table table-bordered">
  15 + <tbody>
  16 + <tr >
  17 + <td width="10%" class="text-right">生产日期:</td>
  18 + <td width="35%" class="text-left">
  19 + <div class="form-inline">
  20 + <input type="date" class="form-control" style="width: 150px;" name="creatTime" placeholder="起" value="<?php if (!empty($gets['creatTime'])){ echo $gets['creatTime']; } ?>"> -
  21 + <input type="date" class="form-control" style="width: 150px;" name="endTime" placeholder="止" value="<?php if (!empty($gets['endTime'])){ echo $gets['endTime']; } ?>">
  22 + </div>
  23 + </td>
  24 + <td width="10%" class="text-right">创建时间:</td>
  25 + <td width="35%" class="text-left">
  26 + <div class="form-inline">
  27 + <input type="date" class="form-control" style="width: 150px;" name="productionCreatTime" placeholder="起" value="<?php if (!empty($gets['productionCreatTime'])){ echo $gets['productionCreatTime']; } ?>"> -
  28 + <input type="date" class="form-control" style="width: 150px;" name="productionEndTime" placeholder="止" value="<?php if (!empty($gets['productionEndTime'])){ echo $gets['productionEndTime']; } ?>">
  29 + </div>
  30 + </td>
  31 + </tr>
  32 + <tr class="search">
  33 + <td colspan="4" class="text-center">
  34 + <button type="submit" class="btn btn-primary btncls" id="search"><i class="glyphicon glyphicon-search"></i> 查 询 </button>
  35 + <a class="btn btn-default btncls" href="<?=Url::toRoute(["/production/production/index"])?>">重&nbsp;&nbsp;&nbsp;&nbsp;置</a>
  36 + </td>
  37 + </tr>
  38 + </tbody>
  39 + </table>
  40 + </form>
  41 + </div>
  42 +</div>
  43 +
  44 +<div class="panel panel-default">
  45 + <div class="panel-body">
  46 + <div style="margin-bottom: 15px;text-align: right;">
  47 + <a href="<?=Url::toRoute("/production/production/create")?>" class="btn btn-success"> + 创建生产日期</a>
  48 + </div>
  49 + <table class="table table-striped table-bordered" id="brand-table">
  50 + <thead>
  51 + <tr>
  52 + <th width="15%">编号</th>
  53 + <th width="25%">生产日期</th>
  54 + <th width="25%">创建时间</th>
  55 + <th width="20%">操作</th>
  56 + </tr>
  57 + </thead>
  58 +
  59 + <tbody>
  60 + <?php if ($listdata) { ?>
  61 + <?php foreach ($listdata as $item) : ?>
  62 + <tr>
  63 + <td style="padding:12px;"><?= (isset($item["production_no"]) ? $item["production_no"] : "") ?></td>
  64 + <td style="padding:12px;"><?= (isset($item["name"]) ? $item["name"] : "") ?>
  65 + <td style="padding:12px;"><?= date("Y-m-d H:i:s", $item['created_at'])?></td>
  66 + <td style="padding:12px;">
  67 + <button class="btn btn-danger btn-sm btn_del" aid="<?=$item['id'] ?>">删除</button>&nbsp;|&nbsp;
  68 + <a class="btn btn-info btn-sm btn_auth_success" href="<?=Url::toRoute(["/production/production/edit", "pid" => $item['id']])?>" aid="<?=$item['id'] ?>">编辑</a>
  69 + </td>
  70 + </tr>
  71 + <?php endforeach; ?>
  72 + <?php } else { ?>
  73 + <tr>
  74 + <td colspan="8">
  75 + <center>暂无记录</center>
  76 + </td>
  77 + </tr>
  78 + <?php } ?>
  79 + </tbody>
  80 + </table>
  81 + </div>
  82 +
  83 + <div class="panel-footer">
  84 + <div class="hqy-panel-pager">
  85 + <?= LinkPager::widget([
  86 + 'pagination' => $pages,
  87 + ]); ?>
  88 + <div class="clearfix"></div>
  89 + </div>
  90 + </div>
  91 +</div>
  92 +<script>
  93 + $(document).ready(function () {
  94 + $(".btn_del").bind("click",function () {
  95 + if (confirm("确定要删除该生产日期吗?")){
  96 + var data_id = $.trim($(this).attr("aid"));
  97 + if (data_id == null || data_id == ""){
  98 + alert("丢失参数,暂时无法删除,请刷新后再试");
  99 + return false;
  100 + }
  101 + var thiz = $(this);
  102 + $.ajax({
  103 + type: "post",
  104 + url: "do-del",
  105 + dataType:"json",
  106 + data: $.csrf({"data_id":data_id}),
  107 + success:function(msg){
  108 + alert(msg['msg']);
  109 + if (msg['status'] == 1){
  110 + thiz.parents("tr").remove();
  111 + }else{
  112 + //提示确认失败
  113 + }
  114 + },
  115 + error:function(msg){
  116 + //提示确认失败
  117 + }
  118 + });
  119 + }
  120 + }) ;
  121 + });
  122 +</script>
0 \ No newline at end of file 123 \ No newline at end of file
app-ht/views/layouts/routes.php
@@ -62,14 +62,14 @@ return [ @@ -62,14 +62,14 @@ return [
62 ] 62 ]
63 ], 63 ],
64 [ 64 [
65 - 'path' => '/createdate', 65 + 'path' => '/production',
66 'label' => '生产日期', 66 'label' => '生产日期',
67 'routes' => [ 67 'routes' => [
68 [ 68 [
69 - 'path' => '/createdate',  
70 - 'redirect' => '/createdate/createdate/index' 69 + 'path' => '/production',
  70 + 'redirect' => '/production/production/index'
71 ], 71 ],
72 - ['label' => '生产日期管理', 'path' => '/createdate/createdate/index'], 72 + ['label' => '生产日期管理', 'path' => '/production/production/index'],
73 ] 73 ]
74 ], 74 ],
75 [ 75 [
domain/manufacturer/ManufacturerRepository.php
@@ -9,7 +9,7 @@ use domain\manufacturer\models\Manufacturer as ManufacturerModel; @@ -9,7 +9,7 @@ use domain\manufacturer\models\Manufacturer as ManufacturerModel;
9 /** 9 /**
10 10
11 * Class ManufacturerRepository 11 * Class ManufacturerRepository
12 - * @package domain\marketing\engineernotice 12 + * @package domain\manufacturer
13 */ 13 */
14 class ManufacturerRepository 14 class ManufacturerRepository
15 { 15 {
@@ -41,9 +41,9 @@ class ManufacturerRepository @@ -41,9 +41,9 @@ class ManufacturerRepository
41 41
42 $manufacturerFind->orderBy("m.id desc"); 42 $manufacturerFind->orderBy("m.id desc");
43 $manufacturerFind->asArray(); 43 $manufacturerFind->asArray();
44 - $noticeList = $manufacturerFind->all(); 44 + $dataList = $manufacturerFind->all();
45 45
46 - return $noticeList; 46 + return $dataList;
47 } 47 }
48 48
49 /** 49 /**
@@ -89,7 +89,7 @@ class ManufacturerRepository @@ -89,7 +89,7 @@ class ManufacturerRepository
89 $manufacturer = ManufacturerModel::find(); 89 $manufacturer = ManufacturerModel::find();
90 $manufacturer->alias("mf"); 90 $manufacturer->alias("mf");
91 $manufacturer->select(["mf.*", "su.username"]); 91 $manufacturer->select(["mf.*", "su.username"]);
92 - $manufacturer->leftJoin(SysUser::tableName() . " su", "su.id = mf.sys_user_id"); 92 + $manufacturer->leftJoin(SysUserModel::tableName() . " su", "su.id = mf.sys_user_id");
93 $manufacturer->where("mf.id = " . $id); 93 $manufacturer->where("mf.id = " . $id);
94 if ($asArr && $manufacturer) { 94 if ($asArr && $manufacturer) {
95 $manufacturer = $manufacturer->asArray(); 95 $manufacturer = $manufacturer->asArray();
domain/production/Production.php 0 → 100644
@@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
  1 +<?php
  2 +
  3 +namespace domain\production;
  4 +
  5 +use Yii;
  6 +use domain\production\models\Production as ProductionModel;
  7 +use Exception;
  8 +
  9 +/**
  10 + * 生产日期
  11 + * Class Production
  12 + * @package domain\production
  13 + */
  14 +class Production
  15 +{
  16 + /**
  17 + * 创建生产日期
  18 + * @param $item
  19 + */
  20 + static function create($item)
  21 + {
  22 + try {
  23 + $productionModel = Yii::createObject(ProductionModel::className());
  24 + $productionModel->production_no = self::getProductionNo();
  25 + $productionModel->name = $item["name"]; // 生产日期
  26 + $saveResult = $productionModel->save();
  27 + return $saveResult;
  28 + } catch (Exception $e) {
  29 + return false;
  30 + }
  31 + }
  32 +
  33 + /**
  34 + * 更新生产日期
  35 + * @param $id
  36 + * @param $item
  37 + * @return null|static
  38 + */
  39 + static function update($id, $item)
  40 + {
  41 + $productionModel = ProductionModel::findOne($id);
  42 + if (empty($productionModel)) {
  43 + return false;
  44 + }
  45 + if (isset($item['name']) && $productionModel->name != $item['name']) {
  46 + $findProductionModel = ProductionModel::findOne(['name' => $item["name"]]);
  47 + if (!empty($findProductionModel)) {
  48 + return -1;
  49 + }
  50 + }
  51 + if (isset($item['name']) && !empty($item['name'])) {
  52 + $productionModel->name = $item['name'];
  53 + }
  54 +
  55 + $resultSave = $productionModel->save();
  56 + return $resultSave;
  57 + }
  58 +
  59 + /**
  60 + * 删除生产日期
  61 + * @param $id
  62 + * @param $item
  63 + * @return null|static
  64 + */
  65 + public static function delete($id)
  66 + {
  67 + $productionModel = ProductionModel::findOne($id);
  68 + if (empty($productionModel)) {
  69 + return false;
  70 + }
  71 +
  72 + return ProductionModel::deleteAll(["id" => $id]);
  73 + }
  74 +
  75 + /**
  76 + * 获取十六进制生产日期编号
  77 + */
  78 + private static function getProductionNo()
  79 + {
  80 + $findProduction = ProductionModel::find()->orderBy("id desc")->asArray()->one();
  81 + if (empty($findProduction)) {
  82 + return "0001";
  83 + }
  84 + $dataNo = hexdec($findProduction['production_no']) + 1;
  85 + $dataNo = (string) dechex($dataNo);
  86 + if (strlen($dataNo) == 1) {
  87 + $dataNo = "000" . $dataNo;
  88 + } else if (strlen($dataNo) == 2) {
  89 + $dataNo = "00" . $dataNo;
  90 + } else if (strlen($dataNo) == 3) {
  91 + $dataNo = "0" . $dataNo;
  92 + }
  93 + return $dataNo;
  94 + }
  95 +}
0 \ No newline at end of file 96 \ No newline at end of file
domain/production/ProductionRepository.php 0 → 100644
@@ -0,0 +1,85 @@ @@ -0,0 +1,85 @@
  1 +<?php
  2 +
  3 +namespace domain\production;
  4 +
  5 +use domain\production\models\Production as ProductionModel;
  6 +
  7 +
  8 +/**
  9 +
  10 + * Class ProductionRepository
  11 + * @package domain\production
  12 + */
  13 +class ProductionRepository
  14 +{
  15 + /**
  16 + * 获取分页数据
  17 + * @param $where
  18 + * @param $offset
  19 + * @param $limit
  20 + * @return array|\yii\db\ActiveRecord[]
  21 + */
  22 + static function getPageList($where, $offset, $limit)
  23 + {
  24 + $productionFind = ProductionModel::find()->alias("p")
  25 + ->select([
  26 + "p.*"
  27 + ]);
  28 +
  29 + if (!empty($where)) {
  30 + $productionFind->where($where);
  31 + }
  32 + if ($offset) {
  33 + $productionFind->offset($offset);
  34 + }
  35 + if ($limit) {
  36 + $productionFind->limit($limit);
  37 + }
  38 +
  39 + $productionFind->orderBy("p.id desc");
  40 + $productionFind->asArray();
  41 + $dataList = $productionFind->all();
  42 +
  43 + return $dataList;
  44 + }
  45 +
  46 + /**
  47 + * 列表页面分页器数量
  48 + * @param string $map
  49 + */
  50 + static function getPageCount($map = '')
  51 + {
  52 + $productionFind = ProductionModel::find()->alias("p");
  53 + if (!empty($map)) {
  54 + $productionFind->where($map);
  55 + }
  56 + $pageCount = $productionFind->count();
  57 +
  58 + return $pageCount;
  59 + }
  60 +
  61 + /**
  62 + * @param $id
  63 + * @param bool|false $asArr
  64 + * @return null|static
  65 + */
  66 + static function selectOne($id, $asArr = false)
  67 + {
  68 + $production = ProductionModel::findOne($id);
  69 + if ($asArr && $production) {
  70 + $production = $production->toArray();
  71 + }
  72 + return $production;
  73 + }
  74 +
  75 + /**
  76 + * @param $id
  77 + * @param bool|false $asArr
  78 + * @return null|static
  79 + */
  80 + static function findOne($condition)
  81 + {
  82 + $production = ProductionModel::findOne($condition);
  83 + return $production;
  84 + }
  85 +}
0 \ No newline at end of file 86 \ No newline at end of file
domain/production/models/Production.php 0 → 100644
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
  1 +<?php
  2 +
  3 +namespace domain\production\models;
  4 +
  5 +use yii\db\ActiveRecord;
  6 +use yii\behaviors\TimestampBehavior;
  7 +
  8 +/**
  9 + * 生产日期
  10 + * Class Production
  11 + * @package domain\production\models
  12 + */
  13 +class Production extends ActiveRecord
  14 +{
  15 + /**
  16 + * @inheritdoc
  17 + */
  18 + public static function tableName()
  19 + {
  20 + return '{{%production}}';
  21 + }
  22 +
  23 + /**
  24 + * @return array
  25 + */
  26 + public function behaviors()
  27 + {
  28 + return [
  29 + 'time' => [
  30 + 'class' => TimestampBehavior::className(),
  31 + 'createdAtAttribute' => 'created_at',
  32 + 'updatedAtAttribute' => 'updated_at',
  33 + ]
  34 + ];
  35 + }
  36 +}
0 \ No newline at end of file 37 \ No newline at end of file