套餐计划增加plan_type过滤,前端下拉增加套餐类型前缀,增加带宽显示
This commit is contained in:
parent
ea2bc6cecf
commit
d38736f137
@ -634,7 +634,10 @@ export default {
|
|||||||
const cpu = plan.core || plan.cpu || '未知';
|
const cpu = plan.core || plan.cpu || '未知';
|
||||||
const memory = plan.memory || '未知';
|
const memory = plan.memory || '未知';
|
||||||
const disk = plan.disk_size || plan.system_disk_size || '未知';
|
const disk = plan.disk_size || plan.system_disk_size || '未知';
|
||||||
|
const bandwidth = plan.bandwidth || '未知';
|
||||||
const price = plan.origin_price || '未知';
|
const price = plan.origin_price || '未知';
|
||||||
|
const planType = plan.plan_type || '';
|
||||||
|
|
||||||
// 处理内存显示(如果是小数,转换为MB)
|
// 处理内存显示(如果是小数,转换为MB)
|
||||||
let memoryDisplay = memory;
|
let memoryDisplay = memory;
|
||||||
if (typeof memory === 'number' && memory < 1) {
|
if (typeof memory === 'number' && memory < 1) {
|
||||||
@ -642,7 +645,33 @@ export default {
|
|||||||
} else if (typeof memory === 'number') {
|
} else if (typeof memory === 'number') {
|
||||||
memoryDisplay = memory + 'GB';
|
memoryDisplay = memory + 'GB';
|
||||||
}
|
}
|
||||||
return `${cpu}核/${memoryDisplay}/${disk}GB - ¥${price}/月`;
|
|
||||||
|
// 处理带宽显示
|
||||||
|
let bandwidthDisplay = bandwidth;
|
||||||
|
if (typeof bandwidth === 'number') {
|
||||||
|
bandwidthDisplay = bandwidth + 'Mbps';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据plan_type添加类型前缀
|
||||||
|
let typePrefix = '';
|
||||||
|
switch (planType) {
|
||||||
|
case 'NORMAL':
|
||||||
|
typePrefix = '通用型 - ';
|
||||||
|
break;
|
||||||
|
case 'MULTI_IP':
|
||||||
|
typePrefix = '多公网IP型 - ';
|
||||||
|
break;
|
||||||
|
case 'INTERNATIONAL':
|
||||||
|
typePrefix = '国际型 - ';
|
||||||
|
break;
|
||||||
|
case 'CAPACITY':
|
||||||
|
typePrefix = '容量型 - ';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
typePrefix = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${typePrefix}${cpu}核/${memoryDisplay}/${disk}GB/${bandwidthDisplay} - ¥${price}/月`;
|
||||||
},
|
},
|
||||||
getSelectedPlanPrice() {
|
getSelectedPlanPrice() {
|
||||||
const selectedPlan = this.plans.find(plan => plan.plan_id === this.selectedPlanId);
|
const selectedPlan = this.plans.find(plan => plan.plan_id === this.selectedPlanId);
|
||||||
|
|||||||
@ -629,7 +629,18 @@ def delete_aliyun_instance(instance_id, region_id='cn-shanghai'):
|
|||||||
def get_aliyun_plans(region_id='cn-shanghai'):
|
def get_aliyun_plans(region_id='cn-shanghai'):
|
||||||
"""获取可用套餐列表"""
|
"""获取可用套餐列表"""
|
||||||
manager = _get_manager()
|
manager = _get_manager()
|
||||||
return manager.get_plans(region_id)
|
result = manager.get_plans(region_id)
|
||||||
|
|
||||||
|
# 过滤指定类型的套餐
|
||||||
|
if result.get('success') and result.get('data') and 'plans' in result['data']:
|
||||||
|
allowed_types = ['NORMAL', 'MULTI_IP', 'INTERNATIONAL', 'CAPACITY']
|
||||||
|
filtered_plans = [
|
||||||
|
plan for plan in result['data']['plans']
|
||||||
|
if plan.get('plan_type') in allowed_types
|
||||||
|
]
|
||||||
|
result['data']['plans'] = filtered_plans
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
@jingrow.whitelist()
|
@jingrow.whitelist()
|
||||||
def get_aliyun_images(image_type='system', region_id='cn-shanghai'):
|
def get_aliyun_images(image_type='system', region_id='cn-shanghai'):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user