Accept Merge Request #15: (feature/hant -> develop)
Merge Request: 添加管理员区域配置 Created By: @todayswind Accepted By: @todayswind URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/15?initial=true
This commit is contained in:
commit
38c553e6f8
|
|
@ -6,7 +6,7 @@ return [
|
|||
'title' => 'AccessKey ID',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '',
|
||||
'value' => 'LTAI5t87F5mAkaXVKfLcmnrB',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
|
|
@ -18,7 +18,7 @@ return [
|
|||
'title' => 'AccessKey Secret',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '',
|
||||
'value' => 'fk7KgdqRdJUS6Jc99TlB6mNLKorrsD',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
|
|
@ -30,36 +30,36 @@ return [
|
|||
'title' => 'Bucket名称',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => 'yourbucket',
|
||||
'value' => 'allocatr',
|
||||
'rule' => 'required;bucket',
|
||||
'msg' => '',
|
||||
'tip' => '阿里云OSS的空间名',
|
||||
'ok' => '',
|
||||
'extend' => 'data-rule-bucket="[/^[0-9a-z_\-]{3,63}$/, \'请输入正确的Bucket名称\']"',
|
||||
'extend' => 'data-rule-bucket="[/^[0-9a-z_\\-]{3,63}$/, \'请输入正确的Bucket名称\']"',
|
||||
],
|
||||
[
|
||||
'name' => 'endpoint',
|
||||
'title' => 'Endpoint',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => 'oss-cn-shenzhen.aliyuncs.com',
|
||||
'value' => 'allocatr.oss-cn-hangzhou.aliyuncs.com',
|
||||
'rule' => 'required;endpoint',
|
||||
'msg' => '',
|
||||
'tip' => '请填写从阿里云存储获取的Endpoint',
|
||||
'ok' => '',
|
||||
'extend' => 'data-rule-endpoint="[/^(?!http(s)?:\/\/).*$/, \'不能以http(s)://开头\']"',
|
||||
'extend' => 'data-rule-endpoint="[/^(?!http(s)?:\\/\\/).*$/, \'不能以http(s)://开头\']"',
|
||||
],
|
||||
[
|
||||
'name' => 'cdnurl',
|
||||
'title' => 'CDN地址',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => 'https://yourbucket.oss-cn-shenzhen.aliyuncs.com',
|
||||
'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)://开头\']"',
|
||||
'extend' => 'data-rule-cdnurl="[/^http(s)?:\\/\\/.*$/, \'必需以http(s)://开头\']"',
|
||||
],
|
||||
[
|
||||
'name' => 'uploadmode',
|
||||
|
|
@ -69,7 +69,7 @@ return [
|
|||
'client' => '客户端直传(速度快,无备份)',
|
||||
'server' => '服务器中转(占用服务器带宽,可备份)',
|
||||
],
|
||||
'value' => 'server',
|
||||
'value' => 'client',
|
||||
'rule' => '',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
|
|
@ -195,7 +195,7 @@ return [
|
|||
'title' => '附件删除时是否同步删除云存储文件',
|
||||
'type' => 'bool',
|
||||
'content' => [],
|
||||
'value' => '0',
|
||||
'value' => '1',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
|
|
@ -207,7 +207,7 @@ return [
|
|||
'title' => 'API接口使用云存储',
|
||||
'type' => 'bool',
|
||||
'content' => [],
|
||||
'value' => '0',
|
||||
'value' => '1',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 会员管理
|
||||
|
|
|
|||
|
|
@ -49,9 +49,7 @@ class Worker extends Backend
|
|||
unset($v['sort']);
|
||||
unset($v['status']);
|
||||
}
|
||||
|
||||
$this->tree = $res;
|
||||
|
||||
$this->view->assign("tree", $res);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\admin\model;
|
||||
|
||||
use fast\Tree;
|
||||
use think\Model;
|
||||
|
||||
|
||||
|
|
@ -17,5 +18,40 @@ class Area extends Model
|
|||
->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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
21
application/admin/view/auth/admin/area.html
Normal file
21
application/admin/view/auth/admin/area.html
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<form id="add-form" class="form-horizontal" role="form"
|
||||
data-toggle="validator" method="POST" action="">
|
||||
{:token()}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">管理区域配置:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<span class="text-muted"><input type="checkbox" name="" id="checkall" /> <label for="checkall"><span>{:__('Check all')}</span></label></span>
|
||||
<span class="text-muted"><input type="checkbox" name="" id="expandall" /> <label for="expandall"><span>{:__('Expand all')}</span></label></span>
|
||||
|
||||
<div id="treeview" style="margin-top: 10px"></div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="text" value="{$user_id}" id="user_id" style="display: none">
|
||||
<input type="hidden" name="row[area_ids]" />
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -33,24 +33,24 @@
|
|||
<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('workers/worker/recyclebin')?'':'hide'}" href="workers/worker/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>
|
||||
|
||||
<form id="select-form" style="padding-left: 15px;margin-top: 10px" role="form" class="form-horizontal" data-toggle="validator" method="POST" action="">
|
||||
<div class="form-group">
|
||||
<label class="col-xs-12 col-sm-2" style="padding-left: 0px;text-align: left">区域:</label>
|
||||
<div style="display: inline-block;width: 300px;position: absolute">
|
||||
<input id="c-city-search" data-rule="required" class="form-control" data-toggle="city-picker" type="text" />
|
||||
<input id="area_id" style="display: none" class="form-control" name="area_id" hidden type="text" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-12 col-sm-2" style="text-align: left;padding-left: 0px;">工种:</label>
|
||||
<div style="width: 300px;display: inline-block;">
|
||||
<select id="citem" data-live-search="true" title="请选择" name="item_id" class="form-control selectpicker show-tick">
|
||||
<option value="0">不过滤</option>
|
||||
{foreach $items as $item}
|
||||
<option value="{$item['id']}">{$item['title']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label class="col-xs-12 col-sm-2" style="padding-left: 0px;text-align: left">区域:</label>-->
|
||||
<!-- <div style="display: inline-block;width: 300px;position: absolute">-->
|
||||
<!-- <input id="c-city-search" data-rule="required" class="form-control" data-toggle="city-picker" type="text" />-->
|
||||
<!-- <input id="area_id" style="display: none" class="form-control" name="area_id" hidden type="text" />-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label class="col-xs-12 col-sm-2" style="text-align: left;padding-left: 0px;">工种:</label>-->
|
||||
<!-- <div style="width: 300px;display: inline-block;">-->
|
||||
<!-- <select id="citem" data-live-search="true" title="请选择" name="item_id" class="form-control selectpicker show-tick">-->
|
||||
<!-- <option value="0">不过滤</option>-->
|
||||
<!-- {foreach $items as $item}-->
|
||||
<!-- <option value="{$item['id']}">{$item['title']}</option>-->
|
||||
<!-- {/foreach}-->
|
||||
<!-- </select>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<div class="form-group">
|
||||
<label class="col-xs-12 col-sm-2" style="padding-left: 0px;text-align: left">关键字:</label>
|
||||
<div style="display: inline-block;width: 300px;position: absolute">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,20 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'],
|
||||
function ($, undefined, Backend, Table, Form) {
|
||||
$.jstree.core.prototype.get_all_checked = function (full) {
|
||||
var obj = this.get_selected(), i, j;
|
||||
for (i = 0, j = obj.length; i < j; i++) {
|
||||
obj = obj.concat(this.get_node(obj[i]).parents);
|
||||
}
|
||||
obj = $.grep(obj, function (v, i, a) {
|
||||
return v != '#';
|
||||
});
|
||||
obj = obj.filter(function (itm, i, a) {
|
||||
return i == a.indexOf(itm);
|
||||
});
|
||||
return full ? $.map(obj, $.proxy(function (i) {
|
||||
return this.get_node(i);
|
||||
}, this)) : obj;
|
||||
};
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
|
|
@ -10,6 +25,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
edit_url: 'auth/admin/edit',
|
||||
del_url: 'auth/admin/del',
|
||||
multi_url: 'auth/admin/multi',
|
||||
area_url: 'auth/admin/setArea',
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -29,21 +45,54 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true, },
|
||||
{field: 'state', checkbox: true,},
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'username', title: __('Username')},
|
||||
{field: 'nickname', title: __('Nickname')},
|
||||
{field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
|
||||
{
|
||||
field: 'groups_text',
|
||||
title: __('Group'),
|
||||
operate: false,
|
||||
formatter: Table.api.formatter.label
|
||||
},
|
||||
{field: 'email', title: __('Email')},
|
||||
{field: 'mobile', title: __('Mobile')},
|
||||
{field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
|
||||
{field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
|
||||
if(row.id == Config.admin.id){
|
||||
{
|
||||
field: 'status',
|
||||
title: __("Status"),
|
||||
searchList: {"normal": __('Normal'), "hidden": __('Hidden')},
|
||||
formatter: Table.api.formatter.status
|
||||
},
|
||||
{
|
||||
field: 'logintime',
|
||||
title: __('Login time'),
|
||||
formatter: Table.api.formatter.datetime,
|
||||
operate: 'RANGE',
|
||||
addclass: 'datetimerange',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), table: table,
|
||||
events: Table.api.events.operate, formatter: function (value, row, index) {
|
||||
if (row.id == Config.admin.id) {
|
||||
return '';
|
||||
}
|
||||
return Table.api.formatter.operate.call(this, value, row, index);
|
||||
}}
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
name: "setArea",
|
||||
text: "配置管理区域",
|
||||
title: "区域",
|
||||
url: 'auth/admin/area',
|
||||
extend: 'data-toggle="tooltip" data-container="body"',
|
||||
classname: 'btn btn-xs btn-warning btn-dialog',
|
||||
//classname:"btn-view btn-dialog",
|
||||
icon: 'fa fa-add',
|
||||
refresh: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
|
@ -56,7 +105,75 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
},
|
||||
edit: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
area: function () {
|
||||
Form.api.bindevent($("form[role=form]"), null, null, function () {
|
||||
if ($("#treeview").length > 0) {
|
||||
var r = $("#treeview").jstree("get_all_checked");
|
||||
$("input[name='row[area_ids]']").val(r.join(','));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
//渲染权限节点树
|
||||
//销毁已有的节点树
|
||||
$("#treeview").jstree("destroy");
|
||||
|
||||
$.ajax({
|
||||
url: "auth/admin/areaget", // 你的 API 地址
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
data: {
|
||||
user_id:$('#user_id').val()
|
||||
},
|
||||
success: function (data) {
|
||||
// console.log(data);
|
||||
Controller.api.rendertree(data);
|
||||
},
|
||||
error: function () {
|
||||
console.error("请求失败");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//全选和展开
|
||||
$(document).on("click", "#checkall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
|
||||
});
|
||||
$(document).on("click", "#expandall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "open_all" : "close_all");
|
||||
});
|
||||
$("select[name='row[pid]']").trigger("change");
|
||||
},
|
||||
api: {
|
||||
rendertree: function (content) {
|
||||
$("#treeview")
|
||||
.on('redraw.jstree', function (e) {
|
||||
$(".layer-footer").attr("domrefresh", Math.random());
|
||||
})
|
||||
.jstree({
|
||||
"themes": {"stripes": true},
|
||||
"checkbox": {
|
||||
"keep_selected_style": false,
|
||||
},
|
||||
"types": {
|
||||
"root": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"menu": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"file": {
|
||||
"icon": "fa fa-file-o",
|
||||
}
|
||||
},
|
||||
"plugins": ["checkbox", "types"],
|
||||
"core": {
|
||||
'check_callback': true,
|
||||
"data": content
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
{field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true, visible: false},
|
||||
{field: 'weigh', title: __('Weigh')},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
{field: 'operate', title: __('Operate'),
|
||||
table: table, events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate,
|
||||
}
|
||||
]
|
||||
],
|
||||
pagination: false,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
{field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
{field: 'operate', title: __('Operate'), table: table,
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate,
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'], function ($, undefined, Backend, Table, Form) {
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'],
|
||||
function ($, undefined, Backend, Table, Form) {
|
||||
$.jstree.core.prototype.get_all_checked = function (full) {
|
||||
var obj = this.get_selected(), i, j;
|
||||
for (i = 0, j = obj.length; i < j; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user