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; + +?> + +
+
+
+
+ " class="btn btn-success"> + 创建生产日期 +
+
+

编辑生产日期

+
+
+ +
+ " style="margin-top: -6px;" name="name" placeholder="请填写生产日期(如:2019-10-28)" class="form-control"> +
+
+
+ + +
+ +
+ + \ 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; +?> + +
+
+
+ + + + + + + + + + + + +
生产日期: +
+ - + +
+
创建时间: +
+ - + +
+
+
+
+
+ +
+
+
+ " class="btn btn-success"> + 创建生产日期 +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
编号生产日期创建时间操作
+ +  |  + $item['id']])?>" aid="">编辑 +
+
暂无记录
+
+
+ + +
+ \ No newline at end of file diff --git a/app-ht/views/layouts/routes.php b/app-ht/views/layouts/routes.php index 4bc4c72..8b7bffb 100644 --- a/app-ht/views/layouts/routes.php +++ b/app-ht/views/layouts/routes.php @@ -62,14 +62,14 @@ return [ ] ], [ - 'path' => '/createdate', + 'path' => '/production', 'label' => '生产日期', 'routes' => [ [ - 'path' => '/createdate', - 'redirect' => '/createdate/createdate/index' + 'path' => '/production', + 'redirect' => '/production/production/index' ], - ['label' => '生产日期管理', 'path' => '/createdate/createdate/index'], + ['label' => '生产日期管理', 'path' => '/production/production/index'], ] ], [ diff --git a/domain/manufacturer/ManufacturerRepository.php b/domain/manufacturer/ManufacturerRepository.php index 06a2ead..16ed893 100644 --- a/domain/manufacturer/ManufacturerRepository.php +++ b/domain/manufacturer/ManufacturerRepository.php @@ -9,7 +9,7 @@ use domain\manufacturer\models\Manufacturer as ManufacturerModel; /** * Class ManufacturerRepository - * @package domain\marketing\engineernotice + * @package domain\manufacturer */ class ManufacturerRepository { @@ -41,9 +41,9 @@ class ManufacturerRepository $manufacturerFind->orderBy("m.id desc"); $manufacturerFind->asArray(); - $noticeList = $manufacturerFind->all(); + $dataList = $manufacturerFind->all(); - return $noticeList; + return $dataList; } /** @@ -89,7 +89,7 @@ class ManufacturerRepository $manufacturer = ManufacturerModel::find(); $manufacturer->alias("mf"); $manufacturer->select(["mf.*", "su.username"]); - $manufacturer->leftJoin(SysUser::tableName() . " su", "su.id = mf.sys_user_id"); + $manufacturer->leftJoin(SysUserModel::tableName() . " su", "su.id = mf.sys_user_id"); $manufacturer->where("mf.id = " . $id); if ($asArr && $manufacturer) { $manufacturer = $manufacturer->asArray(); diff --git a/domain/production/Production.php b/domain/production/Production.php new file mode 100644 index 0000000..eacbc7f --- /dev/null +++ b/domain/production/Production.php @@ -0,0 +1,95 @@ +production_no = self::getProductionNo(); + $productionModel->name = $item["name"]; // 生产日期 + $saveResult = $productionModel->save(); + return $saveResult; + } catch (Exception $e) { + return false; + } + } + + /** + * 更新生产日期 + * @param $id + * @param $item + * @return null|static + */ + static function update($id, $item) + { + $productionModel = ProductionModel::findOne($id); + if (empty($productionModel)) { + return false; + } + if (isset($item['name']) && $productionModel->name != $item['name']) { + $findProductionModel = ProductionModel::findOne(['name' => $item["name"]]); + if (!empty($findProductionModel)) { + return -1; + } + } + if (isset($item['name']) && !empty($item['name'])) { + $productionModel->name = $item['name']; + } + + $resultSave = $productionModel->save(); + return $resultSave; + } + + /** + * 删除生产日期 + * @param $id + * @param $item + * @return null|static + */ + public static function delete($id) + { + $productionModel = ProductionModel::findOne($id); + if (empty($productionModel)) { + return false; + } + + return ProductionModel::deleteAll(["id" => $id]); + } + + /** + * 获取十六进制生产日期编号 + */ + private static function getProductionNo() + { + $findProduction = ProductionModel::find()->orderBy("id desc")->asArray()->one(); + if (empty($findProduction)) { + return "0001"; + } + $dataNo = hexdec($findProduction['production_no']) + 1; + $dataNo = (string) dechex($dataNo); + if (strlen($dataNo) == 1) { + $dataNo = "000" . $dataNo; + } else if (strlen($dataNo) == 2) { + $dataNo = "00" . $dataNo; + } else if (strlen($dataNo) == 3) { + $dataNo = "0" . $dataNo; + } + return $dataNo; + } +} \ No newline at end of file diff --git a/domain/production/ProductionRepository.php b/domain/production/ProductionRepository.php new file mode 100644 index 0000000..e570bef --- /dev/null +++ b/domain/production/ProductionRepository.php @@ -0,0 +1,85 @@ +alias("p") + ->select([ + "p.*" + ]); + + if (!empty($where)) { + $productionFind->where($where); + } + if ($offset) { + $productionFind->offset($offset); + } + if ($limit) { + $productionFind->limit($limit); + } + + $productionFind->orderBy("p.id desc"); + $productionFind->asArray(); + $dataList = $productionFind->all(); + + return $dataList; + } + + /** + * 列表页面分页器数量 + * @param string $map + */ + static function getPageCount($map = '') + { + $productionFind = ProductionModel::find()->alias("p"); + if (!empty($map)) { + $productionFind->where($map); + } + $pageCount = $productionFind->count(); + + return $pageCount; + } + + /** + * @param $id + * @param bool|false $asArr + * @return null|static + */ + static function selectOne($id, $asArr = false) + { + $production = ProductionModel::findOne($id); + if ($asArr && $production) { + $production = $production->toArray(); + } + return $production; + } + + /** + * @param $id + * @param bool|false $asArr + * @return null|static + */ + static function findOne($condition) + { + $production = ProductionModel::findOne($condition); + return $production; + } +} \ No newline at end of file diff --git a/domain/production/models/Production.php b/domain/production/models/Production.php new file mode 100644 index 0000000..a3d0a7b --- /dev/null +++ b/domain/production/models/Production.php @@ -0,0 +1,36 @@ + [ + 'class' => TimestampBehavior::className(), + 'createdAtAttribute' => 'created_at', + 'updatedAtAttribute' => 'updated_at', + ] + ]; + } +} \ No newline at end of file -- libgit2 0.21.0