价格增加总价格设定

This commit is contained in:
GoEdgeLab
2022-07-17 10:53:03 +08:00
parent 760723d94c
commit c6e3c44e71
2 changed files with 24 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ Vue.component("plan-bandwidth-ranges", {
minMB: "", minMB: "",
maxMB: "", maxMB: "",
pricePerMB: "", pricePerMB: "",
totalPrice: "",
addingRange: { addingRange: {
minMB: 0, minMB: 0,
maxMB: 0, maxMB: 0,
@@ -36,6 +37,7 @@ Vue.component("plan-bandwidth-ranges", {
this.minMB = "" this.minMB = ""
this.maxMB = "" this.maxMB = ""
this.pricePerMB = "" this.pricePerMB = ""
this.totalPrice = ""
this.ranges.push(this.addingRange) this.ranges.push(this.addingRange)
this.ranges.$sort(function (v1, v2) { this.ranges.$sort(function (v1, v2) {
if (v1.minMB < v2.minMB) { if (v1.minMB < v2.minMB) {
@@ -83,13 +85,20 @@ Vue.component("plan-bandwidth-ranges", {
pricePerMB = 0 pricePerMB = 0
} }
this.addingRange.pricePerMB = pricePerMB this.addingRange.pricePerMB = pricePerMB
},
totalPrice: function (v) {
let totalPrice = parseFloat(v.toString())
if (isNaN(totalPrice) || totalPrice < 0) {
totalPrice = 0
}
this.addingRange.totalPrice = totalPrice
} }
}, },
template: `<div> template: `<div>
<!-- 已有价格 --> <!-- 已有价格 -->
<div v-if="ranges.length > 0"> <div v-if="ranges.length > 0">
<div class="ui label basic small" v-for="(range, index) in ranges" style="margin-bottom: 0.5em"> <div class="ui label basic small" v-for="(range, index) in ranges" style="margin-bottom: 0.5em">
{{range.minMB}}MB - <span v-if="range.maxMB > 0">{{range.maxMB}}MB</span><span v-else>&infin;</span> &nbsp; 价格:{{range.pricePerMB}}元/MB {{range.minMB}}MB - <span v-if="range.maxMB > 0">{{range.maxMB}}MB</span><span v-else>&infin;</span> &nbsp; 价格:<span v-if="range.totalPrice > 0">{{range.totalPrice}}元</span><span v-else="">{{range.pricePerMB}}元/MB</span>
&nbsp; <a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a> &nbsp; <a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
</div> </div>
<div class="ui divider"></div> <div class="ui divider"></div>
@@ -99,7 +108,7 @@ Vue.component("plan-bandwidth-ranges", {
<div v-if="isAdding"> <div v-if="isAdding">
<table class="ui table"> <table class="ui table">
<tr> <tr>
<td class="title">带宽下限</td> <td class="title">带宽下限 *</td>
<td> <td>
<div class="ui input right labeled"> <div class="ui input right labeled">
<input type="text" placeholder="最小带宽" style="width: 7em" maxlength="10" ref="minMB" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="minMB"/> <input type="text" placeholder="最小带宽" style="width: 7em" maxlength="10" ref="minMB" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="minMB"/>
@@ -108,7 +117,7 @@ Vue.component("plan-bandwidth-ranges", {
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="title">带宽上限</td> <td class="title">带宽上限 *</td>
<td> <td>
<div class="ui input right labeled"> <div class="ui input right labeled">
<input type="text" placeholder="最大带宽" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="maxMB"/> <input type="text" placeholder="最大带宽" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="maxMB"/>
@@ -117,6 +126,16 @@ Vue.component("plan-bandwidth-ranges", {
<p class="comment">如果填0表示上不封顶。</p> <p class="comment">如果填0表示上不封顶。</p>
</td> </td>
</tr> </tr>
<tr>
<td>总价格</td>
<td>
<div class="ui input right labeled">
<input type="text" placeholder="总价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="totalPrice"/>
<span class="ui label">元/MB</span>
</div>
<p class="comment">和单位价格二选一。</p>
</td>
</tr>
<tr> <tr>
<td class="title">单位价格</td> <td class="title">单位价格</td>
<td> <td>
@@ -124,6 +143,7 @@ Vue.component("plan-bandwidth-ranges", {
<input type="text" placeholder="单位价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="pricePerMB"/> <input type="text" placeholder="单位价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="pricePerMB"/>
<span class="ui label">元/MB</span> <span class="ui label">元/MB</span>
</div> </div>
<p class="comment">和总价格二选一。如果设置了单位价格,那么"总价格 = 单位价格 x 带宽"。</p>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -26,7 +26,7 @@ Vue.component("plan-price-view", {
按{{plan.bandwidthPrice.percentile}}th带宽计费 按{{plan.bandwidthPrice.percentile}}th带宽计费
<div> <div>
<div v-for="range in plan.bandwidthPrice.ranges"> <div v-for="range in plan.bandwidthPrice.ranges">
<span class="small grey">{{range.minMB}} - <span v-if="range.maxMB > 0">{{range.maxMB}}MB</span><span v-else>&infin;</span> {{range.pricePerMB}}元/MB</span> <span class="small grey">{{range.minMB}} - <span v-if="range.maxMB > 0">{{range.maxMB}}MB</span><span v-else>&infin;</span> <span v-if="range.totalPrice > 0">{{range.totalPrice}}元</span><span v-else="">{{range.pricePerMB}}元/MB</span></span>
</div> </div>
</div> </div>
</div> </div>