2020-07-15 20:43:19 +08:00
|
|
|
|
<template>
|
2021-01-18 18:58:57 +08:00
|
|
|
|
<div class="right-box right-box-prom" v-clickoutside="{obj:editPromServer,func:clickOutside}">
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
2020-10-15 14:27:46 +08:00
|
|
|
|
<div class="right-box-top-btns right-box-form-delete">
|
2020-12-08 21:53:37 +08:00
|
|
|
|
<button @click="del" type="button" v-has="'prom_delete'" v-if="editPromServer.id"
|
2020-10-15 14:27:46 +08:00
|
|
|
|
class="nz-btn nz-btn-size-normal nz-btn-size-alien"
|
2020-07-15 20:43:19 +08:00
|
|
|
|
id="promServer-edit-del">
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-delete"></i></span>
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--标题-->
|
|
|
|
|
|
<div class="right-box-title">{{editPromServer.id ? ($t("config.promServer.editProm") + " ID:" + editPromServer.id) : $t("config.promServer.createProm")}}</div>
|
|
|
|
|
|
<!-- end--标题-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--表单-->
|
2020-12-14 20:25:24 +08:00
|
|
|
|
<div class="right-box-form-box">
|
2020-10-15 14:27:46 +08:00
|
|
|
|
<el-form class="right-box-form right-box-form-left" :model="editPromServer" label-position="right" label-width="120px" :rules="rules" ref="promServerForm">
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<!--DC-->
|
|
|
|
|
|
<el-form-item :label="$t('config.dc.dc')" prop="idc.name">
|
|
|
|
|
|
<div class="right-box-form-content">
|
2021-02-04 11:21:00 +08:00
|
|
|
|
<el-select value-key="id" popper-class="config-dropdown" v-model="editPromServer.idc" placeholder="" size="small" id="prom-box-input-idc">
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<el-option v-for="item in dcData" :key="item.id" :label="item.name" :value="item" :id="'prom-edit-idc-op-'+item.id">
|
|
|
|
|
|
<span class="config-dropdown-label-txt">{{item.name}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!--host-->
|
|
|
|
|
|
<el-form-item label="Host" prop="host">
|
2021-02-04 11:21:00 +08:00
|
|
|
|
<el-input type="text" placeholder="" v-model="editPromServer.host" size="small" id="prom-box-input-host"></el-input>
|
2020-07-15 20:43:19 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--Port-->
|
|
|
|
|
|
<el-form-item label="Port" prop="port">
|
2021-02-04 11:21:00 +08:00
|
|
|
|
<el-input type="text" placeholder="" v-model.number="editPromServer.port" size="small" id="prom-box-input-port"></el-input>
|
2020-07-15 20:43:19 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--type-->
|
|
|
|
|
|
<el-form-item :label="$t('config.promServer.type')" prop="type">
|
2020-09-01 15:36:21 +08:00
|
|
|
|
<el-cascader
|
2021-02-04 11:21:00 +08:00
|
|
|
|
id="prom-box-input-type"
|
2020-09-01 15:36:21 +08:00
|
|
|
|
style="width: 100%"
|
|
|
|
|
|
v-model="editPromServer.type"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
:options="$CONSTANTS.promServer.theData"
|
|
|
|
|
|
:props="{ multiple: false, checkStrictly: false ,emitPath:false}"
|
|
|
|
|
|
clearable></el-cascader>
|
2020-07-15 20:43:19 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
2020-12-14 20:25:24 +08:00
|
|
|
|
</div>
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<!-- end--表单-->
|
|
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
2021-01-18 18:58:57 +08:00
|
|
|
|
<button v-cancel="{obj:editPromServer,func:esc}" id="prom-esc"
|
2020-10-13 14:30:57 +08:00
|
|
|
|
class="nz-btn nz-btn-size-normal-new nz-btn-style-light-new">
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
2021-01-21 17:29:29 +08:00
|
|
|
|
<button @click="save" id="prom-save"
|
2020-12-21 13:56:36 +08:00
|
|
|
|
class="nz-btn nz-btn-size-normal-new nz-btn-style-normal-new" :disabled="prevent_opt.save" :class="{'nz-btn-disabled':prevent_opt.save}">
|
2020-07-15 20:43:19 +08:00
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import {host} from '../../common/js/validate';
|
|
|
|
|
|
import {port} from '../../common/js/validate';
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "promServerBox",
|
|
|
|
|
|
props: {
|
|
|
|
|
|
promServer: Object
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
rules: {
|
|
|
|
|
|
'idc.name': [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'change'}
|
|
|
|
|
|
],
|
|
|
|
|
|
host: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'},
|
|
|
|
|
|
{validator: host, trigger: 'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
port: [
|
|
|
|
|
|
{validator: port, trigger: 'blur'},
|
|
|
|
|
|
{required: true, message: this.$t('validate.required')}
|
|
|
|
|
|
],
|
|
|
|
|
|
type: [
|
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'change'},
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
editPromServer: {},
|
|
|
|
|
|
dcData: [], //data center数据
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
/*关闭弹框*/
|
|
|
|
|
|
esc(refresh) {
|
|
|
|
|
|
this.$emit("close", refresh);
|
|
|
|
|
|
},
|
2020-07-16 17:33:20 +08:00
|
|
|
|
clickOutside() {
|
|
|
|
|
|
this.esc(false);
|
|
|
|
|
|
},
|
2020-07-15 20:43:19 +08:00
|
|
|
|
/*保存*/
|
|
|
|
|
|
save() {
|
|
|
|
|
|
this.$refs.promServerForm.validate(valid => {
|
|
|
|
|
|
if (valid) {
|
2020-12-21 13:56:36 +08:00
|
|
|
|
this.prevent_opt.save=true;
|
2020-07-15 20:43:19 +08:00
|
|
|
|
if (this.editPromServer.id) {
|
|
|
|
|
|
this.$put('promServer', this.editPromServer).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.esc(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
2020-12-21 13:56:36 +08:00
|
|
|
|
this.prevent_opt.save=false;
|
2020-07-15 20:43:19 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$post('promServer', this.editPromServer).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.esc(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
2020-12-21 13:56:36 +08:00
|
|
|
|
this.prevent_opt.save=false;
|
2020-07-15 20:43:19 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
/*删除*/
|
|
|
|
|
|
del() {
|
|
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.$delete("promServer?ids=" + this.editPromServer.id).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
|
|
|
|
|
this.esc(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
//获取dc下拉列表数据
|
|
|
|
|
|
getDcData() {
|
2020-11-17 17:36:26 +08:00
|
|
|
|
this.$get('idc',{pageSize:-1}).then(response => {
|
2020-07-15 20:43:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.dcData = response.data.list;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
//将prop里的user转为组件内部对象
|
|
|
|
|
|
promServer: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler(n) {
|
|
|
|
|
|
this.editPromServer = JSON.parse(JSON.stringify(n));
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
'editPromServer.idc': function (n, o) {
|
|
|
|
|
|
this.editPromServer.idcId = n.id;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
this.getDcData();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|