升级基础框架

This commit is contained in:
邹景立 2021-07-29 14:22:47 +08:00
parent 2d6468b3cd
commit ec9370b651
26 changed files with 1377 additions and 863 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7561,7 +7561,7 @@ VALUES (4, 'base', 'miitbeian', '');
INSERT INTO `system_config`
VALUES (5, 'base', 'site_copy', '©版权所有 2014-2020 楚才科技');
INSERT INTO `system_config`
VALUES (6, 'base', 'site_icon', 'http://127.0.0.1/upload/f4/7b8fe06e38ae9908e8398da45583b9.png');
VALUES (6, 'base', 'site_icon', 'https://v6.thinkadmin.top/upload/f4/7b8fe06e38ae9908e8398da45583b9.png');
INSERT INTO `system_config`
VALUES (7, 'base', 'site_name', 'ThinkAdmin');
INSERT INTO `system_config`
@ -7608,7 +7608,7 @@ CREATE TABLE `system_menu`
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_menu_status`(`status`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 99 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-菜单' ROW_FORMAT = COMPACT;
) ENGINE = InnoDB AUTO_INCREMENT = 100 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统-菜单' ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of system_menu
@ -7624,13 +7624,15 @@ VALUES (5, 12, '系统用户管理', 'layui-icon layui-icon-username', '', 'admi
INSERT INTO `system_menu`
VALUES (7, 12, '访问权限管理', 'layui-icon layui-icon-vercode', '', 'admin/auth/index', '', '_self', 2, 1, '2018-09-06 15:17:14');
INSERT INTO `system_menu`
VALUES (11, 4, '系统参数配置', 'layui-icon layui-icon-set', '', 'admin/config/index', '', '_self', 4, 1, '2018-09-06 16:43:47');
VALUES (8, 4, '数据字典管理', 'layui-icon layui-icon-code-circle', 'admin/base/index', 'admin/base/index', '', '_self', 2, 1, '2021-07-29 14:17:42');
INSERT INTO `system_menu`
VALUES (11, 4, '系统参数配置', 'layui-icon layui-icon-set', '', 'admin/config/index', '', '_self', 5, 1, '2018-09-06 16:43:47');
INSERT INTO `system_menu`
VALUES (12, 2, '权限管理', '', '', '#', '', '_self', 10, 1, '2018-09-06 18:01:31');
INSERT INTO `system_menu`
VALUES (27, 4, '系统任务管理', 'layui-icon layui-icon-log', '', 'admin/queue/index', '', '_self', 3, 1, '2018-11-29 11:13:34');
VALUES (27, 4, '系统任务管理', 'layui-icon layui-icon-log', '', 'admin/queue/index', '', '_self', 4, 1, '2018-11-29 11:13:34');
INSERT INTO `system_menu`
VALUES (49, 4, '系统日志管理', 'layui-icon layui-icon-form', '', 'admin/oplog/index', '', '_self', 2, 1, '2019-02-18 12:56:56');
VALUES (49, 4, '系统日志管理', 'layui-icon layui-icon-form', '', 'admin/oplog/index', '', '_self', 3, 1, '2019-02-18 12:56:56');
INSERT INTO `system_menu`
VALUES (56, 0, '微信管理', '', '', '#', '', '_self', 200, 1, '2019-12-09 11:00:37');
INSERT INTO `system_menu`
@ -7703,7 +7705,6 @@ INSERT INTO `system_menu`
VALUES (98, 0, '首 页', '', 'data/total.portal/index', 'data/total.portal/index', '', '_self', 400, 1, '2021-04-10 13:43:19');
INSERT INTO `system_menu`
VALUES (99, 60, '关注自动回复', 'layui-icon layui-icon-release', 'wechat/auto/index', 'wechat/auto/index', '', '_self', 0, 1, '2021-04-10 15:56:54');
-- ----------------------------
-- Table structure for system_user
-- ----------------------------

View File

@ -1,52 +1,69 @@
/*
Navicat MySQL Data Transfer
Source Server : anyon.localhost
Source Server Type : MySQL
Source Server Version : 80018
Source Host : localhost:3306
Source Schema : admin_v6
Target Server Type : MySQL
Target Server Version : 80018
File Encoding : 65001
Date: 12/04/2021 10:39:27
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for wechat_auto
-- ----------------------------
CREATE TABLE IF NOT EXISTS `wechat_auto` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '类型(text,image,news)',
`time` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '延迟时间',
`code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '消息编号',
`appid` char(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '公众号APPID',
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '文本内容',
`image_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '图片链接',
`voice_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '语音链接',
`music_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐标题',
`music_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐链接',
`music_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '缩略图片',
`music_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐描述',
`video_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频标题',
`video_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频URL',
`video_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频描述',
`news_id` bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '图文ID',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(0禁用,1启用)',
`create_by` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '创建人',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_wechat_auto_type`(`type`) USING BTREE,
INDEX `idx_wechat_auto_keys`(`time`) USING BTREE,
INDEX `idx_wechat_auto_appid`(`appid`) USING BTREE,
INDEX `idx_wechat_auto_code`(`code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '微信-回复' ROW_FORMAT = COMPACT;
-- 尝试创建微信自动回复数据表
CREATE TABLE IF NOT EXISTS `wechat_auto`
(
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '类型(text,image,news)',
`time` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '延迟时间',
`code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '消息编号',
`appid` char(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '公众号APPID',
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '文本内容',
`image_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '图片链接',
`voice_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '语音链接',
`music_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐标题',
`music_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐链接',
`music_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '缩略图片',
`music_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '音乐描述',
`video_title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频标题',
`video_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频URL',
`video_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '视频描述',
`news_id` bigint(20) UNSIGNED NULL DEFAULT NULL COMMENT '图文ID',
`status` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '状态(0禁用,1启用)',
`create_by` bigint(20) UNSIGNED NULL DEFAULT 0 COMMENT '创建人',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_wechat_auto_type` (`type`) USING BTREE,
INDEX `idx_wechat_auto_keys` (`time`) USING BTREE,
INDEX `idx_wechat_auto_appid` (`appid`) USING BTREE,
INDEX `idx_wechat_auto_code` (`code`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8mb4
COLLATE = utf8mb4_unicode_ci COMMENT = '微信-回复'
ROW_FORMAT = COMPACT;
ALTER TABLE `system_queue` MODIFY COLUMN `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '任务名称' AFTER `code`;
-- 调整字段名称长度
ALTER TABLE `system_queue`
MODIFY COLUMN `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '任务名称' AFTER `code`;
-- 尝试创建数据字典数据表
CREATE TABLE IF NOT EXISTS `system_base`
(
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据类型',
`code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据代码',
`name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据名称',
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '数据内容',
`sort` bigint(20) NULL DEFAULT 0 COMMENT '排序权重',
`status` tinyint(1) NULL DEFAULT 1 COMMENT '数据状态(0禁用,1启动)',
`deleted` tinyint(1) NULL DEFAULT 0 COMMENT '删除状态(0正常,1已删)',
`deleted_at` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '删除时间',
`deleted_by` bigint(20) NULL DEFAULT 0 COMMENT '删除用户',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_system_base_type` (`type`) USING BTREE,
INDEX `idx_system_base_code` (`code`) USING BTREE,
INDEX `idx_system_base_name` (`name`(191)) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
CHARACTER SET = utf8mb4
COLLATE = utf8mb4_unicode_ci COMMENT = '系统-字典'
ROW_FORMAT = COMPACT;
-- 权限表增加身份权限字段
ALTER TABLE `system_auth`
ADD COLUMN `utype` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '身份权限' AFTER `title`;
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -16,6 +16,8 @@
namespace app\admin\controller;
use app\admin\model\SystemAuth;
use app\admin\model\SystemBase;
use think\admin\Controller;
use think\admin\service\AdminService;
@ -44,8 +46,18 @@ class Auth extends Controller
public function index()
{
$this->title = '系统权限管理';
$query = $this->_query($this->table)->dateBetween('create_at');
$query->like('title,desc')->equal('status')->layTable();
$this->types = (new SystemBase)->items('身份权限');
$query = $this->_query(SystemAuth::class)->dateBetween('create_at');
$query->like('title,desc')->equal('status,utype')->layTable();
}
/**
* 数据列表处理
* @param array $data
*/
protected function _page_filter(array &$data)
{
(new SystemBase())->items('身份权限', $data, 'utype', 'utype_info');
}
/**
@ -74,6 +86,17 @@ class Auth extends Controller
$this->_form($this->table, 'form');
}
/**
* 表单处理数据
* @param array $data
*/
protected function _form_filter(array &$data)
{
if ($this->request->isGet()) {
$this->bases = (new SystemBase())->items('身份权限');
}
}
/**
* 修改权限状态
* @auth true

View File

@ -0,0 +1,124 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// | 免费声明 ( https://thinkadmin.top/disclaimer )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\model\SystemBase;
use think\admin\Controller;
/**
* 数据字典管理
* Class Base
* @package app\admin\controller
*/
class Base extends Controller
{
/**
* 绑定数据表
* @var string
*/
protected $table = 'SystemBase';
/**
* 数据字典管理
* @auth true
* @menu true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$this->applyTypes();
$this->title = '数据字典管理';
$query = $this->_query(SystemBase::class)->where(['deleted' => 0]);
$query->equal('type')->like('code,name,status')->dateBetween('create_at')->layTable();
}
/**
* 添加数据字典
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function add()
{
$this->_form($this->table, 'form');
}
/**
* 编辑数据字典
* @auth true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit()
{
$this->_form($this->table, 'form');
}
/**
* 表单数据处理
* @param array $data
*/
protected function _form_filter(array &$data)
{
if ($this->request->isGet()) {
$this->applyTypes(true);
} else {
$map = [['type', '=', $data['type']], ['code', '=', $data['code']], ['deleted', '=', 0]];
if (isset($data['id'])) $map[] = ['id', '<>', $data['id']];
if ($this->app->db->name($this->table)->where($map)->count() > 0) {
$this->error("同类型的数据编码已经存在!");
}
}
}
/**
* 修改数据状态
* @auth true
* @throws \think\db\exception\DbException
*/
public function state()
{
$this->_save($this->table);
}
/**
* 删除数据记录
* @auth true
* @throws \think\db\exception\DbException
*/
public function remove()
{
$this->_delete($this->table);
}
/**
* 初始化数据类型
* @param false $add
*/
private function applyTypes(bool $add = false)
{
$query = $this->app->db->name($this->table)->where(['deleted' => 0]);
$this->types = $query->distinct(true)->order('id asc')->column('type');
if (empty($this->types)) $this->types = ['身份权限'];
$this->type = input('get.type') ?: ($this->types[0] ?? '-');
if ($add) $this->types[] = '--- 新增类型 ---';
}
}

View File

@ -47,10 +47,12 @@ class Oplog extends Controller
{
$this->title = '系统日志管理';
$this->isSupper = AdminService::instance()->isSuper();
// 读取数据类型
$this->users = $this->app->db->name($this->table)->distinct(true)->column('username');
$this->actions = $this->app->db->name($this->table)->distinct(true)->column('action');
// 数据列表处理
$query = $this->_query($this->table)->dateBetween('create_at');
$query->like('action,node,content,username,geoip')->layTable();
$query->equal('username,action')->like('content,geoip,node')->layTable();
}
/**

View File

@ -69,8 +69,8 @@ class Queue extends Controller
$this->title = '系统任务管理';
$this->iswin = ProcessService::instance()->iswin();
// 任务列表查询及分页
$query = $this->_query($this->table)->dateBetween('create_at')->timeBetween('enter_time,exec_time');
$query->like('code,title,command')->equal('status')->order('loops_time desc,id desc')->page();
$query = $this->_query($this->table)->timeBetween('enter_time,exec_time')->dateBetween('create_at');
$query->equal('status')->like('code,title,command')->order('loops_time desc,id desc')->page();
}
/**
@ -120,5 +120,4 @@ class Queue extends Controller
{
$this->_delete($this->table);
}
}

View File

@ -16,9 +16,10 @@
namespace app\admin\controller;
use app\admin\model\SystemBase;
use app\admin\model\SystemUser;
use think\admin\Controller;
use think\admin\service\AdminService;
use think\admin\service\SystemService;
/**
* 系统用户管理
@ -60,7 +61,7 @@ class User extends Controller
public function index()
{
$this->title = '系统用户管理';
$query = $this->_query($this->table);
$query = $this->_query(SystemUser::class);
// 加载对应数据列表
if (($this->type = input('type', 'all')) === 'all') {
$query->where(['is_deleted' => 0, 'status' => 1]);
@ -153,8 +154,11 @@ class User extends Controller
$data['authorize'] = arr2str($data['authorize'] ?? []);
} else {
$data['authorize'] = str2arr($data['authorize'] ?? '');
// 用户权限管理
$query = $this->app->db->name('SystemAuth')->where(['status' => 1]);
$this->authorizes = $query->order('sort desc,id desc')->select()->toArray();
// 身份权限关联
(new SystemBase)->items('身份权限', $this->authorizes, 'utype', 'utypeinfo');
}
}

View File

@ -0,0 +1,37 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// | 免费声明 ( https://thinkadmin.top/disclaimer )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 用户权限模型
* Class SystemAuth
* @package app\admin\model
*/
class SystemAuth extends Model
{
/**
* 格式化创建时间
* @param string $value
* @return string
*/
public function getCreateAtAttr(string $value): string
{
return format_datetime($value);
}
}

View File

@ -0,0 +1,53 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// | 免费声明 ( https://thinkadmin.top/disclaimer )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;
/**
* 数据字典数据模型
* Class SystemBase
* @package app\admin\model
*/
class SystemBase extends Model
{
/**
* 获取指定数据列表
* @param string $type 数据类型
* @param array $data 外围数据
* @param string $field 外链字段
* @param string $bind 绑定字段
* @return array
*/
public function items(string $type, array &$data = [], string $field = 'base_code', string $bind = 'base_info'): array
{
$map = ['status' => 1, 'deleted' => 0, 'type' => $type];
$bases = $this->where($map)->order('sort desc,id desc')->column('code,name,content', 'code');
if (count($data) > 0) foreach ($data as &$vo) $vo[$bind] = $bases[$vo[$field]] ?? [];
return $bases;
}
/**
* 格式化创建时间
* @param string $value
* @return string
*/
public function getCreateAtAttr(string $value): string
{
return format_datetime($value);
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace app\admin\model;
use think\db\Query;
use think\Model;
/**
* 系统用户数据模型
* Class SystemUser
* @package app\admin\model
*/
class SystemUser extends Model
{
/**
* 获取用户数据
* @param array $map 数据查询规则
* @param array $data 用户数据集合
* @param string $field 原外连字段
* @param string $target 关联目标字段
* @param string $fields 关联数据字段
* @return array
*/
public function items(array $map, array &$data = [], string $field = 'uuid', string $target = 'user_info', string $fields = 'username,nickname,headimg,status,is_deleted'): array
{
$query = $this->where($map)->order('sort desc,id desc');
if (count($data) > 0) {
$users = $query->whereIn('id', array_unique(array_column($data, $field)))->column($fields, 'id');
foreach ($data as &$vo) $vo[$target] = $users[$vo[$field]] ?? [];
return $users;
} else {
return $query->column($fields, 'id');
}
}
/**
* 通过身份类型获取
* @param string $type 身份类型
* @param string $fields 数据字段
* @return array
*/
public function itemsByType(string $type, string $fields = 'username,nickname,headimg,status,is_deleted'): array
{
$rids = (new SystemAuth)->where(['status' => 1, 'utype' => $type])->column('id');
return empty($rids) ? [] : $this->where(function (Query $query) use ($rids) {
foreach ($rids as $rid) $query->whereOr('authorize', 'like', "%,{$rid},%");
})->where(['status' => 1, 'is_deleted' => 0])->column($fields, 'id');
}
/**
* 获取用户身份数据
* @param mixed $uuid
* @return array
*/
public function rolesByUuid($uuid): array
{
$types = (new SystemBase)->items('身份权限');
if (empty($types)) return [];
$rrids = str2arr($this->where(['id' => $uuid])->value('authorize') ?: '');
if (empty($rrids)) return [];
$utypes = (new SystemAuth)->where(['status' => 1])->whereIn('id', $rrids)->column('utype');
if (empty($utypes)) return [];
foreach ($types as $key => $type) if (!in_array($type, $utypes)) unset($types[$key]);
return array_values($types);
}
/**
* 格式化登录时间
* @param string $value
* @return string
*/
public function getLoginAtAttr(string $value): string
{
return format_datetime($value);
}
/**
* 格式化创建时间
* @param string $value
* @return string
*/
public function getCreateAtAttr(string $value): string
{
return format_datetime($value);
}
}

View File

@ -1,18 +1,33 @@
<form class="layui-form layui-card" action="{:sysuri()}" data-auto="true" method="post" autocomplete="off">
<form class="layui-form layui-card" id="AuthForm" action="{:sysuri()}" data-auto="true" method="post" autocomplete="off">
<div class="layui-card-body padding-left-40">
<label class="layui-form-item relative block">
<span class="color-green font-w7">系统权限名称</span>
<span class="color-desc margin-left-5">Role Name</span>
<input maxlength="100" class="layui-input" name="title" value='{$vo.title|default=""}' required placeholder="请输入系统权限名称">
<span class="color-green font-w7">权限名称</span>
<span class="color-desc margin-left-5">Permission Name</span>
<input maxlength="100" class="layui-input" name="title" value='{$vo.title|default=""}' required placeholder="请输入权限名称">
<!--<span class="help-block">访问权限名称需要保持不重复,在给用户授权时需要根据名称选择!</span>-->
</label>
{notempty name='bases'}
<div class="layui-form-item">
<span class="color-green font-w7 label-required-prev">身份权限</span>
<span class="color-desc margin-left-5">Identity Permissions</span>
<select class="layui-select" name="utype">
{foreach $bases as $k=>$v}
{if isset($vo.utype) && $k eq $vo.utype}
<option selected value="{$k}">{$v.name} ( {$v.code} )</option>
{else}
<option value="{$k}">{$v.name} ( {$v.code} )</option>
{/if}{/foreach}
</select>
</div>
{/notempty}
<label class="layui-form-item relative block">
<span class="color-green font-w7">系统权限描述</span>
<span class="color-desc margin-left-5">Role Remark</span>
<textarea placeholder="请输入系统权限描述" maxlength="200" class="layui-textarea" name="desc">{$vo.desc|default=""}</textarea>
<span class="color-green font-w7">权限描述</span>
<span class="color-desc margin-left-5">Permission Description</span>
<textarea placeholder="请输入权限描述" maxlength="200" class="layui-textarea" name="desc">{$vo.desc|default=""}</textarea>
</label>
</div>
@ -25,3 +40,7 @@
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
</div>
</form>
<script>
layui.form.render();
$('#AuthForm').parent().css('overflow', 'revert');
</script>

View File

@ -6,7 +6,7 @@
<!--{/if}-->
<!--{if auth("remove")}-->
<button data-action='{:url("remove")}' data-rule="id#{key}" data-confirm="确定要批量删除权限吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
<button data-action='{:url("remove")}' data-table-id="RoleData" data-rule="id#{id}" data-confirm="确定要批量删除权限吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
<!--{/if}-->
{/block}
@ -22,15 +22,23 @@
$(function () {
// 初始化表格组件
var $table = $('#RoleData').layTable({
even: true,
even: true, height: 'full',
sort: {field: 'sort desc,id', type: 'desc'},
cols: [[
{checkbox: true, fixed: true},
{field: 'sort', title: '排序权重', width: 100, align: 'center', sort: true, templet: '#SortInputTpl'},
{field: 'title', title: '权限名称', minWidth: 140, align: 'center', sort: false},
{
field: 'utype', title: '身份权限', minWidth: 140, sort: false, templet: function (d) {
if ((d.utype_info || {}).name) {
return d.utype_info.name + '<span class="color-desc"> ( ' + d.utype_info.code + ' ) </span>'
}
return '<span class="color-desc">-</span>';
}
},
{
field: 'desc', title: '权限描述', align: 'center', sort: false, templet: function (d) {
return d.desc || '<span class="color-desc">未填写权限描述</span>'
return d.desc || '<span class="color-desc">-</span>'
}
},
{field: 'create_at', title: '创建时间', align: 'center', sort: true},
@ -39,15 +47,11 @@
]]
});
// 设置表格最大高度
$table.trigger('setFullHeight');
// 数据状态切换操作
layui.form.on('switch(StatusSwitch)', function (obj) {
$.form.load("{:url('state')}", {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0}, 'post', function (ret) {
if (ret.code < 1) $.msg.error(ret.info, 3, function () {
// 操作异常时重载数据
$table.trigger('reload');
$table.trigger('reload'); // 操作异常时重载数据
});
return false;
}, false);

View File

@ -9,6 +9,22 @@
</div>
</div>
{notempty name='types'}
<div class="layui-form-item layui-inline">
<label class="layui-form-label">身份权限</label>
<div class="layui-input-inline">
<select name='utype' lay-search class="layui-select">
<option value=''>-- 身份权限 --</option>
{foreach $types as $type}{if $type.code eq input('get.utype')}
<option selected value="{$type.code}">( {$type.name} ) {$type.code}</option>
{else}
<option value="{$type.code}">( {$type.name} ) {$type.code}</option>
{/if}{/foreach}
</select>
</div>
</div>
{/notempty}
<div class="layui-form-item layui-inline">
<label class="layui-form-label">权限描述</label>
<div class="layui-input-inline">

View File

@ -0,0 +1,74 @@
<form class="layui-form layui-card" action="{:sysuri()}" data-auto="true" method="post" autocomplete="off">
<div class="layui-card-body padding-left-40">
<div class="layui-form-item">
<span class="color-green font-w7 label-required-prev">数据类型</span>
<span class="color-desc margin-left-5">Database Type</span>
{if isset($vo.type)}
<label><input readonly value="{$vo.type|default=''}" class="layui-input think-bg-gray"></label>
{else}
<select class="layui-select" lay-filter="DataType">
{foreach $types as $type}{if (isset($vo.type) and $type eq $vo.type) or ($type eq input('get.type'))}
<option selected value="{$type}">{$type}</option>
{else}
<option value="{$type}">{$type}</option>
{/if}{/foreach}
</select>
<script>
layui.form.render();
(function (callable) {
layui.form.on('select(DataType)', callable);
callable({value: "{$vo.type|default=''}" || $('[lay-filter=DataType]').val()});
})(function (data) {
if (data.value === '--- 新增类型 ---') {
$('#DataTypeInput').removeClass('layui-hide').find('input').val('').focus();
} else {
$('#DataTypeInput').addClass('layui-hide').find('input').val(data.value);
}
});
</script>
{/if}
<p class="help-block">请选择数据类型,数据创建后不能再次修改哦 ~</p>
<div id="DataTypeInput" class="layui-hide relative">
<input class="layui-input" maxlength="20" name="type" required placeholder="请输入数据类型" value="{$vo.type|default=''}">
<p class="help-block">请输入新的数据类型,数据创建后不能再次修改哦 ~</p>
</div>
</div>
<label class="layui-form-item relative block">
<span class="color-green font-w7">数据编码</span>
<span class="color-desc margin-left-5">Database Code</span>
{if isset($vo.code)}
<input readonly maxlength="50" class="layui-input think-bg-gray" name="code" value='{$vo.code|default=""}' required placeholder="请输入数据编码">
{else}
<input maxlength="50" class="layui-input" name="code" value='{$vo.code|default=""}' required placeholder="请输入数据编码">
{/if}
<span class="help-block">请输入新的数据编码,数据创建后不能再次修改,同种数据类型的数据编码不能出现重复 ~</span>
</label>
<label class="layui-form-item relative block">
<span class="color-green font-w7">数据名称</span>
<span class="color-desc margin-left-5">Database Name</span>
<input maxlength="100" class="layui-input" name="name" value='{$vo.name|default=""}' required placeholder="请输入数据名称">
<span class="help-block">请输入当前数据名称,请尽量保持名称的唯一性,数据名称尽量不要出现重复 ~</span>
</label>
<label class="layui-form-item relative block">
<span class="color-green font-w7">数据内容</span>
<span class="color-desc margin-left-5">Database Content</span>
<textarea name="content" class="layui-textarea" placeholder="请输入数据内容">{$vo.content|default=''}</textarea>
<!--<span class="help-block">访问权限名称需要保持不重复,在给用户授权时需要根据名称选择!</span>-->
</label>
</div>
<div class="hr-line-dashed"></div>
{notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
<div class="layui-form-item text-center">
<button class="layui-btn" type='submit'>保存数据</button>
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
</div>
</form>

View File

@ -0,0 +1,86 @@
{extend name='table'}
{block name="button"}
<!--{if auth("add")}-->
<button data-modal='{:url("add")}?type={$type|default=""}' data-title="添加数据" class='layui-btn layui-btn-sm layui-btn-primary'>添加数据</button>
<!--{/if}-->
<!--{if auth("remove")}-->
<button data-action='{:url("remove")}' data-table-id="BaseData" data-rule="id#{id}" data-confirm="确定要批量删除数据吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
<!--{/if}-->
{/block}
{block name="content"}
<div class="layui-tab layui-tab-card">
<ul class="layui-tab-title">
{foreach $types as $t}{if isset($type) and $type eq $t}
<li class="layui-this color-green" data-open="{:sysuri()}?type={$t}">{$t}</li>
{else}
<li data-open="{:sysuri()}?type={$t}">{$t}</li>
{/if}{/foreach}
</ul>
<div class="layui-tab-content">
{include file='base/index_search'}
<table id="BaseData" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
</div>
</div>
{/block}
{block name='script'}
<script>
$(function () {
// 初始化表格组件
var $table = $('#BaseData').layTable({
even: true, height: 'full',
sort: {field: 'sort desc,id', type: 'desc'},
where: {type: '{$type|default=""}'},
cols: [[
{checkbox: true, fixed: true},
{field: 'sort', title: '排序权重', width: 100, align: 'center', sort: true, templet: '#SortInputTpl'},
// {field: 'type', title: '数据类型', minWidth: 140, align: 'center', sort: false},
{field: 'code', title: '数据编码', minWidth: 140, align: 'center', sort: false},
{field: 'name', title: '数据名称', minWidth: 140, align: 'center', sort: false},
{field: 'create_at', title: '创建时间', align: 'center', sort: true},
{field: 'status', title: '数据状态', align: 'center', minWidth: 110, fixed: 'right', templet: '#StatusSwitchTpl'},
{toolbar: '#toolbar', align: 'center', minWidth: 140, title: '数据操作', fixed: 'right'},
]]
});
// 数据状态切换操作
layui.form.on('switch(StatusSwitch)', function (obj) {
$.form.load("{:url('state')}", {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0}, 'post', function (ret) {
if (ret.code < 1) $.msg.error(ret.info, 3, function () {
$table.trigger('reload'); // 操作异常时重载数据
});
return false;
}, false);
});
});
</script>
<!-- 列表排序权重模板 -->
<script type="text/html" id="SortInputTpl">
<input min="0" type="number" data-blur-number="0" data-action-blur="{:sysuri()}" data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}" class="layui-input text-center">
</script>
<!-- 数据状态切换模板 -->
<script type="text/html" id="StatusSwitchTpl">
<!--{if auth("state")}-->
<input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch" {{d.status>0?'checked':''}}>
<!--{else}-->
{{d.status ? '<b class="color-green">已启用</b>' : '<b class="color-red">已禁用</b>'}}
<!--{/if}-->
</script>
<!-- 数据操作工具条模板 -->
<script type="text/html" id="toolbar">
<!--{if auth('edit')}-->
<a class="layui-btn layui-btn-primary layui-btn-sm" data-title="编辑数据" data-modal='{:url("edit")}?id={{d.id}}'> </a>
<!--{/if}-->
<!--{if auth("remove")}-->
<a class="layui-btn layui-btn-danger layui-btn-sm" data-confirm="确定要删除数据吗?" data-action="{:url('remove')}" data-value="id#{{d.id}}"> </a>
<!--{/if}-->
</script>
{/block}

View File

@ -0,0 +1,46 @@
<fieldset>
<legend>条件搜索</legend>
<form class="layui-form layui-form-pane form-search" action="{:sysuri()}" onsubmit="return false" method="get" autocomplete="off">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">数据编码</label>
<div class="layui-input-inline">
<input name="code" value="{:input('get.code')}" placeholder="请输入数据编码" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">数据名称</label>
<div class="layui-input-inline">
<input name="name" value="{:input('get.name')}" placeholder="请输入数据名称" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">使用状态</label>
<div class="layui-input-inline">
<select class="layui-select" name="status">
<option value=''>-- 状态 --</option>
{foreach ['已禁用的权限','已激活的权限'] as $k=>$v}
{if input('get.status') eq $k.""}
<option selected value="{$k}">{$v}</option>
{else}
<option value="{$k}">{$v}</option>
{/if}{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">创建时间</label>
<div class="layui-input-inline">
<input data-date-range name="create_at" value="{:input('get.create_at')}" placeholder="请选择创建时间" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
<script>form.render()</script>
</fieldset>

View File

@ -1,11 +1,11 @@
{extend name='table'}
{block name="button"}
<!--{if auth("clear")}-->
<button data-load='{:url("clear")}' data-confirm="确定要清理所有记录吗?" class='layui-btn layui-btn-sm layui-btn-primary'>清理所有日志</button>
<!--{/if}-->
<!--{if auth("remove")}-->
<button data-action='{:url("remove")}' data-rule="id#{id}" data-table-id="oplog" data-confirm="确定要删除这些记录吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除日志</button>
<button data-action='{:url("remove")}' data-rule="id#{id}" data-table-id="oplog" data-confirm="确定要删除选中的日志吗?" class='layui-btn layui-btn-sm layui-btn-primary'>批量删除</button>
<!--{/if}-->
<!--{if auth("clear")}-->
<button data-load='{:url("clear")}' data-confirm="确定要清空所有日志吗?" class='layui-btn layui-btn-sm layui-btn-primary'>清空日志</button>
<!--{/if}-->
{/block}
@ -20,6 +20,7 @@
<script>
$(function () {
$('#oplog').layTable({
even: true, height: 'full',
sort: {field: 'id', type: 'desc'},
cols: [[
{checkbox: true},
@ -30,16 +31,16 @@
{field: 'content', title: '操作描述', sort: false},
{field: 'geoip', title: '访问地址', sort: true},
{field: 'geoisp', title: '网络服务商', sort: false},
{field: 'create_at', title: '操作时间', sort: true},
{toolbar: '#toolbar', align: 'center'}
{field: 'create_at', title: '操作时间', minWidth: 170, align: 'center', sort: true},
{toolbar: '#toolbar', align: 'center', fixed: 'right'}
]]
}).trigger('setFullHeight');
});
});
</script>
<script type="text/html" id="toolbar">
<!--{if auth('remove')}-->
<a data-action='{:url("remove")}' data-value="id#{{d.id}}" data-confirm="确认要删除这条记录吗?" class="layui-btn layui-btn-danger layui-btn-sm"> </a>
<a data-action='{:url("remove")}' data-value="id#{{d.id}}" data-confirm="确认要删除这条记录吗?" class="layui-btn layui-btn-sm layui-btn-danger"> </a>
<!--{/if}-->
</script>
{/block}

View File

@ -3,21 +3,28 @@
<form class="layui-form layui-form-pane form-search" action="{:sysuri()}" onsubmit="return false" method="get" autocomplete="off">
<div class="layui-form-item layui-inline">
<label class="layui-form-label">操作账号</label>
<label class="layui-input-inline">
<input name="username" value="{:input('get.username')}" placeholder="请输入操作账号" class="layui-input">
</label>
<div class="layui-input-inline">
<select name='username' lay-search class="layui-select">
<option value=''>-- 全部账号 --</option>
{foreach $users as $user}{if $user eq input('get.username')}
<option selected value="{$user}">{$user}</option>
{else}
<option value="{$user}">{$user}</option>
{/if}{/foreach}
</select>
</div>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">操作节点</label>
<label class="layui-input-inline">
<input name="node" value="{:input('get.node')}" placeholder="请输入操作节点" class="layui-input">
<input name="node" value="{:input('get.node')}" placeholder="请输入操作内容" class="layui-input">
</label>
</div>
<div class="layui-form-item layui-inline">
<label class="layui-form-label">操作行为</label>
<div class="layui-input-inline">
<select name="action" lay-search class="layui-select">
<option value=''>-- 全部日志 --</option>
<option value=''>-- 全部行为 --</option>
{foreach $actions as $action}{if $action eq input('get.action')}
<option selected value="{$action}">{$action}</option>
{else}
@ -58,7 +65,7 @@
require(['excel'], function (excel) {
excel.bind(function (data) {
data.forEach(function (item, index) {
data[index] = [item.username, item.node, item.geoip, item.isp, item.action, item.create_at];
data[index] = [item.username, item.node, item.geoip, item.geoisp, item.action, item.create_at];
});
data.unshift(['操作账号', '访问节点', '访问IP地址', '访问地理区域', '访问操作', '操作时间']);
return data;

View File

@ -8,21 +8,21 @@
<div class="layui-col-xs5">
<label class="block relative">
<span class="color-green font-w7">登录账号</span>
<span class="color-desc margin-left-5">User Name</span>
<span class="color-desc margin-left-5">Login Name</span>
{if isset($vo) and isset($vo.username)}
<input disabled value='{$vo.username|default=""}' class="layui-input think-bg-gray">
<input disabled value='{$vo.username|default=""}' required class="layui-input think-bg-gray">
{else}
<input name="username" value='{$vo.username|default=""}' required pattern="^.{4,}$" placeholder="请输入登录账号" class="layui-input">
{/if}
<span class="help-block">登录账号不能重复,账号创建后不能再次修改</span>
<span class="help-block">登录账号不能重复并且创建后不能再次修改哦。</span>
</label>
</div>
<div class="layui-col-xs5">
<label class="block relative">
<span class="color-green font-w7">用户</span>
<span class="color-desc margin-left-5">Nick Name</span>
<input name="nickname" value='{$vo.nickname|default=""}' required placeholder="请输入用户" class="layui-input">
<span class="help-block">户显示的账号别名,请尽量保持不要重复</span>
<span class="color-green font-w7">用户</span>
<span class="color-desc margin-left-5">User Name</span>
<input name="nickname" value='{$vo.nickname|default=""}' required placeholder="请输入用户" class="layui-input">
<span class="help-block">于区分用户数据的用户名称,请尽量不要重复。</span>
</label>
</div>
</div>
@ -57,22 +57,22 @@
<div class="layui-form-item">
<span class="color-green font-w7">访问权限</span>
<span class="color-desc margin-left-5">User Authorize</span>
<div class="layui-textarea">
<div class="layui-textarea" style="min-height:50px">
{if isset($vo.username) and $vo.username eq $superName}
<span class="color-desc">超级用户不需要配置权限</span>
{elseif empty($authorizes)}
<span class="color-desc">未配置权限</span>
{else}
{foreach $authorizes as $authorize}
{else}{foreach $authorizes as $authorize}
<label class="think-checkbox layui-unselect">
{if in_array($authorize.id, $vo.authorize)}
<input type="checkbox" checked name="authorize[]" value="{$authorize.id}" lay-ignore> {$authorize.title}
<input type="checkbox" checked name="authorize[]" value="{$authorize.id}" lay-ignore>
{$authorize.title} <span class="margin-left-5 color-desc">{notempty name='authorize.utypeinfo'}( {$authorize.utypeinfo.name} ){/notempty}</span>
{else}
<input type="checkbox" name="authorize[]" value="{$authorize.id}" lay-ignore> {$authorize.title}
<input type="checkbox" name="authorize[]" value="{$authorize.id}" lay-ignore>
{$authorize.title} <span class="margin-left-5 color-desc">{notempty name='authorize.utypeinfo'}( {$authorize.utypeinfo.name} ){/notempty}</span>
{/if}
</label>
{/foreach}
{/if}
{/foreach}{/if}
</div>
</div>
{/notempty}

View File

@ -29,13 +29,13 @@
</ul>
<div class="layui-tab-content">
{include file='user/index_search'}
<table id="UserData" data-url="{:sysuri('index')}" data-target-search="form.form-search" class="layui-hide"></table>
<table id="UserData" data-url="{:sysuri('index')}" data-target-search="form.form-search"></table>
</div>
</div>
<script>
$(function () {
var $table = $('#UserData').layTable({
even: true,
even: true, height: 'full',
sort: {field: 'sort desc,id', type: 'desc'},
where: {type: '{$type|default="all"}'},
cols: [[
@ -45,34 +45,33 @@
{field: 'nickname', title: '用户名称', align: 'center', sort: false},
{
field: 'contact_phone', title: '联系电话', sort: false, templet: function (d) {
return d.contact_phone || '<span class="color-desc">无联系电话</span>';
return d.contact_phone || '<span class="color-desc">-</span>';
}
},
{
field: 'contact_mail', title: '联系邮箱', sort: false, templet: function (d) {
return d.contact_mail || '<span class="color-desc">无联系邮箱</span>';
return d.contact_mail || '<span class="color-desc">-</span>';
}
},
{
field: 'login_at', title: '最后登录', sort: true, templet: function (d) {
field: 'login_num', title: '登录次数', align: 'center', sort: false
},
{
field: 'login_at', title: '最后登录', sort: true, align: 'center', minWidth: 170, templet: function (d) {
return d.login_at || '<span class="color-desc">还未登录</span>';
}
},
{field: 'create_at', title: '创建时间', align: 'center', minWidth: 160, sort: true},
{field: 'create_at', title: '创建时间', align: 'center', minWidth: 170, sort: true},
{field: 'status', title: '权限状态', align: 'center', minWidth: 110, fixed: 'right', templet: '#StatusSwitchTpl'},
{toolbar: '#toolbar', title: '操作', align: 'center', minWidth: 200, fixed: 'right'}
{toolbar: '#toolbar', title: '操作', align: 'center', minWidth: 150, fixed: 'right'}
]]
});
// 设置表格最大高度
$table.trigger('setFullHeight');
// 数据状态切换操作
layui.form.on('switch(StatusSwitch)', function (obj) {
$.form.load("{:url('state')}", {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0}, 'post', function (ret) {
if (ret.code < 1) $.msg.error(ret.info, 3, function () {
// 操作异常时重载数据
$table.trigger('reload');
$table.trigger('reload'); // 操作异常时重载数据
});
return false;
}, false);
@ -96,12 +95,12 @@
<script type="text/html" id="toolbar">
{if isset($type) and $type eq 'all'}
<!--{if auth("pass")}-->
<a class="layui-btn layui-btn-sm layui-btn-normal" data-title="设置密码" data-modal='{:url("pass")}?id={{d.id}}'> </a>
<!--{/if}-->
<!--{if auth("edit")}-->
<a class="layui-btn layui-btn-sm" data-title="编辑用户" data-modal='{:url("edit")}?id={{d.id}}'> </a>
<!--{/if}-->
<!--{if auth("pass")}-->
<a class="layui-btn layui-btn-sm layui-btn-normal" data-title="设置密码" data-modal='{:url("pass")}?id={{d.id}}'> </a>
<!--{/if}-->
{else}
<!--{if auth("edit")}-->
<a class="layui-btn layui-btn-sm" data-title="编辑用户" data-modal='{:url("edit")}?id={{d.id}}'> </a>

View File

@ -41,6 +41,5 @@
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
</div>
</form>
<script>form.render()</script>
</fieldset>
<script>form.render()</script>

View File

@ -247,7 +247,7 @@ $(function () {
if (url !== '#') {
location.href = '#' + $.menu.parseUri(url, ele);
} else if (ele && ele.dataset.menuNode) {
$('[data-menu-node^="' + ele.dataset.menuNode + '-"][data-open!="#"]:first').trigger('click');
$('[data-menu-node^="' + ele.dataset.menuNode + '-"]:first').trigger('click');
}
};
/*! 异步加载的数据 */
@ -294,7 +294,7 @@ $(function () {
};
/*! 打开一个iframe窗口 */
this.iframe = function (url, name, area) {
return layer.open({title: name || '窗口', type: 2, area: area || ['800px', '580px'], anim: 2, fixed: true, maxmin: false, content: url});
return layer.open({title: name || '窗口', type: 2, area: area || ['800px', '580px'], fixed: true, maxmin: false, content: url});
};
/*! 加载 HTML 到弹出层 */
this.modal = function (url, data, name, call, load, tips, area) {
@ -383,7 +383,7 @@ $(function () {
};
window.onhashchange = function (hash, node) {
hash = location.hash || '';
if (hash.length < 1) return $('[data-menu-node][data-open!="#"]:first').trigger('click');
if (hash.length < 1) return $('[data-menu-node]:first').trigger('click');
$.form.load(hash), that.syncOpenStatus(2);
/*! 菜单选择切换 */
node = that.queryNode(that.getUri());
@ -413,7 +413,7 @@ $(function () {
$.vali = function (form, callable, options) {
return (new function (that) {
/*! 表单元素 */
that = this, this.tags = 'input,textarea,select';
that = this, this.tags = 'input,select,textarea';
/*! 检测元素事件 */
this.checkEvent = {change: true, blur: true, keyup: false};
/*! 去除字符串的空格 */
@ -560,7 +560,7 @@ $(function () {
/*! 全局文件上传入口 */
$.fn.uploadFile = function (callable) {
if (this.data('inited')) return false;
var that = this, mult = 'one|btn'.indexOf(this.data('file') || 'one') < 0 ? 1 : 0;
var that = this, mult = 'one|btn'.indexOf(this.data('file') || 'one') > -1 ? 1 : 0;
this.data('inited', true).data('multiple', mult), require(['upload'], function (apply) {
apply.call(this, that, callable);
});
@ -654,39 +654,44 @@ $(function () {
}
/*! 组件 LayUI table 功能封装 */
$.fn.layTable = function (options) {
$.fn.layTable = function (params) {
return this.each(function (idx, elem) {
// 动态初始化数据表
this.id = this.id || 't' + Math.random().toString().replace('.', '');
this.dataset.dataId = this.getAttribute('lay-filter') || this.id;
this.setAttribute('lay-filter', this.dataset.dataId);
this.setAttribute('lay-filter', this.dataset.id = this.getAttribute('lay-filter') || this.id);
// 插件初始化参数
var opt = options || {}, data = opt.where || {}, sort = opt.initSort || opt.sort || {};
opt.id = elem.id, opt.elem = elem, opt.url = options.url || elem.dataset.url || location.href;
opt.page = options.page !== false ? (options.page || true) : false, opt.autoSort = options.autoSort === true;
opt.limit = options.limit || 20, opt.cols = options.cols || [[]], opt.done = function () {
var opt = params || {}, data = opt.where || {}, sort = opt.initSort || opt.sort || {};
opt.id = elem.id, opt.elem = elem, opt.url = params.url || elem.dataset.url || location.href;
opt.page = params.page !== false ? (params.page || true) : false, opt.autoSort = params.autoSort === true;
opt.loading = params.loading === true, opt.limit = params.limit || 20, opt.cols = params.cols || [[]];
opt.done = function () {
$(elem).next().find(".layui-btn:not([data-table-id])").attr('data-table-id', elem.id);
};
// 动态设置最大高度
if (opt.height === 'full') {
opt.height = $(window).height() - $(elem).removeClass('layui-hide').offset().top - 45;
}
// 实例并绑定对象
$(this).data('this', layui.table.render(bindData(opt)));
// 绑定实例重载事件
$(this).bind('reload', function (event, object) {
data = $.extend({}, data, (object || {}).where || {});
layui.table.reload(elem.id, bindData(object || {}));
$(this).bind('reload', function (evt, opts) {
opts = opts || {}, opts.loading = true;
data = $.extend({}, data, opts.where || {});
layui.table.reload(elem.id, bindData(opts || {}));
}).bind('row sort tool edit radio toolbar checkbox rowDouble', function (evt, call) {
layui.table.on(evt.type + '(' + elem.dataset.dataId + ')', call)
layui.table.on(evt.type + '(' + elem.dataset.id + ')', call)
}).bind('setFullHeight', function () {
$(elem).trigger('reload', {height: $(window).height() - $(elem).next().offset().top - 35})
}).trigger('sort', function (object) {
(sort = object), $(elem).trigger('reload')
});
// 搜索表单关联对象
var search = options.search || this.dataset.targetSearch;
var search = params.search || this.dataset.targetSearch;
if (search) $body.find(search).map(function () {
$(this).attr('data-table-id', elem.id);
});
// 绑定选择项关联对象
var checked = options.checked || this.dataset.targetChecked;
var checked = params.checked || this.dataset.targetChecked;
if (checked) $body.find(checked).map(function () {
$(this).attr('data-table-id', elem.id);
});
@ -823,7 +828,7 @@ $(function () {
/*! 注册 data-icon 事件行为 */
onEvent('click', '[data-icon]', function () {
var location = tapiRoot + '/api.plugs/icon', field = this.dataset.icon || this.dataset.field || 'icon';
$.form.iframe(location + (location.indexOf('?') > -1 ? '&' : '?') + 'field=' + field, '图标选择', ['800px', '600px']);
$.form.iframe(location + (location.indexOf('?') > -1 ? '&' : '?') + 'field=' + field, '图标选择', ['900px', '700px']);
});
/*! 注册 data-copy 事件行为 */

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
@charset "UTF-8";
@charset "UTF-8";
@import "console.config.less";
// +----------------------------------------------------------------------
@ -169,11 +170,6 @@ fieldset {
}
}
.layui-icon {
float: left;
margin-right: 5px;
}
& + .layui-btn {
margin-left: 8px;
}
@ -446,7 +442,6 @@ table.layui-table[lay-size="lg"] {
}
}
.layui-layer-content {
.layui-form.layui-card {
margin: 0;