title = '工单: ' . $model->title; $this->params['breadcrumbs'][] = ['label' => '工单支持', 'url' => ['index']]; $this->params['breadcrumbs'][] = '工单ID ' . $model->id; YiiAsset::register($this); QuillAsset::register($this); FontAwesomeAsset::register($this); $this->registerCssFile('@web/css/tickets.css'); ?>

title) ?>


$model, 'attributes' => [ 'id', [ 'attribute' => 'status', 'label' => '状态', 'format' => 'raw', // 使用 raw 格式,这样 Yii2 不会对 value 的返回值进行 HTML 编码 'value' => function (Tickets $model) { return match ($model->status) { Tickets::STATUS_OPEN => '工单已开启', Tickets::STATUS_ADMIN_REPLY => '管理员已回复', Tickets::STATUS_USER_REPLY => '用户已回复', Tickets::STATUS_CLOSED => '工单已关闭', default => '未知状态', }; } ], [ '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) . ')'; } ] ], ]) ?>

status===Tickets::STATUS_CLOSED)?'':Html::a('关闭工单', ['delete', 'id' => $model->id], [ 'class' => 'btn btn-danger', 'data' => [ 'confirm' => '您确定要关闭这个工单吗?问题已经解决了吗?', 'method' => 'post', ], ]) ?>

'btn btn-primary', 'id' => 'send']) ?>

id; // 你需要在这里设置正确的工单ID $.ajax({ url: 'index.php?r=tickets%2Freply', type: 'POST', data: { ticketId: ticketId, content: JSON.stringify(content) }, success: function(response) { // 处理服务器的响应 console.log(response); // 如果服务器返回的状态是成功,刷新页面 if (response.status === 'success') { location.reload(); } }, error: function(jqXHR, textStatus, errorThrown) { // 处理错误 console.error(textStatus, errorThrown); } }); }); function quillGetHTML(inputDelta,skipParse=false) { var delta = skipParse?inputDelta:JSON.parse(inputDelta); var tempQuill=new Quill(document.createElement("div")); tempQuill.setContents(delta); return tempQuill.root.innerHTML; } function generateReply(user, message, date) { return '
'+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); ?>