添加 快速工单
This commit is contained in:
parent
1e82681ee9
commit
54d7b36786
30
app/Http/Controllers/Api/TicketController.php
Normal file
30
app/Http/Controllers/Api/TicketController.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Support\WHMCS;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class TicketController extends Controller
|
||||
{
|
||||
public function submit(Request $request, string $provider) {
|
||||
$request->validate([
|
||||
'title' => 'required',
|
||||
'content' => 'required',
|
||||
]);
|
||||
|
||||
try {
|
||||
$whmcs = new WHMCS($provider);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('提供商不存在');
|
||||
}
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
$result = $whmcs->api_openTicket($user->email, $request->input('title'), $request->input('content'));
|
||||
|
||||
return $this->success($result);
|
||||
|
||||
}
|
||||
}
|
@ -137,4 +137,14 @@ public function api_addTraffic(string $email, string $payment, int|float $traffi
|
||||
]);
|
||||
}
|
||||
|
||||
public function api_openTicket(string $email, string $title, string $content)
|
||||
{
|
||||
return $this->api('openTicket', [
|
||||
'email' => $email,
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'department_id' => $this->config['department_id'] ?? 1,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
'test' => [
|
||||
'url' => 'http://whmcs.test',
|
||||
'api_token' => 'abc123456',
|
||||
'department_id' => 1,
|
||||
'payments' => [
|
||||
'laeFastPay' => '莱云 快捷支付',
|
||||
'mailin' => '邮入',
|
||||
|
@ -52,7 +52,10 @@ const items = ref([
|
||||
name: "充值",
|
||||
route: "charge",
|
||||
},
|
||||
|
||||
{
|
||||
name: "发工单",
|
||||
route: "ticket",
|
||||
},
|
||||
{
|
||||
name: "客户端下载",
|
||||
route: "downloads",
|
||||
|
@ -59,6 +59,14 @@ const routes = [
|
||||
title: "流量充值",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/ticket",
|
||||
name: "ticket",
|
||||
component: () => import("../views/Ticket.vue"),
|
||||
meta: {
|
||||
title: "发布工单",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
|
139
resources/js/views/Ticket.vue
Normal file
139
resources/js/views/Ticket.vue
Normal file
@ -0,0 +1,139 @@
|
||||
<template>
|
||||
<div>
|
||||
<h3>发工单</h3>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h5>有遇到什么问题吗?</h5>
|
||||
|
||||
<div class="mb-3">
|
||||
您可以选择以下常见问题:
|
||||
<a @click="common_domain" class="link">域名白名单</a>
|
||||
|
||||
<a @click="common_problem" class="link">映射问题</a>
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<input
|
||||
autofocus
|
||||
type="text"
|
||||
class="form-control"
|
||||
placeholder="简要概述您遇到的问题"
|
||||
v-model="title"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="input-group" v-if="title">
|
||||
<textarea
|
||||
class="form-control"
|
||||
v-model="content"
|
||||
placeholder="详细说明您遇到的问题..."
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<div v-if="title">
|
||||
<div v-if="providers">
|
||||
<h5 class="mt-3">选择发工单的平台</h5>
|
||||
<p>如果您在选中的平台没有账号,我们将会帮您自动创建一个。</p>
|
||||
<template v-for="p in providers">
|
||||
<div class="form-group form-check">
|
||||
<input
|
||||
type="radio"
|
||||
class="form-check-input"
|
||||
name="provider"
|
||||
:id="'providers_' + p"
|
||||
:value="p"
|
||||
v-model.value="provider"
|
||||
/>
|
||||
<label
|
||||
v-text="p"
|
||||
class="form-check-label"
|
||||
:for="'providers_' + p"
|
||||
></label>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else>
|
||||
<h5 class="mt-3">暂时没有可用的提供商</h5>
|
||||
</div>
|
||||
|
||||
<div v-if="content">
|
||||
<button
|
||||
class="btn btn-primary mt-3"
|
||||
@click="submit"
|
||||
v-text="loading ? '请稍后' : '创建工单'"
|
||||
:disabled="loading"
|
||||
></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="loading">正在打开工单...</p>
|
||||
|
||||
<div v-if="link" class="mt-3">
|
||||
<h5>完成</h5>
|
||||
<p>如果您浏览器没有打开新的创建,请点击以下链接来打开。</p>
|
||||
<a :href="link" class="link" target="_blank">打开工单</a>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
|
||||
import http from "../plugins/http";
|
||||
|
||||
const providers = ref([]);
|
||||
const provider = ref("");
|
||||
|
||||
const title = ref("");
|
||||
const content = ref("");
|
||||
|
||||
const link = ref("");
|
||||
const loading = ref(false);
|
||||
|
||||
http.get("providers").then((res) => {
|
||||
providers.value = res.data;
|
||||
|
||||
// 选择第一个(如果有)
|
||||
if (providers.value.length > 0) {
|
||||
provider.value = providers.value[0];
|
||||
}
|
||||
});
|
||||
|
||||
function submit() {
|
||||
loading.value = true;
|
||||
http.post("providers/" + provider.value + "/ticket", {
|
||||
title: title.value,
|
||||
content: content.value,
|
||||
})
|
||||
.then((res) => {
|
||||
link.value = res.data.redirect_url;
|
||||
|
||||
setTimeout(() => {
|
||||
window.open(link.value, "_blank");
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
function common_domain() {
|
||||
title.value = "域名 {你的域名} 过白。";
|
||||
content.value =
|
||||
"您好,我的域名已备案,请将我的域名 {你的域名} 加入白名单,谢谢。";
|
||||
}
|
||||
|
||||
function common_problem() {
|
||||
title.value = "{节点} 的隧道无法连接。";
|
||||
content.value =
|
||||
"您好,这个节点无法连接,请检查。";
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.link {
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
@ -6,6 +6,7 @@
|
||||
use App\Http\Controllers\Api\ServerController;
|
||||
use App\Http\Controllers\Api\TunnelController;
|
||||
use App\Http\Controllers\Api\PortManagerController;
|
||||
use App\Http\Controllers\Api\TicketController;
|
||||
use App\Http\Controllers\Api\TrafficController;
|
||||
use App\Http\Controllers\Application\UserController as ApplicationUserController;
|
||||
|
||||
@ -27,6 +28,7 @@
|
||||
Route::get('providers', [TrafficController::class, 'providers']);
|
||||
Route::get('providers/{provider}/payments', [TrafficController::class, 'payments']);
|
||||
Route::post('providers/{provider}/charge', [TrafficController::class, 'charge']);
|
||||
Route::post('providers/{provider}/ticket', [TicketController::class, 'submit']);
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user