feat: 添加 project 路由跳转到 module 以及 endpoint

This commit is contained in:
zhangyu
2021-04-16 17:02:38 +08:00
parent 6f26ba3d03
commit f92c046208
13 changed files with 136 additions and 41 deletions

View File

@@ -20,7 +20,7 @@ export default {
localStorage.clear() localStorage.clear()
localStorage.setItem('nz-version', version) localStorage.setItem('nz-version', version)
} }
} },
} }
</script> </script>

View File

@@ -546,7 +546,6 @@ export default {
this.endpointTableData = [] this.endpointTableData = []
}, },
handleSizeChange (val) { handleSizeChange (val) {
console.log(val)
this.getAssetList() this.getAssetList()
}, },
handleCurrentChange () { handleCurrentChange () {
@@ -559,7 +558,6 @@ export default {
this.getAssetList() this.getAssetList()
}, },
search (seachLabel) { search (seachLabel) {
console.log(seachLabel)
this.seachLabel = { ...seachLabel } this.seachLabel = { ...seachLabel }
this.getAssetList() this.getAssetList()
}, },
@@ -585,11 +583,9 @@ export default {
}, },
handleSelectionChangeAsset (val) { handleSelectionChangeAsset (val) {
this.assetSelection = val this.assetSelection = val
console.log(val)
}, },
handleSelectionChangeEndpoint (val) { handleSelectionChangeEndpoint (val) {
this.endpointSelection = val this.endpointSelection = val
console.log(val)
}, },
// 保存endpoint // 保存endpoint
save () { save () {
@@ -686,7 +682,6 @@ export default {
} }
this.endpointTableData.push(obj) this.endpointTableData.push(obj)
}) })
console.log(this.endpointTableData)
this.assetTableData = [...this.assetTableData] this.assetTableData = [...this.assetTableData]
this.$refs.multipleTable.clearSelection() this.$refs.multipleTable.clearSelection()
}, },
@@ -704,14 +699,12 @@ export default {
return '' return ''
}, },
editEndpointRow (u) { editEndpointRow (u) {
console.log(u)
this.object = JSON.parse(JSON.stringify(u)) this.object = JSON.parse(JSON.stringify(u))
this.object.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : [] this.object.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : []
this.object.port = this.object.configs.port ? JSON.parse(JSON.stringify(this.object.configs.port)) : 9100 this.object.port = this.object.configs.port ? JSON.parse(JSON.stringify(this.object.configs.port)) : 9100
this.rightBox.show = true this.rightBox.show = true
}, },
showRightBox () { showRightBox () {
console.log(this.blankEndpoint)
this.object = { ...JSON.parse(JSON.stringify(this.blankEndpoint)), projectId: this.currentModuleCopy.projectId, moduleId: this.currentModuleCopy.id, assetName: '', type: this.currentModuleCopy.type } this.object = { ...JSON.parse(JSON.stringify(this.blankEndpoint)), projectId: this.currentModuleCopy.projectId, moduleId: this.currentModuleCopy.id, assetName: '', type: this.currentModuleCopy.type }
this.object.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : [] this.object.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : []
this.object.port = this.object.configs.port ? JSON.parse(JSON.stringify(this.object.configs.port)) : 9100 this.object.port = this.object.configs.port ? JSON.parse(JSON.stringify(this.object.configs.port)) : 9100
@@ -722,10 +715,8 @@ export default {
this.endpointTableData[index] = { ...this.endpointTableData[index], ...this.blankEndpoint } this.endpointTableData[index] = { ...this.endpointTableData[index], ...this.blankEndpoint }
}) })
this.endpointTableData = [...this.endpointTableData] this.endpointTableData = [...this.endpointTableData]
console.log(this.endpointTableData)
}, },
closeRightBox (isEdit, endpoint, isAll) { closeRightBox (isEdit, endpoint, isAll) {
console.log(isEdit, endpoint, isAll)
this.rightBox.show = false this.rightBox.show = false
if (!isEdit) { return } if (!isEdit) { return }
if (isAll) { if (isAll) {
@@ -739,7 +730,6 @@ export default {
} }
}) })
this.endpointTableData = [...this.endpointTableData] this.endpointTableData = [...this.endpointTableData]
console.log(this.endpointTableData)
} }
} }
}, },
@@ -761,7 +751,6 @@ export default {
if (n) { if (n) {
this.$nextTick(() => { this.$nextTick(() => {
const domarr = document.getElementsByClassName('hide-row') const domarr = document.getElementsByClassName('hide-row')
console.log(domarr.length, 'domArr')
this.selectAssetAll = domarr.length === this.pageObj.pageSize this.selectAssetAll = domarr.length === this.pageObj.pageSize
}) })
} }
@@ -789,7 +778,6 @@ export default {
currentModuleCopy: { currentModuleCopy: {
immediate: true, immediate: true,
handler (n, o) { handler (n, o) {
console.log(n)
if (n.type && n.type.toLowerCase() == 'snmp') { if (n.type && n.type.toLowerCase() == 'snmp') {
this.endpointTableTitle[4].show = false this.endpointTableTitle[4].show = false
this.endpointTableTitle[5].show = false this.endpointTableTitle[5].show = false

View File

@@ -418,12 +418,10 @@ export default {
}, },
/* 保存 */ /* 保存 */
save () { save () {
console.log(this.editEndpoint)
this.editEndpoint.configs.params = this.paramToJson(this.editEndpoint.paramObj) this.editEndpoint.configs.params = this.paramToJson(this.editEndpoint.paramObj)
this.editEndpoint.configs.labels = this.labelsToJson(this.editEndpoint.labelModule) this.editEndpoint.configs.labels = this.labelsToJson(this.editEndpoint.labelModule)
this.editEndpoint.paramObj = this.editEndpoint.paramObj.filter(item => item.value && item.value.length) this.editEndpoint.paramObj = this.editEndpoint.paramObj.filter(item => item.value && item.value.length)
this.editEndpoint.labelModule = this.editEndpoint.labelModule.filter(item => item.value) this.editEndpoint.labelModule = this.editEndpoint.labelModule.filter(item => item.value)
console.log(1)
const params = { ...this.editEndpoint } const params = { ...this.editEndpoint }
params.configs.walk = params.walk params.configs.walk = params.walk
params.configs.port = params.port params.configs.port = params.port
@@ -474,7 +472,7 @@ export default {
cancelButtonText: this.$t('tip.no'), cancelButtonText: this.$t('tip.no'),
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$delete('monitor/module?ids=' + this.editEndpoint.id).then(response => { this.$delete('monitor/endpoint?ids=' + this.editEndpoint.id).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.deleteSuccess') }) this.$message({ duration: 1000, type: 'success', message: this.$t('tip.deleteSuccess') })
this.$store.commit('setReloadFacade') this.$store.commit('setReloadFacade')

View File

@@ -317,9 +317,6 @@ export default {
} }
}, },
methods: { methods: {
change () {
console.log(this.$refs['select' + 0])
},
selectWalk (walk) { selectWalk (walk) {
if (this.editModule.walk.indexOf(walk) != -1) { if (this.editModule.walk.indexOf(walk) != -1) {
this.editModule.walk.splice(this.editModule.walk.indexOf(walk), 1) this.editModule.walk.splice(this.editModule.walk.indexOf(walk), 1)
@@ -387,13 +384,11 @@ export default {
this.$get('mib/tree', { pageSize: -1, pageNo: 1 }).then(response => { this.$get('mib/tree', { pageSize: -1, pageNo: 1 }).then(response => {
if (response.code === 200) { if (response.code === 200) {
const obj = JSON.parse(response.data) const obj = JSON.parse(response.data)
console.log(obj)
this.walkData = [] this.walkData = []
for (const item in obj) { for (const item in obj) {
setAttr(obj[item], 'detailShow', false) setAttr(obj[item], 'detailShow', false)
this.walkData.push({ name: item, detailShow: false, subTree: obj[item] }) this.walkData.push({ name: item, detailShow: false, subTree: obj[item] })
} }
console.log(this.walkData)
} }
}) })
function setAttr (tree, name, value) { function setAttr (tree, name, value) {
@@ -433,12 +428,10 @@ export default {
/* 保存 */ /* 保存 */
save () { save () {
this.editModule.configs.params = this.paramToJson(this.editModule.paramObj) this.editModule.configs.params = this.paramToJson(this.editModule.paramObj)
console.log(this.editModule.paramObj, this.editModule.configs.param)
this.editModule.configs.labels = this.labelsToJson(this.editModule.labelModule) this.editModule.configs.labels = this.labelsToJson(this.editModule.labelModule)
const params = { ...this.editModule } const params = { ...this.editModule }
params.configs.walk = params.walk params.configs.walk = params.walk
params.configs.port = params.port params.configs.port = params.port
console.log({ ...params })
params.configs = JSON.stringify(params.configs) params.configs = JSON.stringify(params.configs)
if (this.authType === 2 && !this.editModule.configs.bearer_token) { if (this.authType === 2 && !this.editModule.configs.bearer_token) {
this.$message.error("'token' is required") this.$message.error("'token' is required")
@@ -666,7 +659,6 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler (n) { handler (n) {
console.log(n)
if (n && n.configs) { if (n && n.configs) {
const params = Object.assign({}, n.configs) const params = Object.assign({}, n.configs)
params.params = this.paramToJson(this.editModule.paramObj) params.params = this.paramToJson(this.editModule.paramObj)
@@ -674,7 +666,6 @@ export default {
params.walk = n.walk params.walk = n.walk
params.port = n.port params.port = n.port
Object.keys(params).forEach(key => { Object.keys(params).forEach(key => {
console.log(key, !params[key] || !params[key].length)
if (!params[key]) { if (!params[key]) {
delete params[key] delete params[key]
} }
@@ -695,7 +686,6 @@ export default {
delete params.labels delete params.labels
} }
this.configsCopyValue = JSON.stringify(params, null, 2) this.configsCopyValue = JSON.stringify(params, null, 2)
console.log(this.configsCopyValue)
} }
} }
} }

View File

@@ -225,7 +225,6 @@ export default {
handler (n, o) { handler (n, o) {
this.editCredential = JSON.parse(JSON.stringify(n)) this.editCredential = JSON.parse(JSON.stringify(n))
this.editCredential.config = JSON.parse(this.editCredential.config) this.editCredential.config = JSON.parse(this.editCredential.config)
console.log('edit', this.editCredential)
} }
} }
} }

View File

@@ -196,7 +196,6 @@ export default {
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') }) this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(false) this.esc(false)
} else { } else {
console.error(response.msg)
this.$message.error(response.msg) this.$message.error(response.msg)
} }
}) })

View File

@@ -633,6 +633,7 @@ export default {
}, },
// 点击搜索 // 点击搜索
select () { select () {
console.log(this.select_list);
const objectInfo = {} const objectInfo = {}
this.change_sreach_show = true this.change_sreach_show = true
this.name = '', this.id = '' this.name = '', this.id = ''

View File

@@ -39,12 +39,12 @@
</span> </span>
</template> </template>
<template v-else-if="item.prop === 'moduleNum'" > <template v-else-if="item.prop === 'moduleNum'" >
<span class="module-num"> <span class="module-num" @click="jumpModule(scope.row)">
{{scope.row[item.prop]}} {{scope.row[item.prop]}}
</span> </span>
</template> </template>
<template v-else-if="item.prop === 'endpointNum'"> <template v-else-if="item.prop === 'endpointNum'">
<span class="endpoint-num" :class="scope.row[item.prop]>0?'bagEF7458':'bag23BF9A'"> <span class="endpoint-num" :class="scope.row[item.prop]>0?'bagEF7458':'bag23BF9A'" @click="jumpEndpoint(scope.row)">
{{scope.row[item.prop]}} {{scope.row[item.prop]}}
</span> </span>
</template> </template>
@@ -123,6 +123,14 @@ export default {
methods: { methods: {
changeProjectTopo (project) { changeProjectTopo (project) {
this.$store.commit('currentProjectChange', project) this.$store.commit('currentProjectChange', project)
},
jumpModule (row) {
localStorage.setItem('moduleProjectId', row.id)
this.$router.push({ path: '/monitor/module' })
},
jumpEndpoint (row) {
localStorage.setItem('endpointProjectId', row.id)
this.$router.push({ path: '/monitor/endpoint' })
} }
}, },
computed: { computed: {
@@ -135,16 +143,18 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
.moduleNum{ .module-num{
font-size: 14px; font-size: 14px;
color: #3C92F1; color: #3C92F1;
font-weight: 400; font-weight: 400;
cursor: pointer;
padding: 0 3px;
cursor: pointer;
} }
.endpoint-num{ .endpoint-num{
padding: 0 3px; padding: 0 3px;
} cursor: pointer;
.module-num{ border-radius: 2px;
padding: 0 3px;
} }
.bagEF7458{ .bagEF7458{
background: #EF7458; background: #EF7458;

View File

@@ -35,6 +35,10 @@ export default {
this.containerShow = false this.containerShow = false
this.$nextTick(() => { this.containerShow = true }) this.$nextTick(() => { this.containerShow = true })
} }
},
destroyed () {
localStorage.removeItem('moduleProjectId')
localStorage.removeItem('endpointProjectId')
} }
} }
</script> </script>

View File

@@ -51,6 +51,10 @@ import endpointTable from '@/components/common/table/settings/endpointTable'
import EditEndpointBoxNew from '@/components/common/rightBox/editEndpointBoxNew' import EditEndpointBoxNew from '@/components/common/rightBox/editEndpointBoxNew'
export default { export default {
beforeRouteLeave (to, from, next) { // 路由离开之前触发
localStorage.removeItem('endpointProjectId')
next()
},
name: 'endpointList', name: 'endpointList',
components: { components: {
EditEndpointBoxNew, EditEndpointBoxNew,
@@ -69,14 +73,20 @@ export default {
searchMsg: { // 给搜索框子组件传递的信息 searchMsg: { // 给搜索框子组件传递的信息
zheze_none: true, zheze_none: true,
searchLabelList: [{ searchLabelList: [{
id: 10, id: 11,
name: 'project id',
type: 'input',
label: 'projectIds',
disabled: false
}, {
id: 12,
name: 'endpoint name', name: 'endpoint name',
type: 'input', type: 'input',
label: 'name', label: 'name',
disabled: false disabled: false
}, },
{ {
id: 10, id: 13,
name: 'endpoint id', name: 'endpoint id',
type: 'input', type: 'input',
label: 'id', label: 'id',
@@ -119,7 +129,6 @@ export default {
this.object.moduleId = this.object.module.id this.object.moduleId = this.object.module.id
this.object.type = this.object.module.type this.object.type = this.object.module.type
this.rightBox.editShow = true this.rightBox.editShow = true
console.log(this.rightBox.editShow)
}) })
}, },
closeRightEditBox (refresh) { closeRightEditBox (refresh) {
@@ -128,11 +137,53 @@ export default {
this.delFlag = true this.delFlag = true
this.getTableData() this.getTableData()
} }
},
getTableData () {
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
if (this.searchLabel.projectIds) {
localStorage.setItem('endpointProjectId', this.searchLabel.projectIds)
} else {
localStorage.removeItem('endpointProjectId')
}
this.tools.loading = true
this.$get(this.url, this.searchLabel).then(response => {
this.tools.loading = false
if (response.code === 200) {
for (let i = 0; i < response.data.list.length; i++) {
response.data.list[i].status = response.data.list[i].status + ''
}
this.tableData = response.data.list
this.pageObj.total = response.data.total
if (!this.scrollbarWrap) {
this.$nextTick(() => {
this.scrollbarWrap = this.$refs.dataTable.$refs.dataTable.bodyWrapper
this.toTopBtnHandler(this.scrollbarWrap)
})
}
}
})
} }
}, },
computed: { computed: {
}, },
created () {
if (localStorage.getItem('endpointProjectId')) {
this.searchLabel.projectIds = localStorage.getItem('endpointProjectId')
}
},
mounted () { mounted () {
if (localStorage.getItem('endpointProjectId')) {
this.$refs.dataList.$refs.searchInput.select_list.push({
id: 11,
name: 'project id',
type: 'input',
label: 'projectIds',
disabled: false,
val: localStorage.getItem('endpointProjectId')
})
this.$refs.dataList.$refs.searchInput.sreach_num = 1
}
} }
} }
</script> </script>

View File

@@ -47,6 +47,10 @@ import dataListMixin from '@/components/common/mixin/dataList'
import moduleTable from '@/components/common/table/settings/moduleTable' import moduleTable from '@/components/common/table/settings/moduleTable'
export default { export default {
beforeRouteLeave (to, from, next) { // 路由离开之前触发
localStorage.removeItem('moduleProjectId')
next()
},
name: 'moduleList', name: 'moduleList',
components: { components: {
nzDataList, nzDataList,
@@ -103,10 +107,17 @@ export default {
disabled: false disabled: false
}, },
{ {
id: 10, id: 11,
name: 'project id',
type: 'input',
label: 'projectIds',
disabled: false
},
{
id: 12,
name: 'module id', name: 'module id',
type: 'input', type: 'input',
label: 'id', label: 'ids',
disabled: false disabled: false
}] }]
}, },
@@ -136,11 +147,54 @@ export default {
this.object.paramObj.push({ key: '', value: [] }) this.object.paramObj.push({ key: '', value: [] })
} }
this.rightBox.show = true this.rightBox.show = true
},
getTableData () {
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
if (this.searchLabel.projectIds) {
localStorage.setItem('moduleProjectId', this.searchLabel.projectIds)
} else {
localStorage.removeItem('moduleProjectId')
}
this.tools.loading = true
this.$get(this.url, this.searchLabel).then(response => {
this.tools.loading = false
if (response.code === 200) {
for (let i = 0; i < response.data.list.length; i++) {
response.data.list[i].status = response.data.list[i].status + ''
}
this.tableData = response.data.list
this.pageObj.total = response.data.total
if (!this.scrollbarWrap) {
this.$nextTick(() => {
this.scrollbarWrap = this.$refs.dataTable.$refs.dataTable.bodyWrapper
this.toTopBtnHandler(this.scrollbarWrap)
})
}
}
})
} }
}, },
computed: { computed: {
}, },
created () {
if (localStorage.getItem('moduleProjectId')) {
this.searchLabel.projectIds = localStorage.getItem('moduleProjectId')
}
},
mounted () { mounted () {
if (localStorage.getItem('moduleProjectId')) {
this.$refs.dataList.$refs.searchInput.select_list.push({
id: 11,
name: 'project id',
type: 'input',
label: 'projectIds',
disabled: false,
val: localStorage.getItem('moduleProjectId')
})
this.$refs.dataList.$refs.searchInput.sreach_num = 1
}
} }
} }
</script> </script>

View File

@@ -78,7 +78,7 @@ export default {
id: 10, id: 10,
name: 'Project id', name: 'Project id',
type: 'input', type: 'input',
label: 'id', label: 'ids',
disabled: false disabled: false
}] }]
}, },

View File

@@ -39,6 +39,7 @@ export default new Router({
}, },
{ {
path: '/monitor/module', path: '/monitor/module',
name: '/monitor/module',
component: resolve => require(['../components/page/monitor/module/moduleList.vue'], resolve) component: resolve => require(['../components/page/monitor/module/moduleList.vue'], resolve)
}, },
{ {