+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ [
+ 'attribute' => 'status',
+ 'label' => '状态',
+ 'format' => 'raw', // 使用 raw 格式,这样 Yii2 不会对 value 的返回值进行 HTML 编码
+ 'value' => function (Tickets $model) {
+ switch ($model->status) {
+ case Tickets::STATUS_OPEN:
+ return '
工单已开启';
+ case Tickets::STATUS_ADMIN_REPLY:
+ return '
管理员已回复';
+ case Tickets::STATUS_USER_REPLY:
+ return '
用户已回复';
+ case Tickets::STATUS_CLOSED:
+ return '
工单已关闭';
+ default:
+ return '
未知状态';
+ }
+ }
+ ],
+ [
+ 'attribute' => 'created_at',
+ 'label' => '创建时间',
+ 'format' => 'raw', // 使用 raw 格式,这样 Yii2 不会对 value 的返回值进行 HTML 编码
+ 'value' => function (Tickets $model) {
+ $dateTime = new DateTime($model->created_at, new DateTimeZone('GMT+8'));
+ return $model->created_at . '
(' . Yii::$app->formatter->asRelativeTime($dateTime) . ')';
+ }
+ ],
+ [
+ 'attribute' => 'updated_at',
+ 'label' => '最近更新时间',
+ 'format' => 'raw', // 使用 raw 格式,这样 Yii2 不会对 value 的返回值进行 HTML 编码
+ 'value' => function (Tickets $model) {
+ $dateTime = new DateTime($model->updated_at, new DateTimeZone('GMT+8'));
+ return $model->updated_at . '
(' . Yii::$app->formatter->asRelativeTime($dateTime) . ')';
+ }
+ ]
+ ],
+ ]) ?>
+
+ = Html::a('关闭工单', ['delete', 'id' => $model->id], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => 'Are you sure you want to delete this item?',
+ 'method' => 'post',
+ ],
+ ]) ?>
+
+
+
+
+
+ = Html::button('发送', ['class' => 'btn btn-primary', 'id' => 'send']) ?>
+ = Html::button('重置', ['class' => 'btn btn-link', 'id' => 'reset']) ?>
+