2020-03-02 19:47:57 +08:00
|
|
|
<template>
|
2020-07-30 18:37:04 +08:00
|
|
|
<div class="right-box right-box-cabinet" v-clickoutside="clickOutside">
|
|
|
|
|
<!-- 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" class="nz-btn nz-btn-size-normal nz-btn-size-alien" id="cab-del" type="button" v-has="'dc_cabinet_delete'" v-if="!editCabinet.id">
|
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-30 18:37:04 +08:00
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- end--顶部按钮-->
|
2020-03-02 19:47:57 +08:00
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
<!-- begin--标题-->
|
2020-07-30 18:58:25 +08:00
|
|
|
<div class="right-box-title">{{editCabinet.id ? $t("config.dc.editCabinet") + " ID: " + editCabinet.id : $t("overall.createCabinet")}}</div>
|
2020-07-30 18:37:04 +08:00
|
|
|
<!-- end--标题-->
|
2020-03-02 19:47:57 +08:00
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
<!-- begin--表单-->
|
|
|
|
|
<el-scrollbar class="right-box-form-box">
|
|
|
|
|
<el-form class="right-box-form right-box-form-left" label-width="120px" label-position="right" :model="editCabinet" ref="cabinetForm" :rules="rules">
|
|
|
|
|
<el-form-item :label="$t('overall.name')" prop="name">
|
|
|
|
|
<el-input size='mini' v-model="editCabinet.name"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="$t('config.dc.dc')" prop="idcId">
|
|
|
|
|
<el-input size='mini' v-model="currentDc.name" disabled/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="$t('asset.uSize')" prop="uSize">
|
|
|
|
|
<el-input v-model.number="editCabinet.uSize" :max="47" ></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="$t('config.dc.remark')">
|
|
|
|
|
<el-input size='mini' v-model="editCabinet.remark" type="textarea" :rows="2"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-scrollbar>
|
2020-03-02 19:47:57 +08:00
|
|
|
|
2020-07-30 18:37:04 +08:00
|
|
|
<!--底部按钮-->
|
|
|
|
|
<div class="right-box-bottom-btns">
|
|
|
|
|
<button @click="esc" id="cab-box-esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-min-width-100">
|
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
</button>
|
2020-12-08 21:53:37 +08:00
|
|
|
<button @click="save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100" id="cab-box-save" v-has="'dc_cabinet_save'">
|
2020-07-30 18:37:04 +08:00
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
</button>
|
2020-03-02 19:47:57 +08:00
|
|
|
</div>
|
2020-07-30 18:37:04 +08:00
|
|
|
</div>
|
2020-03-02 19:47:57 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
name: "cabinetBox",
|
|
|
|
|
props:{
|
2020-07-30 18:37:04 +08:00
|
|
|
cabinet: {type:Object},
|
|
|
|
|
currentDc: {type:Object}
|
2020-03-02 19:47:57 +08:00
|
|
|
},
|
|
|
|
|
data(){
|
|
|
|
|
return {
|
2020-07-30 18:37:04 +08:00
|
|
|
editCabinet:{},
|
2020-03-02 19:47:57 +08:00
|
|
|
rules:{
|
|
|
|
|
name: [
|
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
|
|
|
|
],
|
|
|
|
|
uSize: [
|
2020-04-02 20:57:43 +08:00
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'},
|
|
|
|
|
{type: 'number', min: 1, max: 47,message: this.$t('validate.uSize'),trigger: 'blur'}
|
2020-03-02 19:47:57 +08:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods:{
|
2020-07-30 18:37:04 +08:00
|
|
|
clickOutside() {
|
|
|
|
|
this.esc(false);
|
2020-03-02 19:47:57 +08:00
|
|
|
},
|
2020-07-30 18:37:04 +08:00
|
|
|
esc(refresh) {
|
|
|
|
|
this.$emit("close", refresh);
|
2020-03-02 19:47:57 +08:00
|
|
|
},
|
2020-07-30 18:37:04 +08:00
|
|
|
save() {
|
|
|
|
|
this.$refs.cabinetForm.validate((valid => {
|
2020-03-02 19:47:57 +08:00
|
|
|
if(valid){
|
2020-07-30 18:37:04 +08:00
|
|
|
this.editCabinet.idcId = this.currentDc.id;
|
|
|
|
|
if (this.editCabinet.id) {
|
|
|
|
|
this.$put('cabinet', this.editCabinet).then(res => {
|
2020-03-02 19:47:57 +08:00
|
|
|
if (res.code === 200) {
|
2020-07-30 18:37:04 +08:00
|
|
|
this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
this.esc(true);
|
2020-03-02 19:47:57 +08:00
|
|
|
} else {
|
2020-07-30 18:37:04 +08:00
|
|
|
this.$message.error(res.msg);
|
2020-03-02 19:47:57 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
2020-07-30 18:37:04 +08:00
|
|
|
this.$post('cabinet', this.editCabinet).then(res => {
|
2020-03-02 19:47:57 +08:00
|
|
|
if (res.code === 200) {
|
2020-07-30 18:37:04 +08:00
|
|
|
this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
this.esc(true);
|
2020-03-02 19:47:57 +08:00
|
|
|
} else {
|
2020-07-30 18:37:04 +08:00
|
|
|
this.$message.error(res.msg);
|
2020-03-02 19:47:57 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
},
|
2020-07-30 18:37:04 +08:00
|
|
|
del() {
|
2020-03-02 19:47:57 +08:00
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
2020-07-30 18:37:04 +08:00
|
|
|
this.$delete('/cabinet?ids=' + this.editCabinet.id).then(response=>{
|
2020-03-02 19:47:57 +08:00
|
|
|
if(response.code == 200){
|
|
|
|
|
this.$message({duration: 2000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2020-07-30 18:37:04 +08:00
|
|
|
this.esc(true);
|
2020-03-02 19:47:57 +08:00
|
|
|
}else{
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch:{
|
2020-07-30 18:37:04 +08:00
|
|
|
cabinet:{
|
2020-03-02 19:47:57 +08:00
|
|
|
deep:true,
|
|
|
|
|
immediate:true,
|
|
|
|
|
handler:function(n,o){
|
2020-03-25 18:38:13 +08:00
|
|
|
if (n) {
|
2020-07-30 18:37:04 +08:00
|
|
|
this.editCabinet = JSON.parse(JSON.stringify(n));
|
2020-03-25 18:38:13 +08:00
|
|
|
}
|
2020-03-02 19:47:57 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2020-05-28 18:53:41 +08:00
|
|
|
<style >
|
2020-03-02 19:47:57 +08:00
|
|
|
</style>
|