Vue.component("ip-list-table", { props: ["v-items", "v-keyword", "v-show-search-button", "v-total"/** total items >= items length **/], data: function () { let maxDeletes = 10000 if (this.vTotal != null && this.vTotal > 0 && this.vTotal < maxDeletes) { maxDeletes = this.vTotal } return { items: this.vItems, keyword: (this.vKeyword != null) ? this.vKeyword : "", selectedAll: false, hasSelectedItems: false, MaxDeletes: maxDeletes } }, methods: { updateItem: function (itemId) { this.$emit("update-item", itemId) }, deleteItem: function (itemId) { this.$emit("delete-item", itemId) }, viewLogs: function (itemId) { teaweb.popup("/servers/iplists/accessLogsPopup?itemId=" + itemId, { width: "50em", height: "30em" }) }, changeSelectedAll: function () { let boxes = this.$refs.itemCheckBox if (boxes == null) { return } let that = this boxes.forEach(function (box) { box.checked = that.selectedAll }) this.hasSelectedItems = this.selectedAll }, changeSelected: function (e) { let that = this that.hasSelectedItems = false let boxes = that.$refs.itemCheckBox if (boxes == null) { return } boxes.forEach(function (box) { if (box.checked) { that.hasSelectedItems = true } }) }, deleteAll: function () { let boxes = this.$refs.itemCheckBox if (boxes == null) { return } let itemIds = [] boxes.forEach(function (box) { if (box.checked) { itemIds.push(box.value) } }) if (itemIds.length == 0) { return } Tea.action("/servers/iplists/deleteItems") .post() .params({ itemIds: itemIds }) .success(function () { teaweb.successToast("批量删除成功", 1200, teaweb.reload) }) }, deleteCount: function () { let that = this teaweb.confirm("确定要批量删除当前列表中的" + this.MaxDeletes + "个IP吗?", function () { let query = window.location.search if (query.startsWith("?")) { query = query.substring(1) } Tea.action("/servers/iplists/deleteCount?" + query) .post() .params({count: that.MaxDeletes}) .success(function () { teaweb.successToast("批量删除成功", 1200, teaweb.reload) }) }) }, formatSeconds: function (seconds) { if (seconds < 60) { return seconds + "秒" } if (seconds < 3600) { return Math.ceil(seconds / 60) + "分钟" } if (seconds < 86400) { return Math.ceil(seconds / 3600) + "小时" } return Math.ceil(seconds / 86400) + "天" } }, template: `
| 
            		 | 
                IP | 类型 | 级别 | 过期时间 | 备注 | 操作 | 
|---|---|---|---|---|---|---|
| 
					 | 
				
					
					 
						{{item.region}}
						| {{item.isp}}
					 
					{{item.isp}} 
				
					
						添加于 {{item.createdTime}}
							
								@ 
								
								[黑白名单:{{item.list.name}}]
								[黑白名单:{{item.list.name}}
								
								
									
										[服务:{{item.policy.server.name}}]
										[服务:{{item.policy.server.name}}]
									
									
										[策略:{{item.policy.name}}]
									
								
							
						
					 
				 | 
				IPv4 IPv4 IPv6 所有IP | {{item.eventLevelName}} - | 
					 
						{{item.expiredTime}}
						 
					不过期
				
							已过期
						 
						
							{{formatSeconds(item.lifeSeconds)}}
						 
					 | 
				{{item.reason}} - | 日志 修改 删除 |