// 监控节点分组选择 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) } }) } }, watch: { allGroups: function (b) { if (b) { this.groupIds = [] this.groups.forEach(function (v) { v.isChecked = false }) } } }, template: `