正在显示
13 个修改的文件
包含
190 行增加
和
236 行删除
| @@ -74,7 +74,7 @@ class Project extends Backend | @@ -74,7 +74,7 @@ class Project extends Backend | ||
| 74 | ->paginate($limit); | 74 | ->paginate($limit); |
| 75 | 75 | ||
| 76 | foreach ($list as $row) { | 76 | foreach ($list as $row) { |
| 77 | - $row->visible(['id','project_name','image','createtime','starttime','endtime']); | 77 | + $row->visible(['id','project_name','all_working_hours','image','createtime','starttime','endtime']); |
| 78 | $row->visible(['department']); | 78 | $row->visible(['department']); |
| 79 | $row->getRelation('department')->visible(['name']); | 79 | $row->getRelation('department')->visible(['name']); |
| 80 | $row->visible(['user']); | 80 | $row->visible(['user']); |
| @@ -4,6 +4,10 @@ namespace app\admin\controller\user; | @@ -4,6 +4,10 @@ namespace app\admin\controller\user; | ||
| 4 | 4 | ||
| 5 | use app\common\controller\Backend; | 5 | use app\common\controller\Backend; |
| 6 | use app\common\library\Auth; | 6 | use app\common\library\Auth; |
| 7 | +use fast\Random; | ||
| 8 | +use think\Db; | ||
| 9 | +use think\exception\PDOException; | ||
| 10 | +use think\exception\ValidateException; | ||
| 7 | 11 | ||
| 8 | /** | 12 | /** |
| 9 | * 会员管理 | 13 | * 会员管理 |
| @@ -61,10 +65,40 @@ class User extends Backend | @@ -61,10 +65,40 @@ class User extends Backend | ||
| 61 | */ | 65 | */ |
| 62 | public function add() | 66 | public function add() |
| 63 | { | 67 | { |
| 64 | - if ($this->request->isPost()) { | ||
| 65 | - $this->token(); | 68 | + if (false === $this->request->isPost()) { |
| 69 | + return $this->view->fetch(); | ||
| 66 | } | 70 | } |
| 67 | - return parent::add(); | 71 | + $params = $this->request->post('row/a'); |
| 72 | + if (empty($params)) { | ||
| 73 | + $this->error(__('Parameter %s can not be empty', '')); | ||
| 74 | + } | ||
| 75 | + $params = $this->preExcludeFields($params); | ||
| 76 | + | ||
| 77 | + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | ||
| 78 | + $params[$this->dataLimitField] = $this->auth->id; | ||
| 79 | + } | ||
| 80 | + $result = false; | ||
| 81 | + Db::startTrans(); | ||
| 82 | + try { | ||
| 83 | + //是否采用模型验证 | ||
| 84 | + if ($this->modelValidate) { | ||
| 85 | + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | ||
| 86 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | ||
| 87 | + $this->model->validateFailException()->validate($validate); | ||
| 88 | + } | ||
| 89 | + $params['salt']=Random::alnum(); | ||
| 90 | + $params['nickname']=$params['username']; | ||
| 91 | + $params['password'] = $this->getEncryptPassword($params['password'], $params['salt']); | ||
| 92 | + $result = $this->model->allowField(true)->save($params); | ||
| 93 | + Db::commit(); | ||
| 94 | + } catch (ValidateException|PDOException|Exception $e) { | ||
| 95 | + Db::rollback(); | ||
| 96 | + $this->error($e->getMessage()); | ||
| 97 | + } | ||
| 98 | + if ($result === false) { | ||
| 99 | + $this->error(__('No rows were inserted')); | ||
| 100 | + } | ||
| 101 | + $this->success(); | ||
| 68 | } | 102 | } |
| 69 | 103 | ||
| 70 | /** | 104 | /** |
| @@ -72,34 +106,97 @@ class User extends Backend | @@ -72,34 +106,97 @@ class User extends Backend | ||
| 72 | */ | 106 | */ |
| 73 | public function edit($ids = null) | 107 | public function edit($ids = null) |
| 74 | { | 108 | { |
| 75 | - if ($this->request->isPost()) { | ||
| 76 | - $this->token(); | ||
| 77 | - } | ||
| 78 | $row = $this->model->get($ids); | 109 | $row = $this->model->get($ids); |
| 79 | - $this->modelValidate = true; | ||
| 80 | if (!$row) { | 110 | if (!$row) { |
| 81 | $this->error(__('No Results were found')); | 111 | $this->error(__('No Results were found')); |
| 82 | } | 112 | } |
| 83 | - $this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker'])); | ||
| 84 | - return parent::edit($ids); | 113 | + $adminIds = $this->getDataLimitAdminIds(); |
| 114 | + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { | ||
| 115 | + $this->error(__('You have no permission')); | ||
| 116 | + } | ||
| 117 | + if (false === $this->request->isPost()) { | ||
| 118 | + $this->view->assign('row', $row); | ||
| 119 | + return $this->view->fetch(); | ||
| 120 | + } | ||
| 121 | + $params = $this->request->post('row/a'); | ||
| 122 | + if (empty($params)) { | ||
| 123 | + $this->error(__('Parameter %s can not be empty', '')); | ||
| 124 | + } | ||
| 125 | + $params['salt']=Random::alnum(); | ||
| 126 | + $params['nickname']=$params['username']; | ||
| 127 | + $params['password'] = $this->getEncryptPassword($params['password'], $params['salt']); | ||
| 128 | + $params = $this->preExcludeFields($params); | ||
| 129 | + $result = false; | ||
| 130 | + Db::startTrans(); | ||
| 131 | + try { | ||
| 132 | + //是否采用模型验证 | ||
| 133 | + if ($this->modelValidate) { | ||
| 134 | + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | ||
| 135 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; | ||
| 136 | + $row->validateFailException()->validate($validate); | ||
| 137 | + } | ||
| 138 | + if(isset($params['password']) && $params['password'] !== "") { | ||
| 139 | + $params['password']=$this->getEncryptPassword($params['password'], $row->salt); | ||
| 140 | + } | ||
| 141 | + $result = $row->allowField(true)->save($params); | ||
| 142 | + Db::commit(); | ||
| 143 | + } catch (ValidateException|PDOException|Exception $e) { | ||
| 144 | + Db::rollback(); | ||
| 145 | + $this->error($e->getMessage()); | ||
| 146 | + } | ||
| 147 | + if (false === $result) { | ||
| 148 | + $this->error(__('No rows were updated')); | ||
| 149 | + } | ||
| 150 | + $this->success(); | ||
| 151 | + } | ||
| 152 | + /** | ||
| 153 | + * 设置错误信息 | ||
| 154 | + * | ||
| 155 | + * @param string $error 错误信息 | ||
| 156 | + * @return Auth | ||
| 157 | + */ | ||
| 158 | + public function setError($error) | ||
| 159 | + { | ||
| 160 | + $this->_error = $error; | ||
| 161 | + return $this; | ||
| 85 | } | 162 | } |
| 86 | - | ||
| 87 | /** | 163 | /** |
| 88 | * 删除 | 164 | * 删除 |
| 89 | */ | 165 | */ |
| 90 | - public function del($ids = "") | 166 | + public function del($ids = null) |
| 91 | { | 167 | { |
| 92 | - if (!$this->request->isPost()) { | 168 | + if (false === $this->request->isPost()) { |
| 93 | $this->error(__("Invalid parameters")); | 169 | $this->error(__("Invalid parameters")); |
| 94 | } | 170 | } |
| 95 | - $ids = $ids ? $ids : $this->request->post("ids"); | ||
| 96 | - $row = $this->model->get($ids); | ||
| 97 | - $this->modelValidate = true; | ||
| 98 | - if (!$row) { | ||
| 99 | - $this->error(__('No Results were found')); | 171 | + $ids = $ids ?: $this->request->post("ids"); |
| 172 | + if (empty($ids)) { | ||
| 173 | + $this->error(__('Parameter %s can not be empty', 'ids')); | ||
| 100 | } | 174 | } |
| 101 | - Auth::instance()->delete($row['id']); | ||
| 102 | - $this->success(); | 175 | + $pk = $this->model->getPk(); |
| 176 | + $adminIds = $this->getDataLimitAdminIds(); | ||
| 177 | + if (is_array($adminIds)) { | ||
| 178 | + $this->model->where($this->dataLimitField, 'in', $adminIds); | ||
| 103 | } | 179 | } |
| 180 | + $list = $this->model->where($pk, 'in', $ids)->select(); | ||
| 104 | 181 | ||
| 182 | + $count = 0; | ||
| 183 | + Db::startTrans(); | ||
| 184 | + try { | ||
| 185 | + foreach ($list as $item) { | ||
| 186 | + $count += $item->delete(); | ||
| 187 | + } | ||
| 188 | + Db::commit(); | ||
| 189 | + } catch (PDOException|Exception $e) { | ||
| 190 | + Db::rollback(); | ||
| 191 | + $this->error($e->getMessage()); | ||
| 192 | + } | ||
| 193 | + if ($count) { | ||
| 194 | + $this->success(); | ||
| 195 | + } | ||
| 196 | + $this->error(__('No rows were deleted')); | ||
| 197 | + } | ||
| 198 | + public function getEncryptPassword($password, $salt = '') | ||
| 199 | + { | ||
| 200 | + return md5(md5($password) . $salt); | ||
| 201 | + } | ||
| 105 | } | 202 | } |
| @@ -9,6 +9,7 @@ return [ | @@ -9,6 +9,7 @@ return [ | ||
| 9 | 'User_id' => '负责人', | 9 | 'User_id' => '负责人', |
| 10 | 'Starttime' => '开始时间', | 10 | 'Starttime' => '开始时间', |
| 11 | 'Endtime' => '结束时间', | 11 | 'Endtime' => '结束时间', |
| 12 | + 'All_working_hours' => '总工时(小时)', | ||
| 12 | 'Department.name' => '部门名称', | 13 | 'Department.name' => '部门名称', |
| 13 | 'User.username' => '用户名' | 14 | 'User.username' => '用户名' |
| 14 | ]; | 15 | ]; |
| @@ -12,8 +12,7 @@ class User extends Validate | @@ -12,8 +12,7 @@ class User extends Validate | ||
| 12 | protected $rule = [ | 12 | protected $rule = [ |
| 13 | 'username' => 'require|regex:\w{3,30}|unique:user', | 13 | 'username' => 'require|regex:\w{3,30}|unique:user', |
| 14 | 'nickname' => 'require|unique:user', | 14 | 'nickname' => 'require|unique:user', |
| 15 | - 'password' => 'regex:\S{6,30}', | ||
| 16 | - 'email' => 'require|email|unique:user', | 15 | + 'password' => 'require|regex:\S{6,30}', |
| 17 | 'mobile' => 'unique:user' | 16 | 'mobile' => 'unique:user' |
| 18 | ]; | 17 | ]; |
| 19 | 18 | ||
| @@ -31,17 +30,15 @@ class User extends Validate | @@ -31,17 +30,15 @@ class User extends Validate | ||
| 31 | * 验证场景 | 30 | * 验证场景 |
| 32 | */ | 31 | */ |
| 33 | protected $scene = [ | 32 | protected $scene = [ |
| 34 | - 'add' => [], | ||
| 35 | - 'edit' => ['username', 'nickname', 'password', 'email', 'mobile'], | 33 | + 'add' => ['username', 'password', 'mobile'], |
| 34 | + 'edit' => ['username', 'password', 'mobile'], | ||
| 36 | ]; | 35 | ]; |
| 37 | 36 | ||
| 38 | public function __construct(array $rules = [], $message = [], $field = []) | 37 | public function __construct(array $rules = [], $message = [], $field = []) |
| 39 | { | 38 | { |
| 40 | $this->field = [ | 39 | $this->field = [ |
| 41 | 'username' => __('Username'), | 40 | 'username' => __('Username'), |
| 42 | - 'nickname' => __('Nickname'), | ||
| 43 | 'password' => __('Password'), | 41 | 'password' => __('Password'), |
| 44 | - 'email' => __('Email'), | ||
| 45 | 'mobile' => __('Mobile') | 42 | 'mobile' => __('Mobile') |
| 46 | ]; | 43 | ]; |
| 47 | parent::__construct($rules, $message, $field); | 44 | parent::__construct($rules, $message, $field); |
| @@ -8,24 +8,14 @@ | @@ -8,24 +8,14 @@ | ||
| 8 | <input id="c-username" data-rule="required" class="form-control" name="row[username]" type="text" value=""> | 8 | <input id="c-username" data-rule="required" class="form-control" name="row[username]" type="text" value=""> |
| 9 | </div> | 9 | </div> |
| 10 | </div> | 10 | </div> |
| 11 | - <div class="form-group"> | ||
| 12 | - <label for="c-nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label> | ||
| 13 | - <div class="col-xs-12 col-sm-4"> | ||
| 14 | - <input id="c-nickname" data-rule="required" class="form-control" name="row[nickname]" type="text" value=""> | ||
| 15 | - </div> | ||
| 16 | - </div> | 11 | + |
| 17 | <div class="form-group"> | 12 | <div class="form-group"> |
| 18 | <label for="c-password" class="control-label col-xs-12 col-sm-2">{:__('Password')}:</label> | 13 | <label for="c-password" class="control-label col-xs-12 col-sm-2">{:__('Password')}:</label> |
| 19 | <div class="col-xs-12 col-sm-4"> | 14 | <div class="col-xs-12 col-sm-4"> |
| 20 | - <input id="c-password" data-rule="password" class="form-control" name="row[password]" type="password" value="" placeholder="{:__('Leave password blank if dont want to change')}" autocomplete="new-password" /> | ||
| 21 | - </div> | ||
| 22 | - </div> | ||
| 23 | - <div class="form-group"> | ||
| 24 | - <label for="c-email" class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label> | ||
| 25 | - <div class="col-xs-12 col-sm-4"> | ||
| 26 | - <input id="c-email" data-rule="email" class="form-control" name="row[email]" type="text" value=""> | 15 | + <input id="c-password" data-rule="password required" class="form-control" name="row[password]" type="password" value="" placeholder="{:__('Leave password blank if dont want to change')}" autocomplete="new-password" /> |
| 27 | </div> | 16 | </div> |
| 28 | </div> | 17 | </div> |
| 18 | + | ||
| 29 | <div class="form-group"> | 19 | <div class="form-group"> |
| 30 | <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label> | 20 | <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label> |
| 31 | <div class="col-xs-12 col-sm-4"> | 21 | <div class="col-xs-12 col-sm-4"> |
| @@ -47,85 +37,11 @@ | @@ -47,85 +37,11 @@ | ||
| 47 | </div> | 37 | </div> |
| 48 | </div> | 38 | </div> |
| 49 | <div class="form-group"> | 39 | <div class="form-group"> |
| 50 | - <label for="c-level" class="control-label col-xs-12 col-sm-2">{:__('Level')}:</label> | ||
| 51 | - <div class="col-xs-12 col-sm-4"> | ||
| 52 | - <input id="c-level" data-rule="required" class="form-control" name="row[level]" type="number" value=""> | ||
| 53 | - </div> | ||
| 54 | - </div> | ||
| 55 | - | ||
| 56 | - <div class="form-group"> | ||
| 57 | - <label for="c-birthday" class="control-label col-xs-12 col-sm-2">{:__('Birthday')}:</label> | ||
| 58 | - <div class="col-xs-12 col-sm-4"> | ||
| 59 | - <input id="c-birthday" data-rule="" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[birthday]" type="text" value=""> | ||
| 60 | - </div> | ||
| 61 | - </div> | ||
| 62 | - <div class="form-group"> | ||
| 63 | - <label for="c-bio" class="control-label col-xs-12 col-sm-2">{:__('Bio')}:</label> | 40 | + <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> |
| 64 | <div class="col-xs-12 col-sm-8"> | 41 | <div class="col-xs-12 col-sm-8"> |
| 65 | - <input id="c-bio" data-rule="" class="form-control" name="row[bio]" type="text" value=""> | ||
| 66 | - </div> | ||
| 67 | - </div> | ||
| 68 | - <div class="form-group"> | ||
| 69 | - <label for="c-money" class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label> | ||
| 70 | - <div class="col-xs-12 col-sm-4"> | ||
| 71 | - <input id="c-money" data-rule="required" class="form-control" name="row[money]" type="number" value=""> | ||
| 72 | - </div> | ||
| 73 | - </div> | ||
| 74 | - <div class="form-group"> | ||
| 75 | - <label for="c-score" class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label> | ||
| 76 | - <div class="col-xs-12 col-sm-4"> | ||
| 77 | - <input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value=""> | ||
| 78 | - </div> | ||
| 79 | - </div> | ||
| 80 | - <div class="form-group"> | ||
| 81 | - <label for="c-successions" class="control-label col-xs-12 col-sm-2">{:__('Successions')}:</label> | ||
| 82 | - <div class="col-xs-12 col-sm-4"> | ||
| 83 | - <input id="c-successions" data-rule="required" class="form-control" name="row[successions]" type="number" value=""> | ||
| 84 | - </div> | ||
| 85 | - </div> | ||
| 86 | - <div class="form-group"> | ||
| 87 | - <label for="c-maxsuccessions" class="control-label col-xs-12 col-sm-2">{:__('Maxsuccessions')}:</label> | ||
| 88 | - <div class="col-xs-12 col-sm-4"> | ||
| 89 | - <input id="c-maxsuccessions" data-rule="required" class="form-control" name="row[maxsuccessions]" type="number" value=""> | ||
| 90 | - </div> | ||
| 91 | - </div> | ||
| 92 | - <div class="form-group"> | ||
| 93 | - <label for="c-prevtime" class="control-label col-xs-12 col-sm-2">{:__('Prevtime')}:</label> | ||
| 94 | - <div class="col-xs-12 col-sm-4"> | ||
| 95 | - <input id="c-prevtime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[prevtime]" type="text" value=""> | ||
| 96 | - </div> | ||
| 97 | - </div> | ||
| 98 | - <div class="form-group"> | ||
| 99 | - <label for="c-logintime" class="control-label col-xs-12 col-sm-2">{:__('Logintime')}:</label> | ||
| 100 | - <div class="col-xs-12 col-sm-4"> | ||
| 101 | - <input id="c-logintime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[logintime]" type="text" value=""> | ||
| 102 | - </div> | ||
| 103 | - </div> | ||
| 104 | - <div class="form-group"> | ||
| 105 | - <label for="c-loginip" class="control-label col-xs-12 col-sm-2">{:__('Loginip')}:</label> | ||
| 106 | - <div class="col-xs-12 col-sm-4"> | ||
| 107 | - <input id="c-loginip" data-rule="required" class="form-control" name="row[loginip]" type="text" value=""> | ||
| 108 | - </div> | ||
| 109 | - </div> | ||
| 110 | - <div class="form-group"> | ||
| 111 | - <label for="c-loginfailure" class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label> | ||
| 112 | - <div class="col-xs-12 col-sm-4"> | ||
| 113 | - <input id="c-loginfailure" data-rule="required" class="form-control" name="row[loginfailure]" type="number" value=""> | 42 | + {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')])} |
| 114 | </div> | 43 | </div> |
| 115 | </div> | 44 | </div> |
| 116 | - <div class="form-group"> | ||
| 117 | - <label for="c-joinip" class="control-label col-xs-12 col-sm-2">{:__('Joinip')}:</label> | ||
| 118 | - <div class="col-xs-12 col-sm-4"> | ||
| 119 | - <input id="c-joinip" data-rule="required" class="form-control" name="row[joinip]" type="text" value=""> | ||
| 120 | - </div> | ||
| 121 | - </div> | ||
| 122 | - <div class="form-group"> | ||
| 123 | - <label for="c-jointime" class="control-label col-xs-12 col-sm-2">{:__('Jointime')}:</label> | ||
| 124 | - <div class="col-xs-12 col-sm-4"> | ||
| 125 | - <input id="c-jointime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[jointime]" type="text" value=""> | ||
| 126 | - </div> | ||
| 127 | - </div> | ||
| 128 | - | ||
| 129 | <div class="form-group layer-footer"> | 45 | <div class="form-group layer-footer"> |
| 130 | <label class="control-label col-xs-12 col-sm-2"></label> | 46 | <label class="control-label col-xs-12 col-sm-2"></label> |
| 131 | <div class="col-xs-12 col-sm-8"> | 47 | <div class="col-xs-12 col-sm-8"> |
| @@ -2,35 +2,19 @@ | @@ -2,35 +2,19 @@ | ||
| 2 | {:token()} | 2 | {:token()} |
| 3 | <input type="hidden" name="row[id]" value="{$row.id}"> | 3 | <input type="hidden" name="row[id]" value="{$row.id}"> |
| 4 | <div class="form-group"> | 4 | <div class="form-group"> |
| 5 | - <label class="control-label col-xs-12 col-sm-2">{:__('Group')}:</label> | ||
| 6 | - <div class="col-xs-12 col-sm-4"> | ||
| 7 | - {$groupList} | ||
| 8 | - </div> | ||
| 9 | - </div> | ||
| 10 | - <div class="form-group"> | ||
| 11 | <label for="c-username" class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label> | 5 | <label for="c-username" class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label> |
| 12 | <div class="col-xs-12 col-sm-4"> | 6 | <div class="col-xs-12 col-sm-4"> |
| 13 | <input id="c-username" data-rule="required" class="form-control" name="row[username]" type="text" value="{$row.username|htmlentities}"> | 7 | <input id="c-username" data-rule="required" class="form-control" name="row[username]" type="text" value="{$row.username|htmlentities}"> |
| 14 | </div> | 8 | </div> |
| 15 | </div> | 9 | </div> |
| 16 | - <div class="form-group"> | ||
| 17 | - <label for="c-nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label> | ||
| 18 | - <div class="col-xs-12 col-sm-4"> | ||
| 19 | - <input id="c-nickname" data-rule="required" class="form-control" name="row[nickname]" type="text" value="{$row.nickname|htmlentities}"> | ||
| 20 | - </div> | ||
| 21 | - </div> | 10 | + |
| 22 | <div class="form-group"> | 11 | <div class="form-group"> |
| 23 | <label for="c-password" class="control-label col-xs-12 col-sm-2">{:__('Password')}:</label> | 12 | <label for="c-password" class="control-label col-xs-12 col-sm-2">{:__('Password')}:</label> |
| 24 | <div class="col-xs-12 col-sm-4"> | 13 | <div class="col-xs-12 col-sm-4"> |
| 25 | <input id="c-password" data-rule="password" class="form-control" name="row[password]" type="password" value="" placeholder="{:__('Leave password blank if dont want to change')}" autocomplete="new-password" /> | 14 | <input id="c-password" data-rule="password" class="form-control" name="row[password]" type="password" value="" placeholder="{:__('Leave password blank if dont want to change')}" autocomplete="new-password" /> |
| 26 | </div> | 15 | </div> |
| 27 | </div> | 16 | </div> |
| 28 | - <div class="form-group"> | ||
| 29 | - <label for="c-email" class="control-label col-xs-12 col-sm-2">{:__('Email')}:</label> | ||
| 30 | - <div class="col-xs-12 col-sm-4"> | ||
| 31 | - <input id="c-email" data-rule="email" class="form-control" name="row[email]" type="text" value="{$row.email|htmlentities}"> | ||
| 32 | - </div> | ||
| 33 | - </div> | 17 | + |
| 34 | <div class="form-group"> | 18 | <div class="form-group"> |
| 35 | <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label> | 19 | <label for="c-mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label> |
| 36 | <div class="col-xs-12 col-sm-4"> | 20 | <div class="col-xs-12 col-sm-4"> |
| @@ -51,90 +35,7 @@ | @@ -51,90 +35,7 @@ | ||
| 51 | <ul class="row list-inline faupload-preview" id="p-avatar"></ul> | 35 | <ul class="row list-inline faupload-preview" id="p-avatar"></ul> |
| 52 | </div> | 36 | </div> |
| 53 | </div> | 37 | </div> |
| 54 | - <div class="form-group"> | ||
| 55 | - <label for="c-level" class="control-label col-xs-12 col-sm-2">{:__('Level')}:</label> | ||
| 56 | - <div class="col-xs-12 col-sm-4"> | ||
| 57 | - <input id="c-level" data-rule="required" class="form-control" name="row[level]" type="number" value="{$row.level}"> | ||
| 58 | - </div> | ||
| 59 | - </div> | ||
| 60 | - <div class="form-group"> | ||
| 61 | - <label class="control-label col-xs-12 col-sm-2">{:__('Gender')}:</label> | ||
| 62 | - <div class="col-xs-12 col-sm-8"> | ||
| 63 | - {:build_radios('row[gender]', ['1'=>__('Male'), '0'=>__('Female')], $row['gender'])} | ||
| 64 | - </div> | ||
| 65 | - </div> | ||
| 66 | - <div class="form-group"> | ||
| 67 | - <label for="c-birthday" class="control-label col-xs-12 col-sm-2">{:__('Birthday')}:</label> | ||
| 68 | - <div class="col-xs-12 col-sm-4"> | ||
| 69 | - <input id="c-birthday" data-rule="" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[birthday]" type="text" value="{$row.birthday}"> | ||
| 70 | - </div> | ||
| 71 | - </div> | ||
| 72 | - <div class="form-group"> | ||
| 73 | - <label for="c-bio" class="control-label col-xs-12 col-sm-2">{:__('Bio')}:</label> | ||
| 74 | - <div class="col-xs-12 col-sm-8"> | ||
| 75 | - <input id="c-bio" data-rule="" class="form-control" name="row[bio]" type="text" value="{$row.bio|htmlentities}"> | ||
| 76 | - </div> | ||
| 77 | - </div> | ||
| 78 | - <div class="form-group"> | ||
| 79 | - <label for="c-money" class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label> | ||
| 80 | - <div class="col-xs-12 col-sm-4"> | ||
| 81 | - <input id="c-money" data-rule="required" class="form-control" name="row[money]" type="number" value="{$row.money}"> | ||
| 82 | - </div> | ||
| 83 | - </div> | ||
| 84 | - <div class="form-group"> | ||
| 85 | - <label for="c-score" class="control-label col-xs-12 col-sm-2">{:__('Score')}:</label> | ||
| 86 | - <div class="col-xs-12 col-sm-4"> | ||
| 87 | - <input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="{$row.score}"> | ||
| 88 | - </div> | ||
| 89 | - </div> | ||
| 90 | - <div class="form-group"> | ||
| 91 | - <label for="c-successions" class="control-label col-xs-12 col-sm-2">{:__('Successions')}:</label> | ||
| 92 | - <div class="col-xs-12 col-sm-4"> | ||
| 93 | - <input id="c-successions" data-rule="required" class="form-control" name="row[successions]" type="number" value="{$row.successions}"> | ||
| 94 | - </div> | ||
| 95 | - </div> | ||
| 96 | - <div class="form-group"> | ||
| 97 | - <label for="c-maxsuccessions" class="control-label col-xs-12 col-sm-2">{:__('Maxsuccessions')}:</label> | ||
| 98 | - <div class="col-xs-12 col-sm-4"> | ||
| 99 | - <input id="c-maxsuccessions" data-rule="required" class="form-control" name="row[maxsuccessions]" type="number" value="{$row.maxsuccessions}"> | ||
| 100 | - </div> | ||
| 101 | - </div> | ||
| 102 | - <div class="form-group"> | ||
| 103 | - <label for="c-prevtime" class="control-label col-xs-12 col-sm-2">{:__('Prevtime')}:</label> | ||
| 104 | - <div class="col-xs-12 col-sm-4"> | ||
| 105 | - <input id="c-prevtime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[prevtime]" type="text" value="{$row.prevtime|datetime}"> | ||
| 106 | - </div> | ||
| 107 | - </div> | ||
| 108 | - <div class="form-group"> | ||
| 109 | - <label for="c-logintime" class="control-label col-xs-12 col-sm-2">{:__('Logintime')}:</label> | ||
| 110 | - <div class="col-xs-12 col-sm-4"> | ||
| 111 | - <input id="c-logintime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[logintime]" type="text" value="{$row.logintime|datetime}"> | ||
| 112 | - </div> | ||
| 113 | - </div> | ||
| 114 | - <div class="form-group"> | ||
| 115 | - <label for="c-loginip" class="control-label col-xs-12 col-sm-2">{:__('Loginip')}:</label> | ||
| 116 | - <div class="col-xs-12 col-sm-4"> | ||
| 117 | - <input id="c-loginip" data-rule="required" class="form-control" name="row[loginip]" type="text" value="{$row.loginip}"> | ||
| 118 | - </div> | ||
| 119 | - </div> | ||
| 120 | - <div class="form-group"> | ||
| 121 | - <label for="c-loginfailure" class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label> | ||
| 122 | - <div class="col-xs-12 col-sm-4"> | ||
| 123 | - <input id="c-loginfailure" data-rule="required" class="form-control" name="row[loginfailure]" type="number" value="{$row.loginfailure}"> | ||
| 124 | - </div> | ||
| 125 | - </div> | ||
| 126 | - <div class="form-group"> | ||
| 127 | - <label for="c-joinip" class="control-label col-xs-12 col-sm-2">{:__('Joinip')}:</label> | ||
| 128 | - <div class="col-xs-12 col-sm-4"> | ||
| 129 | - <input id="c-joinip" data-rule="required" class="form-control" name="row[joinip]" type="text" value="{$row.joinip}"> | ||
| 130 | - </div> | ||
| 131 | - </div> | ||
| 132 | - <div class="form-group"> | ||
| 133 | - <label for="c-jointime" class="control-label col-xs-12 col-sm-2">{:__('Jointime')}:</label> | ||
| 134 | - <div class="col-xs-12 col-sm-4"> | ||
| 135 | - <input id="c-jointime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[jointime]" type="text" value="{$row.jointime|datetime}"> | ||
| 136 | - </div> | ||
| 137 | - </div> | 38 | + |
| 138 | <div class="form-group"> | 39 | <div class="form-group"> |
| 139 | <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> | 40 | <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> |
| 140 | <div class="col-xs-12 col-sm-8"> | 41 | <div class="col-xs-12 col-sm-8"> |
| @@ -3,6 +3,8 @@ | @@ -3,6 +3,8 @@ | ||
| 3 | namespace app\api\controller; | 3 | namespace app\api\controller; |
| 4 | 4 | ||
| 5 | use app\common\controller\Api; | 5 | use app\common\controller\Api; |
| 6 | +use think\Db; | ||
| 7 | +use think\exception\ErrorException; | ||
| 6 | 8 | ||
| 7 | /** | 9 | /** |
| 8 | * 首页接口 | 10 | * 首页接口 |
| @@ -20,4 +22,54 @@ class Index extends Api | @@ -20,4 +22,54 @@ class Index extends Api | ||
| 20 | { | 22 | { |
| 21 | $this->success('请求成功'); | 23 | $this->success('请求成功'); |
| 22 | } | 24 | } |
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 查询部门列表 | ||
| 28 | + * @return void | ||
| 29 | + */ | ||
| 30 | + public function departmentlist(){ | ||
| 31 | + $res=Db::name("department")->select(); | ||
| 32 | + $this->success('请求成功',$res); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 查询项目列表 | ||
| 37 | + * @return void | ||
| 38 | + */ | ||
| 39 | + public function projectlist(){ | ||
| 40 | + $res=Db::name("project")->select(); | ||
| 41 | + $this->success('请求成功',$res); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public function addworkinghours(){ | ||
| 45 | + $project_id = $this->request->param("project_id");//项目id | ||
| 46 | + $content = $this->request->param("content");//内容 | ||
| 47 | + $working_hours = $this->request->param("working_hours");//工时 | ||
| 48 | + $reporttime = $this->request->param("reporttime");//内容 | ||
| 49 | + $data=[ | ||
| 50 | + 'project_id'=>$project_id, | ||
| 51 | + 'working_hours'=>$working_hours, | ||
| 52 | + 'content'=>$content, | ||
| 53 | + 'user_id'=>$this->auth->id, | ||
| 54 | + 'createtime'=>time(), | ||
| 55 | + 'reporttime'=>$reporttime, | ||
| 56 | + ]; | ||
| 57 | + if($working_hours<=0){ | ||
| 58 | + $this->error("请填写工时"); | ||
| 59 | + } | ||
| 60 | + try { | ||
| 61 | + $res=Db::name("workinghours")->insert($data); | ||
| 62 | + $project=Db::name("project")->where("id",$project_id)->find(); | ||
| 63 | + $all_working_hours=bcadd($project['all_working_hours'],$working_hours,2); | ||
| 64 | + $updateproject=Db::name("project")->where("id",$project['id'])->update(['all_working_hours'=>$all_working_hours]); | ||
| 65 | + if($res){ | ||
| 66 | + $this->success('添加成功'); | ||
| 67 | + }else{ | ||
| 68 | + $this->error("添加失败"); | ||
| 69 | + } | ||
| 70 | + }catch (ErrorException $exception){ | ||
| 71 | + | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + } | ||
| 23 | } | 75 | } |
| @@ -44,8 +44,8 @@ class User extends Api | @@ -44,8 +44,8 @@ class User extends Api | ||
| 44 | */ | 44 | */ |
| 45 | public function login() | 45 | public function login() |
| 46 | { | 46 | { |
| 47 | - $account = $this->request->post('account'); | ||
| 48 | - $password = $this->request->post('password'); | 47 | + $account = $this->request->param('account'); |
| 48 | + $password = $this->request->param('password'); | ||
| 49 | if (!$account || !$password) { | 49 | if (!$account || !$password) { |
| 50 | $this->error(__('Invalid parameters')); | 50 | $this->error(__('Invalid parameters')); |
| 51 | } | 51 | } |
| @@ -212,6 +212,7 @@ class Auth | @@ -212,6 +212,7 @@ class Auth | ||
| 212 | { | 212 | { |
| 213 | $field = Validate::is($account, 'email') ? 'email' : (Validate::regex($account, '/^1\d{10}$/') ? 'mobile' : 'username'); | 213 | $field = Validate::is($account, 'email') ? 'email' : (Validate::regex($account, '/^1\d{10}$/') ? 'mobile' : 'username'); |
| 214 | $user = User::get([$field => $account]); | 214 | $user = User::get([$field => $account]); |
| 215 | + | ||
| 215 | if (!$user) { | 216 | if (!$user) { |
| 216 | $this->setError('Account is incorrect'); | 217 | $this->setError('Account is incorrect'); |
| 217 | return false; | 218 | return false; |
| @@ -27,12 +27,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -27,12 +27,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
| 27 | {checkbox: true}, | 27 | {checkbox: true}, |
| 28 | {field: 'id', title: __('Id')}, | 28 | {field: 'id', title: __('Id')}, |
| 29 | {field: 'project_name', title: __('Project_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, | 29 | {field: 'project_name', title: __('Project_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, |
| 30 | + {field: 'all_working_hours', title: __('All_working_hours'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, | ||
| 30 | {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, | 31 | {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, |
| 31 | - {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | ||
| 32 | {field: 'starttime', title: __('Starttime'), datetimeFormat:"Y-M-D", operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | 32 | {field: 'starttime', title: __('Starttime'), datetimeFormat:"Y-M-D", operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, |
| 33 | {field: 'endtime', title: __('Endtime'), datetimeFormat:"Y-M-D", operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | 33 | {field: 'endtime', title: __('Endtime'), datetimeFormat:"Y-M-D", operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, |
| 34 | {field: 'department.name', title: __('Department_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, | 34 | {field: 'department.name', title: __('Department_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, |
| 35 | {field: 'user.username', title: __('User_id'), operate: 'LIKE'}, | 35 | {field: 'user.username', title: __('User_id'), operate: 'LIKE'}, |
| 36 | + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | ||
| 36 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 37 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
| 37 | ] | 38 | ] |
| 38 | ] | 39 | ] |
| @@ -25,22 +25,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -25,22 +25,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
| 25 | [ | 25 | [ |
| 26 | {checkbox: true}, | 26 | {checkbox: true}, |
| 27 | {field: 'id', title: __('Id'), sortable: true}, | 27 | {field: 'id', title: __('Id'), sortable: true}, |
| 28 | - {field: 'group.name', title: __('Group')}, | ||
| 29 | {field: 'username', title: __('Username'), operate: 'LIKE'}, | 28 | {field: 'username', title: __('Username'), operate: 'LIKE'}, |
| 30 | - {field: 'nickname', title: __('Nickname'), operate: 'LIKE'}, | ||
| 31 | - {field: 'email', title: __('Email'), operate: 'LIKE'}, | ||
| 32 | {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, | 29 | {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, |
| 33 | {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false}, | 30 | {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false}, |
| 34 | - {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true}, | ||
| 35 | - {field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}}, | ||
| 36 | - {field: 'score', title: __('Score'), operate: 'BETWEEN', sortable: true}, | ||
| 37 | - {field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true}, | ||
| 38 | - {field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true}, | ||
| 39 | {field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | 31 | {field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, |
| 40 | - {field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search}, | ||
| 41 | - {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, | ||
| 42 | - {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search}, | ||
| 43 | - {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}}, | ||
| 44 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 32 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
| 45 | ] | 33 | ] |
| 46 | ] | 34 | ] |
| @@ -27,10 +27,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -27,10 +27,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
| 27 | {checkbox: true}, | 27 | {checkbox: true}, |
| 28 | {field: 'id', title: __('Id')}, | 28 | {field: 'id', title: __('Id')}, |
| 29 | {field: 'working_hours', title: __('Working_hours')}, | 29 | {field: 'working_hours', title: __('Working_hours')}, |
| 30 | - {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | ||
| 31 | - {field: 'reporttime', title: __('Reporttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | 30 | + {field: 'reporttime', title: __('Reporttime'), datetimeFormat:"Y-M-D", operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, |
| 32 | {field: 'user.username', title: __('User.username'), operate: 'LIKE'}, | 31 | {field: 'user.username', title: __('User.username'), operate: 'LIKE'}, |
| 33 | {field: 'project.project_name', title: __('Project.project_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, | 32 | {field: 'project.project_name', title: __('Project.project_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, |
| 33 | + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | ||
| 34 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 34 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
| 35 | ] | 35 | ] |
| 36 | ] | 36 | ] |
| @@ -10,8 +10,8 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio | @@ -10,8 +10,8 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio | ||
| 10 | //绑定表单事件 | 10 | //绑定表单事件 |
| 11 | form.validator($.extend({ | 11 | form.validator($.extend({ |
| 12 | rules: { | 12 | rules: { |
| 13 | - username: [/^\w{3,30}$/, __('Username must be 3 to 30 characters')], | ||
| 14 | - password: [/^[\S]{6,30}$/, __('Password must be 6 to 30 characters')] | 13 | + username: [/^\w{3,30}$/, '用户名只能由3-30位数字、字母、下划线组合'], |
| 14 | + password: [/^[\S]{6,30}$/,'密码长度必须在6-30位之间,不能包含空格'] | ||
| 15 | }, | 15 | }, |
| 16 | validClass: 'has-success', | 16 | validClass: 'has-success', |
| 17 | invalidClass: 'has-error', | 17 | invalidClass: 'has-error', |
-
请 注册 或 登录 后发表评论