diff --git a/src/view/cmdb/db/Add.vue b/src/view/cmdb/db/Add.vue index 3ebee68..04e1d1c 100644 --- a/src/view/cmdb/db/Add.vue +++ b/src/view/cmdb/db/Add.vue @@ -32,6 +32,7 @@ + @@ -175,7 +176,7 @@ export default { dialog: Object, formData: Object }, - mounted(){ + mounted () { getGroupList().then(res => { const data = res.data for (var item in data) { diff --git a/src/view/cmdb/db/List.vue b/src/view/cmdb/db/List.vue index 966f0f0..7cbafc9 100644 --- a/src/view/cmdb/db/List.vue +++ b/src/view/cmdb/db/List.vue @@ -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', @@ -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 } }, // 新增 @@ -430,7 +430,7 @@ export default { os_version: '', sn: '', comment: '', - role:'master', + role: 'master', idc: 'other', admin_user: null, group: [], diff --git a/src/view/cmdb/server/Add.vue b/src/view/cmdb/server/Add.vue index ea4f185..7b488af 100644 --- a/src/view/cmdb/server/Add.vue +++ b/src/view/cmdb/server/Add.vue @@ -1,7 +1,7 @@ diff --git a/src/view/cmdb/server/Detail.vue b/src/view/cmdb/server/Detail.vue index abd4978..90c8095 100644 --- a/src/view/cmdb/server/Detail.vue +++ b/src/view/cmdb/server/Detail.vue @@ -1,5 +1,5 @@ diff --git a/src/view/cmdb/server/List.vue b/src/view/cmdb/server/List.vue index f29d1d3..b4c5b8e 100644 --- a/src/view/cmdb/server/List.vue +++ b/src/view/cmdb/server/List.vue @@ -16,7 +16,7 @@
- + @@ -30,7 +30,7 @@ - + @@ -43,7 +43,7 @@ import Api from '@/view/cmdb/common/Api' import multiAdd from './multiAdd' import Detail from './Detail' // import { getTableData } from '@/api/data' -import { getTableData,searchTableData,rsyncHostData,rsyncPublicKeyData,delServer,delMultiServer } from '@/api/cmdb/server.js' +import { getTableData, searchTableData, rsyncHostData, rsyncPublicKeyData, delServer, delMultiServer } from '@/api/cmdb/server.js' export default { name: 'list', components: { @@ -65,24 +65,24 @@ export default { name: '' }, loading: false, - dialog:{ + dialog: { show: false, title: '', option: '' }, - dialog2:{ + dialog2: { show: false, title: '主机详情' }, - multi_dialog:{ + multi_dialog: { show: false, title: '批量添加' }, - del_dialog:{ + del_dialog: { show: false, title: '删除主机' }, - dels_dialog:{ + dels_dialog: { show: false, title: '批量删除主机' }, @@ -103,26 +103,26 @@ export default { // align: 'center', // }, { - title: '主机名', - key: 'hostname', + title: '主机名', + key: 'hostname', sortable: true, align: 'center', render: (h, params) => { - //return h('router-link', {props:{to:'/project/publish/'+params.row.id+ '/'}}, params.row.name) + // return h('router-link', {props:{to:'/project/publish/'+params.row.id+ '/'}}, params.row.name) return h('a', { on: { - click: () => { - this.handleDetail(params.index,params.row) - } + click: () => { + this.handleDetail(params.index, params.row) } - },params.row.hostname + } + }, params.row.hostname ) } }, - {title: 'IP', key: 'ip', align: 'center',}, + {title: 'IP', key: 'ip', align: 'center'}, { - title: '主机组', - key: 'group', + title: '主机组', + key: 'group', align: 'center', render: (h, params) => { const s_group = params.row.group_name.join(' ') @@ -130,39 +130,39 @@ export default { } }, // { - // title: 'Tag', - // key: 'tag', + // title: 'Tag', + // key: 'tag', // align: 'center', // render: (h, params) => { // const s_tag = params.row.tag_name.join(' ') // return h('span', s_tag) // } // }, - {title: 'IDC', key: 'idc_name', align: 'center',}, - {title: '系统类型', key: 'os_platform', align: 'center',}, - {title: 'CPU', key: 'cpu', align: 'center',}, - {title: '内存', key: 'memory', align: 'center',}, - {title: '硬盘', key: 'disk', align: 'center',}, + {title: 'IDC', key: 'idc_name', align: 'center'}, + {title: '系统类型', key: 'os_platform', align: 'center'}, + {title: 'CPU', key: 'cpu', align: 'center'}, + {title: '内存', key: 'memory', align: 'center'}, + {title: '硬盘', key: 'disk', align: 'center'}, { - title: '连通性', - key: 'handle', + title: '连通性', + key: 'handle', align: 'center', - button: [ + button: [ (h, params, vm) => { return h('div', [ - h('Button', { - props: { - type: params.row.public_key == true ? 'success' : 'warning', - size: 'small' - }, - style: { + h('Button', { + props: { + type: params.row.public_key == true ? 'success' : 'warning', + size: 'small' + }, + style: { marginRight: '5px' - } - },params.row.public_key), + } + }, params.row.public_key) ]) } ] - }, + }, { title: '操作', key: 'handle', @@ -171,99 +171,99 @@ export default { button: [ (h, params, vm) => { return h('div', [ - h('Button', { - props: { - type: 'success', - size: 'small' - }, - style: { + h('Button', { + props: { + type: 'success', + size: 'small' + }, + style: { marginRight: '5px' - }, - on: { - click: () => { - window.open('/terminal/?id='+params.row.id) + }, + on: { + click: () => { + window.open('/terminal/?id=' + params.row.id) + } } - } - },'SSH'), - h('Button', { - props: { - type: 'info', - size: 'small' - }, - style: { - marginRight: '5px' - }, - on: { - click: () => { - // this.show(params.index) - this.handleAPI(params.index, params.row) + }, 'SSH'), + h('Button', { + props: { + type: 'info', + size: 'small' + }, + style: { + marginRight: '5px' + }, + on: { + click: () => { + // this.show(params.index) + this.handleAPI(params.index, params.row) + } } - } - }, 'API'), - h('Button', { - props: { - type: 'primary', - size: 'small' - }, - style: { + }, 'API'), + h('Button', { + props: { + type: 'primary', + size: 'small' + }, + style: { marginRight: '5px' - }, - on: { - click: () => { - //this.show(params.index) - this.handleEdit(params.index,params.row) + }, + on: { + click: () => { + // this.show(params.index) + this.handleEdit(params.index, params.row) + } } - } - },'编辑'), - h('Button', { + }, '编辑'), + h('Button', { props: { - type: 'error', - size: 'small' + type: 'error', + size: 'small' }, on: { - click: () => { - //this.remove(params.index) - this.handleRemove(params.row) - } + click: () => { + // this.remove(params.index) + this.handleRemove(params.row) + } } - }, '删除') + }, '删除') ]) } ] - }, + } ], getParams: { pageNum: 1, // 当前页码 - pageSize: 25, // 每页条数 + pageSize: 25 // 每页条数 }, pageTotal: 0, // 数据总数 - + tableData: [], formData_multi: { data: null }, formData: { - hostname: '', - ip: '', - port: 22, - cpu: '', - memory: '', - disk: '', - os_platform: 'Linux', - os_distribution: '', - os_version: '', - sn: '', - comment: '', - idc: 'other', - admin_user: null, - group: [], - tag:[], - username: null, - passowrd: null, - region: null + hostname: '', + ip: '', + port: 22, + cpu: '', + memory: '', + disk: '', + os_platform: 'Linux', + os_distribution: '', + os_version: '', + sn: '', + comment: '', + idc: 'other', + admin_user: null, + group: [], + tag: [], + username: null, + passowrd: null, + region: null }, - select_id : [] + select_id: [] } }, methods: { @@ -277,160 +277,159 @@ export default { // }) // }, remove (index) { - this.tableData.splice(index, 1); + this.tableData.splice(index, 1) }, // 弹出对话框 showModal () { this.dialog.show = true }, - selectOne(selection,row){ + selectOne (selection, row) { this.select_id.push(row.id) }, - unselectOne(selection,row){ - this.select_id.splice(this.select_id.indexOf(row.id),1) + unselectOne (selection, row) { + this.select_id.splice(this.select_id.indexOf(row.id), 1) }, - selectAll(selection){ + selectAll (selection) { let select_list = [] - for(const line in selection){ + for (const line in selection) { select_list.push(selection[line].id) } this.select_id = select_list - //console.log(this.select_id) + // console.log(this.select_id) }, - unselectAllUnselectAll(){ + unselectAllUnselectAll () { // Bug不生效。 console.log(1111) this.select_id = [] }, - - //资产搜集 - rsyncHost(){ - if(this.select_id.length === 0){ + + // 资产搜集 + rsyncHost () { + if (this.select_id.length === 0) { this.$Message.error({ content: '请选择要更新的主机', duration: 3 - }); - }else{ + }) + } else { this.$Spin.show({ render: (h) => { - return h('div', [ - h('Icon', { - 'class': 'demo-spin-icon-load', - props: { - type: 'ios-loading', - size: 18 - } - }), - h('div', '资产更新中....') - ]) + return h('div', [ + h('Icon', { + 'class': 'demo-spin-icon-load', + props: { + type: 'ios-loading', + size: 18 + } + }), + h('div', '资产更新中....') + ]) } - }); + }) rsyncHostData(this.select_id).then(res => { this.$Spin.hide() this.getData() - if(res.data.status == true){ + if (res.data.status == true) { this.$Message.success({ content: '资产更新成功!', duration: 3 - }); - }else{ + }) + } else { this.$Message.error({ - content: res.data.msg, - duration: 10 - }); + content: res.data.msg, + duration: 10 + }) } - }).catch(error =>{ + }).catch(error => { this.$Spin.hide() this.$Message.error({ - content: 'Error', - duration: 10 - }); - }); - + content: 'Error', + duration: 10 + }) + }) } this.select_id = [] }, - //公钥推送 - rsyncPublicKey(){ - if(this.select_id.length === 0){ + // 公钥推送 + rsyncPublicKey () { + if (this.select_id.length === 0) { this.$Message.error({ content: '请选择要推送的主机', duration: 3 - }); - }else{ + }) + } else { this.$Spin.show({ render: (h) => { - return h('div', [ - h('Icon', { - 'class': 'demo-spin-icon-load', - props: { - type: 'ios-loading', - size: 18 - } - }), - h('div', '公钥推送中....') - ]) + return h('div', [ + h('Icon', { + 'class': 'demo-spin-icon-load', + props: { + type: 'ios-loading', + size: 18 + } + }), + h('div', '公钥推送中....') + ]) } - }); + }) rsyncPublicKeyData(this.select_id).then(res => { this.$Spin.hide() this.getData() - //console.log(res.data) - if(res.data.status == true){ + // console.log(res.data) + if (res.data.status == true) { this.$Message.success({ content: '公钥推送成功!', duration: 3 - }); - }else{ + }) + } else { this.$Message.error({ - content: res.data.msg, - duration: 10 - }); + content: res.data.msg, + duration: 10 + }) } - }).catch(error =>{ + }).catch(error => { this.$Spin.hide() this.$Message.error({ - content: 'Error', - duration: 10 - }); - }); + content: 'Error', + duration: 10 + }) + }) } this.select_id = [] }, - //删除 - handleRemove(row){ + // 删除 + handleRemove (row) { this.del_dialog = { show: true, - title: '删除主机 '+ row.hostname, - id : row.id + title: '删除主机 ' + row.hostname, + id: row.id } }, - removeServer(id){ - delServer(id).then(res => { - this.$Message.success({ - content: 'Success!', - duration: 3 - }); - this.closeDelModal() - this.getData() - }).catch(error =>{ - this.$Message.error({ - content: JSON.stringify(error.response.data), - duration: 10 - }); - }); + removeServer (id) { + delServer(id).then(res => { + this.$Message.success({ + content: 'Success!', + duration: 3 + }) + this.closeDelModal() + this.getData() + }).catch(error => { + this.$Message.error({ + content: JSON.stringify(error.response.data), + duration: 10 + }) + }) }, - //批量删除 - multliRemove(){ - if(this.select_id.length === 0){ + // 批量删除 + multliRemove () { + if (this.select_id.length === 0) { this.$Message.error({ content: '请选择要删除的主机', duration: 3 - }); - }else{ + }) + } else { // console.log('select_id------>',this.select_id) this.dels_dialog = { show: true, @@ -438,40 +437,40 @@ export default { } } }, - removeMultiServer(){ + removeMultiServer () { // start multi remove delMultiServer(this.select_id).then(res => { - if(res.data.status == true){ + if (res.data.status == true) { this.$Message.success({ content: '批量删除成功!', duration: 3 - }); + }) this.closeDelsModal() - }else{ + } else { this.$Message.error({ - content: res.data.msg, - duration: 10 - }); + content: res.data.msg, + duration: 10 + }) } - }).catch(error =>{ + }).catch(error => { this.$Spin.hide() this.$Message.error({ - content: 'Error', - duration: 10 - }); - }); + content: 'Error', + duration: 10 + }) + }) this.getData() }, - //批量添加 - multiAdd(){ + // 批量添加 + multiAdd () { this.multi_dialog = { show: true, title: '批量添加主机' } }, // 新增 - handleAdd() { + handleAdd () { this.dialog = { show: true, title: '添加主机', @@ -479,66 +478,66 @@ export default { } }, // 获取API - handleAPI(index, row) { + handleAPI (index, row) { this.api_dialog = { show: true, title: '获取API', - name: 'hostname='+row.hostname + name: 'hostname=' + row.hostname } }, // 编辑 - handleEdit(index,row) { + handleEdit (index, row) { this.dialog = { show: true, title: '编辑主机', option: 'edit' - }; - this.formData= { - hostname: row.hostname, - ip: row.ip, - port: row.port, - cpu: row.cpu, - memory: row.memory, - disk: row.disk, - os_platform: row.os_platform, - os_version: row.os_version, - sn: row.sn, - comment: row.comment, - idc: row.idc, - admin_user: row.admin_user, - group: row.group, - tag: row.tag, - id: row.id, - username: row.username, - password: row.password, - region: row.region } - if(this.formData.username != null){ + this.formData = { + hostname: row.hostname, + ip: row.ip, + port: row.port, + cpu: row.cpu, + memory: row.memory, + disk: row.disk, + os_platform: row.os_platform, + os_version: row.os_version, + sn: row.sn, + comment: row.comment, + idc: row.idc, + admin_user: row.admin_user, + group: row.group, + tag: row.tag, + id: row.id, + username: row.username, + password: row.password, + region: row.region + } + if (this.formData.username != null) { this.formData.single = true } }, - handleDetail(index,row) { + handleDetail (index, row) { this.dialog2.show = true - this.formData= { - hostname: row.hostname, - ip: row.ip, - port: row.port, - cpu: row.cpu, - memory: row.memory, - disk: row.disk, - os_platform: row.os_platform, - os_version: row.os_version, - sn: row.sn, - comment: row.comment, - idc: row.idc, - admin_user: row.admin_user, - group: row.group, - tag: row.tag, - id: row.id, - group_name: row.group_name.join(' '), - admin_user_name: row.admin_user_name, - idc_name: row.idc_name, - region: row.region + this.formData = { + hostname: row.hostname, + ip: row.ip, + port: row.port, + cpu: row.cpu, + memory: row.memory, + disk: row.disk, + os_platform: row.os_platform, + os_version: row.os_version, + sn: row.sn, + comment: row.comment, + idc: row.idc, + admin_user: row.admin_user, + group: row.group, + tag: row.tag, + id: row.id, + group_name: row.group_name.join(' '), + admin_user_name: row.admin_user_name, + idc_name: row.idc_name, + region: row.region } }, @@ -552,66 +551,66 @@ export default { this.getParams.pageSize = value this.getData() }, - handleSearchTable(k,v){ - //子组件table发送过来的搜索条件 - this.getParams= { - pageNum: 1, + handleSearchTable (k, v) { + // 子组件table发送过来的搜索条件 + this.getParams = { + pageNum: 1, pageSize: 25 } - - if(k !== ''){ + + if (k !== '') { // 模糊匹配 - if(k === 'group'){ + if (k === 'group') { this.getParams['group__name'] = v - }else{ - this.getParams[k+'__contains'] = v //contanis包含,startswith开始 + } else { + this.getParams[k + '__contains'] = v // contanis包含,startswith开始 } } this.getData() }, - getData(){ - //获取数据 + getData () { + // 获取数据 getTableData(this.getParams).then(res => { this.tableData = res.data.data this.pageTotal = res.data.count this.apiUrl = res.request.responseURL.split('?')[0] - //console.log(this.tableData) + // console.log(this.tableData) }) }, - closeDelModal(){ + closeDelModal () { this.del_dialog.show = false }, - closeDelsModal(){ + closeDelsModal () { this.dels_dialog.show = false }, - closeMultiModal(){ + closeMultiModal () { this.formData_multi = { data: null } this.multi_dialog.show = false }, - closeModal(){ - //关闭modal + closeModal () { + // 关闭modal this.formData = { - hostname: '', - ip: '', - port: 22, - cpu: '', - memory: '', - disk: '', - os_platform: 'Linux', - os_distribution: '', - os_version: '', - sn: '', - comment: '', - idc: 'other', - admin_user: null, - group: [], - tag:[], - username: null, - password: null, - region: null + hostname: '', + ip: '', + port: 22, + cpu: '', + memory: '', + disk: '', + os_platform: 'Linux', + os_distribution: '', + os_version: '', + sn: '', + comment: '', + idc: 'other', + admin_user: null, + group: [], + tag: [], + username: null, + password: null, + region: null }, this.dialog.show = false }, @@ -626,7 +625,6 @@ export default { } - \ No newline at end of file +