docs: annotate product configuration and quote lifecycles

This commit is contained in:
cieanyau committed 2026-11-06 00:29:13 +08:00
1 parent 3a53d2e58f
commit 60827b8bfb
7 files changed
+75

No files matched your search

+19
View File
@@ -1,4 +1,8 @@
<script>
/**
* 魔方云系列商品配置:支持自选/推荐套餐、磁盘、网络、备份快照及商品开放的预付/按需模式。
* initialProduct/initialImageId 用于进入配置页时续接选择;真实成交价始终来自配置报价接口。
*/
import "~/assets/styles/ConfigResourceOption.Dj4VopnA.css";
import "~/assets/styles/ConfigDiskAdd.C92e9ZuF.css";
import "~/assets/styles/ConfigBandwidth.CWSH1WJZ.css";
@@ -65,6 +69,7 @@ function I(e) {
);
}
function L(e, t) {
// 区间内的值还必须落在步长网格上,不能仅凭最小/最大值认定配置可购买。
if (t == null || t === ``) return !1;
let n = Number(t);
return !e?.length || !Number.isFinite(n)
@@ -128,6 +133,7 @@ function pe() {
};
}
function R(e, t = `mf_cloud`, n = {}) {
// 这里集中维护报价、配置代次及购物车回填;下方 setup 只组织控件与意图事件。
let r = useApi(),
a = `/product/${e}/${t}`,
s = n.customFields === !0 || !!n.edit,
@@ -219,6 +225,7 @@ function R(e, t = `mf_cloud`, n = {}) {
e.peak_defence != null && (w.value.peak_defence = String(e.peak_defence));
}
function fe() {
// 商品若仅售套餐,必须选当前线路的可售推荐配置,不可绕过套餐约束使用自选资源。
if (w.value.recommend_config_id && !k.value)
throw Error(`所选套餐已不可用,请重新选择套餐`);
if (!w.value.recommend_config_id && oe.value) {
@@ -228,6 +235,7 @@ function R(e, t = `mf_cloud`, n = {}) {
} else k.value && de(k.value);
}
function M() {
// 备份、快照和 GPU 额度按商品已开放档位校验;推荐套餐自带 GPU 也保留其合法额度。
for (let [e, t, n] of [
[`备份`, w.value.backup_num, se.value.map((e) => e.num)],
[`快照`, w.value.snap_num, ce.value.map((e) => e.num)],
@@ -294,6 +302,7 @@ function R(e, t = `mf_cloud`, n = {}) {
!B.value,
);
function q() {
// 任意输入改变立即清空已确认报价与折扣,防止旧价在新配置上继续可提交。
((_e += 1),
(ve.value = ``),
(me.value = `—`),
@@ -338,6 +347,7 @@ function R(e, t = `mf_cloud`, n = {}) {
: 16;
});
function J(e, t, n = !1) {
// 磁盘选项结合介质、容量步长和赠送盘规则生成;赠送容量也需保留独立合法档位。
let r = _.value;
if (!r) return [];
let i = r.config,
@@ -403,6 +413,7 @@ function R(e, t = `mf_cloud`, n = {}) {
);
}
function Te() {
// 赠送盘按站点规则补入,并和普通数据盘区分,避免被删除或重复赠送。
let e = _.value?.config,
t = Number(e?.free_disk_size),
n = w.value.data_disk.find((e) => Number(e.is_free) === 1),
@@ -421,6 +432,7 @@ function R(e, t = `mf_cloud`, n = {}) {
} else w.value.data_disk = r;
}
function Ee() {
// 容量或介质变化后,原磁盘性能套餐可能失效,需要在报价前清除不匹配的 disk_limit_id。
for (let [e, t] of [
[`system`, [w.value.system_disk]],
[`data`, w.value.data_disk],
@@ -595,6 +607,7 @@ function R(e, t = `mf_cloud`, n = {}) {
((s = !0), (g.value = !1), _.value && (await Re()));
}
async function Fe(e = G) {
// 同一线路合并在途读取;写回前同时核对配置代次和当前线路,避免串用上一个线路价格。
let t = w.value.line_id;
if (!t) return !1;
if (b.value === t && y.value) return !0;
@@ -659,6 +672,7 @@ function R(e, t = `mf_cloud`, n = {}) {
return !0;
}
async function Le() {
// 报价前完成套餐/额度/线路校验;按需模式还必须获得合法运行费、流量费及保留费信息。
if ((q(), W || !g.value)) return;
if (!d.includes(w.value.billing_cycle)) {
V.value = `当前商品未开放所选计费方式`;
@@ -742,6 +756,7 @@ function R(e, t = `mf_cloud`, n = {}) {
}
}
async function Re(t) {
// 整体初始化重读商品及镜像;登录前选中的镜像若已失效,要求用户重新选择而非静默换系统。
g.value = !1;
let i = ++G;
(q(),
@@ -806,6 +821,7 @@ function R(e, t = `mf_cloud`, n = {}) {
}
}
async function ze(e) {
// 改计费模式必须重读商品配置并清空周期/流量/带宽,不能沿用另一模式的报价。
!W &&
e !== w.value.billing_cycle &&
d.includes(e) &&
@@ -854,6 +870,7 @@ function R(e, t = `mf_cloud`, n = {}) {
await Y(!0);
}
async function Ve() {
// 提交前检查报价快照与自定义字段;加购保持现有 cycle/configoption 协议形状。
(Se(), product_fields_i(F.value, P.value));
let t = {
product_id: e,
@@ -1124,6 +1141,7 @@ var me = {
),
);
watch(
// 将当前镜像选择登记到父级续接路径,watch 清理函数释放上一条登记。
Xe,
(e, t, n) => {
let r = Ye?.(e);
@@ -1474,6 +1492,7 @@ var me = {
}
}
async function At() {
// 只有报价已确认且未锁定身份/操作时才能创建订单,成功结果由父级接入支付流程。
if (et.value) {
((Z.value = `buy`), (Ze.value = ``), (Qe.value = ``));
try {