listData = BalanceAudit::lists($this->condition, $this->params, [ 'select' => 'BA.*,U.USER_NAME,U.REAL_NAME,ADMC.ADMIN_NAME CREATE_ADMIN_NAME,ADMU.ADMIN_NAME AUDIT_ADMIN_NAME', 'orderBy' => 'BA.CREATED_AT DESC, BA.ID DESC', 'from' => BalanceAudit::tableName() . ' AS BA', 'join' => [ ['LEFT JOIN', User::tableName() . ' AS U', 'BA.USER_ID=U.ID'], ['LEFT JOIN', Admin::tableName() . ' AS ADMC', 'BA.UPDATE_ADMIN_ID=ADMC.ID'], ['LEFT JOIN', Admin::tableName() . ' AS ADMU', 'BA.AUDIT_ADMIN_ID=ADMU.ID'], ], 'page' => $this->page, 'pageSize' => $this->pageSize, ]); $auditStatus = array_column(\Yii::$app->params['auditStatus'], null, 'value'); $dealTypes = DealType::getAllTypesForShow(); foreach ($this->listData['list'] as $key => $value) { // $userInfo = Info::baseInfoZh($value['USER_ID']); // $this->listData['list'][$key]['USER_NAME'] = $userInfo['USER_NAME']; // $this->listData['list'][$key]['REAL_NAME'] = $userInfo['REAL_NAME']; $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? ''; $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? ''; $this->listData['list'][$key]['LAST_DEC_ROLE_NAME'] = DecRole::getRoleNameId($value['LAST_DEC_ROLE_ID']); $this->listData['list'][$key]['TYPE_NAME'] = BalanceAudit::TYPE[$value['TYPE']]['label']; $this->listData['list'][$key]['DEAL_TYPE_NAME'] = $dealTypes[$value['DEAL_TYPE']]['TYPE_NAME']; $this->listData['list'][$key]['AUDIT_STATUS_NAME'] = $auditStatus[$value['AUDIT_STATUS']]['label']; } $this->listData['dealTypes'] = $dealTypes; } /** * 要展示和导出的所有字段 * @return array */ public function getColumn() { if (!$this->columns) { $this->columns = [ 'ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID 'AUDIT_STATUS' => null, 'USER_NAME' => [ 'header' => 'Member code',//会员编号 'headerOther' => ['width' => '150'], ], 'REAL_NAME' => [ 'header' => 'Member name',//会员姓名 'headerOther' => [ 'width' => '120', ], ], 'LAST_DEC_LV_NAME' => [ 'header' => 'Member level',//会员级别 'headerOther' => [ 'width' => '110', ], ], 'LAST_DEC_ROLE_NAME' => [ 'header' => 'Declaration center level',//报单中心级别 'headerOther' => [ 'width' => '110', ], ], 'LAST_EMP_LV_NAME' => [ 'header' => 'Rank',//聘级 'headerOther' => [ 'width' => '130', ], ], 'TYPE_NAME' => [ 'header' => 'Account type',//账户类型 'headerOther' => [ 'width' => '140', ], 'valueOther' => function ($row) { return [ 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border'] ]; }, ], 'DEAL_TYPE_NAME' => [ 'header' => 'Transaction type',//交易类型 'headerOther' => [ 'width' => '200', ], 'valueOther' => function ($row) { return [ 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border'] ]; }, ], 'AMOUNT' => [ 'header' => 'Adjustment amount',//调整金额 'headerOther' => [ 'width' => '150', ], 'value' => function ($row) { return Tool::formatPrice($row['AMOUNT']); }, 'valueOther' => function ($row) { return [ 'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border'] ]; }, ], 'CREATE_REMARK' => [ 'header' => 'Remark',//备注 'headerOther' => [ 'width' => '180', ], ], 'REMARK_IS_SHOW' => [ 'header' => 'Whether the front desk displays comments',//前台是否显示备注 'value' => function ($row) { return (new YesNo([ 'value' => $row['REMARK_IS_SHOW'], ]))->result(); }, 'headerOther' => [ 'width' => '160', ], ], 'AUDIT_STATUS_NAME' => [ 'header' => 'Audit status',//审核状态 'headerOther' => [ 'width' => '100', ], 'valueOther' => function ($row) { return [ 'tag' => ['type' => Tool::statusType($row['AUDIT_STATUS']), 'size' => 'small'] ]; }, ], 'CREATE_ADMIN_NAME' => [ 'header' => 'applicant',//申请人 'headerOther' => [ 'width' => '150', ], ], 'CREATED_AT' => [ 'header' => 'Application time',//申请时间 'value' => function ($row) { return (new DateTime([ 'value' => $row['CREATED_AT'], ]))->result(); }, 'headerOther' => ['width' => '190'], ], 'AUDIT_ADMIN_NAME' => [ 'header' => 'Reviewed by',//审核人 'headerOther' => [ 'width' => '150', ], ], 'AUDITED_AT' => [ 'header' => 'Audit time',//审核时间 'value' => function ($row) { return (new DateTime([ 'value' => $row['AUDITED_AT'], ]))->result(); }, 'headerOther' => ['width' => '190'], ], ]; } return $this->columns; } /** * 前台用于筛选的类型集合 * @return mixed */ public function getFilterTypes() { if (!$this->filterTypes) { $this->filterTypes = [ 'USER_NAME' => ['isUserTable' => false, 'name' => 'Member code'],//会员编号 'REAL_NAME' => ['isUserTable' => false, 'name' => 'Member name'],//会员姓名 'LAST_DEC_LV_NAME' => ['isUserTable' => false, 'name' => 'Member level', 'other' => 'decLevel'],//会员级别 'LAST_DEC_ROLE_NAME' => ['isUserTable' => false, 'name' => 'Declaration center level', 'other' => 'decRole'],//报单中心级别 'LAST_EMP_LV_NAME' => ['isUserTable' => false, 'name' => 'rank', 'other' => 'empLevel'],//聘级 'TYPE_NAME' => ['isUserTable' => false, 'name' => 'Account type', 'other' => 'select', 'selectData' => Tool::formatFilter(BalanceAudit::TYPE, 'name', 'label')],//账户类型 'DEAL_TYPE_NAME' => ['isUserTable' => false, 'name' => 'Transaction type', 'other' => 'select', 'selectData' => Tool::formatFilter(DealType::getAllTypesForShow(), 'ID', 'TYPE_NAME')],//交易类型 'AMOUNT' => ['isUserTable' => false, 'name' => 'Adjustment amount'],//调整金额 'CREATE_REMARK' => ['isUserTable' => false, 'name' => 'Remark'],//备注 'REMARK_IS_SHOW' => ['isUserTable' => false, 'name' => 'Whether the front desk displays comments', 'other' => 'yesOrNo'],//前台是否显示备注 'CREATE_ADMIN_NAME' => ['isUserTable' => false, 'name' => 'applicant'],//申请人 'CREATED_AT' => ['isUserTable' => false, 'name' => 'Application time', 'other' => 'date'],//申请时间 'AUDIT_ADMIN_NAME' => ['isUserTable' => false, 'name' => 'Reviewed by'],//审核人 'AUDITED_AT' => ['isUserTable' => false, 'name' => 'Audit time', 'other' => 'date'],//审核时间 ]; } return $this->filterTypes; } }