Files

438 lines
16 KiB
Vue

<script>
// 实例服务概览:统一展示状态、配置与计费信息,并为符合条件的欠费实例提供续费入口。
import "~/assets/styles/FlowPacketPanel.-RJSx13z.css";
import "~/assets/styles/InstanceServiceInfo.BftSVIeW.css";
import { toDisplayString } from "vue";
import { renderList } from "vue";
import { normalizeClass } from "vue";
import { watch } from "vue";
import { defineAsyncComponent } from "vue";
import { createBlock } from "vue";
import { ref } from "vue";
import { withCtx } from "vue";
import { createCommentVNode } from "vue";
import { computed } from "vue";
import { isRef } from "vue";
import { createElementBlock } from "vue";
import { Fragment } 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 { navigateTo } from "#app";
import { loadModule } from "~/utils/load-module.js";
import button from "primevue/button";
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
import message from "primevue/message";
import { r as dict_r } from "~/lib/dict.js";
import { n as instance_status_n } from "~/lib/instance-status.js";
import { t as instance_status_t } from "~/lib/instance-status.js";
import tag from "primevue/tag";
import { c as instance_data_c } from "~/lib/instance-data.js";
import { i as instance_data_i } from "~/lib/instance-data.js";
import { l as instance_data_l } from "~/lib/instance-data.js";
import { n as configuration_display_n } from "~/lib/configuration-display.js";
import FlowPacketPanel from "~/components/instance/FlowPacketPanel.vue";
var N = defineAsyncComponent(() =>
loadModule(
() =>
import("~/components/instance/InstanceRenewDialog.vue").then(
(e) => e.default || e,
),
[],
import.meta.url,
),
),
P = {
class: `service-info`,
"aria-label": `实例信息`,
},
F = {
class: `service-heading`,
},
I = {
key: 2,
class: `traffic-recovery`,
},
L = {
key: 3,
class: `traffic-recovery`,
},
R = {
class: `service-rows`,
},
z = [`aria-label`],
B = Object.assign(
_plugin_vue_export_helper_t(
defineComponent({
__name: `InstanceServiceInfo`,
props: {
host: {},
module: {},
info: {},
},
emits: [`pay`],
setup(i, { emit: g }) {
let b = i,
S = g,
B = computed(() =>
instance_status_t(
b.info?.powerStatus ?? b.info?.power_status,
b.host.status,
),
),
V = computed(() =>
instance_status_n(
b.host,
b.info?.powerStatus ?? b.info?.power_status,
),
),
H = computed(
() =>
b.host.status === `Suspended` &&
b.host.suspend_type === `overdue`,
),
U = computed(() =>
Number(b.host.renew_forbidden) === 1
? `该实例已禁止续费,请联系支持`
: Number(b.host.change_billing_cycle_id) > 0
? `请先取消到期转换计划后再续费`
: [`onetime`, `on_demand`].includes(
b.host.billing_cycle || ``,
)
? `该计费方式不支持续费,请联系支持`
: ``,
),
W = ref(!1);
function G() {
H.value && !U.value && (W.value = !0);
}
watch([() => b.host.id, () => H.value, () => U.value], () => {
W.value = !1;
});
let K = ref(!1),
// 兼容模块详情与主机附加字段的结构,密码默认脱敏后再生成明细行。
q = computed(() => {
let e = b.info ?? {},
t = instance_data_l(e.raw ?? e),
n = instance_data_l(b.host.addition),
r = instance_data_l(e.image ?? t.image),
i = instance_data_l(t.model_config),
a = e.ip || b.host.ip || b.host.dedicate_ip || b.host.assign_ip,
o = configuration_display_n(b.module || ``, t, b.host),
s = String(e.password || n.password || ``);
return [
[`实例编号`, `#${b.host.id}`],
[`实例名称`, b.host.name || `—`],
[`配置摘要`, b.host.base_info || `—`],
[`区域`, o.region || `—`],
[`线路`, o.line || `—`],
[
`IP 地址`,
a || (b.host.status === `Pending` ? `待分配` : `未提供`),
],
[
`CPU`,
e.cpu
? `${e.cpu} ${b.module === `jy_dcim` ? `颗 CPU` : `核`}`
: i.cpu || `未提供`,
],
[`内存`, e.memory ? `${e.memory} GB` : i.memory || `未提供`],
[
`磁盘`,
instance_data_i(e.disks)
.map((e) => `${e.name} ${e.size} GB`)
.join(` / `) ||
i.disk ||
`未提供`,
],
[
`带宽`,
t.bw_show ||
(e.bw || t.bw || t.bandwidth
? `${e.bw || t.bw || t.bandwidth} Mbps`
: `未提供`),
],
[
`操作系统`,
r.name || b.host.image_name || n.image_name || `未提供`,
],
[`用户名`, e.username || n.username || `未提供`],
[
`连接端口`,
String(instance_data_c(e.port ?? n.port) || `未提供`),
],
[`密码`, s ? (K.value ? s : `••••••••`) : `未提供`],
[`计费周期`, b.host.billing_cycle_name || `—`],
[
`续费金额`,
b.host.renew_amount == null ? `—` : `¥${b.host.renew_amount}`,
],
[
`开通时间`,
b.host.active_time
? dict_r(b.host.active_time)
: b.host.status === `Pending` || b.host.status === `Unpaid`
? `尚未开通`
: `未提供`,
],
[`到期时间`, dict_r(b.host.due_time)],
];
}),
J = computed(() => {
let e = instance_data_l(b.info?.raw ?? b.info);
return instance_data_i(e.config_options ?? e.configoptions)
.map((e) => ({
label: String(e.option_name ?? e.name ?? ``),
value: String(e.sub_name ?? e.value ?? ``),
}))
.filter((e) => e.label && e.value);
});
return (r, o) => {
let l = tag,
g = message,
b = button,
w = FlowPacketPanel,
T = N;
return (
openBlock(),
createElementBlock(`section`, P, [
createElementVNode(`div`, F, [
(o[4] ||= createElementVNode(`h3`, null, `实例信息`, -1)),
createVNode(
l,
{
value: unref(B).label,
severity: unref(B).severity,
},
null,
8,
[`value`, `severity`],
),
]),
unref(V)
? (openBlock(),
createBlock(
g,
{
key: 0,
severity: `warn`,
closable: !1,
},
{
default: withCtx(() => [
createTextVNode(
`暂停原因:` + toDisplayString(unref(V)),
1,
),
]),
_: 1,
},
))
: i.host.status === `Pending`
? (openBlock(),
createBlock(
g,
{
key: 1,
severity: `info`,
closable: !1,
},
{
default: withCtx(() => [
...(o[5] ||= [
createTextVNode(
`实例开通中,IP 和连接信息将在开通完成后显示。`,
-1,
),
]),
]),
_: 1,
},
))
: createCommentVNode(``, !0),
unref(H)
? (openBlock(),
createElementBlock(`div`, I, [
createElementVNode(
`p`,
null,
toDisplayString(
unref(U) ||
`可选择续费周期并完成付款。付款后由平台处理恢复,请稍后刷新查看实例状态。`,
),
1,
),
createElementVNode(`div`, null, [
createVNode(
b,
{
label: `立即续费`,
disabled: !!unref(U),
onClick: G,
},
null,
8,
[`disabled`],
),
]),
]))
: createCommentVNode(``, !0),
i.host.status === `Suspended` &&
i.host.suspend_type === `overtraffic`
? (openBlock(),
createElementBlock(`div`, L, [
(o[6] ||= createElementVNode(
`p`,
null,
`可购买流量包补充可用流量。付款后由平台处理恢复,请稍后刷新查看实例状态。`,
-1,
)),
createVNode(
w,
{
"host-id": String(i.host.id),
module: i.module,
flow: null,
mode: `button`,
onPay: (o[0] ||= (e) => S(`pay`, e)),
},
null,
8,
[`host-id`, `module`],
),
]))
: createCommentVNode(``, !0),
createElementVNode(`dl`, R, [
(openBlock(!0),
createElementBlock(
Fragment,
null,
renderList(
unref(q),
([t, r]) => (
openBlock(),
createElementBlock(
`div`,
{
key: t,
},
[
createElementVNode(
`dt`,
null,
toDisplayString(t),
1,
),
createElementVNode(`dd`, null, [
createTextVNode(toDisplayString(r), 1),
t === `密码` && r !== `未提供`
? (openBlock(),
createElementBlock(
`button`,
{
key: 0,
type: `button`,
class: `password-toggle`,
"aria-label": unref(K)
? `隐藏密码`
: `显示密码`,
onClick: (o[1] ||= (e) =>
(K.value = !unref(K))),
},
[
createElementVNode(
`i`,
{
class: normalizeClass([
`pi`,
unref(K)
? `pi-eye-slash`
: `pi-eye`,
]),
},
null,
2,
),
],
8,
z,
))
: createCommentVNode(``, !0),
]),
],
)
),
),
128,
)),
(openBlock(!0),
createElementBlock(
Fragment,
null,
renderList(
unref(J),
(t, n) => (
openBlock(),
createElementBlock(
`div`,
{
key: `config-${n}`,
},
[
createElementVNode(
`dt`,
null,
toDisplayString(t.label),
1,
),
createElementVNode(
`dd`,
null,
toDisplayString(t.value),
1,
),
],
)
),
),
128,
)),
]),
unref(W)
? (openBlock(),
createBlock(
T,
{
key: 4,
modelValue: unref(W),
"onUpdate:modelValue": (o[2] ||= (e) =>
isRef(W) ? (W.value = e) : null),
"host-id": String(i.host.id),
onPaid: (o[3] ||= (e) =>
(`navigateTo` in r
? r.navigateTo
: unref(navigateTo))(`/orders`)),
},
null,
8,
[`modelValue`, `host-id`],
))
: createCommentVNode(``, !0),
])
);
};
},
}),
[[`__scopeId`, `data-v-0ff5d554`]],
),
{
__name: `InstanceServiceInfo`,
},
);
export {};
export default B;
</script>