Compare commits

..

12 Commits
v0.6.8 ... main

Author SHA1 Message Date
7283737f8e 更新 'composer.json' 2023-05-16 16:15:58 +00:00
walkor
4b652aac8d 查询移除lay-verify 2023-05-16 16:02:07 +08:00
walkor
09d4686437 设置lay-verify也允许传空 2023-05-16 15:54:43 +08:00
walkor
425113a0d7 查询时允许字段为空 2023-05-16 12:02:53 +08:00
walkor
ca2af73a2c 修复主键为字符串时返回0的问题 2023-05-16 11:16:46 +08:00
walkor
5d3ce0ff12 主键不自增时主键显示在表单 2023-05-16 10:23:06 +08:00
walkor
3d39d38287 富文本图片上传 2023-05-10 14:54:37 +08:00
walkor
b5c8abcb56 富文本支持 2023-05-10 11:45:49 +08:00
walkor
b0712fac25 mysql support json 2023-05-10 10:25:46 +08:00
walkor
b0d73eaccd fix namespace 2023-05-10 08:50:56 +08:00
walkor
ea86e944cf 支持模糊搜索 2023-05-05 11:01:43 +08:00
walkor
4cba3c47d9
Update Util.php 2023-05-04 16:39:08 +08:00
14 changed files with 277 additions and 68 deletions

View File

@ -2,7 +2,7 @@
"name": "webman/admin",
"type": "project",
"license": "MIT",
"description": "Webman Admin",
"description": "基于Webman官方的Admin修改",
"require": {
"workerman/webman-framework": ">=1.4",
"illuminate/database": ">=7.30",

View File

@ -1,6 +1,7 @@
<?php
namespace plugin\admin\app\common;
use plugin\admin\app\common\Util;
use support\exception\BusinessException;
class Layui
@ -124,6 +125,31 @@ EOF;
</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;
}
@ -138,6 +164,17 @@ EOF;
$this->inputRange($options);
}
/**
* 数字输入框模糊查询
* @param $options
* @return void
*/
public function inputNumberLike($options)
{
$options['props']['type'] = 'number';
$this->inputLike($options);
}
/**
* 密码输入框
* @param $options
@ -170,6 +207,58 @@ EOF;
</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;
}
@ -710,6 +799,7 @@ EOF;
$field = $info['field'];
$default = $columns[$key]['default'];
$control = strtolower($info['control']);
$auto_increment = $columns[$key]['auto_increment'];
// 搜索框里上传组件替换为input
if ($type == 'search' && in_array($control, ['upload', 'uploadimg'])) {
$control = 'input';
@ -718,20 +808,34 @@ EOF;
$props = Util::getControlProps($control, $info['control_args']);
// 增加修改记录验证必填项
if ($filter == 'form_show' && !isset($props['lay-verify']) && !$columns[$key]['nullable'] && $default === null && ($field !== 'password' || $type === 'insert')) {
$props['lay-verify'] = 'required';
if ($filter == 'form_show' && !$columns[$key]['nullable'] && $default === null && ($field !== 'password' || $type === 'insert')) {
if (!isset($props['lay-verify'])) {
$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) {
$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;
}
// 范围查询
if ($type == 'search' && $info['search_type'] == 'between' && method_exists($form, "{$control}Range")) {
$control = "{$control}Range";
// 查询类型
if ($type == 'search') {
if ($info['search_type'] == 'between' && method_exists($form, "{$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 = [

View File

@ -2,12 +2,15 @@
namespace plugin\admin\app\common;
use process\Monitor;
use Throwable;
use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Builder;
use plugin\admin\app\model\Option;
use support\exception\BusinessException;
use support\Db;
use Workerman\Timer;
use Workerman\Worker;
class Util
{
@ -312,6 +315,8 @@ class Util
'char' => ['Input'],
'binary' => ['Input'],
'json' => ['input']
];
}
@ -519,7 +524,7 @@ class Util
/**
* reload webman
* Reload webman
* @return bool
*/
public static function reloadWebman()
@ -537,4 +542,26 @@ class Util
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();
}
}
}

View File

@ -129,7 +129,9 @@ class Crud extends Base
$model = $this->model;
foreach ($where as $column => $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]);
} elseif ($value[0] == 'in') {
$model = $model->whereIn($column, $value[1]);
@ -139,7 +141,7 @@ class Crud extends Base
$model = $model->whereNull($column, $value[1]);
} elseif ($value[0] == 'not null') {
$model = $model->whereNotNull($column, $value[1]);
} else {
} elseif ($value[0] !== '' || $value[1] !== '') {
$model = $model->whereBetween($column, $value);
}
} else {

View File

@ -5,6 +5,7 @@ namespace plugin\admin\app\controller;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use plugin\admin\app\common\Util;
use plugin\admin\app\controller\Base;
use process\Monitor;
use support\exception\BusinessException;
use support\Log;
@ -113,10 +114,7 @@ class PluginController extends Base
}
}
$monitor_support_pause = method_exists(Monitor::class, 'pause');
if ($monitor_support_pause) {
Monitor::pause();
}
Util::pauseFileMonitor();
try {
// 解压zip到plugin目录
if ($has_zip_archive) {
@ -154,9 +152,7 @@ class PluginController extends Base
}
}
} finally {
if ($monitor_support_pause) {
Monitor::resume();
}
Util::resumeFileMonitor();
}
Util::reloadWebman();

