Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
7283737f8e | |||
|
4b652aac8d | ||
|
09d4686437 | ||
|
425113a0d7 | ||
|
ca2af73a2c | ||
|
5d3ce0ff12 | ||
|
3d39d38287 |
@ -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",
|
||||||
|
@ -235,6 +235,9 @@ EOF;
|
|||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
$options_string = '';
|
$options_string = '';
|
||||||
|
if (!isset($props['images_upload_url'])) {
|
||||||
|
$props['images_upload_url'] = '/app/admin/upload/image';
|
||||||
|
}
|
||||||
foreach ($props as $key => $item) {
|
foreach ($props as $key => $item) {
|
||||||
if (is_array($item)) {
|
if (is_array($item)) {
|
||||||
$item = json_encode($item, JSON_UNESCAPED_UNICODE);
|
$item = json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||||
@ -796,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';
|
||||||
@ -804,18 +808,24 @@ 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')) {
|
||||||
$props['lay-verify'] = 'required';
|
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) {
|
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') {
|
if ($type == 'search') {
|
||||||
if ($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";
|
||||||
@ -823,6 +833,10 @@ EOF;
|
|||||||
$control = "{$control}Like";
|
$control = "{$control}Like";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 查询类型移除lay-verify
|
||||||
|
if ($type == 'search' && !empty($props['lay-verify'])) {
|
||||||
|
$props['lay-verify'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
'label' => $info['comment'] ?: $field,
|
'label' => $info['comment'] ?: $field,
|
||||||
|
@ -563,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'];
|
||||||
@ -571,6 +572,18 @@ 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";
|
||||||
@ -585,6 +598,7 @@ class TableController extends Base
|
|||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public \$timestamps = false;
|
public \$timestamps = false;
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -614,9 +628,8 @@ class $class extends Base
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected \$primaryKey = '$pk';
|
protected \$primaryKey = '$pk';
|
||||||
|
|
||||||
$timestamps
|
$timestamps
|
||||||
|
$incrementing
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -858,6 +871,16 @@ EOF
|
|||||||
where: []
|
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){
|
table.on("sort(data-table)", function(obj){
|
||||||
@ -997,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,
|
||||||
@ -1107,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({
|
||||||
|
@ -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({
|
||||||
|
@ -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
|
||||||
|
@ -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