1872 lines
96 KiB
Vue
1872 lines
96 KiB
Vue
<script>
|
|
/** 财务对接型商品配置:将不同财务模块返回值归一化为资源、周期、自定义字段及级联选项。 */
|
|
import "~/assets/styles/ConfigDiskCard.Dx9IqqQ_.css";
|
|
import "~/assets/styles/PromoCodeField.qFEkB6Hm.css";
|
|
import "~/assets/styles/ProductCustomFields.B2QMnPil.css";
|
|
import "~/assets/styles/OsIcon.CAi4Iz2S.css";
|
|
import "~/assets/styles/FinanceConfig.CLwX1CC8.css";
|
|
import { nextTick } from "vue";
|
|
import { toDisplayString } from "vue";
|
|
import { renderList } from "vue";
|
|
import { onMounted } from "vue";
|
|
import { useId } from "vue";
|
|
import { normalizeClass } from "vue";
|
|
import { onBeforeUnmount } from "vue";
|
|
import { renderSlot } from "vue";
|
|
import { watch } from "vue";
|
|
import { createBlock } from "vue";
|
|
import { ref } from "vue";
|
|
import { withCtx } from "vue";
|
|
import { createCommentVNode } from "vue";
|
|
import { createSlots } from "vue";
|
|
import { computed } from "vue";
|
|
import { isRef } from "vue";
|
|
import { createElementBlock } from "vue";
|
|
import { shallowRef } 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 { withKeys } from "vue";
|
|
import { navigateTo } from "#app";
|
|
import { useApi } from "~/lib/auth.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 select from "primevue/select";
|
|
import inputnumber from "primevue/inputnumber";
|
|
import { t as os_name_t } from "~/lib/os-name.js";
|
|
import { r as configuration_display_r } from "~/lib/configuration-display.js";
|
|
import { t as configuration_display_t } from "~/lib/configuration-display.js";
|
|
import { i as product_fields_i } from "~/lib/product-fields.js";
|
|
import { t as product_fields_t } from "~/lib/product-fields.js";
|
|
import { a as storage_capacity_a } from "~/lib/storage-capacity.js";
|
|
import { i as storage_capacity_i } from "~/lib/storage-capacity.js";
|
|
import { n as storage_capacity_n } from "~/lib/storage-capacity.js";
|
|
import { r as storage_capacity_r } from "~/lib/storage-capacity.js";
|
|
import { t as storage_capacity_t } from "~/lib/storage-capacity.js";
|
|
import ConfigLoadingShell from "~/components/config/ConfigLoadingShell.vue";
|
|
import ConfigChoiceGrid from "~/components/config/ConfigChoiceGrid.vue";
|
|
import ProductCustomFields from "~/components/config/ProductCustomFields.vue";
|
|
import ConfigCheckout from "~/components/config/ConfigCheckout.vue";
|
|
import { n as cart_edit_n } from "~/lib/cart-edit.js";
|
|
import { o as cart_edit_o } from "~/lib/cart-edit.js";
|
|
import { r as cart_edit_r } from "~/lib/cart-edit.js";
|
|
import ConfigDiskCard from "~/components/config/ConfigDiskCard.vue";
|
|
function ie(e, t = `remf_finance`, n = {}) {
|
|
// storage-capacity 模块负责协议解析与联动约束,此处负责请求编排和已确认报价状态。
|
|
let r = useApi(),
|
|
i = n.edit,
|
|
a = ref(!i),
|
|
s = cart_edit_r(r, i),
|
|
l = shallowRef(null),
|
|
d = ref({}),
|
|
f = ref({}),
|
|
p = ref({}),
|
|
h = computed(() =>
|
|
(l.value?.options ?? []).flatMap((e) => [
|
|
e,
|
|
...(f.value[e.id]?.options ?? []),
|
|
]),
|
|
),
|
|
g = computed(() => {
|
|
try {
|
|
return {
|
|
links: l.value?.linkDefinitions
|
|
? storage_capacity_i(l.value.linkDefinitions, h.value)
|
|
: (l.value?.links ?? []),
|
|
error: ``,
|
|
};
|
|
} catch (e) {
|
|
return {
|
|
links: [],
|
|
error: e instanceof Error ? e.message : `商品联动配置数据不完整`,
|
|
};
|
|
}
|
|
}),
|
|
v = computed(() => g.value.links),
|
|
y = computed(() => storage_capacity_n(h.value, v.value, d.value)),
|
|
b = ref({}),
|
|
x = ref(``),
|
|
S = ref(``),
|
|
C = ref(``),
|
|
w = ref(1),
|
|
T = ref(`—`),
|
|
E = ref(``),
|
|
D = ref(0),
|
|
O = ref(0),
|
|
k = ref(!0),
|
|
A = ref(!1),
|
|
j = ref(``),
|
|
M = ref(``),
|
|
N = ref(!1),
|
|
P = !1,
|
|
B = 0,
|
|
V = 0,
|
|
H = 0,
|
|
U = computed(() =>
|
|
JSON.stringify({
|
|
options: d.value,
|
|
cycle: C.value,
|
|
qty: w.value,
|
|
promo: E.value,
|
|
hostname: x.value,
|
|
password: S.value,
|
|
fields: b.value,
|
|
}),
|
|
),
|
|
W = computed(
|
|
() =>
|
|
a.value &&
|
|
!k.value &&
|
|
!P &&
|
|
!A.value &&
|
|
!!M.value &&
|
|
U.value === M.value,
|
|
);
|
|
function K() {
|
|
(V++,
|
|
(M.value = ``),
|
|
(T.value = `—`),
|
|
(A.value = !1),
|
|
(D.value = 0),
|
|
(O.value = 0));
|
|
}
|
|
(watch(U, K, {
|
|
flush: `sync`,
|
|
}),
|
|
onBeforeUnmount(() => {
|
|
((P = !0), B++, K());
|
|
}));
|
|
function ie() {
|
|
// 当前周期、数量、库存及每项资源都必须属于有效集合,前端不能提交已被联动排除的值。
|
|
let e = l.value;
|
|
if (!e) throw Error(`请先加载商品配置`);
|
|
if (g.value.error) throw Error(g.value.error);
|
|
if (!e.cycles.some((e) => e.value === C.value))
|
|
throw Error(`请选择有效的购买时长`);
|
|
if (
|
|
!Number.isSafeInteger(w.value) ||
|
|
w.value < 1 ||
|
|
(!e.allowQty && w.value !== 1)
|
|
)
|
|
throw Error(`购买数量无效`);
|
|
if (e.stock !== null && w.value > e.stock) throw Error(`当前商品库存不足`);
|
|
for (let e of y.value) {
|
|
let t = d.value[e.id];
|
|
if (typeof t != `number` || !Number.isFinite(t))
|
|
throw Error(`请选择${e.label}`);
|
|
if (e.kind === `quantity`) {
|
|
if (
|
|
!(
|
|
e.ranges?.length
|
|
? e.ranges
|
|
: [
|
|
{
|
|
min: e.min,
|
|
max: e.max,
|
|
step: e.step,
|
|
},
|
|
]
|
|
).some(
|
|
(e) =>
|
|
t >= e.min &&
|
|
t <= e.max &&
|
|
Math.abs(
|
|
(t - e.min) / e.step - Math.round((t - e.min) / e.step),
|
|
) < 1e-7,
|
|
)
|
|
)
|
|
throw Error(`${e.label}超出可选范围`);
|
|
} else if (!e.choices.some((e) => e.value === t))
|
|
throw Error(`请选择有效的${e.label}`);
|
|
}
|
|
}
|
|
function ae(e = !1) {
|
|
// 报价只提交配置与周期;真正下单时才按商品要求附带开通主机名和密码。
|
|
let t = l.value,
|
|
n = {
|
|
configoption: Object.fromEntries(
|
|
y.value.map((e) => [e.id, d.value[e.id]]),
|
|
),
|
|
cycle: C.value,
|
|
promo_code: E.value,
|
|
event_promotion: ``,
|
|
};
|
|
return (
|
|
e &&
|
|
(t.hostname.show && (n.host = x.value),
|
|
t.password.show && (n.password = S.value)),
|
|
n
|
|
);
|
|
}
|
|
function oe(e) {
|
|
let t =
|
|
e.config_options &&
|
|
typeof e.config_options == `object` &&
|
|
!Array.isArray(e.config_options)
|
|
? cart_edit_n(e.config_options)
|
|
: {},
|
|
n =
|
|
t.configoption &&
|
|
typeof t.configoption == `object` &&
|
|
!Array.isArray(t.configoption)
|
|
? t.configoption
|
|
: {};
|
|
for (let e of l.value?.options ?? []) {
|
|
let t = n[e.id];
|
|
t !== void 0 && Number.isFinite(Number(t)) && (d.value[e.id] = Number(t));
|
|
}
|
|
let r = t.cycle ?? t.billing_cycle;
|
|
r !== void 0 &&
|
|
l.value?.cycles.some((e) => String(e.value) === String(r)) &&
|
|
(C.value = String(r));
|
|
let i = Number(e.qty);
|
|
Number.isInteger(i) && i > 0 && (w.value = i);
|
|
let a = t.host ?? t.hostname;
|
|
(a !== void 0 && (x.value = String(a)),
|
|
t.password !== void 0 && (S.value = String(t.password)));
|
|
let o =
|
|
e.customfield &&
|
|
typeof e.customfield == `object` &&
|
|
!Array.isArray(e.customfield)
|
|
? e.customfield
|
|
: {};
|
|
if (
|
|
o.cascaderParams &&
|
|
typeof o.cascaderParams == `object` &&
|
|
!Array.isArray(o.cascaderParams)
|
|
)
|
|
for (let [e, t] of Object.entries(o.cascaderParams))
|
|
Number.isSafeInteger(Number(t)) &&
|
|
Number(t) > 0 &&
|
|
(p.value[e] = Number(t));
|
|
let s = t.promo_code ?? o.promo_code;
|
|
Array.isArray(s)
|
|
? (E.value = String(s.find(Boolean) ?? ``))
|
|
: s != null && (E.value = String(s));
|
|
let c =
|
|
e.self_defined_field &&
|
|
typeof e.self_defined_field == `object` &&
|
|
!Array.isArray(e.self_defined_field)
|
|
? e.self_defined_field
|
|
: {};
|
|
for (let e of (l.value?.customFields ?? []).filter(
|
|
(e) => e.kind !== `explain`,
|
|
))
|
|
b.value[e.id] = String(c[e.id] ?? ``);
|
|
}
|
|
function se() {
|
|
// 反复应用本地联动直到稳定;重复快照意味着规则冲突,必须阻止继续报价。
|
|
let e = new Set();
|
|
for (let t = 0; t <= (l.value?.options.length ?? 0) * 2 + 2; t++) {
|
|
let t = JSON.stringify(d.value);
|
|
if (e.has(t)) throw Error(`商品联动条件相互冲突,请联系客服`);
|
|
e.add(t);
|
|
for (let e of y.value)
|
|
if (e.kind === `quantity`) {
|
|
if (!e.ranges?.length)
|
|
throw Error(`${e.label}没有符合当前条件的配置`);
|
|
let t = d.value[e.id];
|
|
e.ranges.some(
|
|
(e) =>
|
|
t !== void 0 &&
|
|
t >= e.min &&
|
|
t <= e.max &&
|
|
Math.abs(
|
|
(t - e.min) / e.step - Math.round((t - e.min) / e.step),
|
|
) < 1e-7,
|
|
) || (d.value[e.id] = e.ranges[0].min);
|
|
} else {
|
|
if (!e.choices.length)
|
|
throw Error(`${e.label}没有符合当前条件的配置`);
|
|
e.choices.some((t) => t.value === d.value[e.id]) ||
|
|
(d.value[e.id] = e.choices[0].value);
|
|
}
|
|
if (t === JSON.stringify(d.value)) return;
|
|
}
|
|
throw Error(`商品联动条件无法确定,请联系客服`);
|
|
}
|
|
async function ce(n) {
|
|
// 级联项在 HTTP 边界读取下一级资源,响应只属于当前配置快照和刷新代次。
|
|
for (let i of l.value?.options.filter((e) => e.kind === `cascade`) ?? []) {
|
|
let a = f.value[i.id],
|
|
o = d.value[i.id],
|
|
s = a?.options.find((e) => d.value[e.id] !== a.values[e.id]),
|
|
c = a
|
|
? a.rootValue === o
|
|
? s
|
|
? d.value[s.id]
|
|
: a.parameter
|
|
: o
|
|
: (p.value[i.id] ?? o);
|
|
if (a && a.rootValue === o && c === a.parameter && !s) continue;
|
|
let l = U.value,
|
|
u = await r.get(`/product/${e}/${t}/link`, {
|
|
id: e,
|
|
cid: Number(i.id),
|
|
sub_id: c,
|
|
});
|
|
if (P || H !== n || l !== U.value) return !1;
|
|
let m = storage_capacity_r(u, i.id),
|
|
h = new Set(
|
|
y.value.filter((e) => e.cascadeRoot !== i.id).map((e) => e.id),
|
|
);
|
|
if (m.options.some((e) => h.has(e.id)))
|
|
throw Error(`商品级联配置标识重复`);
|
|
for (let e of a?.options ?? []) delete d.value[e.id];
|
|
(Object.assign(d.value, m.values),
|
|
(f.value[i.id] = {
|
|
rootValue: o,
|
|
parameter: c,
|
|
...m,
|
|
}),
|
|
(p.value[i.id] = c));
|
|
}
|
|
return !0;
|
|
}
|
|
async function le() {
|
|
// 先让级联和联动达成一致,再校验与报价;未得到稳定配置不能接受服务端价格。
|
|
let t = ++H;
|
|
if ((K(), P || !l.value)) return;
|
|
j.value = ``;
|
|
try {
|
|
v.value.length && se();
|
|
let e = l.value.options.filter((e) => e.kind === `cascade`);
|
|
for (let n = 0; e.length; n++) {
|
|
if (n > e.length * 2 + 2)
|
|
throw Error(`商品级联与联动条件相互冲突,请联系客服`);
|
|
if (!(await ce(t))) return;
|
|
if (
|
|
(v.value.length && se(),
|
|
e.every((e) => {
|
|
let t = f.value[e.id];
|
|
return (
|
|
!!t &&
|
|
t.rootValue === d.value[e.id] &&
|
|
t.options.every((e) => t.values[e.id] === d.value[e.id])
|
|
);
|
|
}))
|
|
)
|
|
break;
|
|
}
|
|
ie();
|
|
} catch (e) {
|
|
t === H &&
|
|
!P &&
|
|
(j.value = e instanceof Error ? e.message : `商品配置无效`);
|
|
return;
|
|
}
|
|
if (t !== H || P) return;
|
|
let n = ++V,
|
|
i = U.value,
|
|
a = () => !P && n === V && i === U.value;
|
|
A.value = !0;
|
|
try {
|
|
let t = await r.post(`/product/${e}/config_option`, {
|
|
id: e,
|
|
config_options: ae(),
|
|
qty: w.value,
|
|
});
|
|
if (!a()) return;
|
|
let n = t?.price_total ?? t?.price;
|
|
if (
|
|
n == null ||
|
|
String(n).trim() === `` ||
|
|
!Number.isFinite(Number(n)) ||
|
|
Number(n) < 0
|
|
)
|
|
throw Error(`未获得有效报价,请重新计算`);
|
|
((T.value = String(n)),
|
|
(D.value = Number(t.price_promo_code_discount) || 0),
|
|
(O.value = Number(t.price_client_level_discount) || 0),
|
|
(M.value = i));
|
|
} catch (e) {
|
|
a() &&
|
|
(j.value = e instanceof Error ? e.message : `报价加载失败,请重试`);
|
|
} finally {
|
|
a() && (A.value = !1);
|
|
}
|
|
}
|
|
async function ue() {
|
|
// 仅支持明确列出的财务模块,读取原始 order_page 后统一解析,避免猜测接口数据结构。
|
|
((a.value = !i), H++);
|
|
let n = ++B;
|
|
(K(),
|
|
(k.value = !0),
|
|
(j.value = ``),
|
|
(l.value = null),
|
|
(f.value = {}),
|
|
(p.value = {}));
|
|
try {
|
|
if (
|
|
![`remf_finance`, `remf_finance_dcim`, `remf_finance_common`].includes(
|
|
t,
|
|
)
|
|
)
|
|
throw Error(`商品配置类型不受支持`);
|
|
let [o, s] = await Promise.all([
|
|
r.getRaw(`/product/${e}/${t}/order_page`),
|
|
r.get(`/product/${e}/self_defined_field/order_page`),
|
|
]);
|
|
if (P || n !== B) return;
|
|
if (!Array.isArray(s?.data))
|
|
throw Error(`商品自定义字段加载失败,请重试`);
|
|
let c = storage_capacity_a({
|
|
...o,
|
|
custom_fields: s.data,
|
|
});
|
|
((l.value = c),
|
|
(d.value = Object.fromEntries(
|
|
c.options.map((e) => [
|
|
e.id,
|
|
e.kind === `quantity`
|
|
? e.min
|
|
: e.kind === `boolean`
|
|
? 0
|
|
: e.choices[0].value,
|
|
]),
|
|
)),
|
|
(b.value = product_fields_t(c.customFields)),
|
|
(x.value = c.hostname.value),
|
|
(S.value = c.password.value),
|
|
(C.value = c.cycles[0].value),
|
|
(w.value = 1),
|
|
cart_edit_o(
|
|
i,
|
|
c.customFields.map((e) => e.id),
|
|
),
|
|
i && oe(i.item),
|
|
(a.value = !0),
|
|
await le());
|
|
} catch (e) {
|
|
!P &&
|
|
n === B &&
|
|
(j.value = e instanceof Error ? e.message : `加载商品配置失败`);
|
|
} finally {
|
|
!P && n === B && (k.value = !1);
|
|
}
|
|
}
|
|
async function de(t) {
|
|
// 最终提交包括开通信息、自定义字段及级联参数;编辑模式只能保存购物车不能直接结算。
|
|
if (i && t !== `/cart`) throw Error(`请先保存配置,再返回购物车结算`);
|
|
if (N.value) throw Error(`正在提交,请勿重复操作`);
|
|
if (!W.value) throw Error(`当前配置报价尚未确认,请等待或重新计算报价`);
|
|
ie();
|
|
let n = l.value;
|
|
if ((n.hostname.show && !x.value.trim()) || (n.password.show && !S.value))
|
|
throw Error(`系统生成的开通信息不完整,请重新加载配置`);
|
|
(product_fields_i(n.customFields, b.value), (N.value = !0));
|
|
try {
|
|
let a = {
|
|
product_id: e,
|
|
config_options: ae(!0),
|
|
qty: w.value,
|
|
customfield: {
|
|
promo_code: E.value,
|
|
event_promotion: ``,
|
|
...(Object.keys(p.value).length
|
|
? {
|
|
cascaderParams: {
|
|
...p.value,
|
|
},
|
|
}
|
|
: {}),
|
|
},
|
|
self_defined_field: Object.fromEntries(
|
|
n.customFields
|
|
.filter((e) => e.kind !== `explain`)
|
|
.map((e) => [e.id, b.value[e.id] ?? ``]),
|
|
),
|
|
};
|
|
if (t === `/cart` && i) {
|
|
let e = U.value;
|
|
return await s(a, () => !P && W.value && e === U.value);
|
|
}
|
|
let o = await r.post(t, a);
|
|
return (t === `/product/settle` && K(), o);
|
|
} finally {
|
|
N.value = !1;
|
|
}
|
|
}
|
|
return {
|
|
data: l,
|
|
availableOptions: y,
|
|
configForm: d,
|
|
customFields: b,
|
|
hostname: x,
|
|
password: S,
|
|
cycle: C,
|
|
qty: w,
|
|
price: T,
|
|
promoCode: E,
|
|
promoDiscount: D,
|
|
levelDiscount: O,
|
|
loading: k,
|
|
priceLoading: A,
|
|
error: j,
|
|
quoteReady: W,
|
|
init: ue,
|
|
calcPrice: le,
|
|
addToCart: () => de(`/cart`),
|
|
buyNow: () => de(`/product/settle`),
|
|
};
|
|
}
|
|
var ae = {
|
|
class: `config-page`,
|
|
},
|
|
oe = {
|
|
key: 1,
|
|
class: `panel config-load-error`,
|
|
},
|
|
se = {
|
|
key: 2,
|
|
class: `config-layout`,
|
|
},
|
|
ce = {
|
|
class: `config-options`,
|
|
},
|
|
le = {
|
|
class: `section-title`,
|
|
},
|
|
ue = {
|
|
class: `form-row`,
|
|
},
|
|
de = {
|
|
class: `form-row`,
|
|
},
|
|
fe = [`for`],
|
|
pe = {
|
|
key: 0,
|
|
class: `hint`,
|
|
},
|
|
me = [`aria-label`],
|
|
he = {
|
|
key: 2,
|
|
class: `form-row`,
|
|
},
|
|
ge = [`for`],
|
|
_e = {
|
|
key: 0,
|
|
class: `hint`,
|
|
},
|
|
ve = {
|
|
key: 3,
|
|
class: `form-row`,
|
|
},
|
|
ye = {
|
|
key: 0,
|
|
class: `hint`,
|
|
},
|
|
be = {
|
|
class: `form-row checkout-cycle`,
|
|
},
|
|
xe = [`for`],
|
|
Se = {
|
|
key: 0,
|
|
class: `form-row checkout-quantity`,
|
|
},
|
|
Ce = [`for`],
|
|
we = Object.assign(
|
|
_plugin_vue_export_helper_t(
|
|
defineComponent({
|
|
__name: `FinanceConfig`,
|
|
props: {
|
|
productId: {},
|
|
identityLocked: {
|
|
type: Boolean,
|
|
},
|
|
module: {
|
|
default: `remf_finance`,
|
|
},
|
|
edit: {},
|
|
},
|
|
emits: [`settled`],
|
|
setup(c, { emit: _ }) {
|
|
let S = c,
|
|
ee = _,
|
|
O = S.edit
|
|
? ie(S.productId, S.module, {
|
|
edit: S.edit,
|
|
})
|
|
: ie(S.productId, S.module),
|
|
{
|
|
data: F,
|
|
configForm: I,
|
|
customFields: L,
|
|
cycle: R,
|
|
qty: z,
|
|
price: te,
|
|
loading: ne,
|
|
priceLoading: re,
|
|
error: G,
|
|
quoteReady: we,
|
|
promoCode: Te,
|
|
promoDiscount: Ee,
|
|
levelDiscount: De,
|
|
} = O,
|
|
q = `finance-config-${useId()}`,
|
|
J = ref(null),
|
|
Y = computed(() => !!S.identityLocked || J.value !== null),
|
|
X = ref(``),
|
|
Z = ref(``),
|
|
Oe;
|
|
onBeforeUnmount(() => clearTimeout(Oe));
|
|
let ke = computed(
|
|
() =>
|
|
!!F.value &&
|
|
we.value &&
|
|
!re.value &&
|
|
!Y.value &&
|
|
F.value.cycles.some((e) => e.value === R.value) &&
|
|
F.value.stock !== 0,
|
|
),
|
|
Q = (e) =>
|
|
e.cascadeRoot
|
|
? e.label
|
|
: configuration_display_t(e.label, e.kind),
|
|
Ae = (e, t) =>
|
|
[`操作系统`, `镜像版本`].includes(Q(e))
|
|
? os_name_t(t)
|
|
: Q(e) === `网络类型`
|
|
? configuration_display_r(t)
|
|
: t;
|
|
function je(e) {
|
|
return e.kind === `os`
|
|
? `操作系统`
|
|
: /硬盘|磁盘|系统盘|数据盘|存储/.test(e.label)
|
|
? `存储配置`
|
|
: /带宽|流量|防御|防护|网络|IP|ipv[46]/i.test(e.label)
|
|
? `网络配置`
|
|
: `基础配置`;
|
|
}
|
|
let Me = computed(() =>
|
|
[`基础配置`, `存储配置`, `网络配置`, `操作系统`]
|
|
.map((e) => ({
|
|
title: e,
|
|
options: (
|
|
O.availableOptions?.value ??
|
|
F.value?.options ??
|
|
[]
|
|
).filter((t) => je(t) === e),
|
|
}))
|
|
.filter((e) => e.options.length),
|
|
),
|
|
Ne = (e) => je(e) === `存储配置`;
|
|
function Pe(e) {
|
|
return e.ranges?.length
|
|
? e.ranges
|
|
: [
|
|
{
|
|
min: e.min,
|
|
max: e.max,
|
|
step: e.step,
|
|
},
|
|
];
|
|
}
|
|
function Fe(e) {
|
|
return e.kind !== `choice` || !e.choices.length
|
|
? null
|
|
: e.choices.map((t) => ({
|
|
id: t.value,
|
|
label: t.label,
|
|
capacity: storage_capacity_t(t.label, e.unit),
|
|
}));
|
|
}
|
|
function $(e) {
|
|
return Fe(e)?.find((t) => t.id === I.value[e.id]);
|
|
}
|
|
function Ie(e) {
|
|
let t = Fe(e);
|
|
if (!t) return !1;
|
|
let n = t[0]?.capacity;
|
|
return (
|
|
!n ||
|
|
t.some(
|
|
(e) =>
|
|
!e.capacity ||
|
|
e.capacity.unit !== n.unit ||
|
|
e.capacity.type !== n.type,
|
|
) ||
|
|
new Set(t.map((e) => e.capacity?.size)).size !== t.length
|
|
);
|
|
}
|
|
function Le(e) {
|
|
return (
|
|
storage_capacity_t(`0`, e.unit)?.unit ||
|
|
(!e.unit.trim() &&
|
|
/系统盘|数据盘/.test(e.label) &&
|
|
!/数量|个数|块数|盘数/.test(e.label)
|
|
? `GB`
|
|
: ``)
|
|
);
|
|
}
|
|
function Re(e) {
|
|
if (e.kind === `quantity`)
|
|
return Le(e)
|
|
? Pe(e).map((e) => ({
|
|
type: `step`,
|
|
min_value: e.min,
|
|
max_value: e.max,
|
|
step: e.step,
|
|
}))
|
|
: [];
|
|
let t = $(e)?.capacity;
|
|
return Ie(e)
|
|
? t
|
|
? [
|
|
{
|
|
value: t.size,
|
|
},
|
|
]
|
|
: []
|
|
: (Fe(e)?.flatMap((e) =>
|
|
e.capacity
|
|
? [
|
|
{
|
|
value: e.capacity.size,
|
|
},
|
|
]
|
|
: [],
|
|
) ?? []);
|
|
}
|
|
function ze(e) {
|
|
return e.kind === `quantity` ? I.value[e.id] : $(e)?.capacity?.size;
|
|
}
|
|
function Be(e) {
|
|
return e.kind === `quantity` ? Le(e) : $(e)?.capacity?.unit || ``;
|
|
}
|
|
function Ve(e) {
|
|
return $(e)?.capacity?.type || (Re(e).length ? Q(e) : `存储选项`);
|
|
}
|
|
function He(e) {
|
|
let t = Re(e);
|
|
return (
|
|
t.length === 1 &&
|
|
(`value` in t[0] ||
|
|
(`min_value` in t[0] && t[0].min_value === t[0].max_value))
|
|
);
|
|
}
|
|
function Ue(e, t) {
|
|
if (Y.value) return;
|
|
if (e.kind === `quantity`) {
|
|
Ge(e, t, !1);
|
|
return;
|
|
}
|
|
if (Ie(e)) return;
|
|
let n = Fe(e)?.find((e) => e.capacity?.size === t);
|
|
n && (I.value[e.id] = n.id);
|
|
}
|
|
function We(e) {
|
|
let t = I.value[e.id] ?? e.min;
|
|
return Pe(e).find((e) => t >= e.min && t <= e.max)?.step ?? e.step;
|
|
}
|
|
function Ge(e, t, n = !0) {
|
|
// 数量输入在所有有效区间中吸附,跨区间的单步操作寻找下一个可达档位。
|
|
if (Y.value || t === null || !Number.isFinite(t)) return;
|
|
let r = I.value[e.id],
|
|
i = Pe(e),
|
|
a = e.min,
|
|
o = 1 / 0;
|
|
for (let e of i) {
|
|
let n =
|
|
e.min + Math.floor((e.max - e.min) / e.step + 1e-7) * e.step,
|
|
r = Number(
|
|
Math.max(
|
|
e.min,
|
|
Math.min(
|
|
n,
|
|
e.min + Math.round((t - e.min) / e.step) * e.step,
|
|
),
|
|
).toFixed(8),
|
|
);
|
|
Math.abs(r - t) < o && ((a = r), (o = Math.abs(r - t)));
|
|
}
|
|
if (a === r && Math.abs(t - r) === We(e)) {
|
|
let e = t > r,
|
|
n = i
|
|
.map((t) =>
|
|
e
|
|
? t.min +
|
|
Math.max(
|
|
0,
|
|
Math.floor((r - t.min) / t.step + 1e-7) + 1,
|
|
) *
|
|
t.step
|
|
: t.min +
|
|
Math.min(
|
|
Math.floor((t.max - t.min) / t.step + 1e-7),
|
|
Math.ceil((r - t.min) / t.step - 1e-7) - 1,
|
|
) *
|
|
t.step,
|
|
)
|
|
.filter((e, t) => e >= i[t].min && e <= i[t].max);
|
|
n.length &&
|
|
(a = Number((e ? Math.min(...n) : Math.max(...n)).toFixed(8)));
|
|
}
|
|
a !== r && ((I.value[e.id] = a), n && O.calcPrice());
|
|
}
|
|
async function Ke(t, n) {
|
|
(await Promise.resolve(), await nextTick());
|
|
let r = `originalEvent` in n ? n.originalEvent.target : n.target,
|
|
i = I.value[t.id];
|
|
r &&
|
|
typeof i == `number` &&
|
|
((r.value = `${i}${t.unit ? ` ${t.unit}` : ``}`),
|
|
r.setAttribute(`aria-valuenow`, String(i)));
|
|
}
|
|
function qe(e) {
|
|
return [...new Set(e.choices.map((e) => e.group || `其他系统`))];
|
|
}
|
|
function Je(e) {
|
|
let t = e.choices.find((t) => t.value === I.value[e.id]);
|
|
return t ? t.group || `其他系统` : ``;
|
|
}
|
|
function Ye(e) {
|
|
return e.choices.filter((t) => (t.group || `其他系统`) === Je(e));
|
|
}
|
|
function Xe(e, t) {
|
|
if (Y.value || Je(e) === t) return;
|
|
let n = e.choices.find((e) => (e.group || `其他系统`) === t);
|
|
n && ((I.value[e.id] = n.value), O.calcPrice());
|
|
}
|
|
let Ze = computed(() =>
|
|
(O.availableOptions?.value ?? F.value?.options ?? []).map((e) => {
|
|
let t = I.value[e.id],
|
|
n;
|
|
if (e.kind === `quantity`) {
|
|
let r = (Ne(e) ? Le(e) : ``) || e.unit;
|
|
n = typeof t == `number` ? `${t}${r ? ` ${r}` : ``}` : ``;
|
|
} else if (e.kind === `boolean`) n = t === 1 ? `启用` : `不启用`;
|
|
else {
|
|
let r = e.choices.find((e) => e.value === t);
|
|
n =
|
|
e.kind === `os` ? os_name_t(r?.label) : Ae(e, r?.label || ``);
|
|
}
|
|
return {
|
|
label: Q(e),
|
|
value: n || `未选择`,
|
|
};
|
|
}),
|
|
);
|
|
async function Qe() {
|
|
if (ke.value) {
|
|
((J.value = `cart`),
|
|
(X.value = ``),
|
|
(Z.value = ``),
|
|
clearTimeout(Oe));
|
|
try {
|
|
if ((await O.addToCart(), S.edit)) {
|
|
await navigateTo(`/cart`);
|
|
return;
|
|
}
|
|
((Z.value = S.edit ? `购物车配置已更新` : `已加入购物车`),
|
|
(Oe = setTimeout(() => {
|
|
Z.value = ``;
|
|
}, 4e3)));
|
|
} catch (e) {
|
|
X.value = e instanceof Error ? e.message : `提交失败,请重试`;
|
|
} finally {
|
|
J.value = null;
|
|
}
|
|
}
|
|
}
|
|
async function $e() {
|
|
if (ke.value) {
|
|
((J.value = `buy`), (X.value = ``), (Z.value = ``));
|
|
try {
|
|
ee(`settled`, await O.buyNow());
|
|
} catch (e) {
|
|
X.value = e instanceof Error ? e.message : `提交失败,请重试`;
|
|
} finally {
|
|
J.value = null;
|
|
}
|
|
}
|
|
}
|
|
return (
|
|
onMounted(() => O.init()),
|
|
(e, r) => {
|
|
let i = ConfigLoadingShell,
|
|
o = message,
|
|
u = button,
|
|
m = ConfigChoiceGrid,
|
|
_ = select,
|
|
E = inputnumber,
|
|
ee = ConfigDiskCard,
|
|
N = ProductCustomFields,
|
|
P = ConfigCheckout;
|
|
return (
|
|
openBlock(),
|
|
createElementBlock(`div`, ae, [
|
|
unref(ne)
|
|
? (openBlock(),
|
|
createBlock(
|
|
i,
|
|
{
|
|
key: 0,
|
|
},
|
|
{
|
|
catalog: withCtx(() => [
|
|
renderSlot(
|
|
e.$slots,
|
|
`catalog`,
|
|
{
|
|
disabled: unref(J) !== null,
|
|
},
|
|
void 0,
|
|
!0,
|
|
),
|
|
]),
|
|
_: 3,
|
|
},
|
|
))
|
|
: unref(G) && !unref(F)
|
|
? (openBlock(),
|
|
createElementBlock(`div`, oe, [
|
|
renderSlot(
|
|
e.$slots,
|
|
`catalog`,
|
|
{
|
|
disabled: unref(J) !== null,
|
|
},
|
|
void 0,
|
|
!0,
|
|
),
|
|
createVNode(
|
|
o,
|
|
{
|
|
severity: `error`,
|
|
closable: !1,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
createTextVNode(toDisplayString(unref(G)), 1),
|
|
]),
|
|
_: 1,
|
|
},
|
|
),
|
|
createVNode(
|
|
u,
|
|
{
|
|
label: `重新加载配置`,
|
|
icon: `pi pi-refresh`,
|
|
severity: `secondary`,
|
|
outlined: ``,
|
|
disabled: c.identityLocked,
|
|
onClick: (r[0] ||= (e) => unref(O).init()),
|
|
},
|
|
null,
|
|
8,
|
|
[`disabled`],
|
|
),
|
|
]))
|
|
: unref(F)
|
|
? (openBlock(),
|
|
createElementBlock(`div`, se, [
|
|
createElementVNode(`div`, ce, [
|
|
renderSlot(
|
|
e.$slots,
|
|
`catalog`,
|
|
{
|
|
disabled: unref(J) !== null,
|
|
},
|
|
void 0,
|
|
!0,
|
|
),
|
|
(openBlock(!0),
|
|
createElementBlock(
|
|
Fragment,
|
|
null,
|
|
renderList(
|
|
unref(Me),
|
|
(e) => (
|
|
openBlock(),
|
|
createElementBlock(
|
|
`section`,
|
|
{
|
|
key: e.title,
|
|
class: `panel`,
|
|
},
|
|
[
|
|
createElementVNode(
|
|
`h2`,
|
|
le,
|
|
toDisplayString(e.title),
|
|
1,
|
|
),
|
|
createElementVNode(
|
|
`div`,
|
|
{
|
|
class: normalizeClass({
|
|
"storage-grid":
|
|
e.title === `存储配置`,
|
|
}),
|
|
},
|
|
[
|
|
(openBlock(!0),
|
|
createElementBlock(
|
|
Fragment,
|
|
null,
|
|
renderList(
|
|
e.options,
|
|
(e) => (
|
|
openBlock(),
|
|
createElementBlock(
|
|
Fragment,
|
|
{
|
|
key: e.id,
|
|
},
|
|
[
|
|
e.kind === `os`
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
Fragment,
|
|
{
|
|
key: 0,
|
|
},
|
|
[
|
|
createElementVNode(
|
|
`div`,
|
|
ue,
|
|
[
|
|
createElementVNode(
|
|
`label`,
|
|
null,
|
|
toDisplayString(
|
|
Q(e),
|
|
),
|
|
1,
|
|
),
|
|
createVNode(
|
|
m,
|
|
{
|
|
label:
|
|
Q(e),
|
|
images: ``,
|
|
disabled:
|
|
unref(
|
|
Y,
|
|
),
|
|
"model-value":
|
|
Je(e),
|
|
options:
|
|
qe(
|
|
e,
|
|
).map(
|
|
(
|
|
e,
|
|
) => ({
|
|
label:
|
|
unref(
|
|
os_name_t,
|
|
)(
|
|
e,
|
|
),
|
|
value:
|
|
e,
|
|
}),
|
|
),
|
|
"onUpdate:modelValue":
|
|
(t) =>
|
|
Xe(
|
|
e,
|
|
t,
|
|
),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`label`,
|
|
`disabled`,
|
|
`model-value`,
|
|
`options`,
|
|
`onUpdate:modelValue`,
|
|
],
|
|
),
|
|
],
|
|
),
|
|
createElementVNode(
|
|
`div`,
|
|
de,
|
|
[
|
|
createElementVNode(
|
|
`label`,
|
|
{
|
|
for: `${q}-${e.id}`,
|
|
},
|
|
`镜像版本`,
|
|
8,
|
|
fe,
|
|
),
|
|
createVNode(
|
|
_,
|
|
{
|
|
"input-id": `${q}-${e.id}`,
|
|
"aria-label": `镜像版本`,
|
|
modelValue:
|
|
unref(
|
|
I,
|
|
)[e.id],
|
|
"onUpdate:modelValue":
|
|
(t) =>
|
|
(unref(
|
|
I,
|
|
)[
|
|
e.id
|
|
] =
|
|
t),
|
|
disabled:
|
|
unref(
|
|
Y,
|
|
),
|
|
options:
|
|
Ye(e),
|
|
"option-label":
|
|
(e) =>
|
|
unref(
|
|
os_name_t,
|
|
)(
|
|
e.label,
|
|
),
|
|
"option-value": `value`,
|
|
class: `grow`,
|
|
onChange:
|
|
(r[1] ||=
|
|
(e) =>
|
|
unref(
|
|
O,
|
|
).calcPrice()),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`input-id`,
|
|
`modelValue`,
|
|
`onUpdate:modelValue`,
|
|
`disabled`,
|
|
`options`,
|
|
`option-label`,
|
|
],
|
|
),
|
|
e.description
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
`span`,
|
|
pe,
|
|
toDisplayString(
|
|
e.description,
|
|
),
|
|
1,
|
|
))
|
|
: createCommentVNode(
|
|
``,
|
|
!0,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
64,
|
|
))
|
|
: Ne(e)
|
|
? (openBlock(),
|
|
createBlock(
|
|
ee,
|
|
{
|
|
key: 1,
|
|
label: Q(e),
|
|
title: Ve(e),
|
|
"model-value":
|
|
ze(e),
|
|
options: Re(e),
|
|
unit: Be(e),
|
|
description:
|
|
e.description ||
|
|
$(e)?.label,
|
|
disabled:
|
|
unref(Y),
|
|
"onUpdate:modelValue":
|
|
(t) =>
|
|
Ue(e, t),
|
|
onChange:
|
|
(r[4] ||= (
|
|
e,
|
|
) =>
|
|
unref(
|
|
O,
|
|
).calcPrice()),
|
|
},
|
|
createSlots(
|
|
{
|
|
_: 2,
|
|
},
|
|
[
|
|
Ie(e)
|
|
? {
|
|
name: `type`,
|
|
fn: withCtx(
|
|
() => [
|
|
createVNode(
|
|
m,
|
|
{
|
|
label: `${Q(e)}规格`,
|
|
compact: ``,
|
|
modelValue:
|
|
unref(
|
|
I,
|
|
)[
|
|
e
|
|
.id
|
|
],
|
|
"onUpdate:modelValue":
|
|
(
|
|
t,
|
|
) =>
|
|
(unref(
|
|
I,
|
|
)[
|
|
e.id
|
|
] =
|
|
t),
|
|
disabled:
|
|
unref(
|
|
Y,
|
|
),
|
|
options:
|
|
e.choices,
|
|
onChange:
|
|
(r[2] ||=
|
|
(
|
|
e,
|
|
) =>
|
|
unref(
|
|
O,
|
|
).calcPrice()),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`label`,
|
|
`modelValue`,
|
|
`onUpdate:modelValue`,
|
|
`disabled`,
|
|
`options`,
|
|
],
|
|
),
|
|
],
|
|
),
|
|
key: `0`,
|
|
}
|
|
: void 0,
|
|
He(e) ||
|
|
!Re(e).length
|
|
? {
|
|
name: `default`,
|
|
fn: withCtx(
|
|
() => [
|
|
He(
|
|
e,
|
|
)
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
`div`,
|
|
{
|
|
key: 0,
|
|
class: `storage-fixed-capacity`,
|
|
"aria-label": `${Q(e)}容量`,
|
|
},
|
|
[
|
|
createElementVNode(
|
|
`strong`,
|
|
null,
|
|
toDisplayString(
|
|
ze(
|
|
e,
|
|
),
|
|
),
|
|
1,
|
|
),
|
|
createElementVNode(
|
|
`span`,
|
|
null,
|
|
toDisplayString(
|
|
Be(
|
|
e,
|
|
),
|
|
),
|
|
1,
|
|
),
|
|
],
|
|
8,
|
|
me,
|
|
))
|
|
: e.kind ===
|
|
`quantity`
|
|
? (openBlock(),
|
|
createBlock(
|
|
E,
|
|
{
|
|
key: 1,
|
|
"aria-label":
|
|
Q(
|
|
e,
|
|
),
|
|
"model-value":
|
|
unref(
|
|
I,
|
|
)[
|
|
e
|
|
.id
|
|
],
|
|
disabled:
|
|
unref(
|
|
Y,
|
|
),
|
|
min: e.min,
|
|
max: e.max,
|
|
step: We(
|
|
e,
|
|
),
|
|
suffix:
|
|
e.unit
|
|
? ` ${e.unit}`
|
|
: ``,
|
|
"use-grouping":
|
|
!1,
|
|
"show-buttons": ``,
|
|
"button-layout": `horizontal`,
|
|
"onUpdate:modelValue":
|
|
(
|
|
t,
|
|
) =>
|
|
Ge(
|
|
e,
|
|
t,
|
|
),
|
|
onBlur:
|
|
(
|
|
t,
|
|
) =>
|
|
Ke(
|
|
e,
|
|
t,
|
|
),
|
|
onKeydown:
|
|
withKeys(
|
|
(
|
|
t,
|
|
) =>
|
|
Ke(
|
|
e,
|
|
t,
|
|
),
|
|
[
|
|
`enter`,
|
|
],
|
|
),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`aria-label`,
|
|
`model-value`,
|
|
`disabled`,
|
|
`min`,
|
|
`max`,
|
|
`step`,
|
|
`suffix`,
|
|
`onUpdate:modelValue`,
|
|
`onBlur`,
|
|
`onKeydown`,
|
|
],
|
|
))
|
|
: Ie(
|
|
e,
|
|
)
|
|
? createCommentVNode(
|
|
``,
|
|
!0,
|
|
)
|
|
: (openBlock(),
|
|
createBlock(
|
|
m,
|
|
{
|
|
key: 2,
|
|
label: `${Q(e)}规格`,
|
|
compact: ``,
|
|
modelValue:
|
|
unref(
|
|
I,
|
|
)[
|
|
e
|
|
.id
|
|
],
|
|
"onUpdate:modelValue":
|
|
(
|
|
t,
|
|
) =>
|
|
(unref(
|
|
I,
|
|
)[
|
|
e.id
|
|
] =
|
|
t),
|
|
disabled:
|
|
unref(
|
|
Y,
|
|
),
|
|
options:
|
|
e.kind ===
|
|
`boolean`
|
|
? e.choices.map(
|
|
(
|
|
e,
|
|
) => ({
|
|
...e,
|
|
label:
|
|
e.value
|
|
? `启用`
|
|
: `不启用`,
|
|
}),
|
|
)
|
|
: e.choices,
|
|
onChange:
|
|
(r[3] ||=
|
|
(
|
|
e,
|
|
) =>
|
|
unref(
|
|
O,
|
|
).calcPrice()),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`label`,
|
|
`modelValue`,
|
|
`onUpdate:modelValue`,
|
|
`disabled`,
|
|
`options`,
|
|
],
|
|
)),
|
|
],
|
|
),
|
|
key: `1`,
|
|
}
|
|
: void 0,
|
|
],
|
|
),
|
|
1032,
|
|
[
|
|
`label`,
|
|
`title`,
|
|
`model-value`,
|
|
`options`,
|
|
`unit`,
|
|
`description`,
|
|
`disabled`,
|
|
`onUpdate:modelValue`,
|
|
],
|
|
))
|
|
: e.kind ===
|
|
`quantity`
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
`div`,
|
|
he,
|
|
[
|
|
createElementVNode(
|
|
`label`,
|
|
{
|
|
for: `${q}-${e.id}`,
|
|
},
|
|
toDisplayString(
|
|
Q(e),
|
|
),
|
|
9,
|
|
ge,
|
|
),
|
|
createVNode(
|
|
E,
|
|
{
|
|
"input-id": `${q}-${e.id}`,
|
|
"aria-label":
|
|
Q(e),
|
|
"model-value":
|
|
unref(
|
|
I,
|
|
)[e.id],
|
|
disabled:
|
|
unref(
|
|
Y,
|
|
),
|
|
min: e.min,
|
|
max: e.max,
|
|
step: We(
|
|
e,
|
|
),
|
|
suffix:
|
|
e.unit
|
|
? ` ${e.unit}`
|
|
: ``,
|
|
"use-grouping":
|
|
!1,
|
|
"show-buttons": ``,
|
|
"button-layout": `horizontal`,
|
|
"onUpdate:modelValue":
|
|
(t) =>
|
|
Ge(
|
|
e,
|
|
t,
|
|
),
|
|
onBlur: (
|
|
t,
|
|
) =>
|
|
Ke(
|
|
e,
|
|
t,
|
|
),
|
|
onKeydown:
|
|
withKeys(
|
|
(t) =>
|
|
Ke(
|
|
e,
|
|
t,
|
|
),
|
|
[
|
|
`enter`,
|
|
],
|
|
),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`input-id`,
|
|
`aria-label`,
|
|
`model-value`,
|
|
`disabled`,
|
|
`min`,
|
|
`max`,
|
|
`step`,
|
|
`suffix`,
|
|
`onUpdate:modelValue`,
|
|
`onBlur`,
|
|
`onKeydown`,
|
|
],
|
|
),
|
|
e.description
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
`span`,
|
|
_e,
|
|
toDisplayString(
|
|
e.description,
|
|
),
|
|
1,
|
|
))
|
|
: createCommentVNode(
|
|
``,
|
|
!0,
|
|
),
|
|
],
|
|
))
|
|
: (openBlock(),
|
|
createElementBlock(
|
|
`div`,
|
|
ve,
|
|
[
|
|
createElementVNode(
|
|
`label`,
|
|
null,
|
|
toDisplayString(
|
|
Q(e),
|
|
),
|
|
1,
|
|
),
|
|
createVNode(
|
|
m,
|
|
{
|
|
label:
|
|
Q(e),
|
|
compact:
|
|
!/区域|地区|地域|城市|机房|线路|数据中心/.test(
|
|
e.label,
|
|
),
|
|
modelValue:
|
|
unref(
|
|
I,
|
|
)[e.id],
|
|
"onUpdate:modelValue":
|
|
(t) =>
|
|
(unref(
|
|
I,
|
|
)[
|
|
e.id
|
|
] =
|
|
t),
|
|
disabled:
|
|
unref(
|
|
Y,
|
|
),
|
|
options:
|
|
e.choices.map(
|
|
(
|
|
t,
|
|
) => ({
|
|
...t,
|
|
label:
|
|
e.kind ===
|
|
`boolean`
|
|
? t.value
|
|
? `启用`
|
|
: `不启用`
|
|
: Ae(
|
|
e,
|
|
t.label,
|
|
),
|
|
}),
|
|
),
|
|
onChange:
|
|
(r[5] ||=
|
|
(e) =>
|
|
unref(
|
|
O,
|
|
).calcPrice()),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`label`,
|
|
`compact`,
|
|
`modelValue`,
|
|
`onUpdate:modelValue`,
|
|
`disabled`,
|
|
`options`,
|
|
],
|
|
),
|
|
e.description
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
`span`,
|
|
ye,
|
|
toDisplayString(
|
|
e.description,
|
|
),
|
|
1,
|
|
))
|
|
: createCommentVNode(
|
|
``,
|
|
!0,
|
|
),
|
|
],
|
|
)),
|
|
],
|
|
64,
|
|
)
|
|
),
|
|
),
|
|
128,
|
|
)),
|
|
],
|
|
2,
|
|
),
|
|
],
|
|
)
|
|
),
|
|
),
|
|
128,
|
|
)),
|
|
createVNode(
|
|
N,
|
|
{
|
|
modelValue: unref(L),
|
|
"onUpdate:modelValue": [
|
|
(r[6] ||= (e) =>
|
|
isRef(L) ? (L.value = e) : null),
|
|
(r[7] ||= (e) => unref(O).calcPrice()),
|
|
],
|
|
fields: unref(F).customFields,
|
|
disabled: unref(Y),
|
|
},
|
|
null,
|
|
8,
|
|
[`modelValue`, `fields`, `disabled`],
|
|
),
|
|
]),
|
|
createVNode(
|
|
P,
|
|
{
|
|
"product-id": S.productId,
|
|
quantity: unref(z),
|
|
"edit-position": S.edit?.position,
|
|
editing: !!S.edit,
|
|
summary: unref(Ze),
|
|
price: unref(te),
|
|
"quote-ready": unref(we) && !c.identityLocked,
|
|
"price-loading": unref(re),
|
|
"can-submit": unref(ke),
|
|
"active-action": unref(J),
|
|
disabled: unref(Y),
|
|
"promo-code": unref(Te),
|
|
"onUpdate:promoCode": (r[12] ||= (e) =>
|
|
isRef(Te) ? (Te.value = e) : null),
|
|
"promo-discount": unref(Ee),
|
|
"level-discount": unref(De),
|
|
error: unref(G),
|
|
"action-error": unref(X),
|
|
"cart-tip": unref(Z),
|
|
onCart: Qe,
|
|
onBuy: $e,
|
|
onRecalc: (r[13] ||= (e) =>
|
|
unref(O).calcPrice()),
|
|
onRetry: (r[14] ||= (e) =>
|
|
unref(O).calcPrice()),
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
createElementVNode(`div`, be, [
|
|
createElementVNode(
|
|
`label`,
|
|
{
|
|
for: `${q}-cycle`,
|
|
},
|
|
`购买时长`,
|
|
8,
|
|
xe,
|
|
),
|
|
createVNode(
|
|
_,
|
|
{
|
|
"input-id": `${q}-cycle`,
|
|
"aria-label": `购买时长`,
|
|
modelValue: unref(R),
|
|
"onUpdate:modelValue": (r[8] ||= (e) =>
|
|
isRef(R) ? (R.value = e) : null),
|
|
disabled: unref(Y),
|
|
options: unref(F).cycles,
|
|
"option-label": `label`,
|
|
"option-value": `value`,
|
|
placeholder: `请选择周期`,
|
|
class: `grow`,
|
|
onChange: (r[9] ||= (e) =>
|
|
unref(O).calcPrice()),
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`input-id`,
|
|
`modelValue`,
|
|
`disabled`,
|
|
`options`,
|
|
],
|
|
),
|
|
]),
|
|
unref(F).allowQty
|
|
? (openBlock(),
|
|
createElementBlock(`div`, Se, [
|
|
createElementVNode(
|
|
`label`,
|
|
{
|
|
for: `${q}-qty`,
|
|
},
|
|
`购买数量`,
|
|
8,
|
|
Ce,
|
|
),
|
|
createVNode(
|
|
E,
|
|
{
|
|
"input-id": `${q}-qty`,
|
|
"aria-label": `购买数量`,
|
|
modelValue: unref(z),
|
|
"onUpdate:modelValue": [
|
|
(r[10] ||= (e) =>
|
|
isRef(z)
|
|
? (z.value = e)
|
|
: null),
|
|
(r[11] ||= (e) =>
|
|
unref(O).calcPrice()),
|
|
],
|
|
disabled: unref(Y),
|
|
min: 1,
|
|
max: unref(F).stock ?? void 0,
|
|
"show-buttons": ``,
|
|
"button-layout": `horizontal`,
|
|
},
|
|
null,
|
|
8,
|
|
[
|
|
`input-id`,
|
|
`modelValue`,
|
|
`disabled`,
|
|
`max`,
|
|
],
|
|
),
|
|
]))
|
|
: createCommentVNode(``, !0),
|
|
unref(F).stock === 0
|
|
? (openBlock(),
|
|
createBlock(
|
|
o,
|
|
{
|
|
key: 1,
|
|
severity: `warn`,
|
|
closable: !1,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
...(r[15] ||= [
|
|
createTextVNode(
|
|
`该商品暂时售罄。`,
|
|
-1,
|
|
),
|
|
]),
|
|
]),
|
|
_: 1,
|
|
},
|
|
))
|
|
: createCommentVNode(``, !0),
|
|
]),
|
|
_: 1,
|
|
},
|
|
8,
|
|
[
|
|
`product-id`,
|
|
`quantity`,
|
|
`edit-position`,
|
|
`editing`,
|
|
`summary`,
|
|
`price`,
|
|
`quote-ready`,
|
|
`price-loading`,
|
|
`can-submit`,
|
|
`active-action`,
|
|
`disabled`,
|
|
`promo-code`,
|
|
`promo-discount`,
|
|
`level-discount`,
|
|
`error`,
|
|
`action-error`,
|
|
`cart-tip`,
|
|
],
|
|
),
|
|
]))
|
|
: createCommentVNode(``, !0),
|
|
])
|
|
);
|
|
}
|
|
);
|
|
},
|
|
}),
|
|
[[`__scopeId`, `data-v-1ac7876b`]],
|
|
),
|
|
{
|
|
__name: `FinanceConfig`,
|
|
},
|
|
);
|
|
export {};
|
|
export default we;
|
|
</script>
|