[区域]可以设置区域-价格项目之间的价格

This commit is contained in:
GoEdgeLab
2020-12-10 22:06:54 +08:00
parent dc5d815637
commit 9103f1a7b8
23 changed files with 671 additions and 6 deletions

View File

@@ -0,0 +1,36 @@
{$layout "layout_popup"}
<h3>添加价格项</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<table class="ui table definition selectable">
<tr>
<td class="title">名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus"/>
</td>
</tr>
<tr>
<td>最低流量 *</td>
<td>
<div class="ui input right labeled">
<input type="text" name="bitsFrom" maxlength="16" style="width:10em" v-model="bitsFrom" autocomplete="off"/>
<span class="ui label">MBPS</span>
</div>
<p class="comment">采用1000进制<span v-if="bitsFromMB.length > 0">,相当于{{bitsFromMB}}</span></p>
</td>
</tr>
<tr>
<td>最高流量 *</td>
<td>
<div class="ui input right labeled">
<input type="text" name="bitsTo" maxlength="16" style="width:10em" v-model="bitsTo" autocomplete="off"/>
<span class="ui label">MBPS</span>
</div>
<p class="comment">采用1000进制<span v-if="bitsToMB.length > 0">,相当于{{bitsToMB}}</span></p>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,42 @@
Tea.context(function () {
this.bitsFrom = 0
this.bitsFromMB = ""
this.bitsTo = 0
this.bitsToMB = ""
this.$delay(function () {
let that = this
this.$watch("bitsFrom", function (v) {
this.bitsFromMB = that.formatBits(v)
})
this.$watch("bitsTo", function (v) {
this.bitsToMB = that.formatBits(v)
})
})
this.formatBits = function (bits) {
bits = parseInt(bits)
if (isNaN(bits)) {
bits = 0
}
if (bits < 1000) {
return bits + "MB"
}
if (bits < 1000 * 1000) {
return (bits / 1000) + "GB"
}
if (bits < 1000 * 1000 * 1000) {
return (bits / 1000 / 1000) + "TB"
}
if (bits < 1000 * 1000 * 1000 * 1000) {
return (bits / 1000 / 1000 / 1000) + "PB"
}
return ""
}
})

View File

@@ -0,0 +1,37 @@
{$layout "layout_popup"}
<h3>修改价格项</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="itemId" :value="item.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus" v-model="item.name"/>
</td>
</tr>
<tr>
<td>最低流量 *</td>
<td>
<div class="ui input right labeled">
<input type="text" name="bitsFrom" maxlength="16" style="width:10em" v-model="bitsFrom" autocomplete="off"/>
<span class="ui label">MBPS</span>
</div>
<p class="comment">采用1000进制<span v-if="bitsFromMB.length > 0">,相当于{{bitsFromMB}}</span></p>
</td>
</tr>
<tr>
<td>最高流量 *</td>
<td>
<div class="ui input right labeled">
<input type="text" name="bitsTo" maxlength="16" style="width:10em" v-model="bitsTo" autocomplete="off"/>
<span class="ui label">MBPS</span>
</div>
<p class="comment">采用1000进制<span v-if="bitsToMB.length > 0">,相当于{{bitsToMB}}</span></p>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,45 @@
Tea.context(function () {
this.bitsFrom = this.item.bitsFrom / 1000 / 1000
this.bitsFromMB = ""
this.bitsTo = this.item.bitsTo / 1000 / 1000
this.bitsToMB = ""
this.$delay(function () {
let that = this
this.$watch("bitsFrom", function (v) {
this.bitsFromMB = that.formatBits(v)
})
this.$watch("bitsTo", function (v) {
this.bitsToMB = that.formatBits(v)
})
this.bitsFromMB = that.formatBits(this.bitsFrom)
this.bitsToMB = that.formatBits(this.bitsTo)
})
this.formatBits = function (bits) {
bits = parseInt(bits)
if (isNaN(bits)) {
bits = 0
}
if (bits < 1000) {
return bits + "MB"
}
if (bits < 1000 * 1000) {
return (bits / 1000) + "GB"
}
if (bits < 1000 * 1000 * 1000) {
return (bits / 1000 / 1000) + "TB"
}
if (bits < 1000 * 1000 * 1000 * 1000) {
return (bits / 1000 / 1000 / 1000) + "PB"
}
return ""
}
})