[更新]系统模块代码同步

This commit is contained in:
Anyon 2017-10-13 15:12:10 +08:00
parent d7679d723f
commit c012bf0f60
12 changed files with 120 additions and 183 deletions

View File

@ -68,7 +68,7 @@ class Auth extends BasicAdmin
{
$nodes = NodeService::get();
$checked = Db::name('SystemAuthNode')->where(['auth' => $auth_id])->column('node');
foreach ($nodes as $key => &$node) {
foreach ($nodes as &$node) {
$node['checked'] = in_array($node['node'], $checked);
}
$all = $this->_apply_filter(ToolsService::arr2tree($nodes, 'node', 'pnode', '_sub_'));

View File

@ -14,7 +14,6 @@
namespace app\admin\controller;
use app\store\OrderService;
use controller\BasicAdmin;
use service\ExtendService;
use service\LogService;
@ -61,23 +60,13 @@ class Config extends BasicAdmin
*/
public function file()
{
$this->title = '文件存储配置';
$alert = [
'type' => 'success', 'title' => '操作提示',
'content' => '文件引擎参数影响全局文件上传功能,请勿随意修改!'
'type' => 'danger',
'title' => '操作安全警告(默认使用本地服务存储)',
'content' => '请根据实际情况配置存储引擎,合理做好站点下载分流。建议尽量使用云存储服务,同时保证文件访问协议与网站访问协议一致!'
];
$this->title = '文件存储配置';
$this->assign('alert', $alert);
return $this->index();
}
/**
* 短信参数配置
*/
public function sms()
{
$this->title = '短信服务配置';
$this->assign('result', ExtendService::querySmsBalance());
return $this->index();
}
}

View File

@ -38,7 +38,7 @@ class Index extends BasicAdmin
public function index()
{
NodeService::applyAuthNode();
$list = (array)Db::name('SystemMenu')->where(['status' => '1'])->order('sort asc,id asc')->select();
$list = (array) Db::name('SystemMenu')->where(['status' => '1'])->order('sort asc,id asc')->select();
$menus = $this->_filterMenuData(ToolsService::arr2tree($list), NodeService::get(), !!session('user'));
return view('', ['title' => '系统管理', 'menus' => $menus]);
}

View File

@ -40,17 +40,14 @@ class Log extends BasicAdmin
*/
public function index()
{
$this->title = '系统操作日志';
$get = $this->request->get();
// 日志行为类别
$actions = Db::name($this->table)->group('action')->column('action');
$this->assign('actions', $actions);
// 日志数据库对象
list($this->title, $get) = ['系统操作日志', $this->request->get()];
$db = Db::name($this->table)->order('id desc');
foreach (['action', 'content', 'username'] as $key) {
if (isset($get[$key]) && $get[$key] !== '') {
$db->where($key, 'like', "%{$get[$key]}%");
}
(isset($get[$key]) && $get[$key] !== '') && $db->whereLike($key, "%{$get[$key]}%");
}
if (isset($get['date']) && $get['date'] !== '') {
list($start, $end) = explode('-', str_replace(' ', '', $get['date']));

View File

@ -95,13 +95,14 @@ class Menu extends BasicAdmin
$current_path = "-{$vo['pid']}-{$vo['id']}";
if ($vo['pid'] !== '' && (stripos("{$menu['path']}-", "{$current_path}-") !== false || $menu['path'] === $current_path)) {
unset($menus[$key]);
continue;
}
}
}
// 读取系统功能节点
$nodes = NodeService::get();
foreach ($nodes as $key => $_vo) {
if (empty($_vo['is_menu'])) {
foreach ($nodes as $key => $node) {
if (empty($node['is_menu'])) {
unset($nodes[$key]);
}
}

View File

@ -40,8 +40,12 @@ class Node extends BasicAdmin
*/
public function index()
{
$alert = [
'type' => 'danger',
'title' => '操作安全警告(默认新节点所有人可以访问,请勾选登录控制)',
'content' => '结构为系统自动生成,其权限各选项直接影响到不同权限用户的访问及操作,请勿随意修改数据!'
];
$nodes = ToolsService::arr2table(NodeService::get(), 'node', 'pnode');
$alert = ['type' => 'danger', 'title' => '安全警告', 'content' => '结构为系统自动生成, 状态数据请勿随意修改!'];
return view('', ['title' => '系统节点管理', 'nodes' => $nodes, 'alert' => $alert]);
}
@ -51,9 +55,8 @@ class Node extends BasicAdmin
public function save()
{
if ($this->request->isPost()) {
$post = $this->request->post();
list($data, $post) = [[], $this->request->post()];
if (isset($post['list'])) {
$data = [];
foreach ($post['list'] as $vo) {
$data['node'] = $vo['node'];
$data[$vo['name']] = $vo['value'];

View File

@ -43,9 +43,7 @@ class User extends BasicAdmin
$get = $this->request->get();
$db = Db::name($this->table)->where(['is_deleted' => '0']);
foreach (['username', 'phone', 'mail'] as $key) {
if (isset($get[$key]) && $get[$key] !== '') {
$db->where($key, 'like', "%{$get[$key]}%");
}
(isset($get[$key]) && $get[$key] !== '') && $db->whereLike($key, "%{$get[$key]}%");
}
if (isset($get['date']) && $get['date'] !== '') {
list($start, $end) = explode('-', str_replace(' ', '', $get['date']));
@ -88,11 +86,12 @@ class User extends BasicAdmin
$this->assign('verify', false);
return $this->_form($this->table, 'pass');
}
$data = $this->request->post();
if ($data['password'] !== $data['repassword']) {
$post = $this->request->post();
if ($post['password'] !== $post['repassword']) {
$this->error('两次输入的密码不一致!');
}
if (DataService::save($this->table, ['id' => $data['id'], 'password' => md5($data['password'])], 'id')) {
$data = ['id' => $post['id'], 'password' => md5($post['password'])];
if (DataService::save($this->table, $data, 'id')) {
$this->success('密码修改成功,下次请使用新密码登录!', '');
}
$this->error('密码修改失败,请稍候再试!');
@ -110,7 +109,7 @@ class User extends BasicAdmin
}
if (isset($data['id'])) {
unset($data['username']);
} elseif (Db::name($this->table)->where(['username' => $data['username']])->find()) {
} elseif (Db::name($this->table)->where(['username' => $data['username']])->count() > 0) {
$this->error('用户账号已经存在,请使用其它账号!');
}
} else {

View File

@ -1,11 +1,10 @@
{extend name="extra@admin/content"}
{block name="content"}
<form onsubmit="return false;" action="__SELF__" data-auto="true" method="post"
class='form-horizontal layui-form' style='padding-top:20px'>
<form onsubmit="return false;" action="__SELF__" data-auto="true" method="post" class='form-horizontal layui-form' style='padding-top:20px'>
<div class="form-group">
<label class="col-sm-2 control-label">Storage <span class="nowrap">(存储引擎)</span></label>
<label class="col-sm-2 control-label label-required">Storage <span class="nowrap">(存储引擎)</span></label>
<div class='col-sm-8'>
<label class="think-radio">
<!--{if sysconf('storage_type') eq 'local'}-->
@ -111,11 +110,10 @@
</div>
<div class="form-group" data-storage-type="local">
<label class="col-sm-2 control-label">Allow <span class="nowrap">(允许类型)</span></label>
<label class="col-sm-2 control-label">AllowExts <span class="nowrap">(允许类型)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_local_exts" required="required"
title="请输入系统文件上传后缀" placeholder="请输入系统文件上传后缀"
value="{:sysconf('storage_local_exts')}" class="layui-input">
<input type="text" name="storage_local_exts" required="required" value="{:sysconf('storage_local_exts')}"
title="请输入系统文件上传后缀" placeholder="请输入系统文件上传后缀" class="layui-input">
<p class="help-block">设置系统允许上传文件的后缀多个以英文逗号隔开。如png,jpg,rar,doc</p>
</div>
</div>
@ -123,9 +121,8 @@
<div class="form-group" data-storage-type="qiniu">
<label class="col-sm-2 control-label">Bucket <span class="nowrap">(空间名称)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_qiniu_bucket" required="required"
title="请输入七牛云存储 Bucket (空间名称)" placeholder="请输入七牛云存储 Bucket (空间名称)"
value="{:sysconf('storage_qiniu_bucket')}" class="layui-input">
<input type="text" name="storage_qiniu_bucket" required="required" value="{:sysconf('storage_qiniu_bucket')}"
title="请输入七牛云存储 Bucket (空间名称)" placeholder="请输入七牛云存储 Bucket (空间名称)" class="layui-input">
<p class="help-block">填写七牛云存储空间名称static</p>
</div>
</div>
@ -133,9 +130,8 @@
<div class="form-group" data-storage-type="qiniu">
<label class="col-sm-2 control-label">Domain <span class="nowrap">(访问域名)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_qiniu_domain" required="required"
title="请输入七牛云存储 Domain (访问域名)" placeholder="请输入七牛云存储 Domain (访问域名)"
value="{:sysconf('storage_qiniu_domain')}" class="layui-input">
<input type="text" name="storage_qiniu_domain" required="required" value="{:sysconf('storage_qiniu_domain')}"
title="请输入七牛云存储 Domain (访问域名)" placeholder="请输入七牛云存储 Domain (访问域名)" class="layui-input">
<p class="help-block">填写七牛云存储访问域名static.ctolog.cc</p>
</div>
</div>
@ -143,9 +139,8 @@
<div class="form-group" data-storage-type="qiniu">
<label class="col-sm-2 control-label">AccessKey <span class="nowrap">(访问密钥)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_qiniu_access_key" required="required"
title="请输入七牛云 AccessKey (访问密钥)" placeholder="请输入七牛云 AccessKey (访问密钥)"
value="{:sysconf('storage_qiniu_access_key')}" class="layui-input">
<input type="text" name="storage_qiniu_access_key" required="required" value="{:sysconf('storage_qiniu_access_key')}"
title="请输入七牛云 AccessKey (访问密钥)" placeholder="请输入七牛云 AccessKey (访问密钥)" class="layui-input">
<p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到访问密钥</p>
</div>
</div>
@ -154,9 +149,8 @@
<div class="form-group" data-storage-type="qiniu">
<label class="col-sm-2 control-label">SecretKey <span class="nowrap">(安全密钥)</span></label>
<div class='col-sm-8'>
<input type="password" name="storage_qiniu_secret_key" required="required"
title="请输入七牛云 SecretKey (安全密钥)" placeholder="请输入七牛云 SecretKey (安全密钥)"
value="{:sysconf('storage_qiniu_secret_key')}" maxlength="43" class="layui-input">
<input type="password" name="storage_qiniu_secret_key" required="required" value="{:sysconf('storage_qiniu_secret_key')}" maxlength="43"
title="请输入七牛云 SecretKey (安全密钥)" placeholder="请输入七牛云 SecretKey (安全密钥)" class="layui-input">
<p class="help-block">可以在 [ 七牛云 > 个人中心 ] 设置并获取到安全密钥</p>
</div>
</div>
@ -186,9 +180,8 @@
<div class="form-group" data-storage-type="oss">
<label class="col-sm-2 control-label">Bucket <span class="nowrap">(空间名称)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_oss_bucket" required="required"
title="请输入AliOSS Bucket (空间名称)" placeholder="请输入AliOSS Bucket (空间名称)"
value="{:sysconf('storage_oss_bucket')}" class="layui-input">
<input type="text" name="storage_oss_bucket" required="required" value="{:sysconf('storage_oss_bucket')}"
title="请输入AliOSS Bucket (空间名称)" placeholder="请输入AliOSS Bucket (空间名称)" class="layui-input">
<p class="help-block">填写OSS存储空间名称static</p>
</div>
</div>
@ -196,9 +189,8 @@
<div class="form-group" data-storage-type="oss">
<label class="col-sm-2 control-label">Domain <span class="nowrap">(访问域名)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_oss_domain" required="required"
title="请输入AliOSS存储 Domain (访问域名)" placeholder="请输入AliOSS存储 Domain (访问域名)"
value="{:sysconf('storage_oss_domain')}" class="layui-input">
<input type="text" name="storage_oss_domain" required="required" value="{:sysconf('storage_oss_domain')}"
title="请输入AliOSS存储 Domain (访问域名)" placeholder="请输入AliOSS存储 Domain (访问域名)" class="layui-input">
<p class="help-block">填写OSS存储外部访问域名static.ctolog.cc</p>
</div>
</div>
@ -206,9 +198,8 @@
<div class="form-group" data-storage-type="oss">
<label class="col-sm-2 control-label">AccessKey <span class="nowrap">(访问密钥)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_oss_keyid" required="required"
title="请输入16位AliOSS AccessKey (访问密钥)" placeholder="请输入AliOSS AccessKey (访问密钥)"
value="{:sysconf('storage_oss_keyid')}" maxlength="16" class="layui-input">
<input type="text" name="storage_oss_keyid" required="required" value="{:sysconf('storage_oss_keyid')}" maxlength="16"
title="请输入16位AliOSS AccessKey (访问密钥)" placeholder="请输入AliOSS AccessKey (访问密钥)" class="layui-input">
<p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到访问密钥</p>
</div>
</div>
@ -217,9 +208,8 @@
<div class="form-group" data-storage-type="oss">
<label class="col-sm-2 control-label">SecretKey <span class="nowrap">(安全密钥)</span></label>
<div class='col-sm-8'>
<input type="password" name="storage_oss_secret" required="required"
title="请输入30位AliOSS SecretKey (安全密钥)" placeholder="请输入AliOSS SecretKey (安全密钥)"
value="{:sysconf('storage_oss_secret')}" maxlength="30" class="layui-input">
<input type="password" name="storage_oss_secret" required="required" value="{:sysconf('storage_oss_secret')}" maxlength="30"
title="请输入30位AliOSS SecretKey (安全密钥)" placeholder="请输入AliOSS SecretKey (安全密钥)" class="layui-input">
<p class="help-block">可以在 [ 阿里云 > 个人中心 ] 设置并获取到安全密钥</p>
</div>
</div>
@ -239,7 +229,6 @@
<script>
(function () {
window.form.render();
buildForm('{:sysconf("storage_type")}');
$('[name=storage_type]').on('click', function () {
buildForm($('[name=storage_type]:checked').val())

View File

@ -1,41 +0,0 @@
{extend name="extra@admin/content"}
{block name="content"}
<form onsubmit="return false;" action="__SELF__" data-auto="true" method="post" class='form-horizontal layui-form' style='padding-top:20px'>
<div class="form-group">
<label class="col-sm-2 control-label">State <span class="nowrap">(账号状态)</span></label>
<div class='col-sm-8'>
<input disabled class="layui-input layui-bg-gray" value="{if $result.code}短信剩余 {$result.num}{else}{$result.msg}{/if}">
<p class="help-block">肋通SMS接口状态若短信剩余条数不足时请提前充值。</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Username <span class="nowrap">(平台账号)</span></label>
<div class='col-sm-8'>
<input type="text" name="sms_username" required="required" value="{:sysconf('sms_username')}"
title="请输入助通SMS接口平台账号" placeholder="请输入助通SMS接口平台账号" class="layui-input">
<p class="help-block">助通SMS接口平台账号平台管理 <a target="_blank" href="http://client.ztsms.cn">登录平台</a></p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Password <span class="nowrap">(平台密码)</span></label>
<div class='col-sm-8'>
<input type="password" name="sms_password" required="required" value="{:sysconf('sms_password')}"
title="请输入助通SMS接口平台密码" placeholder="请输入助通SMS接口平台密码" class="layui-input">
<p class="help-block">助通SMS接口平台密码需要在助通平台修改。</p>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="col-sm-4 col-sm-offset-2">
<div class="layui-form-item text-center">
<button class="layui-btn" type="submit">保存配置</button>
</div>
</div>
</form>
{/block}

View File

@ -6,9 +6,9 @@
<select name='pid' class='layui-select full-width' style='display:block'>
<!--{foreach $menus as $menu}-->
<!--{eq name='menu.id' value='$vo.pid|default=0'}-->
<option selected value='{$menu.id}'>{$menu.spl}{$menu.title}</option>
<option selected value='{$menu.id}'>{$menu.spl}{$menu.title}</option>
<!--{else}-->
<option value='{$menu.id}'>{$menu.spl}{$menu.title}</option>
<option value='{$menu.id}'>{$menu.spl}{$menu.title}</option>
<!--{/eq}-->
<!--{/foreach}-->
</select>

View File

@ -66,5 +66,5 @@
<button class="layui-btn" type='submit'>保存数据</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
</div>
<script>window.form.render();</script>
</form>

View File

@ -2,11 +2,11 @@
{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
<button data-modal='{:url("$classuri/add")}' data-title="添加用户" class='layui-btn layui-btn-small'><i
class='fa fa-plus'></i> 添加用户
<button data-modal='{:url("$classuri/add")}' data-title="添加用户" class='layui-btn layui-btn-small'>
<i class='fa fa-plus'></i> 添加用户
</button>
<button data-update data-field='delete' data-action='{:url("$classuri/del")}'
class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除用户
<button data-update data-field='delete' data-action='{:url("$classuri/del")}' class='layui-btn layui-btn-small layui-btn-danger'>
<i class='fa fa-remove'></i> 删除用户
</button>
</div>
{/block}
@ -57,77 +57,77 @@
<input type="hidden" value="resort" name="action"/>
<table class="layui-table" lay-skin="line" lay-size="sm">
<thead>
<tr>
<th class='list-table-check-td'>
<input data-none-auto="" data-check-target='.list-check-box' type='checkbox'/>
</th>
<th class='text-left'>用户账号</th>
<th class='text-left'>手机号</th>
<th class='text-left'>电子邮箱</th>
<th class='text-left'>登录次数</th>
<th class='text-left'>最后登录</th>
<th class='text-left'>状态</th>
<th class='text-left'>操作</th>
</tr>
<tr>
<th class='list-table-check-td'>
<input data-none-auto="" data-check-target='.list-check-box' type='checkbox'/>
</th>
<th class='text-left nowrap'>用户名</th>
<th class='text-left nowrap'>手机号</th>
<th class='text-left nowrap'>电子邮箱</th>
<th class='text-left nowrap'>登录次数</th>
<th class='text-left nowrap'>最后登录</th>
<th class='text-left nowrap'>状态</th>
<th class='text-left nowrap'>操作</th>
</tr>
</thead>
<tbody>
{foreach $list as $key=>$vo}
<tr>
<td class='list-table-check-td'>
<input class="list-check-box" value='{$vo.id}' type='checkbox'/>
</td>
<td class='text-left nowrap'>
{$vo.username}
</td>
<td class='text-left nowrap'>
{$vo.phone|default="<span class='color-desc'>还没有设置手机号</span>"}
</td>
<td class='text-left nowrap'>
{$vo.mail|default="<span class='color-desc'>还没有设置邮箱</span>"}
</td>
<td class='text-left nowrap'>
{$vo.login_num|default="<span class='color-desc'>从未登录</span>"}
</td>
<td class='text-left nowrap'>
{$vo.login_at|format_datetime|default="<span class='color-desc'>从未登录</span>"}
</td>
<td class='text-left nowrap'>
{if $vo.status eq 0}
<span>已禁用</span>
{elseif $vo.status eq 1}
<span style="color:#090">使用中</span>
{/if}
</td>
<td class='text-left nowrap'>
{if auth("$classuri/edit")}
<span class="text-explode">|</span>
<a data-modal='{:url("$classuri/edit")}?id={$vo.id}' href="javascript:void(0)">编辑</a>
{/if}
{if auth("$classuri/auth")}
<span class="text-explode">|</span>
<a data-modal='{:url("$classuri/auth")}?id={$vo.id}' href="javascript:void(0)">授权</a>
{/if}
{if auth("$classuri/pass")}
<span class="text-explode">|</span>
<a data-modal='{:url("$classuri/pass")}?id={$vo.id}' href="javascript:void(0)">密码</a>
{/if}
{if $vo.status eq 1 and auth("$classuri/forbid")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/forbid")}'
href="javascript:void(0)">禁用</a>
{elseif auth("$classuri/resume")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}'
href="javascript:void(0)">启用</a>
{/if}
{if auth("$classuri/del")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}'
href="javascript:void(0)">删除</a>
{/if}
</td>
</tr>
{/foreach}
{foreach $list as $key=>$vo}
<tr>
<td class='list-table-check-td'>
<input class="list-check-box" value='{$vo.id}' type='checkbox'/>
</td>
<td class='text-left nowrap'>
{$vo.username}
</td>
<td class='text-left nowrap'>
{$vo.phone|default="<span class='color-desc'>还没有设置手机号</span>"}
</td>
<td class='text-left nowrap'>
{$vo.mail|default="<span class='color-desc'>还没有设置邮箱</span>"}
</td>
<td class='text-left nowrap'>
{$vo.login_num|default="<span class='color-desc'>从未登录</span>"}
</td>
<td class='text-left nowrap'>
{$vo.login_at|format_datetime|default="<span class='color-desc'>从未登录</span>"}
</td>
<td class='text-left nowrap'>
{if $vo.status eq 0}
<span>已禁用</span>
{elseif $vo.status eq 1}
<span style="color:#090">使用中</span>
{/if}
</td>
<td class='text-left nowrap'>
{if auth("$classuri/edit")}
<span class="text-explode">|</span>
<a data-modal='{:url("$classuri/edit")}?id={$vo.id}' href="javascript:void(0)">编辑</a>
{/if}
{if auth("$classuri/auth")}
<span class="text-explode">|</span>
<a data-modal='{:url("$classuri/auth")}?id={$vo.id}' href="javascript:void(0)">授权</a>
{/if}
{if auth("$classuri/pass")}
<span class="text-explode">|</span>
<a data-modal='{:url("$classuri/pass")}?id={$vo.id}' href="javascript:void(0)">密码</a>
{/if}
{if $vo.status eq 1 and auth("$classuri/forbid")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/forbid")}'
href="javascript:void(0)">禁用</a>
{elseif auth("$classuri/resume")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/resume")}'
href="javascript:void(0)">启用</a>
{/if}
{if auth("$classuri/del")}
<span class="text-explode">|</span>
<a data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}'
href="javascript:void(0)">删除</a>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
{if isset($page)}<p>{$page}</p>{/if}