[区域]增加区域管理

This commit is contained in:
刘祥超
2020-12-10 15:02:55 +08:00
parent 90c5e69157
commit 33676c7c80
17 changed files with 367 additions and 4 deletions

View File

@@ -0,0 +1,15 @@
{$layout "layout_popup"}
<h3>创建区域</h3>
<form class="ui form" method="post" data-tea-success="success" data-tea-action="$">
<csrf-token></csrf-token>
<table class="ui table definition selectable">
<tr>
<td>区域名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus"/>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,35 @@
{$layout}
<first-menu>
<menu-item @click.prevent="createRegion()">创建</menu-item>
<span class="item">|</span>
<menu-item><tip-icon content="可以设置节点所属区域,从而利用区域设置进行不同的价格设定。"></tip-icon></menu-item>
</first-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">
<thead>
<tr>
<th style="width:3em"></th>
<th>区域名称</th>
<th class="width10 center">节点数</th>
<th class="width10">区域状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tbody v-for="region in regions" :v-id="region.id">
<tr>
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
<td :class="{disabled: !region.isOn}">{{region.name}}</td>
<td class="center">{{region.countNodes}}</td>
<td>
<label-on :v-is-on="region.isOn"></label-on>
</td>
<td>
<a href="" @click.prevent="updateRegion(region.id)">修改</a> &nbsp; <a href="" @click.prevent="deleteRegion(region.id)">删除</a>
</td>
</tr>
</tbody>
</table>
<p v-if="regions.length > 0" class="comment">可以拖动左侧的<i class="icon bars"></i>排序。</p>

View File

@@ -0,0 +1,45 @@
Tea.context(function () {
this.$delay(function () {
let that = this
sortTable(function (ids) {
that.$post(".sort")
.params({
regionIds: ids
})
.success(function () {
teaweb.successToast("排序保存成功")
})
})
})
this.createRegion = function () {
teaweb.popup(Tea.url(".createPopup"), {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.updateRegion = function (regionId) {
teaweb.popup(Tea.url(".updatePopup?regionId=" + regionId), {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.deleteRegion = function (regionId) {
let that = this
teaweb.confirm("确定要删除这个区域吗?", function () {
that.$post(".delete")
.params({
regionId: regionId
})
.refresh()
})
}
})

View File

@@ -0,0 +1,27 @@
{$layout "layout_popup"}
<h3>修改区域</h3>
<form class="ui form" method="post" data-tea-success="success" data-tea-action="$">
<csrf-token></csrf-token>
<input type="hidden" name="regionId" :value="region.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">区域名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus" v-model="region.name"/>
</td>
</tr>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>是否启用</td>
<td>
<checkbox name="isOn" v-model="region.isOn"></checkbox>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>
</form>