View File

@ -12,6 +12,7 @@ use plugin\admin\app\model\Option;
use support\exception\BusinessException;
use support\Request;
use support\Response;
use Throwable;
class TableController extends Base
{
@ -470,45 +471,50 @@ class TableController extends Base
$app = strtolower($explode[1]) !== 'controller' ? $explode[1] : '';
}
$model_class = $model_file_name;
$model_namespace = str_replace('/' , '\\', trim($model_path, '/'));
Util::pauseFileMonitor();
try {
$model_class = $model_file_name;
$model_namespace = str_replace('/', '\\', trim($model_path, '/'));
// 创建model
$this->createModel($model_class, $model_namespace, base_path($model_file), $table_name);
// 创建model
$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_class = $controller_file_name;
$controller_namespace = str_replace('/' , '\\', trim($controller_path, '/'));
// 创建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 = str_replace('_', '-', $inflector->tableize($controller_url_name));
$controller_suffix = $plugin ? config("plugin.$plugin.app.controller_suffix") : config('app.controller_suffix');
$controller_class = $controller_file_name;
$controller_namespace = str_replace('/', '\\', trim($controller_path, '/'));
// 创建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 = str_replace('_', '-', $inflector->tableize($controller_url_name));
if ($plugin) {
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]);
if ($plugin) {
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();
}
$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();
if (!$menu) {
$menu = new Rule;
@ -557,6 +563,7 @@ class TableController extends Base
$pk = 'id';
$properties = '';
$timestamps = '';
$incrementing = '';
$columns = [];
try {
$database = config('database.connections')['plugin.admin.mysql']['database'];
@ -565,12 +572,24 @@ class TableController extends Base
if ($item->COLUMN_KEY === 'PRI') {
$pk = $item->COLUMN_NAME;
$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);
$properties .= " * @property $type \${$item->COLUMN_NAME} {$item->COLUMN_COMMENT}\n";
$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'])) {
$timestamps = <<<EOF
/**
@ -579,6 +598,7 @@ class TableController extends Base
* @var bool
*/
public \$timestamps = false;
EOF;
}
@ -608,9 +628,8 @@ class $class extends Base
* @var string
*/
protected \$primaryKey = '$pk';
$timestamps
$incrementing
}
@ -852,6 +871,16 @@ EOF
where: []
})
});
// 字段允许为空
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){
@ -991,6 +1020,15 @@ EOF;
$js
//提交事件
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.$.ajax({
url: INSERT_API,
@ -1101,6 +1139,15 @@ EOF;
//提交事件
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) {
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
layui.$.ajax({
@ -1179,17 +1226,21 @@ EOF;
}
if (isset($allow_column[$column])) {
if (is_array($value)) {
if (in_array($value[0], ['', 'undefined']) || in_array($value[1], ['', 'undefined'])) {
continue;
if ($value[0] === 'like') {
$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 {
$paginator = $paginator->where($column, $value);
}
}
}
$paginator = $paginator->orderBy($field, $order)->paginate($limit, '*', 'page', $page);
$items = $paginator->items();
if ($format == 'tree') {
$items_map = [];

View File

@ -96,7 +96,7 @@
<script type="text/html" id="col-type">
<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>
{{# }); }}
</select>
@ -132,7 +132,7 @@
<script type="text/html" id="form-control">
<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>
{{# }); }}
</select>
@ -160,7 +160,7 @@
<script type="text/html" id="form-search_type">
<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>
{{# }); }}
</select>

View File

@ -125,7 +125,6 @@
return layui.popup.failure(res.msg);
}
return layui.popup.success("操作成功", function () {
parent.refreshTable();
parent.layer.close(parent.layer.getFrameIndex(window.name));
});
}

View File

@ -40,6 +40,17 @@
<?=$form->js(3)?>
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.$.ajax({

View File

@ -98,7 +98,7 @@
<script type="text/html" id="col-type">
<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>
{{# }); }}
</select>
@ -136,7 +136,7 @@
<script type="text/html" id="form-control">
<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>
{{# }); }}
</select>
@ -164,7 +164,7 @@
<script type="text/html" id="form-search_type">
<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>
{{# }); }}
</select>

View File

@ -76,6 +76,15 @@
});
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.$.ajax({

View File

@ -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) {
table.reload("data-table", {
where: data.field

View File

@ -17,5 +17,5 @@ return [
'controller_suffix' => 'Controller',
'controller_reuse' => false,
'plugin_market_host' => 'https://www.workerman.net',
'version' => '0.6.0'
'version' => '0.6.12'
];

View File

@ -25,9 +25,9 @@ layui.define(['jquery'],function (exports) {
}
, success: function (res, succFun, failFun) {//图片上传完成回调 根据自己需要修改
if (res[this.response.statusName] == this.response.statusCode.ok) {
succFun(res[this.response.dataName]);
succFun(res[this.response.dataName]["url"]);
} else {
failFun(res[this.response.msgName]);
failFun(res[this.response.msgName]["url"]);
}
}
};