diff --git a/app-ht/config/main.php b/app-ht/config/main.php index 05d3bd4..b2a30d8 100644 --- a/app-ht/config/main.php +++ b/app-ht/config/main.php @@ -56,8 +56,8 @@ $config = [ 'class' => 'app\ht\modules\home\Module', ] , - 'shop' => [ - 'class' => 'app\ht\modules\shop\Module', + 'production' => [ + 'class' => 'app\ht\modules\production\Module', ] ], 'components' => [ diff --git a/app-ht/config/params.php b/app-ht/config/params.php index 2041c72..ff5b9ce 100644 --- a/app-ht/config/params.php +++ b/app-ht/config/params.php @@ -3,5 +3,5 @@ return [ 'adminEmail' => 'tech@jiwork.com', 'DINGTALKL_URL' => 'https://tdd.jiwork.com/', //在钉钉端用系统扫码之后跳转到钉钉对应的界面,里面要指定钉钉的网址 'BAIDU_MAP_BROWSER_KEY' => 'UzLG5fpQtralY2hXO3wvVFzvlCmw6Rue', - 'VERSION' => 'v0.0.1 build 1', + 'VERSION' => 'v0.0.1 build 2', ]; \ No newline at end of file diff --git a/app-ht/modules/manufacturer/controllers/ManufacturerController.php b/app-ht/modules/manufacturer/controllers/ManufacturerController.php index 19e2438..29c17dd 100644 --- a/app-ht/modules/manufacturer/controllers/ManufacturerController.php +++ b/app-ht/modules/manufacturer/controllers/ManufacturerController.php @@ -12,7 +12,7 @@ use app\ht\controllers\BaseController; /** * 厂商管理 * Class ManufacturerController - * @package app\ht\modules\shop\controllers + * @package app\ht\modules\manufacturer\controllers */ class ManufacturerController extends BaseController { @@ -134,7 +134,7 @@ class ManufacturerController extends BaseController } /** - * 创建厂商 + * 编辑厂商 * @return string */ public function actionDoEdit() @@ -193,7 +193,7 @@ class ManufacturerController extends BaseController } /** - * 删除商品 + * 删除厂商 * @return string * @throws \Exception */ @@ -203,7 +203,7 @@ class ManufacturerController extends BaseController $itemId = $request->post("data_id"); $msg = array(); - // 删除对应的商品 + // 删除对应的厂商 if (Manufacturer::delete($itemId)) { $msg['status'] = 1; $msg['msg'] = "操作成功"; diff --git a/app-ht/modules/manufacturer/views/manufacturer/create.php b/app-ht/modules/manufacturer/views/manufacturer/create.php index d717bc8..400e6f8 100644 --- a/app-ht/modules/manufacturer/views/manufacturer/create.php +++ b/app-ht/modules/manufacturer/views/manufacturer/create.php @@ -3,7 +3,6 @@ use yii\helpers\Url; $this->title = '添加厂商'; -$this->params['breadcrumbs'][] = '厂商管理'; $this->params['breadcrumbs'][] = ['label' => '厂商管理', 'url' => ['/manufacturer/manufacturer/index']]; $this->params['breadcrumbs'][] = $this->title; @@ -45,24 +44,6 @@ $this->params['breadcrumbs'][] = $this->title; rules: { } }); - - //校验价格 - $.validator.addMethod("nameRequired", - function(value, element, params) { - var a = $("input[name='name']").val(); - var b = $("input[name='phone']").val(); - if (a == ""){ - params[0] = "用户名称不能为空"; - return false; - } - if (!utils.isMobile(b)){ - params[0] = "请填写正确的手机号码"; - return false; - } - return true; - }, $.validator.format("{0}") - ); - }); $("#save").bind("click", function () { diff --git a/app-ht/modules/manufacturer/views/manufacturer/edit.php b/app-ht/modules/manufacturer/views/manufacturer/edit.php index 43c1ded..4c1e16f 100644 --- a/app-ht/modules/manufacturer/views/manufacturer/edit.php +++ b/app-ht/modules/manufacturer/views/manufacturer/edit.php @@ -6,7 +6,6 @@ if ($isCreateSuccess) { } else { $this->title = '编辑厂商'; } -$this->params['breadcrumbs'][] = '厂商管理'; $this->params['breadcrumbs'][] = ['label' => '厂商管理', 'url' => ['/manufacturer/manufacturer/index']]; $this->params['breadcrumbs'][] = $this->title; diff --git a/app-ht/modules/manufacturer/views/manufacturer/index.php b/app-ht/modules/manufacturer/views/manufacturer/index.php index f354a41..9857939 100644 --- a/app-ht/modules/manufacturer/views/manufacturer/index.php +++ b/app-ht/modules/manufacturer/views/manufacturer/index.php @@ -5,7 +5,6 @@ use common\helpers\ImageManager; use domain\shop\ShopItemStatus; $this->title = '厂商管理'; -$this->params['breadcrumbs'][] = '厂商管理'; $this->params['breadcrumbs'][] = $this->title; ?> @@ -124,56 +123,5 @@ $this->params['breadcrumbs'][] = $this->title; }); } }) ; - - $(".btn_auth_fail").bind("click",function () { - var data_id = $.trim($(this).attr("aid")); - if (data_id == null || data_id == ""){ - alert("丢失参数,暂时无法审核,请刷新后再试"); - return false; - } - var thiz = $(this); - $.ajax({ - type: "post", - url: "do-auth", - dataType:"json", - data: $.csrf({"data_id":data_id, "auth_type": "auth_fail"}), - success:function(msg){ - alert(msg['msg']); - if (msg['status'] == 1){ - window.location.reload(); - }else{ - //提示确认失败 - } - }, - error:function(msg){ - //提示确认失败 - } - }); - }) ; - $(".btn_auth_success").bind("click",function () { - var data_id = $.trim($(this).attr("aid")); - if (data_id == null || data_id == ""){ - alert("丢失参数,暂时无法审核,请刷新后再试"); - return false; - } - var thiz = $(this); - $.ajax({ - type: "post", - url: "do-auth", - dataType:"json", - data: $.csrf({"data_id":data_id, "auth_type": "auth_success"}), - success:function(msg){ - alert(msg['msg']); - if (msg['status'] == 1){ - window.location.reload(); - }else{ - //提示确认失败 - } - }, - error:function(msg){ - //提示确认失败 - } - }); - }) ; }); \ No newline at end of file diff --git a/app-ht/modules/production/Module.php b/app-ht/modules/production/Module.php new file mode 100644 index 0000000..2c79826 --- /dev/null +++ b/app-ht/modules/production/Module.php @@ -0,0 +1,14 @@ +params['perm'] = require(__DIR__ . '/config/perm.php'); + } +} \ No newline at end of file diff --git a/app-ht/modules/production/config/perm.php b/app-ht/modules/production/config/perm.php new file mode 100644 index 0000000..52d37fb --- /dev/null +++ b/app-ht/modules/production/config/perm.php @@ -0,0 +1,14 @@ + '生产日期', + 'items' => [ + 'shop_city' => [ + 'label' => '生产日期', + 'items' => [ + 2 => '生产日期管理', + ], + 'path' => 'production/production/*' + ], + ] +]; diff --git a/app-ht/modules/production/controllers/ProductionController.php b/app-ht/modules/production/controllers/ProductionController.php new file mode 100644 index 0000000..0cae536 --- /dev/null +++ b/app-ht/modules/production/controllers/ProductionController.php @@ -0,0 +1,189 @@ +dataList(1); + /** + * 渲染模板 + */ + return $this->render('index', $params); + } + + /** + * 查询数据列表 + */ + protected function dataList($type = '') + { + $request = Yii::$app->request; + $creatTime = $request->get('creatTime'); + $endTime = $request->get('endTime'); + $productionCreatTime = $request->get('productionCreatTime'); + $productionEndTime = $request->get('productionEndTime'); + + $gets = [ + 'creatTime' => $creatTime, + 'endTime' => $endTime, + 'productionCreatTime' => $productionCreatTime, + 'productionEndTime' => $productionEndTime, + ]; + + $where = ['and']; + if ($creatTime) { + $creatTime = strtotime($creatTime); + $where[] = ['>=', 'p.created_at', $creatTime]; + } + if ($endTime) { + $endTime = strtotime($endTime) + 86400; + $where[] = ['<=', 'p.created_at', $endTime]; + } + if ($productionCreatTime) { + $productionCreatTime = strtotime($productionCreatTime); + $where[] = ['>=', 'p.name', $productionCreatTime]; + } + if ($productionEndTime) { + $productionEndTime = strtotime($productionEndTime) + 86400; + $where[] = ['<=', 'p.name', $productionEndTime]; + } + if ($type == 0) { + $pageList = ProductionRepository::getPageList($where); + $pages = null; + } else { + $pageSize = 20; + $pages = new Pagination(['totalCount' => ProductionRepository::getPageCount($where), 'pageSize' => $pageSize]); + $pageList = ProductionRepository::getPageList($where, $pages->offset, $pages->limit); + } + + /** + * 数据整理 + */ + return [ + 'listdata' => $pageList, + 'pages' => $pages, + 'gets' => $gets + ]; + } + + /** + * 创建生产日期 + * @return string + */ + public function actionCreate() + { + return $this->render('create'); + } + + /** + * 创建生产日期 + * @return string + */ + public function actionDoAdd() + { + $request = Yii::$app->request; + $name = $request->post("name"); // 生产日期 + if (empty($name)) { + Yii::$app->session->setFlash('error', '生产日期不能为空'); + return $this->render('create'); + } + $result = Production::create($request->post()); + if ($result) { + Yii::$app->session->setFlash('success', '添加成功'); + } else { + Yii::$app->session->setFlash('error', '添加失败'); + } + + return $this->redirect('index'); + } + + /** + * 编辑生产日期 + * @return string + */ + public function actionEdit() + { + $productionId = $this->request->get("pid"); + $info = ProductionRepository::selectOne($productionId, true); + return $this->render('edit', ["info" => $info]); + } + + /** + * 编辑生产日期 + * @return string + */ + public function actionDoEdit() + { + $request = Yii::$app->request; + $name = $request->post("name"); + $pid = $request->post("pid"); + if (empty($pid)) { + Yii::$app->session->setFlash('error', '生产日期编号不能为空'); + $params = $this->dataList(1); + return $this->render('index', $params); + } + $production = ProductionRepository::selectOne($pid,true); + if (empty($production)) { + Yii::$app->session->setFlash('error', '生产日期记录不存在'); + $params = $this->dataList(1); + return $this->render('index', $params); + } + if (empty($name)) { + Yii::$app->session->setFlash('error', '生产日期不能为空'); + return $this->render('edit', ["info" => $production]); + } + + $result = Production::update($pid, $request->post()); + + if ($result === -1) { + Yii::$app->session->setFlash('error', '修改的生产日期' . $name . '已存在'); + return $this->render('edit', ["info" => $production]); + } + if ($result) { + Yii::$app->session->setFlash('success', '编辑成功'); + } else { + Yii::$app->session->setFlash('error', '编辑失败'); + } + $production = ProductionRepository::selectOne($pid,true); + return $this->render('edit', ["info" => $production]); + } + + /** + * 删除生产日期 + * @return string + * @throws \Exception + */ + public function actionDoDel() + { + $request = Yii::$app->request; + $itemId = $request->post("data_id"); + $msg = array(); + + // 删除对应的生产日期 + if (Production::delete($itemId)) { + $msg['status'] = 1; + $msg['msg'] = "操作成功"; + } else { + $msg['status'] = 0; + $msg['msg'] = "操作失败"; + } + + return $this->renderJson($msg); + } + +} \ No newline at end of file diff --git a/app-ht/modules/production/views/production/create.php b/app-ht/modules/production/views/production/create.php new file mode 100644 index 0000000..0e362dc --- /dev/null +++ b/app-ht/modules/production/views/production/create.php @@ -0,0 +1,60 @@ +title = '创建生产日期'; +$this->params['breadcrumbs'][] = ['label' => '生产日期管理', 'url' => ['/production/production/index']]; +$this->params['breadcrumbs'][] = $this->title; + +?> + +
+ + \ No newline at end of file diff --git a/app-ht/modules/production/views/production/edit.php b/app-ht/modules/production/views/production/edit.php new file mode 100644 index 0000000..7633bac --- /dev/null +++ b/app-ht/modules/production/views/production/edit.php @@ -0,0 +1,64 @@ +title = '编辑生产日期'; +$this->params['breadcrumbs'][] = ['label' => '生产日期管理', 'url' => ['/production/production/index']]; +$this->params['breadcrumbs'][] = $this->title; + +?> + + + + \ No newline at end of file diff --git a/app-ht/modules/production/views/production/index.php b/app-ht/modules/production/views/production/index.php new file mode 100644 index 0000000..cc3604c --- /dev/null +++ b/app-ht/modules/production/views/production/index.php @@ -0,0 +1,122 @@ +title = '生产日期管理'; +$this->params['breadcrumbs'][] = $this->title; +?> + +编号 | +生产日期 | +创建时间 | +操作 | +||||
---|---|---|---|---|---|---|---|
= (isset($item["production_no"]) ? $item["production_no"] : "") ?> | += (isset($item["name"]) ? $item["name"] : "") ?> + | = date("Y-m-d H:i:s", $item['created_at'])?> | ++ | + $item['id']])?>" aid="=$item['id'] ?>">编辑 + | +||||
+ |
+