编辑
@@ -245,6 +253,10 @@
开启后用户端无法选购该商品,KVM 商品可由后台定时任务根据 IP 资源自动标记
+
+
+ 限制单个用户对该商品的最大购买数量,0 表示不限制
+
@@ -969,7 +993,8 @@ const productForm = reactive({
recommend_rebate: 0,
arg_type: 'all', // 商品参数类型 all/plan/customize
attribution_id: '', // 归属项ID
- sold_out: false
+ sold_out: false,
+ max_per_user: 0
})
const productRules = {
@@ -1248,7 +1273,8 @@ const handleAdd = () => {
expire_time: 0,
recommend: false,
recommend_rebate: 0,
- arg_type: 'all'
+ arg_type: 'all',
+ max_per_user: 0
})
productFormRef.value?.resetFields()
}
@@ -1274,7 +1300,8 @@ const handleEdit = (row) => {
recommend: row.recommend,
recommend_rebate: row.recommendRebate,
arg_type: row.argType || 'all',
- sold_out: !!row.soldOut
+ sold_out: !!row.soldOut,
+ max_per_user: row.maxPerUser ?? row.max_per_user ?? 0
})
coverPreviewUrl.value = row.cover || ''
}
@@ -1370,7 +1397,8 @@ const submitForm = () => {
expire_time: productForm.expire_time || 0,
recommend_rebate: productForm.recommend_rebate || 0,
arg_type: productForm.arg_type || 'all', // 商品参数类型
- attribution_id: productForm.attribution_id || '' // 归属项ID
+ attribution_id: productForm.attribution_id || '', // 归属项ID
+ max_per_user: Number(productForm.max_per_user) || 0
}
console.log('提交的数据:', submitData) // 调试日志
@@ -1777,7 +1805,8 @@ const planForm = reactive({
index: 0,
disable: false,
show_home: false,
- can_update: false
+ can_update: false,
+ max_per_user: 0
})
const planFormRules = {
@@ -2279,7 +2308,8 @@ const handleAddPlan = async () => {
index: 0,
disable: false,
show_home: false,
- can_update: false
+ can_update: false,
+ max_per_user: 0
})
planFormDialogVisible.value = true
@@ -2331,12 +2361,13 @@ const handleEditPlan = async (row) => {
extra_arg_ids: extraArgIdsArray.join(','),
extra_arg_ids_array: extraArgIdsArray,
inventory: data.inventory || 0,
- fixed_price: ((data.fixedPrice || data.fixed_price || 0) / 100).toFixed(2) * 1, // 分转元
- enable_fixed_price: !!(data.enableFixedPrice || data.enable_fixed_price), // 转为布尔值
+ fixed_price: ((data.fixedPrice || data.fixed_price || 0) / 100).toFixed(2) * 1,
+ enable_fixed_price: !!(data.enableFixedPrice || data.enable_fixed_price),
index: data.index || 0,
disable: data.disable || false,
show_home: !!(data.showHome || data.show_home),
- can_update: !!(data.canUpdate || data.can_update)
+ can_update: !!(data.canUpdate || data.can_update),
+ max_per_user: data.maxPerUser ?? data.max_per_user ?? 0
})
// 从已有的args初始化选择状态(包括额外参数)
@@ -2434,10 +2465,11 @@ const submitPlanForm = () => {
args: planForm.args || '',
extra_arg_ids: extraArgIdsStr || planForm.extra_arg_ids || '',
inventory: Number(planForm.inventory) || 0,
- fixed_price: Math.round(Number(planForm.fixed_price) * 100) || 0, // 元转分
+ fixed_price: Math.round(Number(planForm.fixed_price) * 100) || 0,
index: Number(planForm.index) || 0,
show_home: planForm.show_home === true,
- can_update: planForm.can_update === true
+ can_update: planForm.can_update === true,
+ max_per_user: Number(planForm.max_per_user) || 0
}
// 只有创建时才传递 enable_fixed_price
diff --git a/src/views/product/components/ProductPlanManager.vue b/src/views/product/components/ProductPlanManager.vue
index 45c1cf8..48bef99 100644
--- a/src/views/product/components/ProductPlanManager.vue
+++ b/src/views/product/components/ProductPlanManager.vue
@@ -113,6 +113,9 @@
{{ row.canUpdate || row.can_update ? '允许升级' : '禁止升级' }}
+
+ 限购{{ row.maxPerUser || row.max_per_user }}次
+
@@ -288,6 +291,10 @@
控制用户是否可以升级到此套餐
+
+
+ 限制单个用户对该套餐的最大购买数量,0 表示不限制
+
@@ -378,7 +385,8 @@ const planForm = reactive({
index: 0,
disable: false,
show_home: false,
- can_update: false
+ can_update: false,
+ max_per_user: 0
})
const planFormRules = {
name: [{ required: true, message: '请输入套餐名称', trigger: 'blur' }]
@@ -758,7 +766,7 @@ const handleAddPlan = async () => {
displayUnits[spec.id] = getParamDefaultUnit(spec)
}
}
- Object.assign(planForm, { plan_id: undefined, name: '', note: '', args: '', extra_arg_ids: '', extra_arg_ids_array: [], inventory: 0, fixed_price: 0, enable_fixed_price: false, index: 0, disable: false, show_home: false, can_update: false })
+ Object.assign(planForm, { plan_id: undefined, name: '', note: '', args: '', extra_arg_ids: '', extra_arg_ids_array: [], inventory: 0, fixed_price: 0, enable_fixed_price: false, index: 0, disable: false, show_home: false, can_update: false, max_per_user: 0 })
planFormDialogVisible.value = true
nextTick(() => { planFormRef.value?.resetFields() })
}
@@ -785,7 +793,8 @@ const handleEditPlan = async (row) => {
inventory: data.inventory || 0, fixed_price: ((data.fixedPrice || data.fixed_price || 0) / 100).toFixed(2) * 1,
enable_fixed_price: !!(data.enableFixedPrice || data.enable_fixed_price),
index: data.index || 0, disable: data.disable || false, show_home: !!(data.showHome || data.show_home),
- can_update: !!(data.canUpdate || data.can_update)
+ can_update: !!(data.canUpdate || data.can_update),
+ max_per_user: data.maxPerUser ?? data.max_per_user ?? 0
})
initSelectedArgsFromJson(data.args, extraArgIdsArray)
planFormDialogVisible.value = true
@@ -842,7 +851,8 @@ const submitPlanForm = () => {
args: planForm.args || '', extra_arg_ids: extraArgIdsStr || planForm.extra_arg_ids || '',
inventory: Number(planForm.inventory) || 0, fixed_price: Math.round(Number(planForm.fixed_price) * 100) || 0,
index: Number(planForm.index) || 0, show_home: planForm.show_home === true,
- can_update: planForm.can_update === true
+ can_update: planForm.can_update === true,
+ max_per_user: Number(planForm.max_per_user) || 0
}
if (planFormType.value === 'add') submitData.enable_fixed_price = planForm.enable_fixed_price === true
let res