diff --git a/addons/alioss/config.php b/addons/alioss/config.php index 0d958c2..ac6982f 100644 --- a/addons/alioss/config.php +++ b/addons/alioss/config.php @@ -2,232 +2,232 @@ return [ [ - 'name' => 'accessKeyId', - 'title' => 'AccessKey ID', - 'type' => 'string', + 'name' => 'accessKeyId', + 'title' => 'AccessKey ID', + 'type' => 'string', 'content' => [], - 'value' => '', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => 'LTAI5t87F5mAkaXVKfLcmnrB', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'accessKeySecret', - 'title' => 'AccessKey Secret', - 'type' => 'string', + 'name' => 'accessKeySecret', + 'title' => 'AccessKey Secret', + 'type' => 'string', 'content' => [], - 'value' => '', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => 'fk7KgdqRdJUS6Jc99TlB6mNLKorrsD', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'bucket', - 'title' => 'Bucket名称', - 'type' => 'string', + 'name' => 'bucket', + 'title' => 'Bucket名称', + 'type' => 'string', 'content' => [], - 'value' => 'yourbucket', - 'rule' => 'required;bucket', - 'msg' => '', - 'tip' => '阿里云OSS的空间名', - 'ok' => '', - 'extend' => 'data-rule-bucket="[/^[0-9a-z_\-]{3,63}$/, \'请输入正确的Bucket名称\']"', + 'value' => 'allocatr', + 'rule' => 'required;bucket', + 'msg' => '', + 'tip' => '阿里云OSS的空间名', + 'ok' => '', + 'extend' => 'data-rule-bucket="[/^[0-9a-z_\\-]{3,63}$/, \'请输入正确的Bucket名称\']"', ], [ - 'name' => 'endpoint', - 'title' => 'Endpoint', - 'type' => 'string', + 'name' => 'endpoint', + 'title' => 'Endpoint', + 'type' => 'string', 'content' => [], - 'value' => 'oss-cn-shenzhen.aliyuncs.com', - 'rule' => 'required;endpoint', - 'msg' => '', - 'tip' => '请填写从阿里云存储获取的Endpoint', - 'ok' => '', - 'extend' => 'data-rule-endpoint="[/^(?!http(s)?:\/\/).*$/, \'不能以http(s)://开头\']"', + 'value' => 'allocatr.oss-cn-hangzhou.aliyuncs.com', + 'rule' => 'required;endpoint', + 'msg' => '', + 'tip' => '请填写从阿里云存储获取的Endpoint', + 'ok' => '', + 'extend' => 'data-rule-endpoint="[/^(?!http(s)?:\\/\\/).*$/, \'不能以http(s)://开头\']"', ], [ - 'name' => 'cdnurl', - 'title' => 'CDN地址', - 'type' => 'string', + 'name' => 'cdnurl', + 'title' => 'CDN地址', + 'type' => 'string', 'content' => [], - 'value' => 'https://yourbucket.oss-cn-shenzhen.aliyuncs.com', - 'rule' => 'required;cdnurl', - 'msg' => '', - 'tip' => '请填写CDN地址,必须以http(s)://开头', - 'ok' => '', - 'extend' => 'data-rule-cdnurl="[/^http(s)?:\/\/.*$/, \'必需以http(s)://开头\']"', + 'value' => 'https://allocatr.oss-cn-hangzhou.aliyuncs.com', + 'rule' => 'required;cdnurl', + 'msg' => '', + 'tip' => '请填写CDN地址,必须以http(s)://开头', + 'ok' => '', + 'extend' => 'data-rule-cdnurl="[/^http(s)?:\\/\\/.*$/, \'必需以http(s)://开头\']"', ], [ - 'name' => 'uploadmode', - 'title' => '上传模式', - 'type' => 'select', + 'name' => 'uploadmode', + 'title' => '上传模式', + 'type' => 'select', 'content' => [ 'client' => '客户端直传(速度快,无备份)', 'server' => '服务器中转(占用服务器带宽,可备份)', ], - 'value' => 'server', - 'rule' => '', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => 'client', + 'rule' => '', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'serverbackup', - 'title' => '服务器中转模式备份', - 'type' => 'radio', + 'name' => 'serverbackup', + 'title' => '服务器中转模式备份', + 'type' => 'radio', 'content' => [ 1 => '备份(附件管理将产生2条记录)', 0 => '不备份', ], - 'value' => '1', - 'rule' => '', - 'msg' => '', - 'tip' => '服务器中转模式下是否备份文件', - 'ok' => '', - 'extend' => '', + 'value' => '1', + 'rule' => '', + 'msg' => '', + 'tip' => '服务器中转模式下是否备份文件', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'savekey', - 'title' => '保存文件名', - 'type' => 'string', + 'name' => 'savekey', + 'title' => '保存文件名', + 'type' => 'string', 'content' => [], - 'value' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '/uploads/{year}{mon}{day}/{filemd5}{.suffix}', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'expire', - 'title' => '上传有效时长', - 'type' => 'string', + 'name' => 'expire', + 'title' => '上传有效时长', + 'type' => 'string', 'content' => [], - 'value' => '600', - 'rule' => 'required', - 'msg' => '', - 'tip' => '用户停留页面上传有效时长,单位秒', - 'ok' => '', - 'extend' => '', + 'value' => '600', + 'rule' => 'required', + 'msg' => '', + 'tip' => '用户停留页面上传有效时长,单位秒', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'maxsize', - 'title' => '最大可上传', - 'type' => 'string', + 'name' => 'maxsize', + 'title' => '最大可上传', + 'type' => 'string', 'content' => [], - 'value' => '10M', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '10M', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'mimetype', - 'title' => '可上传后缀格式', - 'type' => 'string', + 'name' => 'mimetype', + 'title' => '可上传后缀格式', + 'type' => 'string', 'content' => [], - 'value' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => 'jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'multiple', - 'title' => '多文件上传', - 'type' => 'bool', + 'name' => 'multiple', + 'title' => '多文件上传', + 'type' => 'bool', 'content' => [], - 'value' => '0', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '0', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'thumbstyle', - 'title' => '缩略图样式', - 'type' => 'string', + 'name' => 'thumbstyle', + 'title' => '缩略图样式', + 'type' => 'string', 'content' => [], - 'value' => '', - 'rule' => '', - 'msg' => '', - 'tip' => '用于后台列表缩略图样式,可使用:?x-oss-process=image/resize,m_lfit,w_120,h_90', - 'ok' => '', - 'extend' => '', + 'value' => '', + 'rule' => '', + 'msg' => '', + 'tip' => '用于后台列表缩略图样式,可使用:?x-oss-process=image/resize,m_lfit,w_120,h_90', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'chunking', - 'title' => '分片上传', - 'type' => 'radio', + 'name' => 'chunking', + 'title' => '分片上传', + 'type' => 'radio', 'content' => [ 1 => '开启', 0 => '关闭', ], - 'value' => '0', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '0', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'chunksize', - 'title' => '分片大小', - 'type' => 'number', + 'name' => 'chunksize', + 'title' => '分片大小', + 'type' => 'number', 'content' => [], - 'value' => '4194304', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '4194304', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'syncdelete', - 'title' => '附件删除时是否同步删除云存储文件', - 'type' => 'bool', + 'name' => 'syncdelete', + 'title' => '附件删除时是否同步删除云存储文件', + 'type' => 'bool', 'content' => [], - 'value' => '0', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '1', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'apiupload', - 'title' => 'API接口使用云存储', - 'type' => 'bool', + 'name' => 'apiupload', + 'title' => 'API接口使用云存储', + 'type' => 'bool', 'content' => [], - 'value' => '0', - 'rule' => 'required', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '1', + 'rule' => 'required', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'noneedlogin', - 'title' => '免登录上传', - 'type' => 'checkbox', + 'name' => 'noneedlogin', + 'title' => '免登录上传', + 'type' => 'checkbox', 'content' => [ - 'api' => 'API', + 'api' => 'API', 'index' => '前台', 'admin' => '后台', ], - 'value' => '', - 'rule' => '', - 'msg' => '', - 'tip' => '', - 'ok' => '', - 'extend' => '', + 'value' => '', + 'rule' => '', + 'msg' => '', + 'tip' => '', + 'ok' => '', + 'extend' => '', ], ]; diff --git a/application/admin/controller/auth/Admin.php b/application/admin/controller/auth/Admin.php index 85f8fb4..16f46ca 100755 --- a/application/admin/controller/auth/Admin.php +++ b/application/admin/controller/auth/Admin.php @@ -8,6 +8,8 @@ use app\common\controller\Backend; use fast\Random; use fast\Tree; use think\Db; +use think\exception\PDOException; +use think\exception\ValidateException; use think\Validate; /** @@ -294,4 +296,66 @@ class Admin extends Backend $this->dataLimitField = 'id'; return parent::selectpage(); } + + public function areaget(){ + $user_id = request()->get('user_id'); + $data = model('area')->getTree(); + + if ($user_id){ + $user = model('admin')->get($user_id); + $in_areas = explode(',',$user->area_ids ?? ''); + foreach ($data as &$datum){ + if (in_array($datum['id'],$in_areas)){ + $datum['state'] = [ + 'selected' => true + ]; + } + } + + } + + return $data; + } + public function area($ids = null){ + if (false === $this->request->isPost()) { + +// dd($areas); + $this->view->assign('user_id',$ids); +// dd($areas); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + // 获取当前ID对应的订单信息 + $user = $this->model->get($ids); + if (!$user) { + $this->error('订单不存在'); + } + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + $result = $user->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } } diff --git a/application/admin/controller/user/User.php b/application/admin/controller/user/User.php index 6908ad6..37d1349 100755 --- a/application/admin/controller/user/User.php +++ b/application/admin/controller/user/User.php @@ -4,6 +4,9 @@ namespace app\admin\controller\user; use app\common\controller\Backend; use app\common\library\Auth; +use think\Db; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 会员管理 diff --git a/application/admin/controller/workers/Worker.php b/application/admin/controller/workers/Worker.php index 5a14ade..160b03b 100644 --- a/application/admin/controller/workers/Worker.php +++ b/application/admin/controller/workers/Worker.php @@ -49,9 +49,7 @@ class Worker extends Backend unset($v['sort']); unset($v['status']); } - $this->tree = $res; - $this->view->assign("tree", $res); } diff --git a/application/admin/model/Area.php b/application/admin/model/Area.php index 89743f0..34c075f 100644 --- a/application/admin/model/Area.php +++ b/application/admin/model/Area.php @@ -2,6 +2,7 @@ namespace app\admin\model; +use fast\Tree; use think\Model; @@ -16,6 +17,41 @@ class Area extends Model return $this->where('area_code','=',$code) ->value('merge_name'); } + + public function getTree(){ + + $res = $this->field(['city_code','code','name','level','province_code']) + ->where('level','<',3) + ->select(); + + +// dd($ruleList); + + foreach ($res as &$v) { + $v = $v->toArray(); + $v['state'] = ['selected' => false]; + if ($v['level'] == 2){ + $v['pid'] = $v['province_code'] ?: 0; + $v['parent'] = $v['province_code'] ?: '#'; + }else{ + $v['pid'] = $v['city_code'] ?: 0; + $v['parent'] = $v['city_code'] ?: '#'; + } + $v['id'] = $v['code']; + $v['text'] = $v['name']; + unset($v['province_code']); + unset($v['city_code']); + unset($v['level']); + unset($v['code']); + } +// dd($res); + Tree::instance()->init($res)->icon = + [' ', ' ', ' ']; + + $res = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0)); +// dd($res); + return $res; + } } diff --git a/application/admin/view/auth/admin/area.html b/application/admin/view/auth/admin/area.html new file mode 100644 index 0000000..6a78481 --- /dev/null +++ b/application/admin/view/auth/admin/area.html @@ -0,0 +1,21 @@ +
\ No newline at end of file diff --git a/application/admin/view/workers/worker/index.html b/application/admin/view/workers/worker/index.html index a4caafc..f96cc4c 100644 --- a/application/admin/view/workers/worker/index.html +++ b/application/admin/view/workers/worker/index.html @@ -33,24 +33,24 @@ {:__('Recycle bin')}