Compare commits
No commits in common. "main" and "v0.6.4" have entirely different histories.
@ -2,7 +2,7 @@
|
|||||||
"name": "webman/admin",
|
"name": "webman/admin",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "基于Webman官方的Admin修改",
|
"description": "Webman Admin",
|
||||||
"require": {
|
"require": {
|
||||||
"workerman/webman-framework": ">=1.4",
|
"workerman/webman-framework": ">=1.4",
|
||||||
"illuminate/database": ">=7.30",
|
"illuminate/database": ">=7.30",
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace plugin\admin\api;
|
namespace plugin\admin\api;
|
||||||
|
|
||||||
use ReflectionException;
|
|
||||||
use Webman\Http\Request;
|
use Webman\Http\Request;
|
||||||
use Webman\Http\Response;
|
use Webman\Http\Response;
|
||||||
use Webman\MiddlewareInterface;
|
use Webman\MiddlewareInterface;
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对外提供的鉴权中间件
|
* 对外提供的webman-admin鉴权中间件
|
||||||
*/
|
*/
|
||||||
class Middleware implements MiddlewareInterface
|
class Middleware implements MiddlewareInterface
|
||||||
{
|
{
|
||||||
@ -17,7 +16,7 @@ class Middleware implements MiddlewareInterface
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param callable $handler
|
* @param callable $handler
|
||||||
* @return Response
|
* @return Response
|
||||||
* @throws ReflectionException
|
* @throws \ReflectionException
|
||||||
* @throws BusinessException
|
* @throws BusinessException
|
||||||
*/
|
*/
|
||||||
public function process(Request $request, callable $handler): Response
|
public function process(Request $request, callable $handler): Response
|
||||||
@ -31,20 +30,7 @@ class Middleware implements MiddlewareInterface
|
|||||||
if ($request->expectsJson()) {
|
if ($request->expectsJson()) {
|
||||||
$response = json(['code' => $code, 'msg' => $msg, 'type' => 'error']);
|
$response = json(['code' => $code, 'msg' => $msg, 'type' => 'error']);
|
||||||
} else {
|
} else {
|
||||||
if ($code === 401) {
|
$response = \response($msg, 401);
|
||||||
$response = response(<<<EOF
|
|
||||||
<script>
|
|
||||||
if (self !== top) {
|
|
||||||
parent.location.reload();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
EOF
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$request->app = '';
|
|
||||||
$request->plugin = 'admin';
|
|
||||||
$response = view('common/error/403')->withStatus(403);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$response = $request->method() == 'OPTIONS' ? response('') : $handler($request);
|
$response = $request->method() == 'OPTIONS' ? response('') : $handler($request);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace plugin\admin\app\common;
|
namespace plugin\admin\app\common;
|
||||||
|
|
||||||
use plugin\admin\app\common\Util;
|
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
class Layui
|
class Layui
|
||||||
@ -125,31 +124,6 @@ EOF;
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
EOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 输入框模糊查询
|
|
||||||
* @param $options
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function inputLike($options)
|
|
||||||
{
|
|
||||||
[$label, $field, $value, $props, $verify_string, $required_string, $class] = $this->options($options);
|
|
||||||
$type = $props['type'] ?? 'text';
|
|
||||||
|
|
||||||
$this->htmlContent .= <<<EOF
|
|
||||||
|
|
||||||
<div class="layui-form-item">
|
|
||||||
$label
|
|
||||||
<div class="$class">
|
|
||||||
<div class="layui-input-block">
|
|
||||||
<input type="hidden" autocomplete="off" name="{$field}[]" value="like" class="layui-input inline-block">
|
|
||||||
<input type="$type" autocomplete="off" name="{$field}[]" class="layui-input">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,17 +138,6 @@ EOF;
|
|||||||
$this->inputRange($options);
|
$this->inputRange($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字输入框模糊查询
|
|
||||||
* @param $options
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function inputNumberLike($options)
|
|
||||||
{
|
|
||||||
$options['props']['type'] = 'number';
|
|
||||||
$this->inputLike($options);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码输入框
|
* 密码输入框
|
||||||
* @param $options
|
* @param $options
|
||||||
@ -207,58 +170,6 @@ EOF;
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
EOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 富文本
|
|
||||||
* @param $options
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function richText($options)
|
|
||||||
{
|
|
||||||
[$label, $field, $value, $props, $verify_string, $required_string, $class] = $this->options($options);
|
|
||||||
|
|
||||||
$placeholder_string = !empty($props['placeholder']) ? ' placeholder="'.$props['placeholder'].'"' : '';
|
|
||||||
$disabled_string = !empty($props['disabled']) ? ' disabled' : '';
|
|
||||||
$id = $field;
|
|
||||||
|
|
||||||
$this->htmlContent .= <<<EOF
|
|
||||||
|
|
||||||
<div class="layui-form-item">
|
|
||||||
$label
|
|
||||||
<div class="$class">
|
|
||||||
<textarea id="$id" name="$field"$required_string$verify_string$placeholder_string$disabled_string class="layui-textarea">$value</textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
EOF;
|
|
||||||
|
|
||||||
$options_string = '';
|
|
||||||
if (!isset($props['images_upload_url'])) {
|
|
||||||
$props['images_upload_url'] = '/app/admin/upload/image';
|
|
||||||
}
|
|
||||||
foreach ($props as $key => $item) {
|
|
||||||
if (is_array($item)) {
|
|
||||||
$item = json_encode($item, JSON_UNESCAPED_UNICODE);
|
|
||||||
$options_string .= "\n $key: $item,";
|
|
||||||
} else {
|
|
||||||
$options_string .= "\n $key: \"$item\",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->jsContent .= <<<EOF
|
|
||||||
|
|
||||||
// 字段 {$options['label']} $field
|
|
||||||
layui.use(["tinymce"], function() {
|
|
||||||
var tinymce = layui.tinymce
|
|
||||||
var edit = tinymce.render({
|
|
||||||
elem: "#$id",$options_string
|
|
||||||
});
|
|
||||||
edit.on("blur", function(){
|
|
||||||
layui.$("#$id").val(edit.getContent());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,9 +612,6 @@ EOF;
|
|||||||
$default_value_string = isset($props['initValue']) && $props['initValue'] != '' ? $props['initValue'] : $value;
|
$default_value_string = isset($props['initValue']) && $props['initValue'] != '' ? $props['initValue'] : $value;
|
||||||
$url = $props['url'] ?? '';
|
$url = $props['url'] ?? '';
|
||||||
$options_string = '';
|
$options_string = '';
|
||||||
if (isset($props['lay-verify'])) {
|
|
||||||
$props['layVerify'] = $props['lay-verify'];
|
|
||||||
}
|
|
||||||
unset($props['lay-verify'], $props['url']);
|
unset($props['lay-verify'], $props['url']);
|
||||||
foreach ($props as $key => $item) {
|
foreach ($props as $key => $item) {
|
||||||
if (is_array($item)) {
|
if (is_array($item)) {
|
||||||
@ -765,7 +673,7 @@ EOF;
|
|||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
$select_label
|
$select_label
|
||||||
<div class="$class">
|
<div class="$class">
|
||||||
<div name="$field" id="$id"$required_string value="$default_value_string" ></div>
|
<div name="$field" id="$id"$verify_string$required_string value="$default_value_string" ></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -799,7 +707,6 @@ EOF;
|
|||||||
$field = $info['field'];
|
$field = $info['field'];
|
||||||
$default = $columns[$key]['default'];
|
$default = $columns[$key]['default'];
|
||||||
$control = strtolower($info['control']);
|
$control = strtolower($info['control']);
|
||||||
$auto_increment = $columns[$key]['auto_increment'];
|
|
||||||
// 搜索框里上传组件替换为input
|
// 搜索框里上传组件替换为input
|
||||||
if ($type == 'search' && in_array($control, ['upload', 'uploadimg'])) {
|
if ($type == 'search' && in_array($control, ['upload', 'uploadimg'])) {
|
||||||
$control = 'input';
|
$control = 'input';
|
||||||
@ -808,34 +715,20 @@ EOF;
|
|||||||
|
|
||||||
$props = Util::getControlProps($control, $info['control_args']);
|
$props = Util::getControlProps($control, $info['control_args']);
|
||||||
// 增加修改记录验证必填项
|
// 增加修改记录验证必填项
|
||||||
if ($filter == 'form_show' && !$columns[$key]['nullable'] && $default === null && ($field !== 'password' || $type === 'insert')) {
|
if ($filter == 'form_show' && !isset($props['lay-verify']) && !$columns[$key]['nullable'] && $default === null && ($field !== 'password' || $type === 'insert')) {
|
||||||
if (!isset($props['lay-verify'])) {
|
$props['lay-verify'] = 'required';
|
||||||
$props['lay-verify'] = 'required';
|
|
||||||
// 非类似字符串类型不允许传空
|
|
||||||
} elseif (!in_array($columns[$key]['type'], ['string', 'text', 'mediumText', 'longText', 'char', 'binary', 'json'])
|
|
||||||
&& strpos($props['lay-verify'], 'required') === false) {
|
|
||||||
$props['lay-verify'] = 'required|' . $props['lay-verify'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 增加记录显示默认值
|
// 增加记录显示默认值
|
||||||
if ($type === 'insert' && !isset($props['value']) && $default !== null) {
|
if ($type === 'insert' && !isset($props['value']) && $default !== null) {
|
||||||
$props['value'] = $default;
|
$props['value'] = $default;
|
||||||
}
|
}
|
||||||
// 主键是自增字段或者表单是更新类型不显示主键
|
// 表单不显示主键
|
||||||
if ($primary_key && $field == $primary_key && (($type == 'insert' && $auto_increment) || $type == 'update')) {
|
if ($filter == 'form_show' && $primary_key && $field == $primary_key) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 查询类型
|
// 范围查询
|
||||||
if ($type == 'search') {
|
if ($type == 'search' && $info['search_type'] == 'between' && method_exists($form, "{$control}Range")) {
|
||||||
if ($info['search_type'] == 'between' && method_exists($form, "{$control}Range")) {
|
$control = "{$control}Range";
|
||||||
$control = "{$control}Range";
|
|
||||||
} elseif ($info['search_type'] == 'like' && method_exists($form, "{$control}Like")) {
|
|
||||||
$control = "{$control}Like";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 查询类型移除lay-verify
|
|
||||||
if ($type == 'search' && !empty($props['lay-verify'])) {
|
|
||||||
$props['lay-verify'] = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
|
@ -2,15 +2,12 @@
|
|||||||
|
|
||||||
namespace plugin\admin\app\common;
|
namespace plugin\admin\app\common;
|
||||||
|
|
||||||
use process\Monitor;
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Illuminate\Database\Connection;
|
use Illuminate\Database\Connection;
|
||||||
use Illuminate\Database\Schema\Builder;
|
use Illuminate\Database\Schema\Builder;
|
||||||
use plugin\admin\app\model\Option;
|
use plugin\admin\app\model\Option;
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use support\Db;
|
use support\Db;
|
||||||
use Workerman\Timer;
|
|
||||||
use Workerman\Worker;
|
|
||||||
|
|
||||||
class Util
|
class Util
|
||||||
{
|
{
|
||||||
@ -315,8 +312,6 @@ class Util
|
|||||||
'char' => ['Input'],
|
'char' => ['Input'],
|
||||||
|
|
||||||
'binary' => ['Input'],
|
'binary' => ['Input'],
|
||||||
|
|
||||||
'json' => ['input']
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +519,7 @@ class Util
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload webman
|
* reload webman (不支持windows)
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function reloadWebman()
|
public static function reloadWebman()
|
||||||
@ -534,34 +529,8 @@ class Util
|
|||||||
posix_kill(posix_getppid(), SIGUSR1);
|
posix_kill(posix_getppid(), SIGUSR1);
|
||||||
return true;
|
return true;
|
||||||
} catch (Throwable $e) {}
|
} catch (Throwable $e) {}
|
||||||
} else {
|
|
||||||
Timer::add(1, function () {
|
|
||||||
Worker::stopAll();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Pause file monitor
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function pauseFileMonitor()
|
|
||||||
{
|
|
||||||
if (method_exists(Monitor::class, 'pause')) {
|
|
||||||
Monitor::pause();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resume file monitor
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function resumeFileMonitor()
|
|
||||||
{
|
|
||||||
if (method_exists(Monitor::class, 'resume')) {
|
|
||||||
Monitor::resume();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -129,9 +129,7 @@ class Crud extends Base
|
|||||||
$model = $this->model;
|
$model = $this->model;
|
||||||
foreach ($where as $column => $value) {
|
foreach ($where as $column => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
if ($value[0] === 'like') {
|
if (in_array($value[0], ['>', '=', '<', '<>', 'like', 'not like'])) {
|
||||||
$model = $model->where($column, 'like', "%$value[1]%");
|
|
||||||
} elseif (in_array($value[0], ['>', '=', '<', '<>', 'not like'])) {
|
|
||||||
$model = $model->where($column, $value[0], $value[1]);
|
$model = $model->where($column, $value[0], $value[1]);
|
||||||
} elseif ($value[0] == 'in') {
|
} elseif ($value[0] == 'in') {
|
||||||
$model = $model->whereIn($column, $value[1]);
|
$model = $model->whereIn($column, $value[1]);
|
||||||
@ -141,7 +139,7 @@ class Crud extends Base
|
|||||||
$model = $model->whereNull($column, $value[1]);
|
$model = $model->whereNull($column, $value[1]);
|
||||||
} elseif ($value[0] == 'not null') {
|
} elseif ($value[0] == 'not null') {
|
||||||
$model = $model->whereNotNull($column, $value[1]);
|
$model = $model->whereNotNull($column, $value[1]);
|
||||||
} elseif ($value[0] !== '' || $value[1] !== '') {
|
} else {
|
||||||
$model = $model->whereBetween($column, $value);
|
$model = $model->whereBetween($column, $value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,6 +4,7 @@ namespace plugin\admin\app\controller;
|
|||||||
|
|
||||||
use plugin\admin\app\common\Util;
|
use plugin\admin\app\common\Util;
|
||||||
use plugin\admin\app\model\User;
|
use plugin\admin\app\model\User;
|
||||||
|
use support\Db;
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
@ -60,7 +61,7 @@ class IndexController
|
|||||||
// 总用户数
|
// 总用户数
|
||||||
$user_count = User::count();
|
$user_count = User::count();
|
||||||
// mysql版本
|
// mysql版本
|
||||||
$version = Util::db()->select('select VERSION() as version');
|
$version = Db::select('select VERSION() as version');
|
||||||
$mysql_version = $version[0]->version ?? 'unknown';
|
$mysql_version = $version[0]->version ?? 'unknown';
|
||||||
|
|
||||||
$day7_detail = [];
|
$day7_detail = [];
|
||||||
|
@ -381,7 +381,6 @@ EOF;
|
|||||||
}
|
}
|
||||||
$params = [
|
$params = [
|
||||||
\PDO::MYSQL_ATTR_INIT_COMMAND => "set names utf8mb4",
|
\PDO::MYSQL_ATTR_INIT_COMMAND => "set names utf8mb4",
|
||||||
\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
|
|
||||||
\PDO::ATTR_EMULATE_PREPARES => false,
|
\PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
\PDO::ATTR_TIMEOUT => 5,
|
\PDO::ATTR_TIMEOUT => 5,
|
||||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||||
|
@ -5,7 +5,6 @@ namespace plugin\admin\app\controller;
|
|||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use plugin\admin\app\common\Util;
|
use plugin\admin\app\common\Util;
|
||||||
use plugin\admin\app\controller\Base;
|
|
||||||
use process\Monitor;
|
use process\Monitor;
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
@ -114,7 +113,10 @@ class PluginController extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Util::pauseFileMonitor();
|
$monitor_support_pause = method_exists(Monitor::class, 'pause');
|
||||||
|
if ($monitor_support_pause) {
|
||||||
|
Monitor::pause();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// 解压zip到plugin目录
|
// 解压zip到plugin目录
|
||||||
if ($has_zip_archive) {
|
if ($has_zip_archive) {
|
||||||
@ -152,7 +154,9 @@ class PluginController extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Util::resumeFileMonitor();
|
if ($monitor_support_pause) {
|
||||||
|
Monitor::resume();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Util::reloadWebman();
|
Util::reloadWebman();
|
||||||
@ -347,7 +351,7 @@ class PluginController extends Base
|
|||||||
protected function getUnzipCmd($zip_file, $extract_to)
|
protected function getUnzipCmd($zip_file, $extract_to)
|
||||||
{
|
{
|
||||||
if ($cmd = $this->findCmd('unzip')) {
|
if ($cmd = $this->findCmd('unzip')) {
|
||||||
$cmd = "$cmd -o -qq $zip_file -d $extract_to";
|
$cmd = "$cmd -qq $zip_file -d $extract_to";
|
||||||
} else if ($cmd = $this->findCmd('7z')) {
|
} else if ($cmd = $this->findCmd('7z')) {
|
||||||
$cmd = "$cmd x -bb0 -y $zip_file -o$extract_to";
|
$cmd = "$cmd x -bb0 -y $zip_file -o$extract_to";
|
||||||
} else if ($cmd = $this->findCmd('7zz')) {
|
} else if ($cmd = $this->findCmd('7zz')) {
|
||||||
@ -365,8 +369,8 @@ class PluginController extends Base
|
|||||||
protected function unzipWithCmd($cmd)
|
protected function unzipWithCmd($cmd)
|
||||||
{
|
{
|
||||||
$desc = [
|
$desc = [
|
||||||
0 => ["pipe", "r"],
|
0 => STDIN,
|
||||||
1 => ["pipe", "w"],
|
1 => STDOUT,
|
||||||
2 => ["pipe", "w"],
|
2 => ["pipe", "w"],
|
||||||
];
|
];
|
||||||
$handler = proc_open($cmd, $desc, $pipes);
|
$handler = proc_open($cmd, $desc, $pipes);
|
||||||
|
@ -12,7 +12,6 @@ use plugin\admin\app\model\Option;
|
|||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class TableController extends Base
|
class TableController extends Base
|
||||||
{
|
{
|
||||||
@ -59,20 +58,16 @@ class TableController extends Base
|
|||||||
*/
|
*/
|
||||||
public function show(Request $request): Response
|
public function show(Request $request): Response
|
||||||
{
|
{
|
||||||
$limit = (int)$request->get('limit', 10);
|
|
||||||
$page = (int)$request->get('page', 1);
|
|
||||||
$offset = ($page - 1) * $limit;
|
|
||||||
$database = config('database.connections')['plugin.admin.mysql']['database'];
|
$database = config('database.connections')['plugin.admin.mysql']['database'];
|
||||||
$field = $request->get('field', 'TABLE_NAME');
|
$field = $request->get('field', 'TABLE_NAME');
|
||||||
$field = Util::filterAlphaNum($field);
|
$field = Util::filterAlphaNum($field);
|
||||||
$order = $request->get('order', 'asc');
|
$order = $request->get('order', 'asc');
|
||||||
$allow_column = ['TABLE_NAME', 'TABLE_COMMENT', 'ENGINE', 'TABLE_ROWS', 'CREATE_TIME', 'UPDATE_TIME', 'TABLE_COLLATION'];
|
$allow_column = ['TABLE_NAME','TABLE_COMMENT','ENGINE','TABLE_ROWS','CREATE_TIME','UPDATE_TIME','TABLE_COLLATION'];
|
||||||
if (!in_array($field, $allow_column)) {
|
if (!in_array($field, $allow_column)) {
|
||||||
$field = 'TABLE_NAME';
|
$field = 'TABLE_NAME';
|
||||||
}
|
}
|
||||||
$order = $order === 'asc' ? 'asc' : 'desc';
|
$order = $order === 'asc' ? 'asc' : 'desc';
|
||||||
$total = Util::db()->select("SELECT count(*)total FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='$database'")[0]->total ?? 0;
|
$tables = Util::db()->select("SELECT TABLE_NAME,TABLE_COMMENT,ENGINE,TABLE_ROWS,CREATE_TIME,UPDATE_TIME,TABLE_COLLATION FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='$database' order by $field $order");
|
||||||
$tables = Util::db()->select("SELECT TABLE_NAME,TABLE_COMMENT,ENGINE,TABLE_ROWS,CREATE_TIME,UPDATE_TIME,TABLE_COLLATION FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='$database' order by $field $order limit $offset,$limit");
|
|
||||||
|
|
||||||
if ($tables) {
|
if ($tables) {
|
||||||
$table_names = array_column($tables, 'TABLE_NAME');
|
$table_names = array_column($tables, 'TABLE_NAME');
|
||||||
@ -85,7 +80,7 @@ class TableController extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return json(['code' => 0, 'msg' => 'ok', 'count' => $total, 'data' => $tables]);
|
return $this->json(0, 'ok', $tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +103,6 @@ class TableController extends Base
|
|||||||
|
|
||||||
$primary_key_count = 0;
|
$primary_key_count = 0;
|
||||||
foreach ($columns as $index => $item) {
|
foreach ($columns as $index => $item) {
|
||||||
$columns[$index]['field'] = trim($item['field']);
|
|
||||||
if (!$item['field']) {
|
if (!$item['field']) {
|
||||||
unset($columns[$index]);
|
unset($columns[$index]);
|
||||||
continue;
|
continue;
|
||||||
@ -213,7 +207,6 @@ class TableController extends Base
|
|||||||
|
|
||||||
$primary_key_count = $auto_increment_count = 0;
|
$primary_key_count = $auto_increment_count = 0;
|
||||||
foreach ($columns as $index => $item) {
|
foreach ($columns as $index => $item) {
|
||||||
$columns[$index]['field'] = trim($item['field']);
|
|
||||||
if (!$item['field']) {
|
if (!$item['field']) {
|
||||||
unset($columns[$index]);
|
unset($columns[$index]);
|
||||||
continue;
|
continue;
|
||||||
@ -471,49 +464,44 @@ class TableController extends Base
|
|||||||
$app = strtolower($explode[1]) !== 'controller' ? $explode[1] : '';
|
$app = strtolower($explode[1]) !== 'controller' ? $explode[1] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
Util::pauseFileMonitor();
|
$model_class = $model_file_name;
|
||||||
try {
|
$model_namespace = str_replace('/' , '\\', trim($model_path, '/'));
|
||||||
$model_class = $model_file_name;
|
|
||||||
$model_namespace = str_replace('/', '\\', trim($model_path, '/'));
|
|
||||||
|
|
||||||
// 创建model
|
// 创建model
|
||||||
$this->createModel($model_class, $model_namespace, base_path($model_file), $table_name);
|
$this->createModel($model_class, $model_namespace, base_path($model_file), $table_name);
|
||||||
|
|
||||||
$controller_suffix = $plugin ? config("plugin.$plugin.app.controller_suffix") : config('app.controller_suffix');
|
$controller_suffix = $plugin ? config("plugin.$plugin.app.controller_suffix") : config('app.controller_suffix');
|
||||||
$controller_class = $controller_file_name;
|
$controller_class = $controller_file_name;
|
||||||
$controller_namespace = str_replace('/', '\\', trim($controller_path, '/'));
|
$controller_namespace = str_replace('/' , '\\', trim($controller_path, '/'));
|
||||||
// 创建controller
|
// 创建controller
|
||||||
$controller_url_name = $controller_suffix && substr($controller_class, -strlen($controller_suffix)) === $controller_suffix ? substr($controller_class, 0, -strlen($controller_suffix)) : $controller_class;
|
$controller_url_name = $controller_suffix && substr($controller_class, -strlen($controller_suffix)) === $controller_suffix ? substr($controller_class, 0, -strlen($controller_suffix)) : $controller_class;
|
||||||
$controller_url_name = str_replace('_', '-', $inflector->tableize($controller_url_name));
|
$controller_url_name = str_replace('_', '-', $inflector->tableize($controller_url_name));
|
||||||
|
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
array_splice($explode, 0, 2);
|
array_splice($explode, 0, 2);
|
||||||
}
|
|
||||||
array_shift($explode);
|
|
||||||
if ($app) {
|
|
||||||
array_shift($explode);
|
|
||||||
}
|
|
||||||
foreach ($explode as $index => $item) {
|
|
||||||
if (strtolower($item) === 'controller') {
|
|
||||||
unset($explode[$index]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$controller_base = implode('/', $explode);
|
|
||||||
$controller_class_with_namespace = "$controller_namespace\\$controller_class";
|
|
||||||
$template_path = $controller_base ? "$controller_base/$controller_url_name" : $controller_url_name;
|
|
||||||
$this->createController($controller_class, $controller_namespace, base_path($controller_file), $model_class, $model_namespace, $title, $template_path);
|
|
||||||
|
|
||||||
// 创建模版
|
|
||||||
$template_file_path = ($plugin ? "/plugin/$plugin" : '') . '/app/' . ($app ? "$app/" : '') . 'view/' . $template_path;
|
|
||||||
|
|
||||||
$model_class_with_namespace = "$model_namespace\\$model_class";
|
|
||||||
$primary_key = (new $model_class_with_namespace)->getKeyName();
|
|
||||||
$url_path_base = ($plugin ? "/app/$plugin/" : '/') . ($app ? "$app/" : '') . $template_path;
|
|
||||||
$this->createTemplate(base_path($template_file_path), $table_name, $url_path_base, $primary_key, "$controller_namespace\\$controller_class");
|
|
||||||
} finally {
|
|
||||||
Util::resumeFileMonitor();
|
|
||||||
}
|
}
|
||||||
|
array_shift($explode);
|
||||||
|
if ($app) {
|
||||||
|
array_shift($explode);
|
||||||
|
}
|
||||||
|
foreach ($explode as $index => $item) {
|
||||||
|
if (strtolower($item) === 'controller') {
|
||||||
|
unset($explode[$index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$controller_base = implode('/', $explode);
|
||||||
|
$controller_class_with_namespace = "$controller_namespace\\$controller_class";
|
||||||
|
$template_path = $controller_base ? "$controller_base/$controller_url_name" : $controller_url_name;
|
||||||
|
$this->createController($controller_class, $controller_namespace, base_path($controller_file), $model_class, $model_namespace, $title, $template_path);
|
||||||
|
|
||||||
|
// 创建模版
|
||||||
|
$template_file_path = ($plugin ? "/plugin/$plugin" : '') . '/app/' . ($app ? "$app/" : '') . 'view/' . $template_path;
|
||||||
|
|
||||||
|
$model_class_with_namespace = "$model_namespace\\$model_class";
|
||||||
|
$primary_key = (new $model_class_with_namespace)->getKeyName();
|
||||||
|
$url_path_base = ($plugin ? "/app/$plugin/" : '/') . ($app ? "$app/" : '') . $template_path;
|
||||||
|
$this->createTemplate(base_path($template_file_path), $table_name, $url_path_base, $primary_key, "$controller_namespace\\$controller_class");
|
||||||
|
|
||||||
$menu = Rule::where('key', $controller_class_with_namespace)->first();
|
$menu = Rule::where('key', $controller_class_with_namespace)->first();
|
||||||
if (!$menu) {
|
if (!$menu) {
|
||||||
@ -563,7 +551,6 @@ class TableController extends Base
|
|||||||
$pk = 'id';
|
$pk = 'id';
|
||||||
$properties = '';
|
$properties = '';
|
||||||
$timestamps = '';
|
$timestamps = '';
|
||||||
$incrementing = '';
|
|
||||||
$columns = [];
|
$columns = [];
|
||||||
try {
|
try {
|
||||||
$database = config('database.connections')['plugin.admin.mysql']['database'];
|
$database = config('database.connections')['plugin.admin.mysql']['database'];
|
||||||
@ -572,24 +559,12 @@ class TableController extends Base
|
|||||||
if ($item->COLUMN_KEY === 'PRI') {
|
if ($item->COLUMN_KEY === 'PRI') {
|
||||||
$pk = $item->COLUMN_NAME;
|
$pk = $item->COLUMN_NAME;
|
||||||
$item->COLUMN_COMMENT .= "(主键)";
|
$item->COLUMN_COMMENT .= "(主键)";
|
||||||
if (strpos(strtolower($item->DATA_TYPE), 'int') === false) {
|
|
||||||
$incrementing = <<<EOF
|
|
||||||
/**
|
|
||||||
* Indicates if the model's ID is auto-incrementing.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
public \$incrementing = false;
|
|
||||||
|
|
||||||
EOF;
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$type = $this->getType($item->DATA_TYPE);
|
$type = $this->getType($item->DATA_TYPE);
|
||||||
$properties .= " * @property $type \${$item->COLUMN_NAME} {$item->COLUMN_COMMENT}\n";
|
$properties .= " * @property $type \${$item->COLUMN_NAME} {$item->COLUMN_COMMENT}\n";
|
||||||
$columns[$item->COLUMN_NAME] = $item->COLUMN_NAME;
|
$columns[$item->COLUMN_NAME] = $item->COLUMN_NAME;
|
||||||
}
|
}
|
||||||
} catch (Throwable $e) {echo $e;}
|
} catch (\Throwable $e) {echo $e;}
|
||||||
if (!isset($columns['created_at']) || !isset($columns['updated_at'])) {
|
if (!isset($columns['created_at']) || !isset($columns['updated_at'])) {
|
||||||
$timestamps = <<<EOF
|
$timestamps = <<<EOF
|
||||||
/**
|
/**
|
||||||
@ -598,7 +573,6 @@ EOF;
|
|||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public \$timestamps = false;
|
public \$timestamps = false;
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -628,8 +602,9 @@ class $class extends Base
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected \$primaryKey = '$pk';
|
protected \$primaryKey = '$pk';
|
||||||
|
|
||||||
$timestamps
|
$timestamps
|
||||||
$incrementing
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,9 +832,6 @@ EOF
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
form.on("submit(table-query)", function(data) {
|
form.on("submit(table-query)", function(data) {
|
||||||
table.reload("data-table", {
|
table.reload("data-table", {
|
||||||
page: {
|
|
||||||
curr: 1
|
|
||||||
},
|
|
||||||
where: data.field
|
where: data.field
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
@ -872,16 +844,6 @@ EOF
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
// 字段允许为空
|
|
||||||
form.verify({
|
|
||||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
|
||||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
|
||||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
|
||||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
|
||||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
|
||||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
|
||||||
});
|
|
||||||
|
|
||||||
// 表格排序事件
|
// 表格排序事件
|
||||||
table.on("sort(data-table)", function(obj){
|
table.on("sort(data-table)", function(obj){
|
||||||
table.reload("data-table", {
|
table.reload("data-table", {
|
||||||
@ -1020,15 +982,6 @@ EOF;
|
|||||||
$js
|
$js
|
||||||
//提交事件
|
//提交事件
|
||||||
layui.use(["form", "popup"], function () {
|
layui.use(["form", "popup"], function () {
|
||||||
// 字段验证允许为空
|
|
||||||
layui.form.verify({
|
|
||||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
|
||||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
|
||||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
|
||||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
|
||||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
|
||||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
|
||||||
});
|
|
||||||
layui.form.on("submit(save)", function (data) {
|
layui.form.on("submit(save)", function (data) {
|
||||||
layui.$.ajax({
|
layui.$.ajax({
|
||||||
url: INSERT_API,
|
url: INSERT_API,
|
||||||
@ -1139,15 +1092,6 @@ EOF;
|
|||||||
|
|
||||||
//提交事件
|
//提交事件
|
||||||
layui.use(["form", "popup"], function () {
|
layui.use(["form", "popup"], function () {
|
||||||
// 字段验证允许为空
|
|
||||||
layui.form.verify({
|
|
||||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
|
||||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
|
||||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
|
||||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
|
||||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
|
||||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
|
||||||
});
|
|
||||||
layui.form.on("submit(save)", function (data) {
|
layui.form.on("submit(save)", function (data) {
|
||||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||||
layui.$.ajax({
|
layui.$.ajax({
|
||||||
@ -1226,21 +1170,17 @@ EOF;
|
|||||||
}
|
}
|
||||||
if (isset($allow_column[$column])) {
|
if (isset($allow_column[$column])) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
if ($value[0] === 'like') {
|
if (in_array($value[0], ['', 'undefined']) || in_array($value[1], ['', 'undefined'])) {
|
||||||
$paginator = $paginator->where($column, 'like', "%$value[1]%");
|
continue;
|
||||||
} elseif (in_array($value[0], ['>', '=', '<', '<>', 'not like'])) {
|
|
||||||
$paginator = $paginator->where($column, $value[0], $value[1]);
|
|
||||||
} else {
|
|
||||||
if($value[0] !== '' || $value[1] !== '') {
|
|
||||||
$paginator = $paginator->whereBetween($column, $value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$paginator = $paginator->whereBetween($column, $value);
|
||||||
} else {
|
} else {
|
||||||
$paginator = $paginator->where($column, $value);
|
$paginator = $paginator->where($column, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$paginator = $paginator->orderBy($field, $order)->paginate($limit, '*', 'page', $page);
|
$paginator = $paginator->orderBy($field, $order)->paginate($limit, '*', 'page', $page);
|
||||||
|
|
||||||
$items = $paginator->items();
|
$items = $paginator->items();
|
||||||
if ($format == 'tree') {
|
if ($format == 'tree') {
|
||||||
$items_map = [];
|
$items_map = [];
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
* Here is your custom functions.
|
* Here is your custom functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use plugin\admin\app\model\User;
|
use app\model\User;
|
||||||
use plugin\admin\app\model\Admin;
|
use plugin\admin\app\model\Admin;
|
||||||
use plugin\admin\app\model\AdminRole;
|
use plugin\admin\app\model\AdminRole;
|
||||||
|
use plugin\admin\app\model\Role;
|
||||||
|
use plugin\admin\app\model\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前管理员id
|
* 当前管理员id
|
||||||
|
@ -300,9 +300,6 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
form.on("submit(table-query)", function(data) {
|
form.on("submit(table-query)", function(data) {
|
||||||
table.reload("data-table", {
|
table.reload("data-table", {
|
||||||
page: {
|
|
||||||
curr: 1
|
|
||||||
},
|
|
||||||
where: data.field
|
where: data.field
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
|
@ -156,9 +156,6 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
form.on("submit(table-query)", function(data) {
|
form.on("submit(table-query)", function(data) {
|
||||||
table.reload("data-table", {
|
table.reload("data-table", {
|
||||||
page: {
|
|
||||||
curr: 1
|
|
||||||
},
|
|
||||||
where: data.field
|
where: data.field
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
|
@ -196,9 +196,6 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
form.on("submit(table-query)", function(data) {
|
form.on("submit(table-query)", function(data) {
|
||||||
table.reload("data-table", {
|
table.reload("data-table", {
|
||||||
page: {
|
|
||||||
curr: 1
|
|
||||||
},
|
|
||||||
where: data.field
|
where: data.field
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
|
|
||||||
<script type="text/html" id="col-type">
|
<script type="text/html" id="col-type">
|
||||||
<select name="columns[{{ d.LAY_INDEX-1 }}][type]" lay-verify="">
|
<select name="columns[{{ d.LAY_INDEX-1 }}][type]" lay-verify="">
|
||||||
{{# layui.each(["integer","string","text","date","enum","float","tinyInteger","smallInteger","mediumInteger","bigInteger","unsignedInteger","unsignedTinyInteger","unsignedSmallInteger","unsignedMediumInteger","unsignedBigInteger","decimal","double","mediumText","longText","dateTime","time","timestamp","char","binary","json"], function (index, item) { }}
|
{{# layui.each(["integer","string","text","date","enum","float","tinyInteger","smallInteger","mediumInteger","bigInteger","unsignedInteger","unsignedTinyInteger","unsignedSmallInteger","unsignedMediumInteger","unsignedBigInteger","decimal","double","mediumText","longText","dateTime","time","timestamp","char","binary"], function (index, item) { }}
|
||||||
<option value="{{ item }}" {{ d.type==item?"selected":""}}>{{ item }}</option>
|
<option value="{{ item }}" {{ d.type==item?"selected":""}}>{{ item }}</option>
|
||||||
{{# }); }}
|
{{# }); }}
|
||||||
</select>
|
</select>
|
||||||
@ -132,7 +132,7 @@
|
|||||||
|
|
||||||
<script type="text/html" id="form-control">
|
<script type="text/html" id="form-control">
|
||||||
<select name="forms[{{ d.LAY_INDEX-1 }}][control]" lay-verify="">
|
<select name="forms[{{ d.LAY_INDEX-1 }}][control]" lay-verify="">
|
||||||
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["richText", "富文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
||||||
<option value="{{ item[0] }}" {{ d.control.toLocaleLowerCase()==item[0].toLocaleLowerCase()?'selected':''}}>{{ item[1] }}</option>
|
<option value="{{ item[0] }}" {{ d.control.toLocaleLowerCase()==item[0].toLocaleLowerCase()?'selected':''}}>{{ item[1] }}</option>
|
||||||
{{# }); }}
|
{{# }); }}
|
||||||
</select>
|
</select>
|
||||||
@ -160,7 +160,7 @@
|
|||||||
|
|
||||||
<script type="text/html" id="form-search_type">
|
<script type="text/html" id="form-search_type">
|
||||||
<select name="forms[{{ d.LAY_INDEX-1 }}][search_type]" lay-verify="">
|
<select name="forms[{{ d.LAY_INDEX-1 }}][search_type]" lay-verify="">
|
||||||
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"], ["like", "模糊查询"]], function (index, item) { }}
|
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"]], function (index, item) { }}
|
||||||
<option value="{{ item[0] }}" {{ d.search_type==item[0]?'selected':''}}>{{ item[1] }}</option>
|
<option value="{{ item[0] }}" {{ d.search_type==item[0]?'selected':''}}>{{ item[1] }}</option>
|
||||||
{{# }); }}
|
{{# }); }}
|
||||||
</select>
|
</select>
|
||||||
|
@ -125,6 +125,7 @@
|
|||||||
return layui.popup.failure(res.msg);
|
return layui.popup.failure(res.msg);
|
||||||
}
|
}
|
||||||
return layui.popup.success("操作成功", function () {
|
return layui.popup.success("操作成功", function () {
|
||||||
|
parent.refreshTable();
|
||||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -40,17 +40,6 @@
|
|||||||
<?=$form->js(3)?>
|
<?=$form->js(3)?>
|
||||||
|
|
||||||
layui.use(["form", "popup"], function () {
|
layui.use(["form", "popup"], function () {
|
||||||
|
|
||||||
// 字段验证允许为空
|
|
||||||
layui.form.verify({
|
|
||||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
|
||||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
|
||||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
|
||||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
|
||||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
|
||||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
|
||||||
});
|
|
||||||
|
|
||||||
//提交事件
|
//提交事件
|
||||||
layui.form.on("submit(save)", function (data) {
|
layui.form.on("submit(save)", function (data) {
|
||||||
layui.$.ajax({
|
layui.$.ajax({
|
||||||
|
@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
<script type="text/html" id="col-type">
|
<script type="text/html" id="col-type">
|
||||||
<select name="columns[{{ d.LAY_INDEX-1 }}][type]" lay-verify="">
|
<select name="columns[{{ d.LAY_INDEX-1 }}][type]" lay-verify="">
|
||||||
{{# layui.each(["integer","string","text","date","enum","float","tinyInteger","smallInteger","mediumInteger","bigInteger","unsignedInteger","unsignedTinyInteger","unsignedSmallInteger","unsignedMediumInteger","unsignedBigInteger","decimal","double","mediumText","longText","dateTime","time","timestamp","char","binary","json"], function (index, item) { }}
|
{{# layui.each(["integer","string","text","date","enum","float","tinyInteger","smallInteger","mediumInteger","bigInteger","unsignedInteger","unsignedTinyInteger","unsignedSmallInteger","unsignedMediumInteger","unsignedBigInteger","decimal","double","mediumText","longText","dateTime","time","timestamp","char","binary"], function (index, item) { }}
|
||||||
<option value="{{ item }}" {{ d.type==item?'selected':''}}>{{ item }}</option>
|
<option value="{{ item }}" {{ d.type==item?'selected':''}}>{{ item }}</option>
|
||||||
{{# }); }}
|
{{# }); }}
|
||||||
</select>
|
</select>
|
||||||
@ -136,7 +136,7 @@
|
|||||||
|
|
||||||
<script type="text/html" id="form-control">
|
<script type="text/html" id="form-control">
|
||||||
<select name="forms[{{ d.LAY_INDEX-1 }}][control]" lay-verify="">
|
<select name="forms[{{ d.LAY_INDEX-1 }}][control]" lay-verify="">
|
||||||
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["richText", "富文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
||||||
<option value="{{ item[0] }}" {{ d.control.toLocaleLowerCase()==item[0].toLocaleLowerCase()?'selected':''}}>{{ item[1] }}</option>
|
<option value="{{ item[0] }}" {{ d.control.toLocaleLowerCase()==item[0].toLocaleLowerCase()?'selected':''}}>{{ item[1] }}</option>
|
||||||
{{# }); }}
|
{{# }); }}
|
||||||
</select>
|
</select>
|
||||||
@ -164,7 +164,7 @@
|
|||||||
|
|
||||||
<script type="text/html" id="form-search_type">
|
<script type="text/html" id="form-search_type">
|
||||||
<select name="forms[{{ d.LAY_INDEX-1 }}][search_type]" lay-verify="">
|
<select name="forms[{{ d.LAY_INDEX-1 }}][search_type]" lay-verify="">
|
||||||
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"], ["like", "模糊查询"]], function (index, item) { }}
|
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"]], function (index, item) { }}
|
||||||
<option value="{{ item[0] }}" {{ d.search_type==item[0]?'selected':''}}>{{ item[1] }}</option>
|
<option value="{{ item[0] }}" {{ d.search_type==item[0]?'selected':''}}>{{ item[1] }}</option>
|
||||||
{{# }); }}
|
{{# }); }}
|
||||||
</select>
|
</select>
|
||||||
|
@ -76,15 +76,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
layui.use(["form", "popup"], function () {
|
layui.use(["form", "popup"], function () {
|
||||||
// 字段验证允许为空
|
|
||||||
layui.form.verify({
|
|
||||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
|
||||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
|
||||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
|
||||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
|
||||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
|
||||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
|
||||||
});
|
|
||||||
//提交事件
|
//提交事件
|
||||||
layui.form.on("submit(save)", function (data) {
|
layui.form.on("submit(save)", function (data) {
|
||||||
layui.$.ajax({
|
layui.$.ajax({
|
||||||
|
@ -237,16 +237,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 字段验证允许为空
|
|
||||||
form.verify({
|
|
||||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
|
||||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
|
||||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
|
||||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
|
||||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
|
||||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
|
||||||
});
|
|
||||||
|
|
||||||
form.on("submit(table-query)", function(data) {
|
form.on("submit(table-query)", function(data) {
|
||||||
table.reload("data-table", {
|
table.reload("data-table", {
|
||||||
where: data.field
|
where: data.field
|
||||||
|
@ -315,9 +315,6 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
form.on("submit(table-query)", function(data) {
|
form.on("submit(table-query)", function(data) {
|
||||||
table.reload("data-table", {
|
table.reload("data-table", {
|
||||||
page: {
|
|
||||||
curr: 1
|
|
||||||
},
|
|
||||||
where: data.field
|
where: data.field
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
|
@ -305,9 +305,6 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
form.on("submit(table-query)", function(data) {
|
form.on("submit(table-query)", function(data) {
|
||||||
table.reload("data-table", {
|
table.reload("data-table", {
|
||||||
page: {
|
|
||||||
curr: 1
|
|
||||||
},
|
|
||||||
where: data.field
|
where: data.field
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
|
@ -442,9 +442,6 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
form.on("submit(table-query)", function(data) {
|
form.on("submit(table-query)", function(data) {
|
||||||
table.reload("data-table", {
|
table.reload("data-table", {
|
||||||
page: {
|
|
||||||
curr: 1
|
|
||||||
},
|
|
||||||
where: data.field
|
where: data.field
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
|
@ -17,5 +17,5 @@ return [
|
|||||||
'controller_suffix' => 'Controller',
|
'controller_suffix' => 'Controller',
|
||||||
'controller_reuse' => false,
|
'controller_reuse' => false,
|
||||||
'plugin_market_host' => 'https://www.workerman.net',
|
'plugin_market_host' => 'https://www.workerman.net',
|
||||||
'version' => '0.6.12'
|
'version' => '0.6.0'
|
||||||
];
|
];
|
||||||
|
@ -21,5 +21,5 @@ return [
|
|||||||
// Fallback language
|
// Fallback language
|
||||||
'fallback_locale' => ['zh_CN', 'en'],
|
'fallback_locale' => ['zh_CN', 'en'],
|
||||||
// Folder where language files are stored
|
// Folder where language files are stored
|
||||||
'path' => base_path() . '/plugin/admin/resource/translations'
|
'path' => base_path() . '/resource/translations',
|
||||||
];
|
];
|
@ -68,17 +68,17 @@ CREATE TABLE IF NOT EXISTS `wa_rules` (
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `wa_uploads` (
|
CREATE TABLE IF NOT EXISTS `wa_uploads` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
`name` varchar(128) NOT NULL COMMENT '名称',
|
`name` varchar(255) NOT NULL COMMENT '名称',
|
||||||
`url` varchar(255) NOT NULL COMMENT '文件',
|
`url` varchar(255) NOT NULL COMMENT '文件',
|
||||||
`admin_id` int(11) DEFAULT NULL COMMENT '管理员',
|
`admin_id` int(11) DEFAULT NULL COMMENT '管理员',
|
||||||
`file_size` int(11) NOT NULL COMMENT '文件大小',
|
`file_size` int(11) NOT NULL COMMENT '文件大小',
|
||||||
`mime_type` varchar(255) NOT NULL COMMENT 'mime类型',
|
`mime_type` varchar(255) NOT NULL COMMENT 'mime类型',
|
||||||
`image_width` int(11) DEFAULT NULL COMMENT '图片宽度',
|
`image_width` int(11) DEFAULT NULL COMMENT '图片宽度',
|
||||||
`image_height` int(11) DEFAULT NULL COMMENT '图片高度',
|
`image_height` int(11) DEFAULT NULL COMMENT '图片高度',
|
||||||
`ext` varchar(128) NOT NULL COMMENT '扩展名',
|
`ext` varchar(255) NOT NULL COMMENT '扩展名',
|
||||||
`storage` varchar(255) NOT NULL DEFAULT 'local' COMMENT '存储位置',
|
`storage` varchar(255) NOT NULL DEFAULT 'local' COMMENT '存储位置',
|
||||||
`created_at` date DEFAULT NULL COMMENT '上传时间',
|
`created_at` date DEFAULT NULL COMMENT '上传时间',
|
||||||
`category` varchar(128) DEFAULT NULL COMMENT '类别',
|
`category` varchar(255) DEFAULT NULL COMMENT '类别',
|
||||||
`updated_at` date DEFAULT NULL COMMENT '更新时间',
|
`updated_at` date DEFAULT NULL COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `category` (`category`),
|
KEY `category` (`category`),
|
||||||
|
@ -25,9 +25,9 @@ layui.define(['jquery'],function (exports) {
|
|||||||
}
|
}
|
||||||
, success: function (res, succFun, failFun) {//图片上传完成回调 根据自己需要修改
|
, success: function (res, succFun, failFun) {//图片上传完成回调 根据自己需要修改
|
||||||
if (res[this.response.statusName] == this.response.statusCode.ok) {
|
if (res[this.response.statusName] == this.response.statusCode.ok) {
|
||||||
succFun(res[this.response.dataName]["url"]);
|
succFun(res[this.response.dataName]);
|
||||||
} else {
|
} else {
|
||||||
failFun(res[this.response.msgName]["url"]);
|
failFun(res[this.response.msgName]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user