AdminPartBController.php
3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\AdminBaseController;
use think\Db;
use think\db\Query;
use app\portal\model\InspectModel;
class AdminPartBController extends AdminBaseController
{
private $identity_arr = ['员工','领导','总领导'];
//列表页
public function index(){
$common = new AdminCommonController();
//查询乙方员工
$staff_B = $common->getPartB();
//员工
$s_ids = '';
//领导
$l_ids = '';
//总领导
$ls_ids = '';
foreach($staff_B as $s_value){
$s_ids .= $s_value['u_s_id'].',' ;
$l_ids .= $s_value['u_l_id'].',';
if(!empty($s_value['u_ls_id'])){
$ls_ids .= $s_value['u_ls_id'].',';
}
}
$ids = $s_ids.$l_ids.$ls_ids;
$ids = explode(',',trim($ids,','));
//根据id获取员工
$list = Db::name('user')
->whereIn('id',$ids)
->where('user_status',1)
->where(function (Query $query) {
$data = $this->request->param();
if (!empty($data['user_login'])) {
$user_login = $data['user_login'];
$query->where('user_login', 'like', "%$user_login%");
}
if (!empty($data['mobile'])) {
$mobile = $data['mobile'];
$query->where('mobile', 'like', "%$mobile%");
}
})
->field('id,user_login,avatar,identity,mobile,position')
->order('id desc')
->paginate(10,false,['query'=>request()->param()]);
$s_user = $list->toArray();
foreach($s_user['data'] as &$value){
$value['identity_b'] = $this->identity_arr[$value['identity']];
$uid = $value['id'];
$value['company_name'] = '';
foreach($staff_B as $c_value){
if($value['identity'] == 0){
//员工
$u_s_ids = explode(',',trim($c_value['u_s_id'],','));
if(in_array($uid,$u_s_ids)){
$value['company_name'] = $c_value['company_name'];
$arr = $common->getProjectB($c_value['id'],$uid);
$value['project_name'] = isset($arr['project_name'])&&!empty($arr['project_name'])?$arr['project_name']:'';
}
}else if($value['identity'] == 1){
//领导
if($uid == $c_value['u_l_id']){
$value['company_name'] = $c_value['company_name'];
}
}else{
//总领导
if($uid == $c_value['u_ls_id']){
$value['company_name'] = $c_value['company_name'];
}
}
}
}
$page = $list->render();
$host = new InspectModel();
$this->assign('host',$host::host);
$this->assign('list',$s_user['data']);
$this->assign('page',$page);
// 渲染模板输出
return $this->fetch();
}
}