正在显示
9 个修改的文件
包含
338 行增加
和
2 行删除
application/admin/controller/Staff.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | +use app\admin\model\User; | ||
7 | +use think\Db; | ||
8 | + | ||
9 | +/** | ||
10 | + * | ||
11 | + * | ||
12 | + * @icon fa fa-circle-o | ||
13 | + */ | ||
14 | +class Staff extends Backend | ||
15 | +{ | ||
16 | + | ||
17 | + /** | ||
18 | + * Staff模型对象 | ||
19 | + * @var \app\admin\model\Staff | ||
20 | + */ | ||
21 | + protected $model = null; | ||
22 | + | ||
23 | + public function _initialize() | ||
24 | + { | ||
25 | + parent::_initialize(); | ||
26 | + $this->model = new \app\admin\model\Staff; | ||
27 | + | ||
28 | + } | ||
29 | + | ||
30 | + /** | ||
31 | + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | ||
32 | + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||
33 | + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||
34 | + */ | ||
35 | + | ||
36 | + | ||
37 | + /** | ||
38 | + * 查看 | ||
39 | + */ | ||
40 | + public function index() | ||
41 | + { | ||
42 | + //当前是否为关联查询 | ||
43 | + $this->relationSearch = true; | ||
44 | + //设置过滤方法 | ||
45 | + $this->request->filter(['strip_tags']); | ||
46 | + if ($this->request->isAjax()) | ||
47 | + { | ||
48 | + //如果发送的来源是Selectpage,则转发到Selectpage | ||
49 | + if ($this->request->request('keyField')) | ||
50 | + { | ||
51 | + return $this->selectpage(); | ||
52 | + } | ||
53 | + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | ||
54 | + $total = $this->model | ||
55 | + ->with(['user']) | ||
56 | + ->where($where) | ||
57 | + ->order($sort, $order) | ||
58 | + ->count(); | ||
59 | + | ||
60 | + $list = $this->model | ||
61 | + ->with(['user']) | ||
62 | + ->where($where) | ||
63 | + ->order($sort, $order) | ||
64 | + ->limit($offset, $limit) | ||
65 | + ->select(); | ||
66 | + | ||
67 | + foreach ($list as $row) { | ||
68 | + | ||
69 | + $row->getRelation('user')->visible(['openid','username','nickname','avatar','mobile','type','inner_staff','start','address','money','score','status']); | ||
70 | + } | ||
71 | + $list = collection($list)->toArray(); | ||
72 | + $result = array("total" => $total, "rows" => $list); | ||
73 | + | ||
74 | + return json($result); | ||
75 | + } | ||
76 | + return $this->view->fetch(); | ||
77 | + } | ||
78 | + | ||
79 | + //设置内部人员 | ||
80 | + public function set($ids){ | ||
81 | + if ($ids) { | ||
82 | + $userModel = new User(); | ||
83 | + $pk = $userModel->getPk(); | ||
84 | + //设置成为内部人员 | ||
85 | + $result2 = $userModel->where($pk, '=', $ids)->where(['status' => 'normal','inner_staff'=>0])->update(['inner_staff' => 1]); | ||
86 | + //插入内部人员数据 | ||
87 | + $result = $this->model->save(['uid'=>$ids]); | ||
88 | + if ($result2 && $result) { | ||
89 | + $this->success('成功'); | ||
90 | + } else { | ||
91 | + $this->error('失败'); | ||
92 | + } | ||
93 | + } | ||
94 | + $this->error(__('Parameter %s can not be empty', 'ids')); | ||
95 | + } | ||
96 | +} |
application/admin/lang/zh-cn/staff.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +return [ | ||
4 | + 'Id' => 'ID', | ||
5 | + 'User.username' => '用户名', | ||
6 | + 'User.nickname' => '昵称', | ||
7 | + 'User.type' => '类型', | ||
8 | + 'User.mobile' => '手机号', | ||
9 | + 'User.avatar' => '头像', | ||
10 | + 'User.start' => '开工状态', | ||
11 | + 'User.score' => '积分', | ||
12 | + 'User.money' => '余额', | ||
13 | + 'User.address' => '上门地址', | ||
14 | + 'User.status' => '状态', | ||
15 | +]; |
application/admin/model/Staff.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\model; | ||
4 | + | ||
5 | +use think\Model; | ||
6 | + | ||
7 | +class Staff extends Model | ||
8 | +{ | ||
9 | + // 表名 | ||
10 | + protected $name = 'staff'; | ||
11 | + | ||
12 | + // 自动写入时间戳字段 | ||
13 | + protected $autoWriteTimestamp = false; | ||
14 | + | ||
15 | + // 定义时间戳字段名 | ||
16 | + protected $createTime = false; | ||
17 | + protected $updateTime = false; | ||
18 | + | ||
19 | + // 追加属性 | ||
20 | + protected $append = [ | ||
21 | + | ||
22 | + ]; | ||
23 | + | ||
24 | + | ||
25 | + | ||
26 | + | ||
27 | + | ||
28 | + | ||
29 | + | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | + public function user() | ||
34 | + { | ||
35 | + return $this->belongsTo('User', 'uid', 'id', [], 'LEFT')->setEagerlyType(0); | ||
36 | + } | ||
37 | +} |
application/admin/validate/Staff.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\validate; | ||
4 | + | ||
5 | +use think\Validate; | ||
6 | + | ||
7 | +class Staff extends Validate | ||
8 | +{ | ||
9 | + /** | ||
10 | + * 验证规则 | ||
11 | + */ | ||
12 | + protected $rule = [ | ||
13 | + ]; | ||
14 | + /** | ||
15 | + * 提示消息 | ||
16 | + */ | ||
17 | + protected $message = [ | ||
18 | + ]; | ||
19 | + /** | ||
20 | + * 验证场景 | ||
21 | + */ | ||
22 | + protected $scene = [ | ||
23 | + 'add' => [], | ||
24 | + 'edit' => [], | ||
25 | + ]; | ||
26 | + | ||
27 | +} |
application/admin/view/staff/index.html
0 → 100644
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> | ||
10 | + <div class="dropdown btn-group {:$auth->check('staff/multi')?'':'hide'}"> | ||
11 | + <ul class="dropdown-menu text-left" role="menu"> | ||
12 | + <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> | ||
13 | + <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> | ||
14 | + </ul> | ||
15 | + </div> | ||
16 | + </div> | ||
17 | + <table id="table" class="table table-striped table-bordered table-hover table-nowrap" | ||
18 | + data-operate-edit="{:$auth->check('staff/edit')}" | ||
19 | + data-operate-del="{:$auth->check('staff/del')}" | ||
20 | + width="100%"> | ||
21 | + </table> | ||
22 | + </div> | ||
23 | + </div> | ||
24 | + | ||
25 | + </div> | ||
26 | + </div> | ||
27 | +</div> |
@@ -46,6 +46,7 @@ class Person extends Api | @@ -46,6 +46,7 @@ class Person extends Api | ||
46 | "license_img": ""//公司营业执照 | 46 | "license_img": ""//公司营业执照 |
47 | "money":100//账户余额 | 47 | "money":100//账户余额 |
48 | "avatar"://头像 | 48 | "avatar"://头像 |
49 | + "start"://是否开工 0:下班 1:上班 | ||
49 | } | 50 | } |
50 | }) | 51 | }) |
51 | */ | 52 | */ |
@@ -53,7 +54,7 @@ class Person extends Api | @@ -53,7 +54,7 @@ class Person extends Api | ||
53 | if($this->request->isGet()){ | 54 | if($this->request->isGet()){ |
54 | $data = Db::table('gc_user') | 55 | $data = Db::table('gc_user') |
55 | ->where(['id'=>$this->user_id]) | 56 | ->where(['id'=>$this->user_id]) |
56 | - ->field('id,nickname,username,mobile,type,address,id_num,id_img,company_name,license_num,license_img,money,avatar') | 57 | + ->field('id,nickname,username,mobile,type,address,id_num,id_img,company_name,license_num,license_img,money,avatar,start') |
57 | ->find(); | 58 | ->find(); |
58 | $this->success('成功', $data); | 59 | $this->success('成功', $data); |
59 | }else{ | 60 | }else{ |
@@ -396,4 +397,37 @@ class Person extends Api | @@ -396,4 +397,37 @@ class Person extends Api | ||
396 | return true; | 397 | return true; |
397 | } | 398 | } |
398 | 399 | ||
400 | + /** | ||
401 | + * @ApiTitle (开工) | ||
402 | + * @ApiSummary (开工) | ||
403 | + * @ApiMethod (POST) | ||
404 | + * @ApiRoute (/api/person/start) | ||
405 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
406 | + * @ApiParams (name="status", type="integer", required=true, description="是否开工 0:下班;1:上班") | ||
407 | + * @ApiReturn ({ | ||
408 | + "code": 1, | ||
409 | + "msg": "成功", | ||
410 | + "time": "1555652055", | ||
411 | + "data": null | ||
412 | + }) | ||
413 | + */ | ||
414 | + public function start(){ | ||
415 | + if($this->request->isPost()) { | ||
416 | + $status = $this->request->post('status');//状态 0:下班,1:上班 | ||
417 | + $rule = config('site.start'); | ||
418 | + $validate = new Validate($rule['rule'],$rule['msg']); | ||
419 | + if (!$validate->check(['status'=>$status])) { | ||
420 | + $this->error($validate->getError()); | ||
421 | + } | ||
422 | + $user = new \app\admin\model\User(); | ||
423 | + $data1 = $user->where(['id'=>$this->user_id])->update(['start'=>$status]); | ||
424 | + if($data1){ | ||
425 | + $this->success('成功'); | ||
426 | + }else{ | ||
427 | + $this->error('失败'); | ||
428 | + } | ||
429 | + }else{ | ||
430 | + $this->error('请求方式错误'); | ||
431 | + } | ||
432 | + } | ||
399 | } | 433 | } |
@@ -331,4 +331,13 @@ return array ( | @@ -331,4 +331,13 @@ return array ( | ||
331 | 'id.require' => '购物车id不能为空', | 331 | 'id.require' => '购物车id不能为空', |
332 | ] | 332 | ] |
333 | ], | 333 | ], |
334 | + 'start' => [ | ||
335 | + 'rule' => [ | ||
336 | + 'status' => 'require|number', | ||
337 | + ], | ||
338 | + 'msg' => [ | ||
339 | + 'status.require' => '开工状态不能为空', | ||
340 | + 'status.number' => '开工状态必须为数字', | ||
341 | + ] | ||
342 | + ], | ||
334 | ); | 343 | ); |
public/assets/js/backend/staff.js
0 → 100644
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'staff/index', | ||
9 | + // add_url: 'staff/add', | ||
10 | + // edit_url: 'staff/edit', | ||
11 | + // del_url: 'staff/del', | ||
12 | + multi_url: 'staff/multi', | ||
13 | + table: 'staff', | ||
14 | + } | ||
15 | + }); | ||
16 | + | ||
17 | + var table = $("#table"); | ||
18 | + | ||
19 | + // 初始化表格 | ||
20 | + table.bootstrapTable({ | ||
21 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
22 | + pk: 'id', | ||
23 | + sortName: 'id', | ||
24 | + columns: [ | ||
25 | + [ | ||
26 | + {checkbox: true}, | ||
27 | + {field: 'id', title: __('Id')}, | ||
28 | + {field: 'user.username', title: __('User.username')}, | ||
29 | + {field: 'user.nickname', title: __('User.nickname')}, | ||
30 | + {field: 'user.type', title: __('User.type'),formatter: Table.api.formatter.label,searchList: {0: __('Person'), 1: __('Company')}}, | ||
31 | + {field: 'user.mobile', title: __('User.mobile')}, | ||
32 | + {field: 'user.avatar', title: __('User.avatar'),formatter: Table.api.formatter.image, operate: false}, | ||
33 | + {field: 'user.start', title: __('User.start'),formatter: Table.api.formatter.label,searchList: {0: __('未开工'), 1: __('已开工')}}, | ||
34 | + {field: 'user.score', title: __('user.score'), operate: 'BETWEEN', sortable: true}, | ||
35 | + {field: 'user.money', title: __('User.money')}, | ||
36 | + {field: 'user.address', title: __('User.address')}, | ||
37 | + // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
38 | + ] | ||
39 | + ] | ||
40 | + }); | ||
41 | + | ||
42 | + // 为表格绑定事件 | ||
43 | + Table.api.bindevent(table); | ||
44 | + }, | ||
45 | + add: function () { | ||
46 | + Controller.api.bindevent(); | ||
47 | + }, | ||
48 | + edit: function () { | ||
49 | + Controller.api.bindevent(); | ||
50 | + }, | ||
51 | + api: { | ||
52 | + bindevent: function () { | ||
53 | + Form.api.bindevent($("form[role=form]")); | ||
54 | + } | ||
55 | + } | ||
56 | + }; | ||
57 | + return Controller; | ||
58 | +}); |
@@ -36,6 +36,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -36,6 +36,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
36 | {field: 'money', title: __('Money')}, | 36 | {field: 'money', title: __('Money')}, |
37 | // {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true}, | 37 | // {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true}, |
38 | {field: 'address', title: __('Address')},//上门地址 | 38 | {field: 'address', title: __('Address')},//上门地址 |
39 | + {field: 'inner_staff', title: __('是否是内部人员'),formatter: Table.api.formatter.label,searchList: {0: __('非'), 1: __('是')}}, | ||
39 | // {field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}}, | 40 | // {field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}}, |
40 | // {field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true}, | 41 | // {field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true}, |
41 | // {field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true}, | 42 | // {field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true}, |
@@ -45,7 +46,39 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -45,7 +46,39 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
45 | // {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search}, | 46 | // {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search}, |
46 | {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}}, | 47 | {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}}, |
47 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons: [ | 48 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons: [ |
48 | - {name: 'offline', text: '我的团队', title: '我的团队', icon: 'fa fa-list', classname: 'btn btn-xs btn-success btn-dialog', url: "off/line/offline"} | 49 | + { |
50 | + name: 'offline', | ||
51 | + text: '我的团队', | ||
52 | + title: '我的团队', | ||
53 | + icon: 'fa fa-list', | ||
54 | + classname: 'btn btn-xs btn-success btn-dialog', | ||
55 | + url: "off/line/offline" | ||
56 | + }, | ||
57 | + { | ||
58 | + name: 'ajax', | ||
59 | + text: __('设置'), | ||
60 | + title: __('设置'), | ||
61 | + classname: 'btn btn-xs btn-success btn-magic btn-ajax', | ||
62 | + icon: 'fa', | ||
63 | + url: 'staff/set', | ||
64 | + confirm: '确认设置内部人员', | ||
65 | + success: function (data, ret) { | ||
66 | + Layer.alert(ret.msg); | ||
67 | + $(".btn-refresh").trigger("click"); | ||
68 | + //如果需要阻止成功提示,则必须使用return false; | ||
69 | + //return false; | ||
70 | + }, | ||
71 | + error: function (data, ret) { | ||
72 | + Layer.alert(ret.msg); | ||
73 | + return false; | ||
74 | + },visible: function (row) { | ||
75 | + if(row.inner_staff == 1){ | ||
76 | + return false;//隐藏 | ||
77 | + }else{ | ||
78 | + return true; | ||
79 | + } | ||
80 | + } | ||
81 | + } | ||
49 | ]} | 82 | ]} |
50 | ] | 83 | ] |
51 | ] | 84 | ] |
-
请 注册 或 登录 后发表评论