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.setItem('nz-version', version)
}
}
},
}
</script>

View File

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

View File

@@ -418,12 +418,10 @@ export default {
},
/* 保存 */
save () {
console.log(this.editEndpoint)
this.editEndpoint.configs.params = this.paramToJson(this.editEndpoint.paramObj)
this.editEndpoint.configs.labels = this.labelsToJson(this.editEndpoint.labelModule)
this.editEndpoint.paramObj = this.editEndpoint.paramObj.filter(item => item.value && item.value.length)
this.editEndpoint.labelModule = this.editEndpoint.labelModule.filter(item => item.value)
console.log(1)
const params = { ...this.editEndpoint }
params.configs.walk = params.walk
params.configs.port = params.port
@@ -474,7 +472,7 @@ export default {
cancelButtonText: this.$t('tip.no'),
type: 'warning'
}).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) {
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.deleteSuccess') })
this.$store.commit('setReloadFacade')

View File

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

View File

@@ -225,7 +225,6 @@ export default {
handler (n, o) {
this.editCredential = JSON.parse(JSON.stringify(n))
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.esc(false)
} else {
console.error(response.msg)
this.$message.error(response.msg)
}
})

View File

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

View File

@@ -39,12 +39,12 @@
</span>
</template>
<template v-else-if="item.prop === 'moduleNum'" >
<span class="module-num">
<span class="module-num" @click="jumpModule(scope.row)">
{{scope.row[item.prop]}}
</span>
</template>
<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]}}
</span>
</template>
@@ -123,6 +123,14 @@ export default {
methods: {
changeProjectTopo (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: {
@@ -135,16 +143,18 @@ export default {
}
</script>
<style scoped>
.moduleNum{
.module-num{
font-size: 14px;
color: #3C92F1;
font-weight: 400;
cursor: pointer;
padding: 0 3px;
cursor: pointer;
}
.endpoint-num{
padding: 0 3px;
}
.module-num{
padding: 0 3px;
cursor: pointer;
border-radius: 2px;
}
.bagEF7458{
background: #EF7458;

View File

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

View File

@@ -51,6 +51,10 @@ import endpointTable from '@/components/common/table/settings/endpointTable'
import EditEndpointBoxNew from '@/components/common/rightBox/editEndpointBoxNew'
export default {
beforeRouteLeave (to, from, next) { // 路由离开之前触发
localStorage.removeItem('endpointProjectId')
next()
},
name: 'endpointList',
components: {
EditEndpointBoxNew,
@@ -69,14 +73,20 @@ export default {
searchMsg: { // 给搜索框子组件传递的信息
zheze_none: true,
searchLabelList: [{
id: 10,
id: 11,
name: 'project id',
type: 'input',
label: 'projectIds',
disabled: false
}, {
id: 12,
name: 'endpoint name',
type: 'input',
label: 'name',
disabled: false
},
{
id: 10,
id: 13,
name: 'endpoint id',
type: 'input',
label: 'id',
@@ -119,7 +129,6 @@ export default {
this.object.moduleId = this.object.module.id
this.object.type = this.object.module.type
this.rightBox.editShow = true
console.log(this.rightBox.editShow)
})
},
closeRightEditBox (refresh) {
@@ -128,11 +137,53 @@ export default {
this.delFlag = true
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: {
},
created () {
if (localStorage.getItem('endpointProjectId')) {
this.searchLabel.projectIds = localStorage.getItem('endpointProjectId')
}
},
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>

View File

@@ -47,6 +47,10 @@ import dataListMixin from '@/components/common/mixin/dataList'
import moduleTable from '@/components/common/table/settings/moduleTable'
export default {
beforeRouteLeave (to, from, next) { // 路由离开之前触发
localStorage.removeItem('moduleProjectId')
next()
},
name: 'moduleList',
components: {
nzDataList,
@@ -103,10 +107,17 @@ export default {
disabled: false
},
{
id: 10,
id: 11,
name: 'project id',
type: 'input',
label: 'projectIds',
disabled: false
},
{
id: 12,
name: 'module id',
type: 'input',
label: 'id',
label: 'ids',
disabled: false
}]
},
@@ -136,11 +147,54 @@ export default {
this.object.paramObj.push({ key: '', value: [] })
}
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: {
},
created () {
if (localStorage.getItem('moduleProjectId')) {
this.searchLabel.projectIds = localStorage.getItem('moduleProjectId')
}
},
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>

View File

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

View File

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