app=$app; } var $addon_cols = 'is_lock'; function column_control($row){ $list['edit'] = ''.app::get('desktop')->_('编辑').''; if($row[$this->col_prefix.'is_lock'] == '1') { $list['unLock'] = ''.app::get('desktop')->_('解锁').''; } $is_operator_edit = kernel::single('desktop_user')->has_permission('operator_edit'); if(!$is_operator_edit){ unset($list['edit']); } else { if($row['user_id'] != 1) { $list['clone'] = ''.app::get('desktop')->_('复制').''; } } return implode(' | ',$list); } public $column_roles = '角色'; public $column_roles_width = 260; public $column_roles_order = 300; private $_roles = null; /** * column_roles * @param mixed $row row * @param mixed $list list * @return mixed 返回值 */ public function column_roles($row, $list) { $html_s = '
'; $html_e = '
'; if (isset($this->_roles)){ $text = implode('、', (array)$this->_roles[$row['user_id']]); return $html_s.$text.$html_e; } $filter = ['user_id' => array_column($list, 'user_id')]; $hasRoles = app::get('desktop')->model('hasrole')->getList('*', $filter); if (!$hasRoles) { $this->_roles = []; return ''; } $roles = app::get('desktop')->model('roles')->getList('role_id,role_name', ['role_id' => array_column($hasRoles, 'role_id')]); $roles = array_column($roles, 'role_name', 'role_id'); foreach ($hasRoles as $hasRole) { $this->_roles[$hasRole['user_id']][] = $roles[$hasRole['role_id']]; } $text = implode('、', (array)$this->_roles[$row['user_id']]); return $html_s.$text.$html_e; } }