listData = UserImmigrant::lists($this->condition, $this->params, [ 'select' => 'UI.*, CU.USER_NAME, ADM.ADMIN_NAME, BC.NAME AS before_country, AC.NAME AS after_country', 'orderBy' => 'UI.CREATED_AT DESC, UI.id DESC', 'from' => UserImmigrant::tableName() . ' AS UI', 'join' => [ ['INNER JOIN', Admin::tableName() . ' AS ADM', 'UI.created_by=ADM.ID'], ['INNER JOIN', User::tableName() . ' AS CU', 'UI.user_id=CU.ID'], ['INNER JOIN', Countries::tableName() . ' AS BC', 'UI.before_country_id=CU.ID'], ['INNER JOIN', Countries::tableName() . ' AS AC', 'UI.after_country_id=CU.ID'], ], 'page' => $this->page, 'pageSize' => $this->pageSize, ]); } /** * 要展示和导出的所有字段 * @return array */ public function getColumn() { if (!$this->columns) { $this->columns = [ 'id' => null, 'user_id' => null, 'USER_NAME' => [ 'header' => Yii::t('ctx', 'memberCode'), ], 'before_country' => [ 'header' => Yii::t('ctx', 'beforeCountry'), 'valueOther' => [ 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'] ], ], 'after_country' => [ 'header' => Yii::t('ctx', 'afterCountry'), 'valueOther' => [ 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'] ], ], 'ADMIN_NAME' => [ 'header' => Yii::t('ctx', 'operationAdministrator'), ], 'CREATED_AT' => [ 'header' => Yii::t('ctx', 'createAt'), 'value' => function($row) { return (new DateTime([ 'value' => $row['CREATED_AT'], ]))->result(); }, ], ]; } return $this->columns; } /** * 前台用于筛选的类型集合 * @return mixed */ public function getFilterTypes() { if (!$this->filterTypes) { $this->filterTypes = [ 'USER_NAME'=> ['isUserTable' => false, 'name'=> Yii::t('ctx', 'memberCode')], 'CREATED_AT' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'createAt'), 'other' => 'date'], 'ADMIN_NAME' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'operationAdministrator')], ]; } return $this->filterTypes; } }