支持工单功能(4/10)

*前端改进
*导航栏调整位置
This commit is contained in:
Chenx221 2024-04-18 15:22:02 +08:00
parent bdb66e167a
commit 3a4e552e78
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
2 changed files with 33 additions and 4 deletions

View File

@ -83,7 +83,7 @@ FontAwesomeAsset::register($this);
}, },
'delete' => function ($url, $model, $key) { 'delete' => function ($url, $model, $key) {
if ($model->status !== Tickets::STATUS_CLOSED) { if ($model->status !== Tickets::STATUS_CLOSED) {
return Html::a('<i class="fa-solid fa-xmark"></i>', $url, [ return Html::a('<i class="fa-solid fa-xmark"></i>', ['delete', 'id' => $model->id, 'from' => 'index'], [
'title' => '关闭工单', 'title' => '关闭工单',
'data-pjax' => '0', 'data-pjax' => '0',
'data-confirm' => '你确定要关闭这个工单吗?', 'data-confirm' => '你确定要关闭这个工单吗?',

View File

@ -72,10 +72,10 @@ $this->registerCssFile('@web/css/tickets.css');
], ],
]) ?> ]) ?>
<p> <p>
<?= Html::a('关闭工单', ['delete', 'id' => $model->id], [ <?= ($model->status===Tickets::STATUS_CLOSED)?'':Html::a('关闭工单', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger', 'class' => 'btn btn-danger',
'data' => [ 'data' => [
'confirm' => 'Are you sure you want to delete this item?', 'confirm' => '您确定要关闭这个工单吗?问题已经解决了吗?',
'method' => 'post', 'method' => 'post',
], ],
]) ?> ]) ?>
@ -103,7 +103,36 @@ $core_js = <<<JS
const quill = new Quill('#editor', { const quill = new Quill('#editor', {
theme: theme theme: theme
}); });
$('#send').on('click', function() {
var content = quill.getContents();
// check content not empty
if (quill.getLength()===1) {
alert('内容不能为空');
return false;
}
var ticketId = $model->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) { function quillGetHTML(inputDelta,skipParse=false) {
var delta = skipParse?inputDelta:JSON.parse(inputDelta); var delta = skipParse?inputDelta:JSON.parse(inputDelta);
var tempQuill=new Quill(document.createElement("div")); var tempQuill=new Quill(document.createElement("div"));