Staff.php
1.2 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
<?php
namespace app\inspection\controller;
use app\common\controller\Frontend;
use fast\Tree;
class Staff extends Frontend
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $layout = '';
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\inspection\Staff;
$tree = Tree::instance();
$departModel = new \app\admin\model\inspection\Depart();
$tree->init(collection($departModel->order('weigh asc,id asc')->select())->toArray(), 'pid');
$departdata = ['' => ['depart_name' => '请选择部门']];
foreach ($tree->getTreeList($tree->getTreeArray(0), 'depart_name') as $k => $v) {
$departdata[$v['id']] = $v;
}
$this->view->assign("departList", $departdata);
}
public function list()
{
$list = $this->model
->alias('sta')
->field('sta.*,dep.depart_name')
->join('inspection_depart dep','dep.id=sta.depart_id','LEFT')
->paginate(10,'',['query'=>$this->request->param()]);
$this->view->assign('list',$list);
return $this->view->fetch();
}
}