Vue.component("ad-instance-objects-box", { props: ["v-objects", "v-user-id"], mounted: function () { this.getUserServers(1) }, data: function () { let objects = this.vObjects if (objects == null) { objects = [] } let objectCodes = [] objects.forEach(function (v) { objectCodes.push(v.code) }) return { userId: this.vUserId, objects: objects, objectCodes: objectCodes, isAdding: true, servers: [], serversIsLoading: false } }, methods: { add: function () { this.isAdding = true }, cancel: function () { this.isAdding = false }, remove: function (index) { let that = this teaweb.confirm("确定要删除此防护对象吗?", function () { that.objects.$remove(index) that.notifyChange() }) }, removeObjectCode: function (objectCode) { let index = -1 this.objectCodes.forEach(function (v, k) { if (objectCode == v) { index = k } }) if (index >= 0) { this.objects.$remove(index) this.notifyChange() } }, getUserServers: function (page) { if (Tea.Vue == null) { let that = this setTimeout(function () { that.getUserServers(page) }, 100) return } let that = this this.serversIsLoading = true Tea.Vue.$post(".userServers") .params({ userId: this.userId, page: page, pageSize: 5 }) .success(function (resp) { that.servers = resp.data.servers that.$refs.serverPage.updateMax(resp.data.page.max) that.serversIsLoading = false }) .error(function () { that.serversIsLoading = false }) }, changeServerPage: function (page) { this.getUserServers(page) }, selectServerObject: function (server) { if (this.existObjectCode("server:" + server.id)) { return } this.objects.push({ "type": "server", "code": "server:" + server.id, "id": server.id, "name": server.name }) this.notifyChange() }, notifyChange: function () { let objectCodes = [] this.objects.forEach(function (v) { objectCodes.push(v.code) }) this.objectCodes = objectCodes }, existObjectCode: function (objectCode) { let found = false this.objects.forEach(function (v) { if (v.code == objectCode) { found = true } }) return found } }, template: `
暂时还没有设置任何防护对象。
已选中防护对象
网站:{{object.name}}  
对象类型 网站
网站列表 加载中...
暂时还没有可选的网站。
网站名称 操作
{{server.name}} 选中 取消
` })