ChangeHighestEmpLevelList.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 Yii;
  11. class ChangeHighestEmpLevelList extends \common\libs\dataList\DataList implements DataListInterface
  12. {
  13. /**
  14. * 列表名称
  15. * @return string
  16. */
  17. public function getListName(){
  18. return '会员最高聘级调整列表';
  19. }
  20. /**
  21. * 列表筛选到的数据
  22. */
  23. public function dataHandle()
  24. {
  25. $this->listData = HighestEmpLevelLog::lists($this->condition, $this->params, [
  26. 'select' => 'LL.*, CU.USER_NAME, ADM.ADMIN_NAME, C.NAME AS COUNTRY',
  27. 'orderBy' => 'LL.CREATED_AT DESC, LL.ID DESC',
  28. 'from' => HighestEmpLevelLog::tableName() . ' AS LL',
  29. 'join' => [
  30. ['LEFT JOIN', Admin::tableName() . ' AS ADM', 'LL.ADMIN_ID=ADM.ID'],
  31. ['INNER JOIN', User::tableName() . ' AS CU', 'LL.USER_ID=CU.ID'],
  32. ['INNER JOIN', Countries::tableName() . ' AS C', 'CU.COUNTRY_ID=C.ID'],
  33. ],
  34. 'page' => $this->page,
  35. 'pageSize' => $this->pageSize,
  36. ]);
  37. }
  38. /**
  39. * 要展示和导出的所有字段
  40. * @return array
  41. */
  42. public function getColumn() {
  43. $empLevelConfig = Cache::getEmpLevelConfig();
  44. if (!$this->columns) {
  45. $this->columns = [
  46. 'ID' => null,
  47. 'USER_ID' => null,
  48. 'USER_NAME' => [
  49. 'header' => Yii::t('ctx', 'memberCode'),
  50. ],
  51. 'COUNTRY' => [
  52. 'header' => Yii::t('ctx', 'country'),
  53. ],
  54. 'FROM_HIGHEST_EMP_LV_NAME' => [
  55. 'header' => Yii::t('ctx', 'levelBeforeModification'),
  56. 'value' => function($row) use($empLevelConfig) {
  57. return $empLevelConfig[$row['FROM_ID']]['LEVEL_NAME'] ?? '';
  58. },
  59. 'valueOther' => [
  60. 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  61. ],
  62. ],
  63. 'TO_HIGHEST_EMP_LV_NAME' => [
  64. 'header' => Yii::t('ctx', 'modifiedLevel'),
  65. 'value' => function($row) use($empLevelConfig) {
  66. return $empLevelConfig[$row['TO_ID']]['LEVEL_NAME'] ?? '';
  67. },
  68. 'valueOther' => [
  69. 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  70. ],
  71. ],
  72. 'ADMIN_NAME' => [
  73. 'header' => Yii::t('ctx', 'operationAdministrator'),
  74. ],
  75. 'CREATED_AT' => [
  76. 'header' => Yii::t('ctx', 'createAt'),
  77. 'value' => function($row) {
  78. return (new DateTime([
  79. 'value' => $row['CREATED_AT'],
  80. ]))->result();
  81. },
  82. ],
  83. ];
  84. }
  85. return $this->columns;
  86. }
  87. /**
  88. * 前台用于筛选的类型集合
  89. * @return mixed
  90. */
  91. public function getFilterTypes()
  92. {
  93. if (!$this->filterTypes) {
  94. $this->filterTypes = [
  95. 'USER_NAME'=> ['isUserTable' => false,'name'=> Yii::t('ctx', 'memberCode')],
  96. 'CREATED_AT' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'createAt'), 'other' => 'date'],
  97. 'ADMIN_NAME' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'operationAdministrator')],
  98. ];
  99. }
  100. return $this->filterTypes;
  101. }
  102. }