ChangeHighestEmpLevelList.php 3.5 KB

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