|
@@ -2,6 +2,7 @@ |
|
@@ -2,6 +2,7 @@ |
2
|
|
2
|
|
3
|
namespace app\admin\controller;
|
3
|
namespace app\admin\controller;
|
4
|
|
4
|
|
|
|
5
|
+use think\Db;
|
5
|
use app\common\controller\Backend;
|
6
|
use app\common\controller\Backend;
|
6
|
|
7
|
|
7
|
/**
|
8
|
/**
|
|
@@ -32,4 +33,56 @@ class Seller extends Backend |
|
@@ -32,4 +33,56 @@ class Seller extends Backend |
32
|
*/
|
33
|
*/
|
33
|
|
34
|
|
34
|
|
35
|
|
|
|
36
|
+ /**
|
|
|
37
|
+ * 编辑
|
|
|
38
|
+ */
|
|
|
39
|
+ public function edit($ids = null)
|
|
|
40
|
+ {
|
|
|
41
|
+ $row = $this->model->get($ids);
|
|
|
42
|
+ if (!$row) {
|
|
|
43
|
+ $this->error(__('No Results were found'));
|
|
|
44
|
+ }
|
|
|
45
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
46
|
+ if (is_array($adminIds)) {
|
|
|
47
|
+ if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
48
|
+ $this->error(__('You have no permission'));
|
|
|
49
|
+ }
|
|
|
50
|
+ }
|
|
|
51
|
+ if ($this->request->isPost()) {
|
|
|
52
|
+ $params = $this->request->post("row/a");
|
|
|
53
|
+ if ($params) {
|
|
|
54
|
+ $params = $this->preExcludeFields($params);
|
|
|
55
|
+ $result = false;
|
|
|
56
|
+ Db::startTrans();
|
|
|
57
|
+ try {
|
|
|
58
|
+ //是否采用模型验证
|
|
|
59
|
+ if ($this->modelValidate) {
|
|
|
60
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
61
|
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
62
|
+ $row->validateFailException(true)->validate($validate);
|
|
|
63
|
+ }
|
|
|
64
|
+ $params['talk_num'] = 0;
|
|
|
65
|
+ $result = $row->allowField(true)->save($params);
|
|
|
66
|
+ Db::commit();
|
|
|
67
|
+ } catch (ValidateException $e) {
|
|
|
68
|
+ Db::rollback();
|
|
|
69
|
+ $this->error($e->getMessage());
|
|
|
70
|
+ } catch (PDOException $e) {
|
|
|
71
|
+ Db::rollback();
|
|
|
72
|
+ $this->error($e->getMessage());
|
|
|
73
|
+ } catch (Exception $e) {
|
|
|
74
|
+ Db::rollback();
|
|
|
75
|
+ $this->error($e->getMessage());
|
|
|
76
|
+ }
|
|
|
77
|
+ if ($result !== false) {
|
|
|
78
|
+ $this->success();
|
|
|
79
|
+ } else {
|
|
|
80
|
+ $this->error(__('No rows were updated'));
|
|
|
81
|
+ }
|
|
|
82
|
+ }
|
|
|
83
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
84
|
+ }
|
|
|
85
|
+ $this->view->assign("row", $row);
|
|
|
86
|
+ return $this->view->fetch();
|
|
|
87
|
+ }
|
35
|
} |
88
|
} |