Skip to content

Commit

Permalink
cmdb增加region字段
Browse files Browse the repository at this point in the history
  • Loading branch information
yangmv authored and yangmv committed Jan 9, 2019
1 parent 4fab890 commit 4dfcc45
Show file tree
Hide file tree
Showing 5 changed files with 430 additions and 430 deletions.
3 changes: 2 additions & 1 deletion src/view/cmdb/db/Add.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<Option value="qcloud" >腾讯云</Option>
<Option value="aliyun" >阿里云</Option>
<Option value="aws" >AWS</Option>
<Option value="internal" >内网</Option>
<Option value="other" >其他</Option>
</Select>
</FormItem>
Expand Down Expand Up @@ -175,7 +176,7 @@ export default {
dialog: Object,
formData: Object
},
mounted(){
mounted () {
getGroupList().then(res => {
const data = res.data
for (var item in data) {
Expand Down
8 changes: 4 additions & 4 deletions src/view/cmdb/db/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default {
port: 3306,
username: null,
password: null,
role:'master',
role: 'master',
idc: 'other',
db_type: 'MySQL',
db_version: '5.7',
Expand Down Expand Up @@ -307,11 +307,11 @@ export default {
}
},
// 获取API
handleAPI(index, row) {
handleAPI (index, row) {
this.api_dialog = {
show: true,
title: '获取API',
name: 'host='+row.host
name: 'host=' + row.host
}
},
// 新增
Expand Down Expand Up @@ -430,7 +430,7 @@ export default {
os_version: '',
sn: '',
comment: '',
role:'master',
role: 'master',
idc: 'other',
admin_user: null,
group: [],
Expand Down
253 changes: 127 additions & 126 deletions src/view/cmdb/server/Add.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<!-- <div> -->
<!-- <Card> -->
<Modal width="600px;" v-model="dialog.show" :title="dialog.title" :loading=true :footer-hide=true @on-cancel="handleCancel">
<Modal width="600px;" v-model="dialog.show" :title="dialog.title" :loading=true :footer-hide=true @on-cancel="handleCancel">
<Form ref="formData" :model="formData" :rules="ruleValidate" :label-width="80">
<FormItem label="主机名" prop="hostname">
<Input v-model="formData.hostname" placeholder=""></Input>
Expand All @@ -23,6 +23,7 @@
<Option value="qcloud" >腾讯云</Option>
<Option value="aliyun" >阿里云</Option>
<Option value="aws" >AWS</Option>
<Option value="internal" >内网</Option>
<Option value="other" >其他</Option>
</Select>
</FormItem>
Expand Down Expand Up @@ -54,7 +55,7 @@
<FormItem label="IP" prop="ip">
<Input v-model="formData.ip" placeholder=""></Input>
</FormItem>

<FormItem label="Port">
<Input v-model="formData.port" placeholder=""></Input>
</FormItem>
Expand Down Expand Up @@ -101,7 +102,7 @@
@on-change="tagHandleChange">
</Transfer>
</FormItem>

<FormItem>
<Button type="primary" @click="handleSubmit('formData')">提交</Button>
<Button @click="handleReset('formData')" style="margin-left: 8px">重置</Button>
Expand All @@ -112,132 +113,132 @@
<!-- </div> -->
</template>
<script>
import { getAdmUser,getGroupList,getTagList,addProject } from '@/api/cmdb/server'
//import { getAppList } from '@/api/app'
export default {
name: 'add',
data () {
return {
single : false,
GroupList: [],
TagList: [],
groupTitle: ['可关联','已关联'],
tagTitle: ['可关联','已关联'],
AdmUser: [],
ruleValidate: {
hostname: [
{ required: true, message: '项目名称不能为空', trigger: 'blur' }
],
ip: [
{ required: true, message: 'IP不能为空', trigger: 'blur' }
],
port: [
{ required: true, message: '端口不能为空', trigger: 'blur' }
]
}
}
},
methods: {
groupHandleChange (newTargetKeys) {
console.log(this.formData.group)
this.formData.group = newTargetKeys;
},
groupFilter (data, query) {
return data.label.indexOf(query) > -1;
},
tagHandleChange (newTargetKeys) {
console.log(this.formData.tag)
this.formData.tag = newTargetKeys;
},
tagFilter (data, query) {
return data.label.indexOf(query) > -1;
},
handleCancel(){
this.$emit('e-close');
},
handleSubmit (name) {
this.$refs[name].validate((valid) => {
if (valid) {
// add => post => /api/cmdb/server/
// edit => put => /api/cmdb/server/1
console.log(this.formData)
const url = this.dialog.option == 'add' ? '/' : `/${this.formData.id}/`;
const action = this.dialog.option == 'add' ? 'post' : 'put';
const msg = this.dialog.option == 'add' ? '主机添加成功' : '主机修改成功';
addProject(this.formData,url,action).then(res => {
console.log(res)
if (res.status){
this.$Message.success({
content: msg,
duration: 3
});
this.$emit('e-close');
this.$emit('e-update');
}else{
this.$Message.error({
content: res.data.msg,
duration: 3
});
}
}).catch(error =>{
this.$Message.error({
content: JSON.stringify(error.response.data),
duration: 10
});
});
} else {
this.$Message.error({
content: '请检查必选项',
duration: 3
});
}
})
},
handleReset (name) {
console.log('name..',name)
this.$refs[name].resetFields();
}
},
props:{
dialog: Object,
formData: Object
},
watch:{
formData: function(){
this.single = this.formData.single
},
single: function(){
if(this.single == false){
this.formData.username = null
this.formData.password = null
}
import { getAdmUser, getGroupList, getTagList, addProject } from '@/api/cmdb/server'
// import { getAppList } from '@/api/app'
export default {
name: 'add',
data () {
return {
single: false,
GroupList: [],
TagList: [],
groupTitle: ['可关联', '已关联'],
tagTitle: ['可关联', '已关联'],
AdmUser: [],
ruleValidate: {
hostname: [
{ required: true, message: '项目名称不能为空', trigger: 'blur' }
],
ip: [
{ required: true, message: 'IP不能为空', trigger: 'blur' }
],
port: [
{ required: true, message: '端口不能为空', trigger: 'blur' }
]
}
}
},
methods: {
groupHandleChange (newTargetKeys) {
console.log(this.formData.group)
this.formData.group = newTargetKeys
},
groupFilter (data, query) {
return data.label.indexOf(query) > -1
},
tagHandleChange (newTargetKeys) {
console.log(this.formData.tag)
this.formData.tag = newTargetKeys
},
tagFilter (data, query) {
return data.label.indexOf(query) > -1
},
handleCancel () {
this.$emit('e-close')
},
handleSubmit (name) {
this.$refs[name].validate((valid) => {
if (valid) {
// add => post => /api/cmdb/server/
// edit => put => /api/cmdb/server/1
console.log(this.formData)
const url = this.dialog.option == 'add' ? '/' : `/${this.formData.id}/`
const action = this.dialog.option == 'add' ? 'post' : 'put'
const msg = this.dialog.option == 'add' ? '主机添加成功' : '主机修改成功'
addProject(this.formData, url, action).then(res => {
console.log(res)
if (res.status) {
this.$Message.success({
content: msg,
duration: 3
})
this.$emit('e-close')
this.$emit('e-update')
} else {
this.$Message.error({
content: res.data.msg,
duration: 3
})
}
},
mounted(){
getGroupList().then(res => {
const data = res.data
for(var item in data){
this.GroupList.push({
key: data[item].id,
label: data[item].name
})
}
}),
getTagList().then(res => {
const data = res.data
for(var item in data){
this.TagList.push({
key: data[item].id,
label: data[item].name
})
}
}),
getAdmUser().then(res => {
this.AdmUser = res.data
console.log(this.AdmUser)
}).catch(error => {
this.$Message.error({
content: JSON.stringify(error.response.data),
duration: 10
})
})
} else {
this.$Message.error({
content: '请检查必选项',
duration: 3
})
}
})
},
handleReset (name) {
console.log('name..', name)
this.$refs[name].resetFields()
}
},
props: {
dialog: Object,
formData: Object
},
watch: {
formData: function () {
this.single = this.formData.single
},
single: function () {
if (this.single == false) {
this.formData.username = null
this.formData.password = null
}
}
},
mounted () {
getGroupList().then(res => {
const data = res.data
for (var item in data) {
this.GroupList.push({
key: data[item].id,
label: data[item].name
})
}
}),
getTagList().then(res => {
const data = res.data
for (var item in data) {
this.TagList.push({
key: data[item].id,
label: data[item].name
})
}
}),
getAdmUser().then(res => {
this.AdmUser = res.data
console.log(this.AdmUser)
})
}
}
</script>
16 changes: 8 additions & 8 deletions src/view/cmdb/server/Detail.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<Modal width="600px;" v-model="dialog.show" :title="dialog.title" :loading=true :footer-hide=true>
<Modal width="600px;" v-model="dialog.show" :title="dialog.title" :loading=true :footer-hide=true>
<Card dis-hover>
<div class="inner" >
<Alert show-icon>基本信息</Alert>
Expand Down Expand Up @@ -80,11 +80,11 @@

</template>
<script>
export default {
name: 'detail',
props:{
dialog: Object,
formData: Object
}
}
export default {
name: 'detail',
props: {
dialog: Object,
formData: Object
}
}
</script>
Loading

0 comments on commit 4dfcc45

Please sign in to comment.