122 lines
3.6 KiB
Vue
122 lines
3.6 KiB
Vue
<script>
|
|
/** 加载 /ticket/config 中启用的工单通知;失败可手动重试,富文本经过统一清理后展示。 */
|
|
import { toDisplayString } from "vue";
|
|
import { onMounted } from "vue";
|
|
import { onBeforeUnmount } from "vue";
|
|
import { createBlock } from "vue";
|
|
import { ref } from "vue";
|
|
import { withCtx } from "vue";
|
|
import { createCommentVNode } from "vue";
|
|
import { createElementVNode } from "vue";
|
|
import { createTextVNode } from "vue";
|
|
import { unref } from "vue";
|
|
import { defineComponent } from "vue";
|
|
import { createVNode } from "vue";
|
|
import { openBlock } from "vue";
|
|
import { useApi } from "~/lib/auth.js";
|
|
import button from "primevue/button";
|
|
import message from "primevue/message";
|
|
import { n as sanitize_n } from "~/lib/sanitize.js";
|
|
var _ = [`innerHTML`],
|
|
v = Object.assign(
|
|
defineComponent({
|
|
__name: `TicketNotice`,
|
|
setup(u) {
|
|
let v = useApi(),
|
|
y = ref(``),
|
|
b = ref(``),
|
|
x = ref(!1),
|
|
S = !1;
|
|
async function C() {
|
|
// loading 防止重复请求,S 标记卸载,异步响应不应写入已离开的页面。
|
|
if (!x.value) {
|
|
((x.value = !0), (b.value = ``));
|
|
try {
|
|
let e = await v.get(`/ticket/config`);
|
|
if (S) return;
|
|
y.value =
|
|
Number(e.ticket_notice_open) === 1
|
|
? sanitize_n(e.ticket_notice_description || ``)
|
|
: ``;
|
|
} catch (e) {
|
|
S ||
|
|
(b.value =
|
|
e instanceof Error ? e.message : `工单通知说明加载失败`);
|
|
} finally {
|
|
S || (x.value = !1);
|
|
}
|
|
}
|
|
}
|
|
return (
|
|
onMounted(C),
|
|
onBeforeUnmount(() => {
|
|
S = !0;
|
|
}),
|
|
(t, n) => {
|
|
let i = message,
|
|
u = button;
|
|
return unref(y)
|
|
? (openBlock(),
|
|
createBlock(
|
|
i,
|
|
{
|
|
key: 0,
|
|
severity: `info`,
|
|
closable: !1,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
createElementVNode(
|
|
`div`,
|
|
{
|
|
innerHTML: unref(y),
|
|
},
|
|
null,
|
|
8,
|
|
_,
|
|
),
|
|
]),
|
|
_: 1,
|
|
},
|
|
))
|
|
: unref(b)
|
|
? (openBlock(),
|
|
createBlock(
|
|
i,
|
|
{
|
|
key: 1,
|
|
severity: `warn`,
|
|
closable: !1,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
createTextVNode(toDisplayString(unref(b)) + ` `, 1),
|
|
createVNode(
|
|
u,
|
|
{
|
|
label: `重试通知说明`,
|
|
text: ``,
|
|
loading: unref(x),
|
|
onClick: C,
|
|
},
|
|
null,
|
|
8,
|
|
[`loading`],
|
|
),
|
|
]),
|
|
_: 1,
|
|
},
|
|
))
|
|
: createCommentVNode(``, !0);
|
|
}
|
|
);
|
|
},
|
|
}),
|
|
{
|
|
__name: `TicketNotice`,
|
|
},
|
|
);
|
|
export {};
|
|
export default v;
|
|
</script>
|