index.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. use yii\grid\GridView;
  3. use common\enums\AppEnum;
  4. use common\helpers\Html;
  5. use common\helpers\Url;
  6. use common\helpers\DebrisHelper;
  7. use common\helpers\MemberHelper;
  8. use kartik\daterange\DateRangePicker;
  9. $this->title = '全局日志';
  10. $this->params['breadcrumbs'][] = ['label' => $this->title, 'url' => ['index']];
  11. ?>
  12. <div class="row">
  13. <div class="col-sm-12">
  14. <div class="nav-tabs-custom">
  15. <ul class="nav nav-tabs">
  16. <li class="active"><a href="<?= Url::to(['index']) ?>"> <?= $this->title; ?></a></li>
  17. <li><a href="<?= Url::to(['statistics']) ?>"> 数据统计</a></li>
  18. <li><a href="<?= Url::to(['ip-statistics']) ?>"> IP 统计</a></li>
  19. </ul>
  20. <div class="tab-content">
  21. <div class="active tab-pane">
  22. <?= GridView::widget([
  23. 'dataProvider' => $dataProvider,
  24. 'filterModel' => $searchModel,
  25. // 重新定义分页样式
  26. 'tableOptions' => ['class' => 'table table-hover'],
  27. 'columns' => [
  28. 'id',
  29. [
  30. 'attribute' => 'method',
  31. 'headerOptions' => ['class' => 'col-md-1'],
  32. ],
  33. [
  34. 'attribute' => 'app_id',
  35. 'filter' => Html::activeDropDownList($searchModel, 'app_id', AppEnum::getMap(), [
  36. 'prompt' => '全部',
  37. 'class' => 'form-control'
  38. ]),
  39. 'value' => function ($model) {
  40. return AppEnum::getValue($model->app_id);
  41. },
  42. 'headerOptions' => ['class' => 'col-md-1'],
  43. ],
  44. MemberHelper::gridView($searchModel),
  45. 'url',
  46. [
  47. 'label' => '位置信息',
  48. 'attribute' => 'ip',
  49. 'value' => function ($model) {
  50. $str = [];
  51. $str[] = DebrisHelper::analysisIp($model->ip);
  52. $str[] = $model->ip;
  53. return implode("</br>", $str);
  54. },
  55. 'format' => 'raw',
  56. ],
  57. [
  58. 'attribute' => 'error_code',
  59. 'label' => '状态码',
  60. 'headerOptions' => ['class' => 'col-md-1'],
  61. 'value' => function ($model) {
  62. if ($model->error_code < 300) {
  63. return '<span class="label label-outline-success">' . $model->error_code . '</span>';
  64. } else {
  65. return '<span class="label label-outline-danger">' . $model->error_code . '</span>';
  66. }
  67. },
  68. 'format' => 'raw',
  69. ],
  70. [
  71. 'attribute' => 'created_at',
  72. 'filter' => DateRangePicker::widget([
  73. 'language' => 'zh-CN',
  74. 'name' => 'queryDate',
  75. 'value' => (!empty($startTime) && !empty($endTime)) ? ($startTime . '-' . $endTime) : '',
  76. 'readonly' => 'readonly',
  77. 'useWithAddon' => false,
  78. 'convertFormat' => true,
  79. 'startAttribute' => 'start_time',
  80. 'endAttribute' => 'end_time',
  81. 'startInputOptions' => ['value' => $startTime],
  82. 'endInputOptions' => ['value' => $endTime],
  83. 'presetDropdown' => true,
  84. 'containerTemplate' => <<< HTML
  85. <div class="kv-drp-dropdown">
  86. <span class="left-ind">{pickerIcon}</span>
  87. <input type="text" readonly class="form-control range-value" value="{value}">
  88. </div>
  89. {input}
  90. HTML,
  91. 'pluginOptions' => [
  92. 'locale' => ['format' => 'Y-m-d H:i'],
  93. 'timePicker' => true,
  94. 'timePicker24Hour' => true,
  95. 'timePickerIncrement' => 5
  96. ]
  97. ]),
  98. 'value' => function ($model) {
  99. return date('Y-m-d H:i:s', $model['created_at']);
  100. },
  101. 'format' => 'raw',
  102. ],
  103. [
  104. 'header' => "操作",
  105. 'class' => 'yii\grid\ActionColumn',
  106. 'template' => '{view}',
  107. 'buttons' => [
  108. 'view' => function ($url, $model, $key) {
  109. return Html::linkButton(['view', 'id' => $model->id], '查看详情', [
  110. 'class' => 'btn btn-white btn-sm openIframeView',
  111. ]);
  112. },
  113. ],
  114. ],
  115. ],
  116. ]); ?>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
粤ICP备19079148号