Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
7283737f8e | |||
|
4b652aac8d | ||
|
09d4686437 | ||
|
425113a0d7 | ||
|
ca2af73a2c | ||
|
5d3ce0ff12 | ||
|
3d39d38287 |
@ -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",
|
||||
|
@ -235,6 +235,9 @@ EOF;
|
||||
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);
|
||||
@ -796,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';
|
||||
@ -804,18 +808,24 @@ 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') {
|
||||
if ($info['search_type'] == 'between' && method_exists($form, "{$control}Range")) {
|
||||
$control = "{$control}Range";
|
||||
@ -823,6 +833,10 @@ EOF;
|
||||
$control = "{$control}Like";
|
||||
}
|
||||
}
|
||||
// 查询类型移除lay-verify
|
||||
if ($type == 'search' && !empty($props['lay-verify'])) {
|
||||
$props['lay-verify'] = '';
|
||||
}
|
||||
|
||||
$options = [
|
||||
'label' => $info['comment'] ?: $field,
|
||||
|
@ -563,6 +563,7 @@ class TableController extends Base
|
||||
$pk = 'id';
|
||||
$properties = '';
|
||||
$timestamps = '';
|
||||
$incrementing = '';
|
||||
$columns = [];
|
||||
try {
|
||||
$database = config('database.connections')['plugin.admin.mysql']['database'];
|
||||
@ -571,6 +572,18 @@ 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";
|
||||
@ -585,6 +598,7 @@ class TableController extends Base
|
||||
* @var bool
|
||||
*/
|
||||
public \$timestamps = false;
|
||||
|
||||
EOF;
|
||||
|
||||
}
|
||||
@ -614,9 +628,8 @@ class $class extends Base
|
||||
* @var string
|
||||
*/
|
||||
protected \$primaryKey = '$pk';
|
||||
|
||||
$timestamps
|
||||
|
||||
$incrementing
|
||||
|
||||
}
|
||||
|
||||
@ -858,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){
|
||||
@ -997,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,
|
||||
@ -1107,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({
|
||||
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
@ -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({
|
||||
|
@ -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({
|
||||
|
@ -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
|
||||
|
@ -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'
|
||||
];
|
||||
|
@ -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"]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user