作者 Karson

新增系统配置删除功能

修复会员分组规则编辑的BUG
... ... @@ -85,10 +85,10 @@ class Config extends Backend
if ($result !== false) {
try {
$this->refreshFile();
$this->success();
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->success();
} else {
$this->error($this->model->getError());
}
... ... @@ -126,15 +126,32 @@ class Config extends Backend
$this->model->allowField(true)->saveAll($configList);
try {
$this->refreshFile();
$this->success();
} catch (Exception $e) {
$this->error($e->getMessage());
}
$this->success();
}
$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;
use fast\Tree;
use think\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();
$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) {
$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);
}
return $nodeList;
... ...
... ... @@ -4,10 +4,16 @@
.edit-form tr th:first-child,.edit-form tr td:first-child{
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;
}
}
.edit-form table > tbody > tr td a.btn-delcfg{
visibility: hidden;
}
.edit-form table > tbody > tr:hover td a.btn-delcfg{
visibility: visible;
}
</style>
<div class="panel panel-default panel-intro">
<div class="panel-heading">
... ... @@ -32,8 +38,9 @@
<thead>
<tr>
<th width="15%">{:__('Title')}</th>
<th width="70%">{:__('Value')}</th>
<th width="68%">{:__('Value')}</th>
<th width="15%">{:__('Name')}</th>
<th width="2%"></th>
</tr>
</thead>
<tbody>
... ... @@ -121,6 +128,7 @@
</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>
{/foreach}
</tbody>
... ... @@ -132,6 +140,7 @@
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</td>
<td></td>
<td></td>
</tr>
</tfoot>
</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 () {
Controller.api.bindevent();
... ...