Initial commit (code only without large binaries)
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>添加用户流量包</h3>
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
|
||||
<input type="hidden" name="packageId" :value="packageId"/>
|
||||
<input type="hidden" name="regionId" :value="regionId"/>
|
||||
<input type="hidden" name="periodId" :value="periodId"/>
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td>选择用户 *</td>
|
||||
<td>
|
||||
<user-selector></user-selector>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">选择流量包规格 *</td>
|
||||
<td>
|
||||
<span v-if="packages.length > 0"><a v-for="p in packages" class="ui label basic" :class="{blue: p.id == packageId}" @click.prevent="selectPackage(p.id)">{{p.size}}{{p.unit.toUpperCase().replace(/(.)B/, "$1iB")}}</a></span>
|
||||
<span v-else="" class="red">没有流量包可供选择</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>选择区域 *</td>
|
||||
<td>
|
||||
<span v-if="regions.length > 0"><a v-for="region in regions" class="ui label basic" :class="{blue: region.id == regionId && hasRegionPrice(region.id), disabled: !hasRegionPrice(region.id)}" @click.prevent="selectRegion(region.id)">{{region.name}}</a></span>
|
||||
<span v-else="" class="red">没有区域可供选择</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>选择有效期 *</td>
|
||||
<td>
|
||||
<span v-if="periods.length > 0"><a v-for="period in periods" class="ui label basic" :class="{blue: period.id == periodId && hasPeriodPrice(period.id), disabled: !hasPeriodPrice(period.id)}" @click.prevent="selectPeriod(period.id)">{{period.count}}{{period.unitName}}</a></span>
|
||||
<span v-else="" class="red">没有有效期可供选择</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>流量包数量 *</td>
|
||||
<td>
|
||||
<div class="ui input">
|
||||
<select class="ui dropdown" name="count" v-model="count" @change="changeCount">
|
||||
<option v-for="i in 20" :value="i">{{i}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>价格</td>
|
||||
<td>
|
||||
<span v-if="amount == 0" class="disabled">没有找到对应价格</span>
|
||||
<span v-if="amount > 0">{{amount}}元</span>
|
||||
<p class="comment">管理员操作时,此价格仅供展示,并不会从用户账户中扣款。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn :class="{disabled: amount <= 0}"></submit-btn>
|
||||
</form>
|
||||
@@ -0,0 +1,70 @@
|
||||
Tea.context(function () {
|
||||
this.packageId = 0
|
||||
this.regionId = 0
|
||||
this.periodId = 0
|
||||
this.amount = -1
|
||||
this.count = 1
|
||||
|
||||
this.selectPackage = function (packageId) {
|
||||
this.packageId = packageId
|
||||
this.regionId = 0
|
||||
this.periodId = 0
|
||||
this.reloadPrice()
|
||||
}
|
||||
|
||||
this.selectRegion = function (regionId) {
|
||||
this.regionId = regionId
|
||||
this.periodId = 0
|
||||
this.reloadPrice()
|
||||
}
|
||||
|
||||
this.selectPeriod = function (periodId) {
|
||||
this.periodId = periodId
|
||||
this.reloadPrice()
|
||||
}
|
||||
|
||||
this.changeCount = function () {
|
||||
this.reloadPrice()
|
||||
}
|
||||
|
||||
var requestId = 0
|
||||
this.reloadPrice = function () {
|
||||
var newRequestId = (++requestId)
|
||||
this.$post(".price")
|
||||
.params({
|
||||
packageId: this.packageId,
|
||||
regionId: this.regionId,
|
||||
periodId: this.periodId,
|
||||
count: this.count
|
||||
})
|
||||
.success(function (resp) {
|
||||
if (newRequestId == requestId) {
|
||||
this.amount = resp.data.amount
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.hasRegionPrice = function (regionId) {
|
||||
if (this.packageId <= 0) {
|
||||
return false
|
||||
}
|
||||
for (let k in this.prices) {
|
||||
if (k.startsWith(this.packageId + "@" + regionId + "@")) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
this.hasPeriodPrice = function (periodId) {
|
||||
if (this.packageId <= 0 || this.regionId <= 0) {
|
||||
return false
|
||||
}
|
||||
for (let k in this.prices) {
|
||||
if (k == this.packageId + "@" + this.regionId + "@" + periodId) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,53 @@
|
||||
{$layout}
|
||||
{$template "../menu"}
|
||||
|
||||
<second-menu>
|
||||
<menu-item @click.prevent="createUserPackage">[添加用户流量包]</menu-item>
|
||||
</second-menu>
|
||||
|
||||
<p class="comment" v-if="userPackages.length == 0">暂时还没有用户流量包。</p>
|
||||
|
||||
<div v-if="userPackages.length > 0">
|
||||
<table class="ui table selectable celled">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>用户</th>
|
||||
<th>流量包</th>
|
||||
<th style="width: 7em">区域</th>
|
||||
<th style="width: 7em">有效期</th>
|
||||
<th style="width: 7em">开始日期</th>
|
||||
<th style="width: 7em">结束日期</th>
|
||||
<th style="width: 7em">已用流量</th>
|
||||
<th style="width: 7em">剩余流量</th>
|
||||
<th class="one op">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="up in userPackages">
|
||||
<td><user-link :v-user="up.user"></user-link></td>
|
||||
<td>
|
||||
<span v-if="up.package != null">{{up.package.size}}{{up.package.unit.toUpperCase().replace(/(.)B/, "$1iB")}}</span>
|
||||
<span v-else class="disabled">[已删除]</span>
|
||||
|
||||
<div v-if="up.isUsedAll || up.isExpired">
|
||||
<span v-if="up.isUsedAll" class="small red">已用尽</span>
|
||||
<span v-else-if="up.isExpired" class="small red">已过期</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="up.region != null">{{up.region.name}}</span>
|
||||
<span v-else="" class="disabled">[已删除]</span>
|
||||
</td>
|
||||
<td>{{up.periodCount}}{{up.periodUnitName}}</td>
|
||||
<td>{{up.dayFrom}}</td>
|
||||
<td>{{up.dayTo}}</td>
|
||||
<td><span :class="{disabled: up.usedSize == '0B'}">{{up.usedSize}}</span></td>
|
||||
<td><span :class="{disabled: up.availableSize == '0B'}">{{up.availableSize}}</span></td>
|
||||
<td>
|
||||
<a href="" v-if="up.canDelete" @click.prevent="deleteUserPackage(up.id)">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<page-box></page-box>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
Tea.context(function () {
|
||||
this.createUserPackage = function () {
|
||||
teaweb.popup("/finance/packages/user-packages/createPopup", {
|
||||
width: "44em",
|
||||
height: "28em",
|
||||
callback: function () {
|
||||
teaweb.successRefresh("保存成功")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.deleteUserPackage = function (userPackageId) {
|
||||
let that = this
|
||||
teaweb.confirm("确定要删除此用户流量包吗?", function () {
|
||||
that.$post(".delete")
|
||||
.params({
|
||||
userPackageId: userPackageId
|
||||
})
|
||||
.success(function () {
|
||||
teaweb.successRefresh("删除成功")
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user