From 611ce6693ede48976eaa1287fab6c9a183d3bae6 Mon Sep 17 00:00:00 2001 From: caoming <604844710@qq.com> Date: Mon, 28 Oct 2019 12:30:08 +0800 Subject: [PATCH] app-ht(build v0.0.1 build 1) 1. 后台厂商编辑功能实现。 --- app-ht/config/params.php | 2 +- app-ht/modules/manufacturer/controllers/ManufacturerController.php | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- app-ht/modules/manufacturer/views/manufacturer/edit.php | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app-ht/modules/manufacturer/views/manufacturer/index.php | 6 +++--- domain/manufacturer/Manufacturer.php | 16 ++++++++++++++-- domain/manufacturer/ManufacturerRepository.php | 39 ++++++++++++++++++++++++++++++++++++--- 6 files changed, 237 insertions(+), 10 deletions(-) create mode 100644 app-ht/modules/manufacturer/views/manufacturer/edit.php diff --git a/app-ht/config/params.php b/app-ht/config/params.php index ee76965..2041c72 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' => 'v1.8.6 build 6', + 'VERSION' => 'v0.0.1 build 1', ]; \ 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 389ec13..19e2438 100644 --- a/app-ht/modules/manufacturer/controllers/ManufacturerController.php +++ b/app-ht/modules/manufacturer/controllers/ManufacturerController.php @@ -6,6 +6,7 @@ use Yii; use yii\data\Pagination; use domain\manufacturer\Manufacturer; use domain\manufacturer\ManufacturerRepository; +use common\models\SysUser as SysUserModel; use app\ht\controllers\BaseController; /** @@ -116,9 +117,80 @@ class ManufacturerController extends BaseController } else { Yii::$app->session->setFlash('error', '添加失败'); } - return $this->render('create'); + $info = ManufacturerRepository::selectInfoById($result, true); + + return $this->render('edit', ["isCreateSuccess" => true, "info" => $info]); + } + + /** + * 编辑厂商 + * @return string + */ + public function actionEdit() + { + $manufacturerId = $this->request->get("mid"); + $info = ManufacturerRepository::selectInfoById($manufacturerId, true); + return $this->render('edit', ["isCreateSuccess" => false, "info" => $info]); } + /** + * 创建厂商 + * @return string + */ + public function actionDoEdit() + { + $request = Yii::$app->request; + $name = $request->post("name"); + $phone = $request->post("phone"); + $username = $request->post("username"); + $password = $request->post("password"); + $mid = $request->post("mid"); + if (empty($mid)) { + Yii::$app->session->setFlash('error', '厂商编号不能为空'); + $params = $this->dataList(1); + return $this->render('index', $params); + } + $manufacturer = ManufacturerRepository::selectInfoById($mid,true); + if (empty($manufacturer)) { + 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', ["isCreateSuccess" => false, "info" => $manufacturer]); + } + if (empty($phone)) { + Yii::$app->session->setFlash('error', '厂商电话不能为空'); + return $this->render('edit', ["isCreateSuccess" => false, "info" => $manufacturer]); + } + if (empty($username)) { + Yii::$app->session->setFlash('error', '账号不能为空'); + return $this->render('edit', ["isCreateSuccess" => false, "info" => $manufacturer]); + } + if (empty($password)) { + Yii::$app->session->setFlash('error', '密码不能为空'); + return $this->render('edit', ["isCreateSuccess" => false, "info" => $manufacturer]); + } + if (isset($manufacturer["name"]) && $name != $manufacturer["name"]) { + if (ManufacturerRepository::findOne(["name" => $name])) { + Yii::$app->session->setFlash('error', '修改的用户名已经存在'); + return $this->render('edit', ["isCreateSuccess" => false, "info" => $manufacturer]); + } + if (SysUserModel::findOne(["username" => $username])) { + Yii::$app->session->setFlash('error', '账号已经存在'); + return $this->render('edit', ["isCreateSuccess" => false, "info" => $manufacturer]); + } + } + $result = Manufacturer::update($mid, $request->post()); + if ($result) { + Yii::$app->session->setFlash('success', '编辑成功'); + } else { + Yii::$app->session->setFlash('error', '编辑失败'); + } + $manufacturer = ManufacturerRepository::selectInfoById($mid,true); + return $this->render('edit', ["isCreateSuccess" => false, "info" => $manufacturer]); + } /** * 删除商品 diff --git a/app-ht/modules/manufacturer/views/manufacturer/edit.php b/app-ht/modules/manufacturer/views/manufacturer/edit.php new file mode 100644 index 0000000..43c1ded --- /dev/null +++ b/app-ht/modules/manufacturer/views/manufacturer/edit.php @@ -0,0 +1,110 @@ +title = '创建账号'; +} else { + $this->title = '编辑厂商'; +} +$this->params['breadcrumbs'][] = '厂商管理'; +$this->params['breadcrumbs'][] = ['label' => '厂商管理', 'url' => ['/manufacturer/manufacturer/index']]; +$this->params['breadcrumbs'][] = $this->title; + +?> + +
+
+
+
+ " class="btn btn-success"> + 创建厂商账号 +
+
+ +

厂商创建成功!

+ +

编辑厂商

+ +
+
+ +
+ " name="name" placeholder="请填写厂商名称" class="form-control"> +
+
+
+ +
+ " name="phone" placeholder="请填写联系电话" class="form-control" > +
+
+
+ +
+ " name="username" placeholder="请填写账号名称" class="form-control" > +
+
+
+ +
+ +
+
+
+ + +
+ +
+ + \ No newline at end of file diff --git a/app-ht/modules/manufacturer/views/manufacturer/index.php b/app-ht/modules/manufacturer/views/manufacturer/index.php index 38e30cf..f354a41 100644 --- a/app-ht/modules/manufacturer/views/manufacturer/index.php +++ b/app-ht/modules/manufacturer/views/manufacturer/index.php @@ -70,8 +70,8 @@ $this->params['breadcrumbs'][] = $this->title;  |  -  |  - + $item['id']])?>" aid="">编辑  |  + $item['id']])?>" aid="">查看 @@ -98,7 +98,7 @@ $this->params['breadcrumbs'][] = $this->title;