// 监控节点分组选择 Vue.component("report-node-groups-selector", { props: ["v-group-ids"], mounted: function () { let that = this Tea.action("/clusters/monitors/groups/options") .post() .success(function (resp) { that.groups = resp.data.groups.map(function (group) { group.isChecked = that.groupIds.$contains(group.id) return group }) that.isLoaded = true }) }, data: function () { var groupIds = this.vGroupIds if (groupIds == null) { groupIds = [] } return { groups: [], groupIds: groupIds, isLoaded: false, allGroups: groupIds.length == 0 } }, methods: { check: function (group) { group.isChecked = !group.isChecked this.groupIds = [] let that = this this.groups.forEach(function (v) { if (v.isChecked) { that.groupIds.push(v.id) } }) this.change() }, change: function () { let that = this let groups = [] this.groupIds.forEach(function (groupId) { let group = that.groups.$find(function (k, v) { return v.id == groupId }) if (group == null) { return } groups.push({ id: group.id, name: group.name }) }) this.$emit("change", groups) } }, watch: { allGroups: function (b) { if (b) { this.groupIds = [] this.groups.forEach(function (v) { v.isChecked = false }) } this.change() } }, template: `
还没有分组。
` })