62 lines
1.8 KiB
PHP
62 lines
1.8 KiB
PHP
<!--公告列表-->
|
|
<?php
|
|
use common\models\Notice;
|
|
use common\utils\EnumUtil;
|
|
use yii\data\ActiveDataProvider;
|
|
use yii\grid\GridView;
|
|
use yii\helpers\Html;
|
|
use yii\helpers\Url;
|
|
|
|
echo Html::a('添加', ['comm/notice-edit'], ['class' => 'btn btn-primary']);
|
|
|
|
$query = Notice::find()->where(['del' => EnumUtil::DELETE_NOT]);
|
|
|
|
$provider = new ActiveDataProvider([
|
|
'query' => $query,
|
|
'sort' => [
|
|
'defaultOrder' => [
|
|
'updated_at' => SORT_DESC,
|
|
]
|
|
],
|
|
]);
|
|
|
|
echo GridView::widget([
|
|
'dataProvider' => $provider,
|
|
'columns' => [
|
|
'id',
|
|
[
|
|
'label' => '标题',
|
|
'headerOptions' => ['width' => '200'],
|
|
'value' => 'title',
|
|
],
|
|
[
|
|
'label' => '内容',
|
|
'headerOptions' => ['width' => '1200'],
|
|
'value' => 'message',
|
|
],
|
|
'updated_at_str',
|
|
[
|
|
'class' => 'yii\grid\ActionColumn',
|
|
'header' => '操作',
|
|
'template' => '{edit} {del}',
|
|
'buttons' => [
|
|
'edit' => function ($url, $models, $key) {
|
|
$url = ['/comm/notice-edit', 'id' => $models->id];
|
|
$options = ['title' => '修改',];
|
|
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, $options);
|
|
},
|
|
'del' => function ($url, $models, $key) {
|
|
$url = ['/comm/notice-del', 'id' => $models->id];
|
|
$url = Url::to($url);
|
|
$click='delConfirm("你确定要删除吗?","'.$url.'");';
|
|
$options = ['title' => '删除','class'=>'btn-link glyphicon glyphicon-remove', 'onclick' => $click];
|
|
return Html::button("", $options);
|
|
}
|
|
]
|
|
],
|
|
],
|
|
]);
|
|
?>
|
|
|
|
|