// 一个节点的多个集群选择器 Vue.component("node-clusters-selector", { props: ["v-primary-cluster", "v-secondary-clusters"], data: function () { let primaryCluster = this.vPrimaryCluster let secondaryClusters = this.vSecondaryClusters if (secondaryClusters == null) { secondaryClusters = [] } return { primaryClusterId: (primaryCluster == null) ? 0 : primaryCluster.id, secondaryClusterIds: secondaryClusters.map(function (v) { return v.id }), primaryCluster: primaryCluster, secondaryClusters: secondaryClusters } }, methods: { addPrimary: function () { let that = this let selectedClusterIds = [this.primaryClusterId].concat(this.secondaryClusterIds) teaweb.popup("/clusters/selectPopup?selectedClusterIds=" + selectedClusterIds.join(",") + "&mode=single", { height: "30em", width: "50em", callback: function (resp) { if (resp.data.cluster != null) { that.primaryCluster = resp.data.cluster that.primaryClusterId = that.primaryCluster.id that.notifyChange() } } }) }, removePrimary: function () { this.primaryClusterId = 0 this.primaryCluster = null this.notifyChange() }, addSecondary: function () { let that = this let selectedClusterIds = [this.primaryClusterId].concat(this.secondaryClusterIds) teaweb.popup("/clusters/selectPopup?selectedClusterIds=" + selectedClusterIds.join(",") + "&mode=multiple", { height: "30em", width: "50em", callback: function (resp) { if (resp.data.cluster != null) { that.secondaryClusterIds.push(resp.data.cluster.id) that.secondaryClusters.push(resp.data.cluster) that.notifyChange() } } }) }, removeSecondary: function (index) { this.secondaryClusterIds.$remove(index) this.secondaryClusters.$remove(index) this.notifyChange() }, notifyChange: function () { this.$emit("change", { clusterId: this.primaryClusterId }) } }, template: `
主集群
{{primaryCluster.name}}  

多个集群配置有冲突时,优先使用主集群配置。

从集群
{{cluster.name}}  
` })