作者 郭静帆
1 个管道 的构建 通过 耗费 3 秒

公众号

... ... @@ -5,6 +5,7 @@ namespace app\admin\controller\user;
use app\common\controller\Backend;
use app\common\library\Auth;
use fast\Tree;
use think\Db;
/**
* 会员管理
... ... @@ -121,6 +122,8 @@ class User extends Backend
$this->error(__('No Results were found'));
}
$this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
$this->view->assign('start_time',date('Y-m-d',strtotime('-1month')));
$this->view->assign('end_time',date('Y-m-d',strtotime('0day')));
return parent::edit($ids);
}
... ... @@ -141,5 +144,4 @@ class User extends Backend
Auth::instance()->delete($row['id']);
$this->success();
}
}
... ...
<?php
namespace app\admin\controller\user;
use app\common\controller\Backend;
/**
* 招聘补贴管理
*
* @icon fa fa-circle-o
*/
class UserRecruitSubsidyLog extends Backend
{
/**
* UserRecruitSubsidyLog模型对象
* @var \app\admin\model\user\UserRecruitSubsidyLog
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\user\UserRecruitSubsidyLog;
}
public function import()
{
parent::import();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['user','children'])
->where($where)
->where('user_id',$this->request->request('user_id'))
->field('user_recruit_subsidy_log.*,sum(user_recruit_subsidy_log.recruit_subsidy) as recruit_subsidy')
->order($sort, $order)
->group('user_recruit_subsidy_log.children_id')
->paginate($limit);
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname','avatar']);
$row->getRelation('children')->visible(['nickname','avatar']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
/**
* 下一级
*/
public function indexof()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
// var_dump($this->request->request('children_id'));
$list = $this->model
->with(['user','children'])
->where($where)
->where('user_id',$this->request->request('xia_id'))
->field('user_recruit_subsidy_log.*,sum(user_recruit_subsidy_log.recruit_subsidy) as recruit_subsidy')
->order($sort, $order)
->group('user_recruit_subsidy_log.children_id')
->paginate($limit);
foreach ($list as $row) {
$row->getRelation('user')->visible(['nickname','avatar']);
$row->getRelation('children')->visible(['nickname','avatar']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
}
... ...
<?php
return [
'Id' => 'ID',
'User_id' => '用户ID',
'Recruit_subsidy' => '给上级收益',
'Children_id' => '下级ID',
'Work_date' => '工作日期',
'User_work_log_id' => '打卡ID',
'Createtime' => '创建时间',
'Leave' => '等级',
'Leave 0' => '1级',
'Leave 1' => '2级',
'User.nickname' => '昵称',
'User.avatar' => '头像',
'Children.nickname' => '昵称',
'Children.avatar' => '头像'
];
... ...
<?php
namespace app\admin\model\user;
use think\Model;
class UserRecruitSubsidyLog extends Model
{
// 表名
protected $name = 'user_recruit_subsidy_log';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
];
public function user()
{
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function children()
{
return $this->belongsTo('app\admin\model\User', 'children_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
<?php
namespace app\admin\validate\user;
use think\Validate;
class UserRecruitSubsidyLog extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<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('comment/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('comment/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('comment/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('comment/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('comment/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>
<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('comment/recyclebin')?'':'hide'}" href="comment/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('comment/edit')}"
data-operate-del="{:$auth->check('comment/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -20,6 +20,14 @@
<input id="c-mobile" data-rule="" class="form-control" name="row[mobile]" type="text" value="{$row.mobile|htmlentities}" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Join_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-join_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-date-min-date="{$start_time}" data-date-max-date="{$end_time}" data-use-current="true" name="row[join_time]" type="text" value="{:$row.join_time?datetime($row.join_time):''}">
</div>
</div>
<div class="form-group">
<label for="c-avatar" class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</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">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Recruit_subsidy')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-recruit_subsidy" data-rule="required" class="form-control" step="0.01" name="row[recruit_subsidy]" type="number" value="0.00">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Children_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-children_id" data-rule="required" data-source="children/index" class="form-control selectpage" name="row[children_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Work_date')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-work_date" class="form-control" name="row[work_date]" type="number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_work_log_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_work_log_id" data-rule="required" data-source="user/work/log/index" class="form-control selectpage" name="row[user_work_log_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Leave')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-leave" data-rule="required" class="form-control" name="row[leave]" type="number" value="0">
</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">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Recruit_subsidy')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-recruit_subsidy" data-rule="required" class="form-control" step="0.01" name="row[recruit_subsidy]" type="number" value="{$row.recruit_subsidy|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Children_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-children_id" data-rule="required" data-source="children/index" class="form-control selectpage" name="row[children_id]" type="text" value="{$row.children_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Work_date')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-work_date" class="form-control" name="row[work_date]" type="number" value="{$row.work_date|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_work_log_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_work_log_id" data-rule="required" data-source="user/work/log/index" class="form-control selectpage" name="row[user_work_log_id]" type="text" value="{$row.user_work_log_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Leave')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-leave" data-rule="required" class="form-control" name="row[leave]" type="number" value="{$row.leave|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('user/user_recruit_subsidy_log/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('user/user_recruit_subsidy_log/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('user/user_recruit_subsidy_log/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('user/user_recruit_subsidy_log/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('user/user_recruit_subsidy_log/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"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
<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('user/user_recruit_subsidy_log/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('user/user_recruit_subsidy_log/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('user/user_recruit_subsidy_log/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('user/user_recruit_subsidy_log/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('user/user_recruit_subsidy_log/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"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -82,10 +82,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'user/work_log?user_id={id}',
},
{
name: 'detail',
text: __('查看下级'),
icon: 'fa fa-list',
classname: 'btn btn-info btn-xs btn-detail btn-dialog',
url: 'user/user_recruit_subsidy_log?user_id={id}'
}
],
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: 'user/user_recruit_subsidy_log/index' + location.search,
// add_url: 'user/user_recruit_subsidy_log/add',
// edit_url: 'user/user_recruit_subsidy_log/edit',
// del_url: 'user/user_recruit_subsidy_log/del',
// multi_url: 'user/user_recruit_subsidy_log/multi',
// import_url: 'user/user_recruit_subsidy_log/import',
table: 'user_recruit_subsidy_log',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
// {field: 'user_id', title: __('User_id')},
{field: 'children.nickname', title: __('Children.nickname'), operate: 'LIKE'},
{field: 'children.avatar', title: __('Children.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'recruit_subsidy', title: __('Recruit_subsidy'), operate:'BETWEEN'},
{field: 'children_id', title: __('Children_id'),visible:false},
// {field: 'work_date', title: __('Work_date')},
// {field: 'user_work_log_id', title: __('User_work_log_id')},
{field: 'leave', title: __('Leave'), searchList: {"0":__('Leave 0'),"1":__('Leave 1')}, formatter: Table.api.formatter.normal},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
// {field: 'leave', title: __('Leave')},
{field: 'operate', title: __('Operate'), table: table,
events: Table.api.events.operate,
buttons: [{
name: 'indexof',
text: __('查看下级'),
icon: 'fa fa-list',
classname: 'btn btn-info btn-xs btn-detail btn-dialog',
url: 'user/user_recruit_subsidy_log/indexof?xia_id={children_id}'
}],
formatter: Table.api.formatter.operate
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
indexof: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user/user_recruit_subsidy_log/indexof' + location.search,
// add_url: 'user/user_recruit_subsidy_log/add',
// edit_url: 'user/user_recruit_subsidy_log/edit',
// del_url: 'user/user_recruit_subsidy_log/del',
// multi_url: 'user/user_recruit_subsidy_log/multi',
// import_url: 'user/user_recruit_subsidy_log/import',
table: 'user_recruit_subsidy_log',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
// {field: 'user_id', title: __('User_id')},
{field: 'children.nickname', title: __('Children.nickname'), operate: 'LIKE'},
{field: 'children.avatar', title: __('Children.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'recruit_subsidy', title: __('Recruit_subsidy'), operate:'BETWEEN'},
{field: 'children_id', title: __('Children_id'),visible:false},
// {field: 'work_date', title: __('Work_date')},
// {field: 'user_work_log_id', title: __('User_work_log_id')},
{field: 'leave', title: __('Leave'), searchList: {"0":__('Leave 0'),"1":__('Leave 1')}, formatter: Table.api.formatter.normal},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
// {field: 'leave', title: __('Leave')},
{field: 'operate', title: __('Operate'), table: table,
events: Table.api.events.operate,
buttons: [{
name: 'indexof',
text: __('查看下级'),
icon: 'fa fa-list',
classname: 'btn btn-info btn-xs btn-detail btn-dialog',
url: 'user/user_recruit_subsidy_log/indexof?xia_id={children_id}'
}],
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
... ...