作者 杨育虎

2

<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
*
*
* @icon fa fa-circle-o
*/
class SoLevelDay extends Backend
{
/**
* SoLevelDay模型对象
* @var \app\admin\model\SoLevelDay
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\SoLevelDay;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
*
*
* @icon fa fa-circle-o
*/
class SoLevelMonth extends Backend
{
/**
* SoLevelMonth模型对象
* @var \app\admin\model\SoLevelMonth
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\SoLevelMonth;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}
... ...
... ... @@ -22,7 +22,7 @@ class User extends Backend
{
parent::_initialize();
$this->model = new \app\admin\model\User;
$this->view->assign("userLevelList", $this->model->getUserLevelList());
}
/**
... ...
... ... @@ -5,5 +5,7 @@ return [
'Avatar' => '轮播图',
'Createtime' => '创建时间',
'Updatetime' => '更改时间',
'Color' => '颜色'
'Color' => '颜色',
'Web' => '链接',
'Con' => '文字描述'
];
... ...
<?php
return [
'Id' => 'ID',
'Keywords' => '关键字',
'Num' => '搜索次数',
'Createtime' => '创建时间'
];
... ...
<?php
return [
'Id' => 'ID',
'Keywords' => '关键字',
'Num' => '搜索次数',
'Createtime' => '创建时间'
];
... ...
<?php
return [
'Id' => 'ID',
'Mobile' => '手机号',
'Password' => '密码',
'Token' => 'token',
'Login_time' => '最近登陆时间',
'Createtime' => '创建时间',
'Updatetime' => '资料更新时间',
'Username' => '用户名',
'Email' => '邮箱'
'Id' => 'ID',
'Mobile' => '手机号',
'Password' => '密码',
'Token' => 'token',
'Login_time' => '最近登陆时间',
'Createtime' => '创建时间',
'Updatetime' => '资料更新时间',
'Username' => '用户名',
'Email' => '邮箱',
'Zongedu' => '总额度',
'Shengyuedu' => '剩余额度',
'User_level' => '用户身份',
'User_level 1' => '普通用户',
'User_level 2' => '公司普通用户',
'User_level 3' => '公司管理用户'
];
... ...
<?php
namespace app\admin\model;
use think\Model;
class SoLevelDay extends Model
{
// 表名
protected $name = 'so_level_day';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
<?php
namespace app\admin\model;
use think\Model;
class SoLevelMonth extends Model
{
// 表名
protected $name = 'so_level_month';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
}
... ...
... ... @@ -25,12 +25,16 @@ class User extends Model
// 追加属性
protected $append = [
'login_time_text'
'login_time_text',
'user_level_text'
];
public function getUserLevelList()
{
return ['1' => __('User_level 1'), '2' => __('User_level 2'), '3' => __('User_level 3')];
}
public function getLoginTimeTextAttr($value, $data)
... ... @@ -39,6 +43,14 @@ class User extends Model
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getUserLevelTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['user_level']) ? $data['user_level'] : '');
$list = $this->getUserLevelList();
return isset($list[$value]) ? $list[$value] : '';
}
protected function setLoginTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class SoLevelDay extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class SoLevelMonth extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
... ... @@ -20,6 +20,18 @@
<input id="c-color" data-rule="required" class="form-control" name="row[color]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Web')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-web" data-rule="required" class="form-control" name="row[web]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Con')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-con" data-rule="required" class="form-control" name="row[con]" type="text">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -20,6 +20,18 @@
<input id="c-color" data-rule="required" class="form-control" name="row[color]" type="text" value="{$row.color|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Web')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-web" data-rule="required" class="form-control" name="row[web]" type="text" value="{$row.web|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Con')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-con" data-rule="required" class="form-control" name="row[con]" type="text" value="{$row.con|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Keywords')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-keywords" data-rule="required" class="form-control" name="row[keywords]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-num" data-rule="required" class="form-control" name="row[num]" type="number">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Keywords')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-keywords" data-rule="required" class="form-control" name="row[keywords]" type="text" value="{$row.keywords|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-num" data-rule="required" class="form-control" name="row[num]" type="number" value="{$row.num|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('so_level_day/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('so_level_day/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('so_level_day/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('so_level_day/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<div class="dropdown btn-group {:$auth->check('so_level_day/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('so_level_day/edit')}"
data-operate-del="{:$auth->check('so_level_day/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Keywords')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-keywords" data-rule="required" class="form-control" name="row[keywords]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-num" data-rule="required" class="form-control" name="row[num]" type="number">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Keywords')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-keywords" data-rule="required" class="form-control" name="row[keywords]" type="text" value="{$row.keywords|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-num" data-rule="required" class="form-control" name="row[num]" type="number" value="{$row.num|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('so_level_month/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('so_level_month/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('so_level_month/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('so_level_month/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
<div class="dropdown btn-group {:$auth->check('so_level_month/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('so_level_month/edit')}"
data-operate-del="{:$auth->check('so_level_month/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -36,6 +36,30 @@
<input id="c-email" class="form-control" name="row[email]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Zongedu')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-zongedu" class="form-control" name="row[zongedu]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shengyuedu')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shengyuedu" class="form-control" name="row[shengyuedu]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_level')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-user_level" data-rule="required" class="form-control selectpicker" name="row[user_level]">
{foreach name="userLevelList" item="vo"}
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -36,6 +36,30 @@
<input id="c-email" class="form-control" name="row[email]" type="text" value="{$row.email|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Zongedu')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-zongedu" class="form-control" name="row[zongedu]" type="text" value="{$row.zongedu|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Shengyuedu')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shengyuedu" class="form-control" name="row[shengyuedu]" type="text" value="{$row.shengyuedu|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_level')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-user_level" data-rule="required" class="form-control selectpicker" name="row[user_level]">
{foreach name="userLevelList" item="vo"}
<option value="{$key}" {in name="key" value="$row.user_level"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -29,6 +29,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'color', title: __('Color')},
{field: 'web', title: __('Web')},
{field: 'con', title: __('Con')},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'so_level_day/index' + location.search,
add_url: 'so_level_day/add',
edit_url: 'so_level_day/edit',
del_url: 'so_level_day/del',
multi_url: 'so_level_day/multi',
table: 'so_level_day',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'keywords', title: __('Keywords')},
{field: 'num', title: __('Num')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'so_level_month/index' + location.search,
add_url: 'so_level_month/add',
edit_url: 'so_level_month/edit',
del_url: 'so_level_month/del',
multi_url: 'so_level_month/multi',
table: 'so_level_month',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'keywords', title: __('Keywords')},
{field: 'num', title: __('Num')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...
... ... @@ -33,6 +33,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'username', title: __('Username')},
{field: 'email', title: __('Email')},
{field: 'zongedu', title: __('Zongedu')},
{field: 'shengyuedu', title: __('Shengyuedu')},
{field: 'user_level', title: __('User_level'), searchList: {"1":__('User_level 1'),"2":__('User_level 2'),"3":__('User_level 3')}, formatter: Table.api.formatter.normal},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...