Compare commits

..

3 Commits

4 changed files with 413 additions and 526 deletions

View File

@ -3,7 +3,7 @@ AWS_SECRET_ACCESS_KEY=BQjaaHNm5skCN/3k3r/uNdEG9xb49are+hv5fajK
AWS_DEFAULT_REGION=us-east-1
# MySQL数据库配置
MYSQL_HOST=47.76.209.7
MYSQL_HOST=163.123.183.106
MYSQL_USER=aws_price
MYSQL_PASSWORD=123456
MYSQL_PASSWORD=YCwjLmHM5dZtwHEw
MYSQL_DATABASE=aws_price

View File

@ -7,7 +7,7 @@
<el-menu mode="horizontal" router :default-active="'/awsSearch'" class="menu" background-color="#3498db" text-color="#fff" active-text-color="#ffd04b">
<!-- <el-menu-item index="/"><i class="el-icon-s-finance"></i> 价格计算器</el-menu-item> -->
<el-menu-item index="/awsSearch"><i class="el-icon-search"></i>AWS报价</el-menu-item>
<!-- <el-menu-item index="/awsSearchDiscount"><i class="el-icon-search"></i>AWS折扣</el-menu-item> -->
<el-menu-item index="/awsSearchDiscount"><i class="el-icon-search"></i>AWS折扣</el-menu-item>
<!-- <el-menu-item index="/compare"><i class="el-icon-data-analysis"></i> 价格对比</el-menu-item> -->
</el-menu>
</div>

View File

