提交 e5538267 authored 作者: chengye's avatar chengye

加入抄表员角色,并且只有分配了抄表员的角色,才会在抄表单抄表人列表显示

上级 8eac879e
......@@ -101,7 +101,7 @@ class Useage extends Base
$this->assign('uid',$user['user_id']);
//员工列表
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin']));
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin'],'','useage'));
$this->assign('em',$em);
if($em->rule->pricing_type == 1){
......
<?php
namespace app\em\model;
use app\admin\model\DepartmentModel;
use app\admin\model\RoleModel;
use app\admin\model\StaffModel;
use app\admin\model\StaffRoleModel;
use think\Session;
class Staff extends Base
{
protected $table = 'staff';
public function getStaffs($is_admin=false,$staff_id=''){
public function getStaffs($is_admin=false,$staff_id='',$filter=false){
if($is_admin){
$staffs = StaffModel::field('id,name')->select()->toArray();
} else {
......@@ -19,7 +21,25 @@ class Staff extends Base
$staff = StaffModel::where('id','=',$staff_id)->find();
}
$dIds = (new DepartmentModel)->getNodeIds($staff['d_id']);
$staffs = StaffModel::field('id,name')->where('d_id','in',$dIds)->select()->toArray();
//过滤角色权限
if($filter == 'useage'){
$role = RoleModel::get(['title'=>'抄表员']);
if($role){
$fStaffIds = StaffRoleModel::where(['role_id'=>$role->id])->column('staff_id');
$staffs = StaffModel::field('id,name')
->where('d_id','in',$dIds)
->where('staff_id','in',$fStaffIds)
->select()->toArray();
}
} else {
$staffs = StaffModel::field('id,name')
->where('d_id','in',$dIds)
->select()->toArray();
}
}
return $staffs;
}
......
......@@ -100,7 +100,7 @@
function del(obj,id){
layer.confirm('确认要删除吗?',function(index){
$.ajax({
url: '/copy_del',
url: '/useage/del',
method: "POST",
data: {id:id},
dataType: "json",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论