Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
7283737f8e | |||
|
4b652aac8d | ||
|
09d4686437 | ||
|
425113a0d7 | ||
|
ca2af73a2c | ||
|
5d3ce0ff12 | ||
|
3d39d38287 | ||
|
b5c8abcb56 | ||
|
b0712fac25 | ||
|
b0d73eaccd | ||
|
ea86e944cf | ||
|
4cba3c47d9 | ||
|
af0167a44b | ||
|
92b1551284 | ||
|
e5af2418b0 | ||
|
2418b0caa3 |
@ -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,6 +1,7 @@
|
|||||||
<?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
|
||||||
@ -124,6 +125,31 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +164,17 @@ 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
|
||||||
@ -170,6 +207,58 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,6 +799,7 @@ 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';
|
||||||
@ -718,20 +808,34 @@ EOF;
|
|||||||
|
|
||||||
$props = Util::getControlProps($control, $info['control_args']);
|
$props = Util::getControlProps($control, $info['control_args']);
|
||||||
// 增加修改记录验证必填项
|
// 增加修改记录验证必填项
|
||||||
if ($filter == 'form_show' && !isset($props['lay-verify']) && !$columns[$key]['nullable'] && $default === null && ($field !== 'password' || $type === 'insert')) {
|
if ($filter == 'form_show' && !$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 ($filter == 'form_show' && $primary_key && $field == $primary_key) {
|
if ($primary_key && $field == $primary_key && (($type == 'insert' && $auto_increment) || $type == 'update')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 范围查询
|
// 查询类型
|
||||||
if ($type == 'search' && $info['search_type'] == 'between' && method_exists($form, "{$control}Range")) {
|
if ($type == 'search') {
|
||||||
|
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,12 +2,15 @@
|
|||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
@ -312,6 +315,8 @@ class Util
|
|||||||
'char' => ['Input'],
|
'char' => ['Input'],
|
||||||
|
|
||||||
'binary' => ['Input'],
|
'binary' => ['Input'],
|
||||||
|
|
||||||
|
'json' => ['input']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +524,7 @@ class Util
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reload webman (不支持windows)
|
* Reload webman
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function reloadWebman()
|
public static function reloadWebman()
|
||||||
@ -529,8 +534,34 @@ 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,7 +129,9 @@ 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 (in_array($value[0], ['>', '=', '<', '<>', 'like', 'not like'])) {
|
if ($value[0] === '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]);
|
||||||
@ -139,7 +141,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]);
|
||||||
} else {
|
} elseif ($value[0] !== '' || $value[1] !== '') {
|
||||||
$model = $model->whereBetween($column, $value);
|
$model = $model->whereBetween($column, $value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -381,6 +381,7 @@ 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,6 +5,7 @@ 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;
|
||||||
@ -113,10 +114,7 @@ class PluginController extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$monitor_support_pause = method_exists(Monitor::class, 'pause');
|
Util::pauseFileMonitor();
|
||||||
if ($monitor_support_pause) {
|
|
||||||
Monitor::pause();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// 解压zip到plugin目录
|
// 解压zip到plugin目录
|
||||||
if ($has_zip_archive) {
|
if ($has_zip_archive) {
|
||||||
@ -154,9 +152,7 @@ class PluginController extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if ($monitor_support_pause) {
|
Util::resumeFileMonitor();
|
||||||
Monitor::resume();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Util::reloadWebman();
|
Util::reloadWebman();
|
||||||
|
@ -12,6 +12,7 @@ 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
|
||||||
{
|
{
|
||||||
@ -470,15 +471,17 @@ class TableController extends Base
|
|||||||
$app = strtolower($explode[1]) !== 'controller' ? $explode[1] : '';
|
$app = strtolower($explode[1]) !== 'controller' ? $explode[1] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Util::pauseFileMonitor();
|
||||||
|
try {
|
||||||
$model_class = $model_file_name;
|
$model_class = $model_file_name;
|
||||||
$model_namespace = str_replace('/' , '\\', trim($model_path, '/'));
|
$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));
|
||||||
@ -508,6 +511,9 @@ class TableController extends Base
|
|||||||
$primary_key = (new $model_class_with_namespace)->getKeyName();
|
$primary_key = (new $model_class_with_namespace)->getKeyName();
|
||||||
$url_path_base = ($plugin ? "/app/$plugin/" : '/') . ($app ? "$app/" : '') . $template_path;
|
$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");
|
$this->createTemplate(base_path($template_file_path), $table_name, $url_path_base, $primary_key, "$controller_namespace\\$controller_class");
|
||||||
|
} finally {
|
||||||
|
Util::resumeFileMonitor();
|
||||||
|
}
|
||||||
|
|
||||||
$menu = Rule::where('key', $controller_class_with_namespace)->first();
|
$menu = Rule::where('key', $controller_class_with_namespace)->first();
|
||||||
if (!$menu) {
|
if (!$menu) {
|
||||||
@ -557,6 +563,7 @@ 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'];
|
||||||
@ -565,12 +572,24 @@ 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
|
||||||
/**
|
/**
|
||||||
@ -579,6 +598,7 @@ class TableController extends Base
|
|||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public \$timestamps = false;
|
public \$timestamps = false;
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -608,9 +628,8 @@ class $class extends Base
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected \$primaryKey = '$pk';
|
protected \$primaryKey = '$pk';
|
||||||
|
|
||||||
$timestamps
|
$timestamps
|
||||||
|
$incrementing
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,6 +857,9 @@ 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;
|
||||||
@ -850,6 +872,16 @@ 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", {
|
||||||
@ -988,6 +1020,15 @@ 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,
|
||||||
@ -1098,6 +1139,15 @@ 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({
|
||||||
@ -1176,17 +1226,21 @@ EOF;
|
|||||||
}
|
}
|
||||||
if (isset($allow_column[$column])) {
|
if (isset($allow_column[$column])) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
if (in_array($value[0], ['', 'undefined']) || in_array($value[1], ['', 'undefined'])) {
|
if ($value[0] === 'like') {
|
||||||
continue;
|
$paginator = $paginator->where($column, 'like', "%$value[1]%");
|
||||||
}
|
} 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 = [];
|
||||||
|
@ -300,6 +300,9 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
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,6 +156,9 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
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,6 +196,9 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
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"], 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","json"], 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", "多行文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["richText", "富文本"],["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", "范围查询"]], function (index, item) { }}
|
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"], ["like", "模糊查询"]], 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,7 +125,6 @@
|
|||||||
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,6 +40,17 @@
|
|||||||
<?=$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"], 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","json"], 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", "多行文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["richText", "富文本"],["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", "范围查询"]], function (index, item) { }}
|
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"], ["like", "模糊查询"]], 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,6 +76,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
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,6 +237,16 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 字段验证允许为空
|
||||||
|
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,6 +315,9 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
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,6 +305,9 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
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,6 +442,9 @@
|
|||||||
// 表格顶部搜索事件
|
// 表格顶部搜索事件
|
||||||
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.0'
|
'version' => '0.6.12'
|
||||||
];
|
];
|
||||||
|
@ -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]);
|
succFun(res[this.response.dataName]["url"]);
|
||||||
} else {
|
} else {
|
||||||
failFun(res[this.response.msgName]);
|
failFun(res[this.response.msgName]["url"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user