[WAF]省份封禁增加全选功能

This commit is contained in:
GoEdgeLab
2020-12-04 09:51:18 +08:00
parent 1dad8af0c3
commit 9e3dc3d2d2
4 changed files with 40 additions and 2 deletions

View File

@@ -9,6 +9,7 @@
<tr> <tr>
<td class="title">已封禁</td> <td class="title">已封禁</td>
<td> <td>
<span v-if="countSelectedCountries == 0" class="disabled">暂时没有选择封禁区域。</span>
<div class="ui label tiny basic" v-for="country in countries" v-if="country.isChecked" style="margin-bottom: 0.5em"> <div class="ui label tiny basic" v-for="country in countries" v-if="country.isChecked" style="margin-bottom: 0.5em">
<input type="hidden" name="countryIds" :value="country.id"/> <input type="hidden" name="countryIds" :value="country.id"/>
({{country.letter}}){{country.name}} <a href="" @click.prevent="deselectCountry(country)" title="取消封禁"><i class="icon remove"></i></a> ({{country.letter}}){{country.name}} <a href="" @click.prevent="deselectCountry(country)" title="取消封禁"><i class="icon remove"></i></a>

View File

@@ -5,6 +5,9 @@ Tea.context(function () {
this.selectedGroup = "ABC" this.selectedGroup = "ABC"
this.letterCountries = {} this.letterCountries = {}
let that = this let that = this
this.countSelectedCountries = this.countries.$count(function (k, country) {
return country.isChecked
})
this.countries.forEach(function (country) { this.countries.forEach(function (country) {
if (typeof (that.letterCountries[country.letter]) == "undefined") { if (typeof (that.letterCountries[country.letter]) == "undefined") {
that.letterCountries[country.letter] = [] that.letterCountries[country.letter] = []
@@ -19,10 +22,12 @@ Tea.context(function () {
this.selectCountry = function (country) { this.selectCountry = function (country) {
country.isChecked = !country.isChecked country.isChecked = !country.isChecked
this.change()
} }
this.deselectCountry = function (country) { this.deselectCountry = function (country) {
country.isChecked = false country.isChecked = false
this.change()
} }
this.checkAll = function () { this.checkAll = function () {
@@ -31,6 +36,8 @@ Tea.context(function () {
this.countries.forEach(function (country) { this.countries.forEach(function (country) {
country.isChecked = that.isCheckingAll country.isChecked = that.isCheckingAll
}) })
this.change()
} }
this.success = function () { this.success = function () {
@@ -39,6 +46,11 @@ Tea.context(function () {
}) })
} }
this.change = function () {
this.countSelectedCountries = this.countries.$count(function (k, country) {
return country.isChecked
})
}
/** /**
* 添加IP名单菜单 * 添加IP名单菜单

View File

@@ -9,6 +9,7 @@
<tr> <tr>
<td class="title">已封禁</td> <td class="title">已封禁</td>
<td> <td>
<span v-if="countSelectedProvinces == 0" class="disabled">暂时没有选择封禁省份。</span>
<div class="ui label tiny basic" v-for="province in provinces" v-if="province.isChecked" style="margin-bottom: 0.5em"> <div class="ui label tiny basic" v-for="province in provinces" v-if="province.isChecked" style="margin-bottom: 0.5em">
<input type="hidden" name="provinceIds" :value="province.id"/> <input type="hidden" name="provinceIds" :value="province.id"/>
{{province.name}} <a href="" @click.prevent="deselectProvince(province)" title="取消封禁"><i class="icon remove"></i></a> {{province.name}} <a href="" @click.prevent="deselectProvince(province)" title="取消封禁"><i class="icon remove"></i></a>
@@ -18,7 +19,16 @@
<tr> <tr>
<td>选择封禁区域</td> <td>选择封禁区域</td>
<td> <td>
<more-options-indicator>选择省份/自治区</more-options-indicator>
<first-menu>
<menu-item><more-options-indicator>选择省份/自治区</more-options-indicator></menu-item>
<div class="item right" v-if="moreOptionsVisible">
<div class="ui checkbox" @click.prevent="checkAll">
<input type="checkbox" v-model="isCheckingAll"/>
<label>全选</label>
</div>
</div>
</first-menu>
<div class="province-list" v-show="moreOptionsVisible" style="margin-top:0.5em"> <div class="province-list" v-show="moreOptionsVisible" style="margin-top:0.5em">
<div class="item" v-for="province in provinces"> <div class="item" v-for="province in provinces">

View File

@@ -1,20 +1,28 @@
Tea.context(function () { Tea.context(function () {
this.isCheckingAll = false this.isCheckingAll = false
this.countSelectedProvinces = this.provinces.$count(function (k, province) {
return province.isChecked
})
this.selectProvince = function (province) { this.selectProvince = function (province) {
province.isChecked = !province.isChecked province.isChecked = !province.isChecked
this.change()
} }
this.deselectProvince = function (province) { this.deselectProvince = function (province) {
province.isChecked = false province.isChecked = false
this.change()
} }
this.checkAll = function () { this.checkAll = function () {
this.isCheckingAll = !this.isCheckingAll this.isCheckingAll = !this.isCheckingAll
let that = this
this.provinces.forEach(function (province) { this.provinces.forEach(function (province) {
province.isChecked = that.isCheckingAll province.isChecked = that.isCheckingAll
}) })
this.change()
} }
this.success = function () { this.success = function () {
@@ -23,6 +31,13 @@ Tea.context(function () {
}) })
} }
this.change = function () {
this.countSelectedProvinces = this.provinces.$count(function (k, province) {
return province.isChecked
})
}
/** /**
* 添加IP名单菜单 * 添加IP名单菜单
*/ */