前台区域改成输入选择框
This commit is contained in:
parent
79dd7667bf
commit
5bb223d6c8
@ -54,9 +54,16 @@
|
|||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :md="6" :sm="24">
|
<el-col :md="6" :sm="24">
|
||||||
<el-form-item label="区域">
|
<el-form-item label="区域">
|
||||||
<el-select v-model="form.region" placeholder="请选择区域" class="full-width">
|
<el-select
|
||||||
|
v-model="form.region"
|
||||||
|
placeholder="请选择区域"
|
||||||
|
class="full-width"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
:filter-method="filterRegions"
|
||||||
|
:remote-method="filterRegions">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="region in regions"
|
v-for="region in filteredRegions"
|
||||||
:key="region.code"
|
:key="region.code"
|
||||||
:label="region.name"
|
:label="region.name"
|
||||||
:value="region.code">
|
:value="region.code">
|
||||||
@ -435,6 +442,7 @@
|
|||||||
yearly_discount: 0.85 // 默认60%,即6折
|
yearly_discount: 0.85 // 默认60%,即6折
|
||||||
},
|
},
|
||||||
regions: [],
|
regions: [],
|
||||||
|
filteredRegions: [], // 添加筛选后的区域列表
|
||||||
searchResults: [],
|
searchResults: [],
|
||||||
selectedInstance: null,
|
selectedInstance: null,
|
||||||
comparisonList: [], // 用于存储要比较的实例
|
comparisonList: [], // 用于存储要比较的实例
|
||||||
@ -450,6 +458,7 @@
|
|||||||
try {
|
try {
|
||||||
// 使用API服务获取区域列表
|
// 使用API服务获取区域列表
|
||||||
this.regions = await apiService.getRegions()
|
this.regions = await apiService.getRegions()
|
||||||
|
this.filteredRegions = [...this.regions] // 初始化筛选后的区域列表
|
||||||
|
|
||||||
// 如果数据加载成功,默认选择第一个区域
|
// 如果数据加载成功,默认选择第一个区域
|
||||||
if (this.regions && this.regions.length > 0) {
|
if (this.regions && this.regions.length > 0) {
|
||||||
@ -457,7 +466,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 从本地存储加载之前保存的对比列表
|
// 从本地存储加载之前保存的对比列表
|
||||||
const savedComparison = localStorage.getItem('instance_comparison')
|
const savedComparison = localStorage.getItem('instance_comparison_discount')
|
||||||
if (savedComparison) {
|
if (savedComparison) {
|
||||||
this.comparisonList = JSON.parse(savedComparison)
|
this.comparisonList = JSON.parse(savedComparison)
|
||||||
}
|
}
|
||||||
@ -467,6 +476,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
filterRegions(query) {
|
||||||
|
if (query) {
|
||||||
|
this.filteredRegions = this.regions.filter(region => {
|
||||||
|
return region.name.toLowerCase().includes(query.toLowerCase()) ||
|
||||||
|
region.code.toLowerCase().includes(query.toLowerCase())
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.filteredRegions = [...this.regions]
|
||||||
|
}
|
||||||
|
},
|
||||||
async searchInstances() {
|
async searchInstances() {
|
||||||
if (!this.form.cpu_cores && !this.form.memory_gb && !this.form.disk_gb) {
|
if (!this.form.cpu_cores && !this.form.memory_gb && !this.form.disk_gb) {
|
||||||
this.$message.warning('请至少指定一项配置要求')
|
this.$message.warning('请至少指定一项配置要求')
|
||||||
@ -540,7 +559,7 @@
|
|||||||
this.$message.success('已添加到对比列表')
|
this.$message.success('已添加到对比列表')
|
||||||
|
|
||||||
// 保存到本地存储
|
// 保存到本地存储
|
||||||
localStorage.setItem('instance_comparison', JSON.stringify(this.comparisonList))
|
localStorage.setItem('instance_comparison_discount', JSON.stringify(this.comparisonList))
|
||||||
|
|
||||||
// 滚动到对比列表区域
|
// 滚动到对比列表区域
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -552,12 +571,12 @@
|
|||||||
},
|
},
|
||||||
removeFromComparison(index) {
|
removeFromComparison(index) {
|
||||||
this.comparisonList.splice(index, 1)
|
this.comparisonList.splice(index, 1)
|
||||||
localStorage.setItem('instance_comparison', JSON.stringify(this.comparisonList))
|
localStorage.setItem('instance_comparison_discount', JSON.stringify(this.comparisonList))
|
||||||
this.$message.success('已从对比列表中移除')
|
this.$message.success('已从对比列表中移除')
|
||||||
},
|
},
|
||||||
clearComparison() {
|
clearComparison() {
|
||||||
this.comparisonList = []
|
this.comparisonList = []
|
||||||
localStorage.removeItem('instance_comparison')
|
localStorage.removeItem('instance_comparison_discount')
|
||||||
this.$message.success('已清空对比列表')
|
this.$message.success('已清空对比列表')
|
||||||
},
|
},
|
||||||
exportComparison() {
|
exportComparison() {
|
||||||
|
|||||||
@ -54,9 +54,16 @@
|
|||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :md="6" :sm="24">
|
<el-col :md="6" :sm="24">
|
||||||
<el-form-item label="区域">
|
<el-form-item label="区域">
|
||||||
<el-select v-model="form.region" placeholder="请选择区域" class="full-width">
|
<el-select
|
||||||
|
v-model="form.region"
|
||||||
|
placeholder="请选择区域"
|
||||||
|
class="full-width"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
:filter-method="filterRegions"
|
||||||
|
:remote-method="filterRegions">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="region in regions"
|
v-for="region in filteredRegions"
|
||||||
:key="region.code"
|
:key="region.code"
|
||||||
:label="region.name"
|
:label="region.name"
|
||||||
:value="region.code">
|
:value="region.code">
|
||||||
@ -389,6 +396,7 @@ export default {
|
|||||||
operating_system: 'Linux' // 默认Linux
|
operating_system: 'Linux' // 默认Linux
|
||||||
},
|
},
|
||||||
regions: [],
|
regions: [],
|
||||||
|
filteredRegions: [], // 添加筛选后的区域列表
|
||||||
searchResults: [],
|
searchResults: [],
|
||||||
selectedInstance: null,
|
selectedInstance: null,
|
||||||
comparisonList: [], // 用于存储要比较的实例
|
comparisonList: [], // 用于存储要比较的实例
|
||||||
@ -404,6 +412,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
// 使用API服务获取区域列表
|
// 使用API服务获取区域列表
|
||||||
this.regions = await apiService.getRegions()
|
this.regions = await apiService.getRegions()
|
||||||
|
this.filteredRegions = [...this.regions] // 初始化筛选后的区域列表
|
||||||
|
|
||||||
// 如果数据加载成功,默认选择第一个区域
|
// 如果数据加载成功,默认选择第一个区域
|
||||||
if (this.regions && this.regions.length > 0) {
|
if (this.regions && this.regions.length > 0) {
|
||||||
@ -421,6 +430,16 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
filterRegions(query) {
|
||||||
|
if (query) {
|
||||||
|
this.filteredRegions = this.regions.filter(region => {
|
||||||
|
return region.name.toLowerCase().includes(query.toLowerCase()) ||
|
||||||
|
region.code.toLowerCase().includes(query.toLowerCase())
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.filteredRegions = [...this.regions]
|
||||||
|
}
|
||||||
|
},
|
||||||
async searchInstances() {
|
async searchInstances() {
|
||||||
if (!this.form.cpu_cores && !this.form.memory_gb && !this.form.disk_gb) {
|
if (!this.form.cpu_cores && !this.form.memory_gb && !this.form.disk_gb) {
|
||||||
this.$message.warning('请至少指定一项配置要求')
|
this.$message.warning('请至少指定一项配置要求')
|
||||||
|
|||||||
@ -26,9 +26,16 @@
|
|||||||
|
|
||||||
<el-col :md="12" :sm="24">
|
<el-col :md="12" :sm="24">
|
||||||
<el-form-item label="区域">
|
<el-form-item label="区域">
|
||||||
<el-select v-model="form.region" placeholder="请选择区域" class="full-width">
|
<el-select
|
||||||
|
v-model="form.region"
|
||||||
|
placeholder="请选择区域"
|
||||||
|
class="full-width"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
:filter-method="filterRegions"
|
||||||
|
:remote-method="filterRegions">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="region in regions"
|
v-for="region in filteredRegions"
|
||||||
:key="region"
|
:key="region"
|
||||||
:label="region"
|
:label="region"
|
||||||
:value="region">
|
:value="region">
|
||||||
@ -160,6 +167,7 @@ export default {
|
|||||||
},
|
},
|
||||||
instanceTypes: [],
|
instanceTypes: [],
|
||||||
regions: [],
|
regions: [],
|
||||||
|
filteredRegions: [],
|
||||||
priceResult: null
|
priceResult: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -172,12 +180,22 @@ export default {
|
|||||||
|
|
||||||
this.instanceTypes = instanceTypes
|
this.instanceTypes = instanceTypes
|
||||||
this.regions = regions.map(region => region.code)
|
this.regions = regions.map(region => region.code)
|
||||||
|
this.filteredRegions = [...this.regions] // 初始化筛选后的区域列表
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching data:', error)
|
console.error('Error fetching data:', error)
|
||||||
this.$message.error('获取数据失败')
|
this.$message.error('获取数据失败')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
filterRegions(query) {
|
||||||
|
if (query) {
|
||||||
|
this.filteredRegions = this.regions.filter(region => {
|
||||||
|
return region.toLowerCase().includes(query.toLowerCase())
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.filteredRegions = [...this.regions]
|
||||||
|
}
|
||||||
|
},
|
||||||
async calculatePrice() {
|
async calculatePrice() {
|
||||||
try {
|
try {
|
||||||
this.priceResult = await apiService.calculatePrice(this.form)
|
this.priceResult = await apiService.calculatePrice(this.form)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user