diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js
index b3d4a4f02..fa2958e5c 100644
--- a/nezha-fronted/src/components/common/language/en.js
+++ b/nezha-fronted/src/components/common/language/en.js
@@ -371,6 +371,7 @@ const en = {
dc: {
dc: 'Datacenter',
area: "Area",
+ selectArea: 'Select area',
cabinetNum: "Cabinet number"
}
},
diff --git a/nezha-fronted/src/components/common/popBox/selectArea.vue b/nezha-fronted/src/components/common/popBox/selectArea.vue
new file mode 100644
index 000000000..048e222bc
--- /dev/null
+++ b/nezha-fronted/src/components/common/popBox/selectArea.vue
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
{{$t('config.dc.selectArea')}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nezha-fronted/src/components/common/rightBox/dcBox.vue b/nezha-fronted/src/components/common/rightBox/dcBox.vue
index d1aa3d465..b67fc02dd 100644
--- a/nezha-fronted/src/components/common/rightBox/dcBox.vue
+++ b/nezha-fronted/src/components/common/rightBox/dcBox.vue
@@ -3,7 +3,7 @@
-
+
@@ -75,6 +87,18 @@
},
data() {
return {
+ currentDc: {
+ id: '',
+ name: '',
+ location: '',
+ tel: '',
+ principal: '',
+ area: {
+ id: '',
+ name: ''
+ },
+ areaId: ''
+ },
rightBox: {
show: false,
title: '',
@@ -82,8 +106,7 @@
},
rules: {
name: [
- {required: true, message: this.$t('validate.required'), trigger: 'blur'},
- {validator: noSpecialChar,trigger: "change"}
+ {required: true, message: this.$t('validate.required'), trigger: 'blur'}
],
},
areaData: [],
@@ -132,51 +155,6 @@
}]
}
},
- data2: [{
- id: 1,
- label: '一级 1',
- children: [{
- id: 4,
- label: '二级 1-1',
- children: [{
- id: 9,
- label: '三级 1-1-1'
- }, {
- id: 10,
- label: '三级 1-1-2'
- }]
- }]
- }, {
- id: 2,
- label: '一级 2',
- children: [{
- id: 5,
- label: '二级 2-1'
- }, {
- id: 6,
- label: '二级 2-2'
- }]
- }, {
- id: 3,
- label: '一级 3',
- children: [{
- id: 7,
- label: '二级 3-1'
- }, {
- id: 8,
- label: '二级 3-2',
- children: [{
- id: 11,
- label: '三级 3-2-1'
- }, {
- id: 12,
- label: '三级 3-2-2'
- }, {
- id: 13,
- label: '三级 3-2-3'
- }]
- }]
- }],
}
},
methods: {
@@ -190,12 +168,20 @@
this.rightBox.show = false;
},
+ /*弹出选择area弹框*/
+ toSelectArea() {
+ this.$refs.selectArea.openBox(this.currentDc.area);
+ },
+
/*保存*/
save() {
this.$refs.dcForm.validate((valid) => {
if (valid) {
- if (this.dc.id) {
- this.$put('idc', this.dc).then(response => {
+ if (this.currentDc.id) {
+ if (this.currentDc.area) {
+ this.currentDc.areaId = this.currentDc.area.id;
+ }
+ this.$put('idc', this.currentDc).then(response => {
if (response.code === 200) {
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
this.rightBox.show = false;
@@ -205,10 +191,14 @@
}
});
} else {
- this.$post('idc', this.dc).then(response => {
+ if (this.currentDc.area) {
+ this.currentDc.areaId = this.currentDc.area.id;
+ }
+ this.$post('idc', this.currentDc).then(response => {
if (response.code === 200) {
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
this.rightBox.show = false;
+ this.$emit("reload");
} else {
this.$message.error(response.msg);
}
@@ -222,7 +212,7 @@
saveOrToEdit: function() {
if (!this.rightBox.isEdit) {
this.rightBox.isEdit = true;
- this.rightBox.title = this.$t("asset.createAssetTab.editIdcTab.title") + " ID:" + this.dc.id;
+ this.rightBox.title = this.$t("asset.createAssetTab.editIdcTab.title") + " ID:" + this.currentDc.id;
} else {
this.save();
}
@@ -234,11 +224,11 @@
cancelButtonText: this.$t("tip.no"),
type: 'warning'
}).then(() => {
- this.$delete("idc?ids=" + this.dc.id).then(response => {
+ this.$delete("idc?ids=" + this.currentDc.id).then(response => {
if (response.code === 200) {
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
this.rightBox.show = false;
- this.$store.commit('dcListChange');
+ this.$emit("reload");
} else {
this.$message.error(response.msg);
}
@@ -246,19 +236,16 @@
});
},
getAreaData() {
- this.areaData = this.toTreeData(this.data);
-
- /*this.$get('area', {}).then(response => {
+ this.$get('area', {pid: 0}).then(response => {
if (response.code === 200) {
- let rawData = response.data.list;
- //将原始数据处理为el-tree格式
-
+ this.areaData = response.data.list;
}
- });*/
+ });
},
- toTreeData(rawData) {
- return rawData;
+ selectArea(area) {
+ this.currentDc.area.id = area.id;
+ this.currentDc.area.name = area.name;
}
},
mounted() {
@@ -271,6 +258,7 @@
immediate: true,
deep:true,
handler(n, o) {
+ this.currentDc = JSON.parse(JSON.stringify(n));
if (n && n.id) {
this.rightBox.title =this.rightBox.isEdit? this.$t("asset.createAssetTab.editIdcTab.title") + " ID:" + n.id : this.$t("config.dc.dc") + " ID:" + n.id ;
} else {
diff --git a/nezha-fronted/src/components/page/config/dc.vue b/nezha-fronted/src/components/page/config/dc.vue
index 76d1deb0b..d76d4b5bf 100644
--- a/nezha-fronted/src/components/page/config/dc.vue
+++ b/nezha-fronted/src/components/page/config/dc.vue
@@ -23,7 +23,7 @@