ImmigrantList.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\user;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\Cache;
  5. use common\libs\dataList\DataListInterface;
  6. use common\models\Countries;
  7. use common\models\HighestEmpLevelLog;
  8. use common\models\User;
  9. use common\libs\dataList\column\DateTime;
  10. use common\models\UserImmigrant;
  11. use Yii;
  12. class ImmigrantList extends \common\libs\dataList\DataList implements DataListInterface
  13. {
  14. /**
  15. * 列表名称
  16. * @return string
  17. */
  18. public function getListName(){
  19. return '会员移民列表';
  20. }
  21. /**
  22. * 列表筛选到的数据
  23. */
  24. public function dataHandle()
  25. {
  26. $this->listData = UserImmigrant::lists($this->condition, $this->params, [
  27. 'select' => 'UI.*, CU.USER_NAME, ADM.ADMIN_NAME, BC.NAME AS before_country, AC.NAME AS after_country',
  28. 'orderBy' => 'UI.CREATED_AT DESC, UI.id DESC',
  29. 'from' => UserImmigrant::tableName() . ' AS UI',
  30. 'join' => [
  31. ['INNER JOIN', Admin::tableName() . ' AS ADM', 'UI.created_by=ADM.ID'],
  32. ['INNER JOIN', User::tableName() . ' AS CU', 'UI.user_id=CU.ID'],
  33. ['INNER JOIN', Countries::tableName() . ' AS BC', 'UI.before_country_id=CU.ID'],
  34. ['INNER JOIN', Countries::tableName() . ' AS AC', 'UI.after_country_id=CU.ID'],
  35. ],
  36. 'page' => $this->page,
  37. 'pageSize' => $this->pageSize,
  38. ]);
  39. }
  40. /**
  41. * 要展示和导出的所有字段
  42. * @return array
  43. */
  44. public function getColumn() {
  45. if (!$this->columns) {
  46. $this->columns = [
  47. 'id' => null,
  48. 'user_id' => null,
  49. 'USER_NAME' => [
  50. 'header' => Yii::t('ctx', 'memberCode'),
  51. ],
  52. 'before_country' => [
  53. 'header' => Yii::t('ctx', 'beforeCountry'),
  54. 'valueOther' => [
  55. 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  56. ],
  57. ],
  58. 'after_country' => [
  59. 'header' => Yii::t('ctx', 'afterCountry'),
  60. 'valueOther' => [
  61. 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  62. ],
  63. ],
  64. 'ADMIN_NAME' => [
  65. 'header' => Yii::t('ctx', 'operationAdministrator'),
  66. ],
  67. 'CREATED_AT' => [
  68. 'header' => Yii::t('ctx', 'createAt'),
  69. 'value' => function($row) {
  70. return (new DateTime([
  71. 'value' => $row['CREATED_AT'],
  72. ]))->result();
  73. },
  74. ],
  75. ];
  76. }
  77. return $this->columns;
  78. }
  79. /**
  80. * 前台用于筛选的类型集合
  81. * @return mixed
  82. */
  83. public function getFilterTypes()
  84. {
  85. if (!$this->filterTypes) {
  86. $this->filterTypes = [
  87. 'USER_NAME'=> ['isUserTable' => false, 'name'=> Yii::t('ctx', 'memberCode')],
  88. 'CREATED_AT' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'createAt'), 'other' => 'date'],
  89. 'ADMIN_NAME' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'operationAdministrator')],
  90. ];
  91. }
  92. return $this->filterTypes;
  93. }
  94. }