| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
- namespace backendApi\modules\v1\models\lists\log;
- use common\helpers\MongodbSearchFilter;
- use common\libs\dataList\DataListInterface;
- use common\libs\dataList\column\DateTime;
- use common\models\LogSystem;
- class SystemList extends \common\libs\dataList\DataList implements DataListInterface
- {
- /**
- * 列表名称
- * @return string
- */
- public function getListName(){
- return '系统日志';
- }
- /**
- * 列表筛选到的数据
- * @throws \yii\base\Exception
- */
- public function dataHandle()
- {
- $filter = MongodbSearchFilter::filterCondition([
- 'opt_type' => 'opt_type',
- 'opt_target_name' => 'opt_target_name',
- 'opt_obj_name' => 'opt_obj_name',
- 'opt_user' => 'opt_user',
- 'created_at' => 'created_at',
- 'period_num' => 'period_num',
- 'ip' => 'ip',
- 'device' => 'device',
- 'user_agent' => 'user_agent',
- 'request_route' => 'request_route',
- ]);
- $this->listData = LogSystem::lists($filter['condition'], []);
- }
- /**
- * 要展示和导出的所有字段
- * @return array
- */
- public function getColumn(){
- if(!$this->columns){
- $this->columns = [
- 'opt_type' => [
- 'header' => \Yii::t('ctx', 'operatingType'),
- 'headerOther' => [
- 'width' => '120',
- ],
- 'value' => function($row) {
- return (isset($row['opt_type']) && $row['opt_type'] == 'call' )? \Yii::t('ctx', 'call') : \Yii::t('ctx', 'beCcalled');
- },
- 'valueOther' => function($row) {
- return [
- 'tag'=>['type'=>(isset($row['opt_type']) && $row['opt_type'] == 'call' )? 'success' : 'danger', 'size' => 'small']
- ];
- },
- ],
- 'opt_target_name' => [
- 'header' => \Yii::t('ctx', 'operatingObject'),
- 'headerOther' => [
- 'width' => '120',
- ],
- ],
- 'opt_obj_name' => [
- 'header' => \Yii::t('ctx', 'objectNumber'),
- 'headerOther' => [
- 'width' => '110',
- ],
- ],
- 'request_content' => [
- 'header' => \Yii::t('ctx', 'requestContent'),
- 'headerOther' => [
- 'show-overflow-tooltip'=>true,
- 'min-width'=>'250',
- ],
- ],
- 'response_content' => [
- 'header' => \Yii::t('ctx', 'requestContent'),
- 'headerOther' => [
- 'show-overflow-tooltip'=>true,
- 'min-width'=>'250',
- ],
- ],
- 'opt_user' => [
- 'header' => \Yii::t('ctx', 'operator'),
- 'headerOther' => [
- 'width' => '130',
- ],
- ],
- 'created_at' => [
- 'header' => \Yii::t('ctx', 'operatingTime'),
- 'value' => function($row) {
- return (new DateTime([
- 'value' => $row['created_at'],
- ]))->result();
- },
- 'headerOther' => ['width' => '180'],
- ],
- 'period_num' => \Yii::t('ctx', 'numberOfPhases'),
- 'ip' => [
- 'header' => \Yii::t('ctx', 'IPAddress'),
- 'headerOther' => [
- 'width' => '150',
- ],
- ],
- 'device' => [
- 'header' => \Yii::t('ctx', 'IPAddress'),
- 'headerOther' => [
- 'width' => '150',
- ],
- ],
- 'user_agent' => [
- 'header' => \Yii::t('ctx', 'operatingSystem'),
- 'headerOther' => [
- 'width' => '350',
- ],
- ],
- 'request_route' => [
- 'header' => \Yii::t('ctx', 'requestPath'),
- 'headerOther' => [
- 'width' => '250',
- ],
- ],
- ];
- }
- return $this->columns;
- }
- /**
- * 前台用于筛选的类型集合
- * @return mixed
- */
- public function getFilterTypes()
- {
- if(!$this->filterTypes){
- $this->filterTypes = [
- 'opt_type' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operatingType'), 'other'=> 'select', 'selectData'=> [['id'=> 'call', 'name'=> \Yii::t('ctx', 'call')], ['id'=> 'called', 'name'=> \Yii::t('ctx', 'beCcalled')]]],
- 'opt_target_name' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operatingObject')],
- 'opt_obj_name' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'objectNumber')],
- 'opt_user' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operator')],
- 'created_at' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operatingTime'), 'other'=> 'date'],
- 'period_num' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'numberOfPhases')],
- 'ip' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'IPAddress')],
- 'device' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'client')],
- 'user_agent' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'operatingSystem')],
- 'request_route' => ['isUserTable'=>false, 'name'=>\Yii::t('ctx', 'requestPath')],
- ];
- }
- return $this->filterTypes;
- }
- }
|