joinWith('mainCorp2'); // add conditions that should always apply here $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => false ]); $this->load($params); // grid filtering conditions $query->andFilterWhere([ 'STATUS' => $this->STATUS, 'MAIN_CORP_ID2' => (Yii::$app->user->identity->USER_ROLE2 == self::SUPER_ADMIN_FO) ? null : Yii::$app->user->identity->MAIN_CORP_ID2, 'corp_type' => BaseMainCorporation::CORP_FO ]); if ($this->USER_ROLE2 != null && $this->USER_ROLE2 != '') $query->andWhere("user_role2 REGEXP '[[:<:]]" . $this->USER_ROLE2 . "[[:>:]]'"); $query->andFilterWhere(['like', 'USER_NAME', $this->USER_NAME]) ->andFilterWhere(['like', 'TRUE_NAME', $this->TRUE_NAME]) ->andFilterWhere(['<>', 'MAIN_CORP_ID2', 0]); return $dataProvider; } /* * 是否是车系统超级管理员 * @return bool */ public static function isSuperAdmin($user_role2) { $roles = explode(',', $user_role2); if (empty(in_array(self::SUPER_ADMIN_FO, $roles))) { return false; } else return true; } }