2020-02-21 17:57:19 +08:00
|
|
|
|
<template>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<div class="right-box right-box-dc" v-clickoutside="clickOutside">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
|
|
|
|
|
<div class="right-box-top-btns">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<button id="dc-del" type="button" v-if="editDc.id" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<span class="right-box-top-btn-icon"><i class="el-icon-delete"></i></span>
|
|
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- end--顶部按钮-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--标题-->
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<div class="right-box-title">{{editDc.id ? ($t("asset.editIdcTab.title") + " ID:" + editDc.id) : $t("asset.AddIdcTab.title")}}</div>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<!-- end--标题-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--表单-->
|
|
|
|
|
|
<el-scrollbar class="right-box-form-box">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-form class="right-box-form right-box-form-left" label-width="120px" :model="editDc" label-position="right" :rules="rules" ref="dcForm">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<el-form-item :label='$t("overall.name")' prop="name">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-input placeholder="" maxlength="64" show-word-limit v-model="editDc.name" size="small"></el-input>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</el-form-item>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<el-form-item :label='$t("asset.location")' prop="location">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-input placeholder="" v-model="editDc.location" size="small"></el-input>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</el-form-item>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<el-form-item :label='$t("asset.tel")' prop="tel">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-input placeholder="" v-model="editDc.tel" size="small"></el-input>
|
2020-02-24 15:26:51 +08:00
|
|
|
|
</el-form-item>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<el-form-item :label='$t("asset.principal")' prop="principal">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-select value-key="id" popper-class="config-dropdown" v-model="editDc.principal" placeholder="" size="small">
|
|
|
|
|
|
<el-option @click.native="" v-for="item in userData" :key="item.userId" :label="item.username" :value="item.userId" :id="'dc-principal-op-'+item.userId">
|
2020-02-24 15:26:51 +08:00
|
|
|
|
<span>{{item.username}}</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label='$t("config.dc.area")' prop="area">
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<select-area ref="selectArea" :areaData="areaData" :placement="'bottom-start'" @selectArea="selectArea" :currentArea="editDc.area.id">
|
2020-02-24 20:27:14 +08:00
|
|
|
|
<template v-slot:trigger>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<el-input placeholder="" v-model="editDc.area.name" size="small" readonly="readonly" @click.native="toSelectArea"></el-input>
|
2020-02-24 20:27:14 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</select-area>
|
2020-02-24 15:26:51 +08:00
|
|
|
|
</el-form-item>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
|
|
|
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
|
|
|
|
|
<button @click="esc" id="dc-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-07-16 17:33:20 +08:00
|
|
|
|
<button @click="save" id="dc-box-save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100">
|
2020-02-21 17:57:19 +08:00
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2020-02-24 20:27:14 +08:00
|
|
|
|
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
import selectArea from "../popBox/selectArea"; //dc弹框
|
2020-02-21 17:57:19 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: "dcBox",
|
|
|
|
|
|
props: {
|
2020-02-24 15:26:51 +08:00
|
|
|
|
dc: Object,
|
|
|
|
|
|
userData: Array
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
2020-07-16 17:33:20 +08:00
|
|
|
|
components:{
|
|
|
|
|
|
'select-area': selectArea
|
|
|
|
|
|
},
|
2020-02-21 17:57:19 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
editDc: {},
|
2020-02-21 17:57:19 +08:00
|
|
|
|
rules: {
|
|
|
|
|
|
name: [
|
2020-02-24 20:27:14 +08:00
|
|
|
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
2020-02-21 17:57:19 +08:00
|
|
|
|
],
|
|
|
|
|
|
},
|
2020-02-24 15:26:51 +08:00
|
|
|
|
areaData: [],
|
2020-02-21 17:57:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
/*关闭弹框*/
|
2020-07-16 17:33:20 +08:00
|
|
|
|
esc(refresh) {
|
|
|
|
|
|
this.$emit("close", refresh);
|
|
|
|
|
|
},
|
|
|
|
|
|
clickOutside() {
|
|
|
|
|
|
this.esc(false);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
2020-02-24 20:27:14 +08:00
|
|
|
|
/*弹出选择area弹框*/
|
|
|
|
|
|
toSelectArea() {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.$refs.selectArea.openBox(this.editDc.area);
|
2020-02-24 20:27:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2020-02-21 17:57:19 +08:00
|
|
|
|
/*保存*/
|
|
|
|
|
|
save() {
|
|
|
|
|
|
this.$refs.dcForm.validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
if (this.editDc.id) {
|
|
|
|
|
|
if (this.editDc.area) {
|
|
|
|
|
|
this.editDc.areaId = this.editDc.area.id;
|
2020-02-24 20:27:14 +08:00
|
|
|
|
}
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.$put('idc', this.editDc).then(response => {
|
2020-02-21 17:57:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.esc(true);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
if (this.editDc.area) {
|
|
|
|
|
|
this.editDc.areaId = this.editDc.area.id;
|
2020-02-24 20:27:14 +08:00
|
|
|
|
}
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.$post('idc', this.editDc).then(response => {
|
2020-02-21 17:57:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.esc(true);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/*删除*/
|
|
|
|
|
|
del() {
|
|
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.$delete("idc?ids=" + this.editDc.id).then(response => {
|
2020-02-21 17:57:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.esc(true);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-02-24 15:26:51 +08:00
|
|
|
|
getAreaData() {
|
2020-02-24 20:27:14 +08:00
|
|
|
|
this.$get('area', {pid: 0}).then(response => {
|
2020-02-24 15:26:51 +08:00
|
|
|
|
if (response.code === 200) {
|
2020-02-24 20:27:14 +08:00
|
|
|
|
this.areaData = response.data.list;
|
2020-02-24 15:26:51 +08:00
|
|
|
|
}
|
2020-02-24 20:27:14 +08:00
|
|
|
|
});
|
2020-02-24 15:26:51 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2020-02-24 20:27:14 +08:00
|
|
|
|
selectArea(area) {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.editDc.area.id = area.id;
|
|
|
|
|
|
this.editDc.area.name = area.name;
|
2020-02-24 15:26:51 +08:00
|
|
|
|
}
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
2020-02-24 15:26:51 +08:00
|
|
|
|
mounted() {
|
|
|
|
|
|
this.getAreaData();
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
dc: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep:true,
|
|
|
|
|
|
handler(n, o) {
|
2020-07-16 17:33:20 +08:00
|
|
|
|
this.editDc = JSON.parse(JSON.stringify(n));
|
2020-02-21 17:57:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|