@ -361,25 +361,41 @@
<el-table-column label="官方月付全额" width="120" align="center">
<template #default="scope">
<span class="price-value">${{ scope.row.total_monthly_price.toFixed(2) }}</span>
<div class="price-breakdown-text">
<div>实例: ${{ (Number(scope.row.monthly_price) || 0).toFixed(2) }}</div>
<div>磁盘: ${{ (Number(scope.row.disk_monthly_price) || 0).toFixed(2) }}</div>
<div class="price-value highlight">共计: ${{ getOfficialMonthlyPrice(scope.row).toFixed(2) }}</div>
</div>
</template>
</el-table-column>
<el-table-column label="月付优惠价" width="120" align="center">
<template #default="scope">
<span class="price-value highlight">${{ (scope.row.total_monthly_price * form.monthly_discount).toFixed(2) }}</span>
<div class="price-breakdown-text">
<div>实例: ${{ (scope.row.monthly_price * form.monthly_discount).toFixed(2) }}</div>
<div>磁盘: ${{ scope.row.disk_monthly_price.toFixed(2) }}</div>
<div class="price-value highlight">共计: ${{ getDiscountedMonthlyPrice(scope.row).toFixed(2) }}</div>
</div>
</template>
</el-table-column>
<el-table-column label="官方年付全额" width="120" align="center">
<template #default="scope">
<span class="price-value">${{ (scope.row.total_monthly_price * 12).toFixed(2) }}</span>
<div class="price-breakdown-text">
<div>实例: ${{ ((Number(scope.row.monthly_price) || 0) * 12).toFixed(2) }}</div>
<div>磁盘: ${{ ((Number(scope.row.disk_monthly_price) || 0) * 12).toFixed(2) }}</div>
<div class="price-value highlight">共计: ${{ getOfficialYearlyPrice(scope.row).toFixed(2) }}</div>
</div>
</template>
</el-table-column>
<el-table-column label="年付优惠价" width="120" align="center">
<template #default="scope">
<span class="price-value highlight">${{ (scope.row.total_monthly_price * 12 * form.yearly_discount).toFixed(2) }}</span>
<div class="price-breakdown-text">
<div>实例: ${{ (scope.row.monthly_price * 12 * form.yearly_discount).toFixed(2) }}</div>
<div>磁盘: ${{ (scope.row.disk_monthly_price * 12).toFixed(2) }}</div>
<div class="price-value highlight">共计: ${{ getDiscountedYearlyPrice(scope.row).toFixed(2) }}</div>
</div>
</template>
</el-table-column>
@ -401,8 +417,8 @@
<div class="note-title">说明事项:</div>
<div class="note-items">
<div class="note-item">1. 以上价格仅包服务器和磁盘的费用, 以上价格仅包服务器和磁盘的费用, 公共带宽流量按官网价格 均价$0.12USD/GB</div>
<div class="note-item">2. 月付按官网价 {{ formatDiscount(form.monthly_discount) }} </div>
<div class="note-item">3. 年付按官网价 {{ formatDiscount(form.yearly_discount) }} </div>
<div class="note-item">2. 月付仅实例部分按官网价 {{ formatDiscount(form.monthly_discount) }} 磁盘不参与优惠</div>
<div class="note-item">3. 年付仅实例部分按官网价 {{ formatDiscount(form.yearly_discount) }} 磁盘不参与优惠</div>
</div>
</div>
@ -605,10 +621,32 @@
//
const dataRows = this.comparisonList.map(instance => {
const officialMonthlyPrice = instance.total_monthly_price
const discountedMonthlyPrice = officialMonthlyPrice * this.form.monthly_discount
const officialYearlyPrice = officialMonthlyPrice * 12
const discountedYearlyPrice = officialYearlyPrice * this.form.yearly_discount
const officialMonthlyPrice = this.getOfficialMonthlyPrice(instance)
const officialYearlyPrice = this.getOfficialYearlyPrice(instance)
const discountedMonthlyPrice = this.getDiscountedMonthlyPrice(instance)
const discountedYearlyPrice = this.getDiscountedYearlyPrice(instance)
const instanceMonthlyPrice = Number(instance.monthly_price) || 0
const diskMonthlyPrice = Number(instance.disk_monthly_price) || 0
const officialMonthlyDetail = [
`实例: $${instanceMonthlyPrice.toFixed(2)}`,
`磁盘: $${diskMonthlyPrice.toFixed(2)}`,
`共计: $${officialMonthlyPrice.toFixed(2)}`
].join('\n')
const discountedMonthlyDetail = [
`实例: $${(instanceMonthlyPrice * Number(this.form.monthly_discount || 0)).toFixed(2)}`,
`磁盘: $${diskMonthlyPrice.toFixed(2)}`,
`共计: $${discountedMonthlyPrice.toFixed(2)}`
].join('\n')
const officialYearlyDetail = [
`实例: $${(instanceMonthlyPrice * 12).toFixed(2)}`,
`磁盘: $${(diskMonthlyPrice * 12).toFixed(2)}`,
`共计: $${officialYearlyPrice.toFixed(2)}`
].join('\n')
const discountedYearlyDetail = [
`实例: $${(instanceMonthlyPrice * 12 * Number(this.form.yearly_discount || 0)).toFixed(2)}`,
`磁盘: $${(diskMonthlyPrice * 12).toFixed(2)}`,
`共计: $${discountedYearlyPrice.toFixed(2)}`
].join('\n')
return [
'EC2',
@ -616,10 +654,10 @@
`${instance.disk_gb}G GP3`,
this.formatOS(instance.operating_system),
this.getRegionName(instance.region),
officialMonthlyPrice.toFixed(2),
discountedMonthlyPrice.toFixed(2),
officialYearlyPrice.toFixed(2),
discountedYearlyPrice.toFixed(2)
officialMonthlyDetail,
discountedMonthlyDetail,
officialYearlyDetail,
discountedYearlyDetail
]
})
@ -628,8 +666,8 @@
emptyRow,
['说明事项:'],
['1. 以上价格仅包服务器和磁盘的费用, 以上价格仅包服务器和磁盘的费用, 公共带宽流量按官网价格 均价$0.12USD/GB'],
[`2. 月付按官网价 ${this.formatDiscount(this.form.monthly_discount)}`],
[`3. 年付按官网价 ${this.formatDiscount(this.form.yearly_discount)}`]
[`2. 月付(仅实例部分)按官网价 ${this.formatDiscount(this.form.monthly_discount)},磁盘不参与优惠`],
[`3. 年付(仅实例部分)按官网价 ${this.formatDiscount(this.form.yearly_discount)},磁盘不参与优惠`]
]
//
@ -656,6 +694,9 @@
const rowHeights = Array(allRows.length).fill({ hpt: 25 })
rowHeights[0] = { hpt: 35 } //
rowHeights[4] = { hpt: 30 } //
for (let i = 0; i < dataRows.length; i++) {
rowHeights[4 + 1 + i] = { hpt: 55 }
}
ws['!rows'] = rowHeights
//
@ -737,11 +778,20 @@
}
}
//
for (let r = noteStartRow; r < noteStartRow + 5; r++) {
for (let c = 0; c < 9; c++) {
const cellRef = XLSX.utils.encode_cell({ r, c })
if (!ws[cellRef]) ws[cellRef] = { v: '', t: 's' }
if (!ws[cellRef].s) ws[cellRef].s = {}
ws[cellRef].s.alignment = { horizontal: 'left', vertical: 'center', wrapText: true }
}
}
//
const priceColsStyle = {
numFmt: '0.00',
font: { color: { rgb: '1F7B69' } },
alignment: { horizontal: 'center', vertical: 'center' },
alignment: { horizontal: 'left', vertical: 'center', wrapText: true },
border: {
top: { style: 'thin' },
bottom: { style: 'thin' },
@ -808,6 +858,26 @@
if (os === 'Windows') return 'Windows'
return os
},
getOfficialMonthlyPrice(instance) {
const instancePrice = Number(instance.monthly_price) || 0
const diskPrice = Number(instance.disk_monthly_price) || 0
return instancePrice + diskPrice
},
getOfficialYearlyPrice(instance) {
return this.getOfficialMonthlyPrice(instance) * 12
},
getDiscountedMonthlyPrice(instance) {
const instancePrice = Number(instance.monthly_price) || 0
const diskPrice = Number(instance.disk_monthly_price) || 0
const discount = Number(this.form.monthly_discount) || 0
return instancePrice * discount + diskPrice
},
getDiscountedYearlyPrice(instance) {
const instancePrice = Number(instance.monthly_price) || 0
const diskPrice = Number(instance.disk_monthly_price) || 0
const discount = Number(this.form.yearly_discount) || 0
return instancePrice * 12 * discount + diskPrice * 12
},
//
calculateDiscountedPrice(originalPrice, discount) {
return originalPrice * discount;
@ -961,6 +1031,14 @@
font-weight: 700;
}
.price-breakdown-text {
display: flex;
flex-direction: column;
gap: 2px;
font-size: 12px;
line-height: 1.3;
}
.no-results {
padding: 40px 0;
}

File diff suppressed because it is too large Load Diff