管理员表新增mobile字段

pull/406/head
Karson 2022-05-27 16:21:36 +08:00
parent b3c4692164
commit 85e0f4bacc
7 changed files with 21 additions and 3 deletions

View File

@ -33,7 +33,7 @@ CREATE TABLE `fa_admin` (
-- Records of fa_admin -- Records of fa_admin
-- ---------------------------- -- ----------------------------
BEGIN; BEGIN;
INSERT INTO `fa_admin` VALUES (1, 'admin', 'Admin', '', '', '/assets/img/avatar.png', 'admin@admin.com', 0, 1491635035, '127.0.0.1',1491635035, 1491635035, '', 'normal'); INSERT INTO `fa_admin` VALUES (1, 'admin', 'Admin', '', '', '/assets/img/avatar.png', 'admin@admin.com', '', 0, 1491635035, '127.0.0.1',1491635035, 1491635035, '', 'normal');
COMMIT; COMMIT;
-- ---------------------------- -- ----------------------------

View File

@ -192,6 +192,7 @@ class Admin extends Backend
$adminValidate->rule([ $adminValidate->rule([
'username' => 'require|regex:\w{3,30}|unique:admin,username,' . $row->id, 'username' => 'require|regex:\w{3,30}|unique:admin,username,' . $row->id,
'email' => 'require|email|unique:admin,email,' . $row->id, 'email' => 'require|email|unique:admin,email,' . $row->id,
'mobile' => 'regex:1[3-9]\d{9}|unique:admin,mobile,' . $row->id,
'password' => 'regex:\S{32}', 'password' => 'regex:\S{32}',
]); ]);
$result = $row->validate('Admin.edit')->save($params); $result = $row->validate('Admin.edit')->save($params);

View File

@ -1,6 +1,8 @@
<?php <?php
return [ return [
'Email' => '电子邮箱',
'Mobile' => '手机号',
'Group' => '所属组别', 'Group' => '所属组别',
'Loginfailure' => '登录失败次数', 'Loginfailure' => '登录失败次数',
'Login time' => '最后登录', 'Login time' => '最后登录',

View File

@ -15,6 +15,7 @@ class Admin extends Validate
'nickname' => 'require', 'nickname' => 'require',
'password' => 'require|regex:\S{32}', 'password' => 'require|regex:\S{32}',
'email' => 'require|email|unique:admin,email', 'email' => 'require|email|unique:admin,email',
'mobile' => 'regex:1[3-9]\d{9}|unique:admin,mobile',
]; ];
/** /**
@ -33,8 +34,8 @@ class Admin extends Validate
* 验证场景 * 验证场景
*/ */
protected $scene = [ protected $scene = [
'add' => ['username', 'email', 'nickname', 'password'], 'add' => ['username', 'email', 'nickname', 'password', 'mobile'],
'edit' => ['username', 'email', 'nickname', 'password'], 'edit' => ['username', 'email', 'nickname', 'password', 'mobile'],
]; ];
public function __construct(array $rules = [], $message = [], $field = []) public function __construct(array $rules = [], $message = [], $field = [])
@ -44,6 +45,7 @@ class Admin extends Validate
'nickname' => __('Nickname'), 'nickname' => __('Nickname'),
'password' => __('Password'), 'password' => __('Password'),
'email' => __('Email'), 'email' => __('Email'),
'mobile' => __('Mobile'),
]; ];
$this->message = array_merge($this->message, [ $this->message = array_merge($this->message, [
'username.regex' => __('Please input correct username'), 'username.regex' => __('Please input correct username'),

View File

@ -18,6 +18,12 @@
<input type="email" class="form-control" id="email" name="row[email]" value="" data-rule="required;email" /> <input type="email" class="form-control" id="email" name="row[email]" value="" data-rule="required;email" />
</div> </div>
</div> </div>
<div class="form-group">
<label for="mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
<div class="col-xs-12 col-sm-8">
<input type="text" class="form-control" id="mobile" name="row[mobile]" value="" data-rule="mobile" />
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label> <label for="nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">

View File

@ -18,6 +18,12 @@
<input type="email" class="form-control" id="email" name="row[email]" value="{$row.email|htmlentities}" data-rule="required;email" /> <input type="email" class="form-control" id="email" name="row[email]" value="{$row.email|htmlentities}" data-rule="required;email" />
</div> </div>
</div> </div>
<div class="form-group">
<label for="mobile" class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
<div class="col-xs-12 col-sm-8">
<input type="text" class="form-control" id="mobile" name="row[mobile]" value="{$row.mobile|default=''|htmlentities}" data-rule="mobile" />
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label> <label for="nickname" class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">

View File

@ -35,6 +35,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'nickname', title: __('Nickname')}, {field: 'nickname', title: __('Nickname')},
{field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label}, {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
{field: 'email', title: __('Email')}, {field: 'email', title: __('Email')},
{field: 'mobile', title: __('Mobile')},
{field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status}, {field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
{field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {