fix: 修复资产树点击的bug

This commit is contained in:
ibuler
2021-08-18 11:03:24 +08:00
committed by 老广
parent 5c94c1c870
commit 8906fa3292
7 changed files with 26 additions and 26 deletions

View File

@@ -89,7 +89,7 @@ export default {
return return
} }
if (currentNode) { if (currentNode) {
currentNode.name = currentNode.meta.node.value currentNode.name = currentNode.meta.data.value
} }
this.zTree.editName(currentNode) this.zTree.editName(currentNode)
}, },
@@ -108,12 +108,12 @@ export default {
const query = Object.assign({}, this.$route.query) const query = Object.assign({}, this.$route.query)
if (treeNode.meta.type === 'node') { if (treeNode.meta.type === 'node') {
this.currentNode = treeNode this.currentNode = treeNode
this.currentNodeId = treeNode.meta.node.id this.currentNodeId = treeNode.meta.data.id
query['node'] = this.currentNodeId query['node'] = this.currentNodeId
url = `${this.setting.url}${combinator}node_id=${treeNode.meta.node.id}&show_current_asset=${show_current_asset}` url = `${this.setting.url}${combinator}node_id=${treeNode.meta.data.id}&show_current_asset=${show_current_asset}`
} else if (treeNode.meta.type === 'asset') { } else if (treeNode.meta.type === 'asset') {
query['asset'] = treeNode.meta.asset.id query['asset'] = treeNode.meta.data.id
url = `${this.setting.url}${combinator}asset_id=${treeNode.meta.asset.id}&show_current_asset=${show_current_asset}` url = `${this.setting.url}${combinator}asset_id=${treeNode.meta.data.id}&show_current_asset=${show_current_asset}`
} }
this.$router.push({ query }) this.$router.push({ query })
this.$emit('urlChange', url) this.$emit('urlChange', url)
@@ -125,7 +125,7 @@ export default {
return return
} }
this.$axios.delete( this.$axios.delete(
`${this.treeSetting.nodeUrl}${currentNode.meta.node.id}/` `${this.treeSetting.nodeUrl}${currentNode.meta.data.id}/`
).then(() => { ).then(() => {
this.$message.success(this.$t('common.deleteSuccessMsg')) this.$message.success(this.$t('common.deleteSuccessMsg'))
this.zTree.removeNode(currentNode) this.zTree.removeNode(currentNode)
@@ -143,7 +143,7 @@ export default {
url, url,
{ 'value': treeNode.name } { 'value': treeNode.name }
).then(res => { ).then(res => {
let assetsAmount = treeNode.meta.node.assetsAmount let assetsAmount = treeNode.meta.data.assetsAmount
if (!assetsAmount) { if (!assetsAmount) {
assetsAmount = 0 assetsAmount = 0
} }
@@ -208,9 +208,9 @@ export default {
onDrop: function(event, treeId, treeNodes, targetNode, moveType) { onDrop: function(event, treeId, treeNodes, targetNode, moveType) {
const treeNodesIds = [] const treeNodesIds = []
$.each(treeNodes, function(index, value) { $.each(treeNodes, function(index, value) {
treeNodesIds.push(value.meta.node.id) treeNodesIds.push(value.meta.data.id)
}) })
const theUrl = `${this.treeSetting.nodeUrl}${targetNode.meta.node.id}/children/add/` const theUrl = `${this.treeSetting.nodeUrl}${targetNode.meta.data.id}/children/add/`
this.$axios.put( this.$axios.put(
theUrl, { theUrl, {
nodes: treeNodesIds nodes: treeNodesIds
@@ -229,7 +229,7 @@ export default {
} }
this.zTree.expandNode(parentNode, true, false, true, false) this.zTree.expandNode(parentNode, true, false, true, false)
// http://localhost/api/v1/assets/nodes/85aa4ee2-0bd9-41db-9079-aa3646448d0c/children/ // http://localhost/api/v1/assets/nodes/85aa4ee2-0bd9-41db-9079-aa3646448d0c/children/
const url = `${this.treeSetting.nodeUrl}${parentNode.meta.node.id}/children/` const url = `${this.treeSetting.nodeUrl}${parentNode.meta.data.id}/children/`
this.$axios.post(url, {}).then(data => { this.$axios.post(url, {}).then(data => {
const newNode = { const newNode = {
id: data['key'], id: data['key'],
@@ -243,7 +243,7 @@ export default {
this.zTree.addNodes(parentNode, 0, newNode) this.zTree.addNodes(parentNode, 0, newNode)
// vm.$refs.dataztree.refresh() // vm.$refs.dataztree.refresh()
const node = this.zTree.getNodeByParam('id', newNode.id, parentNode) const node = this.zTree.getNodeByParam('id', newNode.id, parentNode)
this.currentNodeId = node.meta.node.id || newNode.id this.currentNodeId = node.meta.data.id || newNode.id
this.zTree.editName(node) this.zTree.editName(node)
this.$message.success(this.$t('common.createSuccessMsg')) this.$message.success(this.$t('common.createSuccessMsg'))
}).catch(error => { }).catch(error => {

View File

@@ -27,7 +27,7 @@ export default {
vm.tableConfig.initialUrl = vm.tableConfig.url vm.tableConfig.initialUrl = vm.tableConfig.url
} }
const initialUrl = vm.tableConfig.initialUrl const initialUrl = vm.tableConfig.initialUrl
const nodeId = node.meta.node.id const nodeId = node.meta.data.id
const url = initialUrl.replace('/assets/', `/nodes/${nodeId}/assets/`) const url = initialUrl.replace('/assets/', `/nodes/${nodeId}/assets/`)
vm.tableConfig.url = url vm.tableConfig.url = url
} }

View File

@@ -24,7 +24,7 @@ export default {
refresh: () => {}, refresh: () => {},
onSelected: function(event, treeNode) { onSelected: function(event, treeNode) {
if (treeNode.meta.type === 'node') { if (treeNode.meta.type === 'node') {
const currentNodeId = treeNode.meta.node.id const currentNodeId = treeNode.meta.data.id
this.tableConfig.url = `/api/v1/perms/users/nodes/${currentNodeId}/assets/?cache_policy=1` this.tableConfig.url = `/api/v1/perms/users/nodes/${currentNodeId}/assets/?cache_policy=1`
} }
}.bind(this) }.bind(this)

View File

@@ -33,11 +33,11 @@ export default {
onSelected: function(event, treeNode) { onSelected: function(event, treeNode) {
let url = '/api/v1/assets/accounts/' let url = '/api/v1/assets/accounts/'
if (treeNode.meta.type === 'node') { if (treeNode.meta.type === 'node') {
const nodeId = treeNode.meta.node.id const nodeId = treeNode.meta.data.id
url = setUrlParam(url, 'asset', '') url = setUrlParam(url, 'asset', '')
url = setUrlParam(url, 'node', nodeId) url = setUrlParam(url, 'node', nodeId)
} else if (treeNode.meta.type === 'asset') { } else if (treeNode.meta.type === 'asset') {
const assetId = treeNode.meta.asset.id const assetId = treeNode.meta.data.id
url = setUrlParam(url, 'node', '') url = setUrlParam(url, 'node', '')
url = setUrlParam(url, 'asset', assetId) url = setUrlParam(url, 'asset', assetId)
} }

View File

@@ -420,7 +420,7 @@ export default {
return return
} }
this.$axios.post( this.$axios.post(
`/api/v1/assets/nodes/${currentNode.meta.node.id}/tasks/`, `/api/v1/assets/nodes/${currentNode.meta.data.id}/tasks/`,
{ 'action': 'refresh' } { 'action': 'refresh' }
).then((res) => { ).then((res) => {
openTaskPage(res['task']) openTaskPage(res['task'])
@@ -435,7 +435,7 @@ export default {
return return
} }
this.$axios.post( this.$axios.post(
`/api/v1/assets/nodes/${currentNode.meta.node.id}/tasks/`, `/api/v1/assets/nodes/${currentNode.meta.data.id}/tasks/`,
{ 'action': 'test' } { 'action': 'test' }
).then((res) => { ).then((res) => {
openTaskPage(res['task']) openTaskPage(res['task'])
@@ -451,7 +451,7 @@ export default {
} }
this.$cookie.set('show_current_asset', '1', 1) this.$cookie.set('show_current_asset', '1', 1)
this.decorateRMenu() this.decorateRMenu()
const url = `${this.treeSetting.url}?node_id=${currentNode.meta.node.id}&show_current_asset=1` const url = `${this.treeSetting.url}?node_id=${currentNode.meta.data.id}&show_current_asset=1`
this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url) this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url)
}, },
rMenuShowAssetAllChildrenNode: function() { rMenuShowAssetAllChildrenNode: function() {
@@ -462,7 +462,7 @@ export default {
} }
this.$cookie.set('show_current_asset', '0', 1) this.$cookie.set('show_current_asset', '0', 1)
this.decorateRMenu() this.decorateRMenu()
const url = `${this.treeSetting.url}?node_id=${currentNode.meta.node.id}&show_current_asset=0` const url = `${this.treeSetting.url}?node_id=${currentNode.meta.data.id}&show_current_asset=0`
this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url) this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url)
}, },
rMenuShowNodeInfo: function() { rMenuShowNodeInfo: function() {
@@ -472,7 +472,7 @@ export default {
return return
} }
this.$axios.get( this.$axios.get(
`/api/v1/assets/nodes/${currentNode.meta.node.id}/` `/api/v1/assets/nodes/${currentNode.meta.data.id}/`
).then(res => { ).then(res => {
this.nodeInfoDialogSetting.dialogVisible = true this.nodeInfoDialogSetting.dialogVisible = true
this.nodeInfoDialogSetting.items = [ this.nodeInfoDialogSetting.items = [
@@ -512,9 +512,9 @@ export default {
if (!currentNode || assetsSelected.length === 0) { if (!currentNode || assetsSelected.length === 0) {
return return
} }
let url = `/api/v1/assets/nodes/${currentNode.meta.node.id}/assets/add/` let url = `/api/v1/assets/nodes/${currentNode.meta.data.id}/assets/add/`
if (this.assetTreeTableDialogSetting.action === 'move') { if (this.assetTreeTableDialogSetting.action === 'move') {
url = `/api/v1/assets/nodes/${currentNode.meta.node.id}/assets/replace/` url = `/api/v1/assets/nodes/${currentNode.meta.data.id}/assets/replace/`
} }
this.$axios.put( this.$axios.put(
url, { assets: assetsSelected } url, { assets: assetsSelected }

View File

@@ -142,7 +142,7 @@ export default {
}, },
onClick(event, treeId, treeNode, clickFlag) { onClick(event, treeId, treeNode, clickFlag) {
// if (treeNode.meta.type === 'asset') { // if (treeNode.meta.type === 'asset') {
// const protocolsStr = treeNode.meta.asset.protocols + '' // const protocolsStr = treeNode.meta.data.protocols + ''
// if (protocolsStr.indexOf('ssh/') === -1) { // if (protocolsStr.indexOf('ssh/') === -1) {
// // Don't Support SSH // // Don't Support SSH
// } // }
@@ -162,7 +162,7 @@ export default {
const assetsNode = [] const assetsNode = []
nodes.forEach(function(node) { nodes.forEach(function(node) {
if (node.meta.type === 'asset' && !node.isHidden) { if (node.meta.type === 'asset' && !node.isHidden) {
const protocolsStr = node.meta.asset.protocols + '' const protocolsStr = node.meta.data.protocols + ''
if (assetsNodeId.indexOf(node.id) === -1 && protocolsStr.indexOf('ssh') > -1) { if (assetsNodeId.indexOf(node.id) === -1 && protocolsStr.indexOf('ssh') > -1) {
assetsNodeId.push(node.id) assetsNodeId.push(node.id)
assetsNode.push(node) assetsNode.push(node)

View File

@@ -62,11 +62,11 @@ export default {
onSelected: function(event, treeNode) { onSelected: function(event, treeNode) {
let url = vm.assetUserConfig.url let url = vm.assetUserConfig.url
if (treeNode.meta.type === 'node') { if (treeNode.meta.type === 'node') {
const nodeId = treeNode.meta.node.id const nodeId = treeNode.meta.data.id
url = setUrlParam(url, 'asset_id', '') url = setUrlParam(url, 'asset_id', '')
url = setUrlParam(url, 'node_id', nodeId) url = setUrlParam(url, 'node_id', nodeId)
} else if (treeNode.meta.type === 'asset') { } else if (treeNode.meta.type === 'asset') {
const assetId = treeNode.meta.asset.id const assetId = treeNode.meta.data.id
url = setUrlParam(url, 'node_id', '') url = setUrlParam(url, 'node_id', '')
url = setUrlParam(url, 'asset_id', assetId) url = setUrlParam(url, 'asset_id', assetId)
} }