实现公告功能
*前端 公告管理部分
This commit is contained in:
parent
cd6276503f
commit
475cd97946
25
views/admin/_announcements_form.php
Normal file
25
views/admin/_announcements_form.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\Announcements $model */
|
||||||
|
/** @var yii\widgets\ActiveForm $form */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="announcements-form">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'content')->textarea(['rows' => 6]) ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('发布', ['class' => 'btn btn-success']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
38
views/admin/_announcements_search.php
Normal file
38
views/admin/_announcements_search.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\AnnouncementsSearch $model */
|
||||||
|
/** @var yii\widgets\ActiveForm $form */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="announcements-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['index'],
|
||||||
|
'method' => 'get',
|
||||||
|
'options' => [
|
||||||
|
'data-pjax' => 1
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'id') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'title') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'content') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'published_at') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'updated_at') ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::resetButton('Reset', ['class' => 'btn btn-outline-secondary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
20
views/admin/announcements_create.php
Normal file
20
views/admin/announcements_create.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\Announcements $model */
|
||||||
|
|
||||||
|
$this->title = '发布公告';
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => '公告管理', 'url' => ['announcements-manage']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="announcements-create">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_announcements_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
68
views/admin/announcements_index.php
Normal file
68
views/admin/announcements_index.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use app\models\Announcements;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
use yii\grid\ActionColumn;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use yii\widgets\Pjax;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\AnnouncementsSearch $searchModel */
|
||||||
|
/** @var yii\data\ActiveDataProvider $dataProvider */
|
||||||
|
|
||||||
|
$this->title = '公告管理';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="announcements-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('发布公告', ['announcements-create'], ['class' => 'btn btn-success']) ?>
|
||||||
|
</p>
|
||||||
|
<p>Tips: 只有最新的三条公告对用户可见</p>
|
||||||
|
<?php Pjax::begin(); ?>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'filterModel' => $searchModel,
|
||||||
|
'columns' => [
|
||||||
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
'id',
|
||||||
|
[
|
||||||
|
'attribute' => 'title',
|
||||||
|
'format' => 'raw',
|
||||||
|
'value' => function (Announcements $model) {
|
||||||
|
return Html::a($model->title, ['announcements-view', 'id' => $model->id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'content',
|
||||||
|
'label' => '内容',
|
||||||
|
// if the content is too long, only show the first 30 characters
|
||||||
|
'value' => function (Announcements $model) {
|
||||||
|
return mb_substr($model->content, 0, 30) . '...';
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
'published_at',
|
||||||
|
'updated_at',
|
||||||
|
[
|
||||||
|
'class' => ActionColumn::class,
|
||||||
|
'urlCreator' => function ($action, Announcements $model, $key, $index, $column) {
|
||||||
|
if ($action === 'view') {
|
||||||
|
return Url::to(['announcements-view', 'id' => $model->id]);
|
||||||
|
} elseif ($action === 'update') {
|
||||||
|
return Url::to(['announcements-update', 'id' => $model->id]);
|
||||||
|
} else { //delete
|
||||||
|
return Url::to(['announcements-delete', 'id' => $model->id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<?php Pjax::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
21
views/admin/announcements_update.php
Normal file
21
views/admin/announcements_update.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\Announcements $model */
|
||||||
|
|
||||||
|
$this->title = '修改公告: ' . $model->title;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => '公告管理', 'url' => ['announcements-manage']];
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => '公告ID '.$model->id, 'url' => ['announcements-view', 'id' => $model->id]];
|
||||||
|
$this->params['breadcrumbs'][] = '修改公告';
|
||||||
|
?>
|
||||||
|
<div class="announcements-update">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_announcements_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
41
views/admin/announcements_view.php
Normal file
41
views/admin/announcements_view.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\web\YiiAsset;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
|
/** @var yii\web\View $this */
|
||||||
|
/** @var app\models\Announcements $model */
|
||||||
|
|
||||||
|
$this->title = '公告ID '.$model->id;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => '公告管理', 'url' => ['announcements-manage']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
YiiAsset::register($this);
|
||||||
|
?>
|
||||||
|
<div class="announcements-view">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('修改公告', ['announcements-update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::a('删除公告', ['announcements-delete', 'id' => $model->id], [
|
||||||
|
'class' => 'btn btn-danger',
|
||||||
|
'data' => [
|
||||||
|
'confirm' => '你确定要删除这条公告?',
|
||||||
|
'method' => 'post',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= DetailView::widget([
|
||||||
|
'model' => $model,
|
||||||
|
'attributes' => [
|
||||||
|
'id',
|
||||||
|
'title',
|
||||||
|
'content:ntext',
|
||||||
|
'published_at',
|
||||||
|
'updated_at',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
@ -76,7 +76,7 @@ $this->registerCssFile('@web/css/fuckyou-navpadding.css');
|
|||||||
['label' => '用户管理', 'url' => ['/admin/user']],
|
['label' => '用户管理', 'url' => ['/admin/user']],
|
||||||
['label' => '文件分享管理', 'url' => ['/admin/share-manage']],
|
['label' => '文件分享管理', 'url' => ['/admin/share-manage']],
|
||||||
['label' => '文件收集管理', 'url' => ['/admin/collection-manage']],
|
['label' => '文件收集管理', 'url' => ['/admin/collection-manage']],
|
||||||
['label' => '站点公告管理', 'url' => ['/admin/notice-manage']], // 未完工
|
['label' => '站点公告管理', 'url' => ['/admin/announcements-manage']],
|
||||||
['label' => '工单支持管理', 'url' => ['/admin/ticket-manage']],
|
['label' => '工单支持管理', 'url' => ['/admin/ticket-manage']],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user