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

This commit is contained in:
刘祥超
2020-12-10 22:06:54 +08:00
parent dd852ae149
commit a6ad4a739d
23 changed files with 671 additions and 6 deletions

View File

@@ -0,0 +1,6 @@
<first-menu>
<menu-item href="/clusters/regions" code="region">区域</menu-item>
<menu-item href="/clusters/regions/prices" code="price">价格</menu-item>
<span class="item">|</span>
<menu-item><tip-icon content="可以设置节点所属区域,从而利用区域设置进行不同的价格设定。"></tip-icon></menu-item>
</first-menu>

View File

@@ -1,14 +1,13 @@
{$layout}
{$template "menu"}
<first-menu>
<second-menu>
<menu-item @click.prevent="createRegion()">创建</menu-item>
<span class="item">|</span>
<menu-item><tip-icon content="可以设置节点所属区域,从而利用区域设置进行不同的价格设定。"></tip-icon></menu-item>
</first-menu>
</second-menu>
<p class="comment" v-if="regions.length == 0">暂时还没有区域。</p>
<table class="ui table selectable" v-if="regions.length > 0" style="width: 35em" id="sortable-table">
<table class="ui table selectable" v-if="regions.length > 0" id="sortable-table">
<thead>
<tr>
<th style="width:3em"></th>

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 ""
}
})

View File

@@ -0,0 +1,15 @@
th span {
font-size: 0.9em;
font-weight: normal;
color: grey;
}
th a {
font-weight: normal;
}
td a {
display: none;
}
td:hover a {
display: inline;
}
/*# sourceMappingURL=prices.css.map */

View File

@@ -0,0 +1 @@
{"version":3,"sources":["prices.less"],"names":[],"mappings":"AAAA,EACC;EACC,gBAAA;EACA,mBAAA;EACA,WAAA;;AAJF,EAOC;EACC,mBAAA;;AAIF,EACC;EACC,aAAA;;AAIF,EAAE,MACD;EACC,eAAA","file":"prices.css"}

View File

@@ -0,0 +1,31 @@
{$layout}
{$template "menu"}
<p class="comment" v-if="regions.length == 0">暂时还没有区域。</p>
<table class="ui table selectable">
<thead>
<tr>
<th style="width:7em">区域\范围</th>
<th v-for="item in items">
{{item.name}}
&nbsp; <a href="" title="修改" @click.prevent="updateItem(item.id)"><i class="icon pencil small"></i></a> &nbsp;
<a href="" title="删除" @click.prevent="deleteItem(item.id)"><i class="icon remove small"></i></a>
<br/>
<span>{{item.bitsFromString}}-{{item.bitsToString}}</span>
</th>
<th class="width10">
<a href="" @click.prevent="createItem">[+添加价格项]</a>
</th>
</tr>
</thead>
<tr v-for="region in regions">
<td>{{region.name}}</td>
<td v-for="item in items">
<span v-if="region.prices[item.id.toString()] != null">¥{{region.prices[item.id.toString()]}}元/GB &nbsp;</span>
<a href="" title="修改单位价格" @click.prevent="updatePrice(region.id, item.id)">[设置]</a>
</td>
<td></td>
</tr>
</table>

View File

@@ -0,0 +1,42 @@
Tea.context(function () {
this.createItem = function () {
teaweb.popup(Tea.url(".items.createPopup"), {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.updateItem = function (itemId) {
teaweb.popup(Tea.url(".items.updatePopup", {itemId: itemId}), {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.deleteItem = function (itemId) {
let that = this
teaweb.confirm("确定要删除此价格项吗?", function () {
that.$post(".items.delete")
.params({
itemId: itemId
})
.refresh()
})
}
this.updatePrice = function (regionId, itemId) {
teaweb.popup(Tea.url(".updatePricePopup", {regionId: regionId, itemId: itemId}), {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
})

View File

@@ -0,0 +1,23 @@
th {
span {
font-size: 0.9em;
font-weight: normal;
color: grey;
}
a {
font-weight: normal;
}
}
td {
a {
display: none;
}
}
td:hover {
a {
display: inline;
}
}

View File

@@ -0,0 +1,30 @@
{$layout "layout_popup"}
<h3>修改价格</h3>
<form class="ui form" method="post" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="regionId" :value="region.id"/>
<input type="hidden" name="itemId" :value="item.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">区域</td>
<td>{{region.name}}</td>
</tr>
<tr>
<td>价格项</td>
<td>{{item.name}}</td>
</tr>
<tr>
<td class="title">单位价格 *</td>
<td>
<div class="ui input right labeled">
<input type="text" name="price" maxlength="10" style="width:6em" ref="focus" v-model="price"/>
<span class="ui label">元/GB</span>
</div>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>