Skip to content

Commit 4dfcc45

Browse files
yangmvyangmv
authored andcommitted
cmdb增加region字段
1 parent 4fab890 commit 4dfcc45

5 files changed

Lines changed: 430 additions & 430 deletions

File tree

src/view/cmdb/db/Add.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<Option value="qcloud" >腾讯云</Option>
3333
<Option value="aliyun" >阿里云</Option>
3434
<Option value="aws" >AWS</Option>
35+
<Option value="internal" >内网</Option>
3536
<Option value="other" >其他</Option>
3637
</Select>
3738
</FormItem>
@@ -175,7 +176,7 @@ export default {
175176
dialog: Object,
176177
formData: Object
177178
},
178-
mounted(){
179+
mounted () {
179180
getGroupList().then(res => {
180181
const data = res.data
181182
for (var item in data) {

src/view/cmdb/db/List.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export default {
186186
port: 3306,
187187
username: null,
188188
password: null,
189-
role:'master',
189+
role: 'master',
190190
idc: 'other',
191191
db_type: 'MySQL',
192192
db_version: '5.7',
@@ -307,11 +307,11 @@ export default {
307307
}
308308
},
309309
// 获取API
310-
handleAPI(index, row) {
310+
handleAPI (index, row) {
311311
this.api_dialog = {
312312
show: true,
313313
title: '获取API',
314-
name: 'host='+row.host
314+
name: 'host=' + row.host
315315
}
316316
},
317317
// 新增
@@ -430,7 +430,7 @@ export default {
430430
os_version: '',
431431
sn: '',
432432
comment: '',
433-
role:'master',
433+
role: 'master',
434434
idc: 'other',
435435
admin_user: null,
436436
group: [],

src/view/cmdb/server/Add.vue

Lines changed: 127 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<!-- <div> -->
33
<!-- <Card> -->
4-
<Modal width="600px;" v-model="dialog.show" :title="dialog.title" :loading=true :footer-hide=true @on-cancel="handleCancel">
4+
<Modal width="600px;" v-model="dialog.show" :title="dialog.title" :loading=true :footer-hide=true @on-cancel="handleCancel">
55
<Form ref="formData" :model="formData" :rules="ruleValidate" :label-width="80">
66
<FormItem label="主机名" prop="hostname">
77
<Input v-model="formData.hostname" placeholder=""></Input>
@@ -23,6 +23,7 @@
2323
<Option value="qcloud" >腾讯云</Option>
2424
<Option value="aliyun" >阿里云</Option>
2525
<Option value="aws" >AWS</Option>
26+
<Option value="internal" >内网</Option>
2627
<Option value="other" >其他</Option>
2728
</Select>
2829
</FormItem>
@@ -54,7 +55,7 @@
5455
<FormItem label="IP" prop="ip">
5556
<Input v-model="formData.ip" placeholder=""></Input>
5657
</FormItem>
57-
58+
5859
<FormItem label="Port">
5960
<Input v-model="formData.port" placeholder=""></Input>
6061
</FormItem>
@@ -101,7 +102,7 @@
101102
@on-change="tagHandleChange">
102103
</Transfer>
103104
</FormItem>
104-
105+
105106
<FormItem>
106107
<Button type="primary" @click="handleSubmit('formData')">提交</Button>
107108
<Button @click="handleReset('formData')" style="margin-left: 8px">重置</Button>
@@ -112,132 +113,132 @@
112113
<!-- </div> -->
113114
</template>
114115
<script>
115-
import { getAdmUser,getGroupList,getTagList,addProject } from '@/api/cmdb/server'
116-
//import { getAppList } from '@/api/app'
117-
export default {
118-
name: 'add',
119-
data () {
120-
return {
121-
single : false,
122-
GroupList: [],
123-
TagList: [],
124-
groupTitle: ['可关联','已关联'],
125-
tagTitle: ['可关联','已关联'],
126-
AdmUser: [],
127-
ruleValidate: {
128-
hostname: [
129-
{ required: true, message: '项目名称不能为空', trigger: 'blur' }
130-
],
131-
ip: [
132-
{ required: true, message: 'IP不能为空', trigger: 'blur' }
133-
],
134-
port: [
135-
{ required: true, message: '端口不能为空', trigger: 'blur' }
136-
]
137-
}
138-
}
139-
},
140-
methods: {
141-
groupHandleChange (newTargetKeys) {
142-
console.log(this.formData.group)
143-
this.formData.group = newTargetKeys;
144-
},
145-
groupFilter (data, query) {
146-
return data.label.indexOf(query) > -1;
147-
},
148-
tagHandleChange (newTargetKeys) {
149-
console.log(this.formData.tag)
150-
this.formData.tag = newTargetKeys;
151-
},
152-
tagFilter (data, query) {
153-
return data.label.indexOf(query) > -1;
154-
},
155-
handleCancel(){
156-
this.$emit('e-close');
157-
},
158-
handleSubmit (name) {
159-
this.$refs[name].validate((valid) => {
160-
if (valid) {
161-
// add => post => /api/cmdb/server/
162-
// edit => put => /api/cmdb/server/1
163-
console.log(this.formData)
164-
const url = this.dialog.option == 'add' ? '/' : `/${this.formData.id}/`;
165-
const action = this.dialog.option == 'add' ? 'post' : 'put';
166-
const msg = this.dialog.option == 'add' ? '主机添加成功' : '主机修改成功';
167-
addProject(this.formData,url,action).then(res => {
168-
console.log(res)
169-
if (res.status){
170-
this.$Message.success({
171-
content: msg,
172-
duration: 3
173-
});
174-
this.$emit('e-close');
175-
this.$emit('e-update');
176-
}else{
177-
this.$Message.error({
178-
content: res.data.msg,
179-
duration: 3
180-
});
181-
}
182-
}).catch(error =>{
183-
this.$Message.error({
184-
content: JSON.stringify(error.response.data),
185-
duration: 10
186-
});
187-
});
188-
} else {
189-
this.$Message.error({
190-
content: '请检查必选项',
191-
duration: 3
192-
});
193-
}
194-
})
195-
},
196-
handleReset (name) {
197-
console.log('name..',name)
198-
this.$refs[name].resetFields();
199-
}
200-
201-
},
202-
props:{
203-
dialog: Object,
204-
formData: Object
205-
},
206-
watch:{
207-
formData: function(){
208-
this.single = this.formData.single
209-
},
210-
single: function(){
211-
if(this.single == false){
212-
this.formData.username = null
213-
this.formData.password = null
214-
}
116+
import { getAdmUser, getGroupList, getTagList, addProject } from '@/api/cmdb/server'
117+
// import { getAppList } from '@/api/app'
118+
export default {
119+
name: 'add',
120+
data () {
121+
return {
122+
single: false,
123+
GroupList: [],
124+
TagList: [],
125+
groupTitle: ['可关联', '已关联'],
126+
tagTitle: ['可关联', '已关联'],
127+
AdmUser: [],
128+
ruleValidate: {
129+
hostname: [
130+
{ required: true, message: '项目名称不能为空', trigger: 'blur' }
131+
],
132+
ip: [
133+
{ required: true, message: 'IP不能为空', trigger: 'blur' }
134+
],
135+
port: [
136+
{ required: true, message: '端口不能为空', trigger: 'blur' }
137+
]
138+
}
139+
}
140+
},
141+
methods: {
142+
groupHandleChange (newTargetKeys) {
143+
console.log(this.formData.group)
144+
this.formData.group = newTargetKeys
145+
},
146+
groupFilter (data, query) {
147+
return data.label.indexOf(query) > -1
148+
},
149+
tagHandleChange (newTargetKeys) {
150+
console.log(this.formData.tag)
151+
this.formData.tag = newTargetKeys
152+
},
153+
tagFilter (data, query) {
154+
return data.label.indexOf(query) > -1
155+
},
156+
handleCancel () {
157+
this.$emit('e-close')
158+
},
159+
handleSubmit (name) {
160+
this.$refs[name].validate((valid) => {
161+
if (valid) {
162+
// add => post => /api/cmdb/server/
163+
// edit => put => /api/cmdb/server/1
164+
console.log(this.formData)
165+
const url = this.dialog.option == 'add' ? '/' : `/${this.formData.id}/`
166+
const action = this.dialog.option == 'add' ? 'post' : 'put'
167+
const msg = this.dialog.option == 'add' ? '主机添加成功' : '主机修改成功'
168+
addProject(this.formData, url, action).then(res => {
169+
console.log(res)
170+
if (res.status) {
171+
this.$Message.success({
172+
content: msg,
173+
duration: 3
174+
})
175+
this.$emit('e-close')
176+
this.$emit('e-update')
177+
} else {
178+
this.$Message.error({
179+
content: res.data.msg,
180+
duration: 3
181+
})
215182
}
216-
},
217-
mounted(){
218-
getGroupList().then(res => {
219-
const data = res.data
220-
for(var item in data){
221-
this.GroupList.push({
222-
key: data[item].id,
223-
label: data[item].name
224-
})
225-
}
226-
}),
227-
getTagList().then(res => {
228-
const data = res.data
229-
for(var item in data){
230-
this.TagList.push({
231-
key: data[item].id,
232-
label: data[item].name
233-
})
234-
}
235-
}),
236-
getAdmUser().then(res => {
237-
this.AdmUser = res.data
238-
console.log(this.AdmUser)
183+
}).catch(error => {
184+
this.$Message.error({
185+
content: JSON.stringify(error.response.data),
186+
duration: 10
239187
})
188+
})
189+
} else {
190+
this.$Message.error({
191+
content: '请检查必选项',
192+
duration: 3
193+
})
240194
}
195+
})
196+
},
197+
handleReset (name) {
198+
console.log('name..', name)
199+
this.$refs[name].resetFields()
200+
}
241201
202+
},
203+
props: {
204+
dialog: Object,
205+
formData: Object
206+
},
207+
watch: {
208+
formData: function () {
209+
this.single = this.formData.single
210+
},
211+
single: function () {
212+
if (this.single == false) {
213+
this.formData.username = null
214+
this.formData.password = null
215+
}
242216
}
217+
},
218+
mounted () {
219+
getGroupList().then(res => {
220+
const data = res.data
221+
for (var item in data) {
222+
this.GroupList.push({
223+
key: data[item].id,
224+
label: data[item].name
225+
})
226+
}
227+
}),
228+
getTagList().then(res => {
229+
const data = res.data
230+
for (var item in data) {
231+
this.TagList.push({
232+
key: data[item].id,
233+
label: data[item].name
234+
})
235+
}
236+
}),
237+
getAdmUser().then(res => {
238+
this.AdmUser = res.data
239+
console.log(this.AdmUser)
240+
})
241+
}
242+
243+
}
243244
</script>

src/view/cmdb/server/Detail.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Modal width="600px;" v-model="dialog.show" :title="dialog.title" :loading=true :footer-hide=true>
2+
<Modal width="600px;" v-model="dialog.show" :title="dialog.title" :loading=true :footer-hide=true>
33
<Card dis-hover>
44
<div class="inner" >
55
<Alert show-icon>基本信息</Alert>
@@ -80,11 +80,11 @@
8080

8181
</template>
8282
<script>
83-
export default {
84-
name: 'detail',
85-
props:{
86-
dialog: Object,
87-
formData: Object
88-
}
89-
}
83+
export default {
84+
name: 'detail',
85+
props: {
86+
dialog: Object,
87+
formData: Object
88+
}
89+
}
9090
</script>

0 commit comments

Comments
 (0)