创建集群的时候可以填写DNS信息/集群设置页增加DNS设置功能

This commit is contained in:
刘祥超
2020-11-15 16:28:25 +08:00
parent 5d652c2f77
commit e09f1575b4
16 changed files with 497 additions and 19 deletions

View File

@@ -0,0 +1,38 @@
{$layout "layout_popup"}
<h3>修改集群DNS设置</h3>
<form method="post" class="ui form" data-tea-success="success" data-tea-action="$">
<csrf-token></csrf-token>
<table class="ui table definition selectable">
<tr>
<td class="title">DNS服务商</td>
<td>
<select name="providerType" class="ui dropdown auto-width" v-model="providerType" @change="changeProviderType">
<option v-for="providerType in providerTypes" :value="providerType.code">{{providerType.name}}</option>
</select>
</td>
</tr>
<tr>
<td>账号</td>
<td>
<p class="comment" v-if="providers.length == 0">没有账号可选</p>
<select name="providerId" class="ui dropdown auto-width" v-model="providerId" v-show="providers.length > 0">
<option v-for="provider in providers" :value="provider.id">{{provider.name}}</option>
</select>
</td>
</tr>
<tr v-show="providerId > 0">
<td>域名</td>
<td>
<p class="comment" v-if="domains.length == 0">没有域名可选</p>
<select name="domainId" class="ui dropdown auto-width" v-model="domainId" v-show="domains.length > 0">
<option v-for="domain in domains" :value="domain.id">{{domain.name}}</option>
</select>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,80 @@
Tea.context(function () {
this.$delay(function () {
this.changeProviderType()
this.changeProvider()
this.$watch("providerId", function () {
this.changeProvider()
})
this.$watch("domainId", function () {
this.changeDomain()
})
})
this.success = NotifyPopup
// 初始化的内容
// this.domainId = 0
// this.domain = ""
// this.providerId = 0
if (this.providerType == "") {
this.providerType = this.providerTypes[0].code
}
this.providers = []
this.domains = []
this.changeProviderType = function () {
this.$post("/dns/providerOptions")
.params({
type: this.providerType
})
.success(function (resp) {
this.providers = resp.data.providers
// 检查providerId
if (this.providers.length == 0) {
this.providerId = 0
return
}
let that = this
if (this.providers.$find(function (k, v) {
return v.id == that.providerId
}) == null) {
this.providerId = this.providers[0].id
}
this.changeProvider()
})
}
this.changeProvider = function () {
this.$post("/dns/domainOptions")
.params({
providerId: this.providerId
})
.success(function (resp) {
this.domains = resp.data.domains
this.changeDomain()
})
}
this.changeDomain = function () {
if (this.domains.length == 0) {
this.domainId = 0
this.domain = ""
return
}
let domainId = this.domainId
let domainInfo = this.domains.$find(function (k, v) {
return v.id == domainId
})
if (domainInfo == null) {
// 默认选取第一个
this.domainId = this.domains[0].id
this.domain = this.domains[0].name
} else {
this.domain = domainInfo.name
}
}
})