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

+13
View File
@@ -1,4 +1,8 @@
<script>
/**
* 快快云 ECS 商品配置:区域/CPU 型号决定可售套餐,套餐再约束网络、磁盘、防护和周期。
* productId 确定商品,edit 表示购物车编辑;settled 只在创建即时购买订单后通知父级。
*/
import "~/assets/styles/ConfigDiskAdd.C92e9ZuF.css";
import "~/assets/styles/ConfigBandwidth.CWSH1WJZ.css";
import "~/assets/styles/ConfigDiskCard.Dx9IqqQ_.css";
@@ -62,6 +66,7 @@ function ue(e) {
};
}
function M(e, t) {
// 将磁盘容量吸附到 min + n*step,最大值必须是区间内可达档位。
let n = ue(t);
if (!n) return ``;
let r = e === `` || !Number.isFinite(Number(e)) ? n.min : Number(e),
@@ -98,6 +103,7 @@ function de() {
};
}
function fe(e, t = {}) {
// 配置状态与报价分开保存;N 为当前输入快照,P 为最近成功报价对应快照。
let n = useApi(),
i = t.edit,
o = ref(!i),
@@ -152,6 +158,7 @@ function fe(e, t = {}) {
return Number.isFinite(t) && t > 0 ? Math.floor(t) : 0;
});
function ie() {
// 切换套餐后重新约束系统盘和数据盘,并截断超出商品允许数量的附加磁盘。
let e = l.value;
if (!e) return;
let t = p.value,
@@ -258,6 +265,7 @@ function fe(e, t = {}) {
throw Error(`当前配置报价尚未确认,请等待或重新计算报价`);
}
function he() {
// 依据服务端可售集合修正级联选择:区域 → CPU 型号/套餐 → 网络 → 计费方式。
let e = l.value;
if (!e) return;
let t = p.value;
@@ -374,6 +382,7 @@ function fe(e, t = {}) {
return ((p.value.duration_name = a?.name ?? ``), !0);
}
async function B() {
// 报价绑定输入快照与请求序号;配置变化立即废弃旧价格,不能让迟到响应恢复购买按钮。
if (!o.value || (z(), F || !p.value.duration_id || !p.value.image_id))
return;
if (l.value && !T.value.some((e) => C(e.id, p.value.package_config_id))) {
@@ -416,6 +425,7 @@ function fe(e, t = {}) {
}
}
async function be() {
// 初始化并行读取镜像与可售配置,编辑场景再回填购物车和自定义字段,最后获取周期与报价。
o.value = !1;
let r = ++I;
(z(), (b.value = !0), (S.value = ``), i && ge(i.item));
@@ -464,6 +474,7 @@ function fe(e, t = {}) {
}
}
async function V(e = {}) {
// 上游选项改变时清空依赖选项,再按顺序重新读取配置、周期、价格。
let t = ++I;
(z(),
(S.value = ``),
@@ -483,6 +494,7 @@ function fe(e, t = {}) {
}
}
async function xe() {
// 加购与编辑都必须使用已确认报价和已校验字段;编辑保存期间仍核对快照未变化。
(me(), product_fields_i(h.value, m.value));
let t = {
product_id: e,
@@ -505,6 +517,7 @@ function fe(e, t = {}) {
return n.post(`/cart`, t);
}
async function Se() {
// 编辑模式只能先保存回购物车;即时购买将当前配置提交到 /product/settle。
if (i) throw Error(`请先保存配置,再返回购物车结算`);
return (
me(),