mirror of https://gitee.com/karson/fastadmin.git
parent
453bb1ddeb
commit
7e831339c8
|
|
@ -85,10 +85,10 @@ class Config extends Backend
|
||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
try {
|
try {
|
||||||
$this->refreshFile();
|
$this->refreshFile();
|
||||||
$this->success();
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->error($e->getMessage());
|
$this->error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
$this->success();
|
||||||
} else {
|
} else {
|
||||||
$this->error($this->model->getError());
|
$this->error($this->model->getError());
|
||||||
}
|
}
|
||||||
|
|
@ -126,15 +126,32 @@ class Config extends Backend
|
||||||
$this->model->allowField(true)->saveAll($configList);
|
$this->model->allowField(true)->saveAll($configList);
|
||||||
try {
|
try {
|
||||||
$this->refreshFile();
|
$this->refreshFile();
|
||||||
$this->success();
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->error($e->getMessage());
|
$this->error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
$this->success();
|
||||||
}
|
}
|
||||||
$this->error(__('Parameter %s can not be empty', ''));
|
$this->error(__('Parameter %s can not be empty', ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function del($ids = "")
|
||||||
|
{
|
||||||
|
$name = $this->request->request('name');
|
||||||
|
$config = ConfigModel::getByName($name);
|
||||||
|
if ($config) {
|
||||||
|
try {
|
||||||
|
$config->delete();
|
||||||
|
$this->refreshFile();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
$this->success();
|
||||||
|
} else {
|
||||||
|
$this->error(__('Invalid parameters'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新配置文件
|
* 刷新配置文件
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace app\admin\model;
|
namespace app\admin\model;
|
||||||
|
|
||||||
|
use fast\Tree;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|
||||||
class UserRule extends Model
|
class UserRule extends Model
|
||||||
|
|
@ -43,8 +44,16 @@ class UserRule extends Model
|
||||||
{
|
{
|
||||||
$ruleList = collection(self::where('status', 'normal')->order('weigh desc,id desc')->select())->toArray();
|
$ruleList = collection(self::where('status', 'normal')->order('weigh desc,id desc')->select())->toArray();
|
||||||
$nodeList = [];
|
$nodeList = [];
|
||||||
|
Tree::instance()->init($ruleList);
|
||||||
|
$ruleList = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'name');
|
||||||
|
$hasChildrens = [];
|
||||||
|
foreach ($ruleList as $k => $v)
|
||||||
|
{
|
||||||
|
if ($v['haschild'])
|
||||||
|
$hasChildrens[] = $v['id'];
|
||||||
|
}
|
||||||
foreach ($ruleList as $k => $v) {
|
foreach ($ruleList as $k => $v) {
|
||||||
$state = array('selected' => $v['ismenu'] ? false : in_array($v['id'], $selected));
|
$state = array('selected' => in_array($v['id'], $selected) && !in_array($v['id'], $hasChildrens));
|
||||||
$nodeList[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => __($v['title']), 'type' => 'menu', 'state' => $state);
|
$nodeList[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => __($v['title']), 'type' => 'menu', 'state' => $state);
|
||||||
}
|
}
|
||||||
return $nodeList;
|
return $nodeList;
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,16 @@
|
||||||
.edit-form tr th:first-child,.edit-form tr td:first-child{
|
.edit-form tr th:first-child,.edit-form tr td:first-child{
|
||||||
width:20%;
|
width:20%;
|
||||||
}
|
}
|
||||||
.edit-form tr th:last-child,.edit-form tr td:last-child{
|
.edit-form tr th:nth-last-of-type(-n+2),.edit-form tr td:nth-last-of-type(-n+2){
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.edit-form table > tbody > tr td a.btn-delcfg{
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
.edit-form table > tbody > tr:hover td a.btn-delcfg{
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="panel panel-default panel-intro">
|
<div class="panel panel-default panel-intro">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
|
|
@ -32,8 +38,9 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="15%">{:__('Title')}</th>
|
<th width="15%">{:__('Title')}</th>
|
||||||
<th width="70%">{:__('Value')}</th>
|
<th width="68%">{:__('Value')}</th>
|
||||||
<th width="15%">{:__('Name')}</th>
|
<th width="15%">{:__('Name')}</th>
|
||||||
|
<th width="2%"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
@ -121,6 +128,7 @@
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>{php}echo "{\$site.". $item['name'] . "}";{/php}</td>
|
<td>{php}echo "{\$site.". $item['name'] . "}";{/php}</td>
|
||||||
|
<td><a href="javascript:;" class="btn-delcfg text-muted" data-name="{$item.name}"><i class="fa fa-times"></i></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
@ -132,6 +140,7 @@
|
||||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//删除配置
|
||||||
|
$(document).on("click", ".btn-delcfg", function () {
|
||||||
|
var that = this;
|
||||||
|
Layer.confirm(__('Are you sure you want to delete this item?'), {icon: 3, title:'提示'}, function (index) {
|
||||||
|
Backend.api.ajax({
|
||||||
|
url: "general/config/del?receiver=" + value,
|
||||||
|
data: {name: $(that).data("name")}
|
||||||
|
}, function () {
|
||||||
|
$(that).closest("tr").remove();
|
||||||
|
Layer.close(index);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
},
|
},
|
||||||
add: function () {
|
add: function () {
|
||||||
Controller.api.bindevent();
|
Controller.api.bindevent();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue