diff --git a/views/tickets/_form.php b/views/tickets/_form.php index d6c4aee..cd96494 100644 --- a/views/tickets/_form.php +++ b/views/tickets/_form.php @@ -1,11 +1,13 @@
@@ -14,7 +16,15 @@ use yii\widgets\ActiveForm; field($model, 'title')->textInput(['maxlength' => true]) ?> - field($model, 'description')->textarea(['rows' => 6]) ?> + field($model, 'description')->hiddenInput()->label(false) ?> + + + +
+ +
+ +
'btn btn-success']) ?> @@ -23,3 +33,23 @@ use yii\widgets\ActiveForm;
+registerJs($js); +?> \ No newline at end of file diff --git a/views/tickets/create.php b/views/tickets/create.php index 589860e..35f3302 100644 --- a/views/tickets/create.php +++ b/views/tickets/create.php @@ -18,3 +18,5 @@ $this->params['breadcrumbs'][] = $this->title; ]) ?>
+ + diff --git a/views/tickets/view.php b/views/tickets/view.php index 5e35e59..b1bfdbb 100644 --- a/views/tickets/view.php +++ b/views/tickets/view.php @@ -1,43 +1,140 @@ title = '工单: '.$model->title; +$this->title = '工单: ' . $model->title; $this->params['breadcrumbs'][] = ['label' => '工单支持', 'url' => ['index']]; -$this->params['breadcrumbs'][] = '工单ID '.$model->id; +$this->params['breadcrumbs'][] = '工单ID ' . $model->id; YiiAsset::register($this); +QuillAsset::register($this); +FontAwesomeAsset::register($this); +$this->registerCssFile('@web/css/tickets.css'); ?> -
+
-

title) ?>

+

title) ?>

+
-

- $model->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', - ], - ]) ?> -

- $model, - 'attributes' => [ - 'id', - 'user_id', - 'title', - 'description:ntext', - 'status', - 'created_at', - 'updated_at', - 'ip', - ], - ]) ?> +
+
+ + $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) . ')'; + } + ] + ], + ]) ?> +

+ $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+
+
+ +
+ +
-
+
+
+ 'btn btn-primary', 'id' => 'send']) ?> + 'btn btn-link', 'id' => 'reset']) ?> +
+
+ +
+
+
+ +
+
'+user+'
用户
'+date+'
'+message+'
'; + } + function generateAdminReply(user, message, date) { + return '
'+user+'
管理员
'+date+'
'+message+'
'; + } + var ticketContent = $model->description; + var ticketContentElement = $('#ticket-content'); + ticketContentElement.append(generateReply('您', quillGetHTML(ticketContent,true), '$model->created_at')); + var TicketReplies = $ticketReplies; + for (let i = 0; i < TicketReplies.length; i++) { + let reply = TicketReplies[i]; + let message = quillGetHTML(reply.message); + let date = reply.created_at; + if (reply.is_admin !== 1) { + ticketContentElement.append(generateReply(reply.name, message, date)); + } else { + ticketContentElement.append(generateAdminReply(reply.name, message, date)); + } + } + +JS; + +$this->registerJs($core_js); +?> \ No newline at end of file diff --git a/web/css/tickets.css b/web/css/tickets.css new file mode 100644 index 0000000..51859d4 --- /dev/null +++ b/web/css/tickets.css @@ -0,0 +1,35 @@ +.ticket-reply { + margin-bottom: 24px; + border: 1px solid #e6e8ec; + background: #fff; + border-radius: 4px; +} +.ticket-reply-top { + border-bottom: 1px solid #e6e8ec; + background: #f6f7f8; + padding: 10px 15px; +} +.ticket-reply .user i { + color: #b9bdc5; + margin-right: 6px; +} +.ticket-reply .info { + display: flex; + justify-content: space-between; + font-size: 12px; + line-height: 18px; + color: #7c8088; +} +.ticket-reply .ticket-message { + padding: 25px 15px; +} +.ticket-reply.admin { + border-color: #d5e7fb; +} +.ticket-reply.admin .ticket-reply-top { + background-color: #e3effc; + border-color: #d5e7fb; +} +.ticket-reply.admin .user i { + color: #1062fe; +} \ No newline at end of file