[Update] 添加显示节点信息的执行逻辑

This commit is contained in:
Bai 2020-06-08 16:41:32 +08:00
parent 8da771af3f
commit 937d139a6b
4 changed files with 52 additions and 5 deletions

View File

@ -210,7 +210,18 @@ export default {
this.$emit('urlChange', `${this.setting.url}?node_id=${currentNode.meta.node.id}&show_current_asset=0`) this.$emit('urlChange', `${this.setting.url}?node_id=${currentNode.meta.node.id}&show_current_asset=0`)
}, },
showNodeInfo: function() { showNodeInfo: function() {
this.hideRMenu()
const currentNode = this.zTree.getSelectedNodes()[0]
if (!currentNode) {
return
}
this.$axios.get(
`/api/v1/assets/nodes/${currentNode.meta.node.id}/`
).then(res => {
this.$emit('showNodeInfoDialog', res)
}).catch(error => {
this.$message.error(this.$t('common.getErrorMsg' + ' ' + error))
})
}, },
onRename: function(event, treeId, treeNode, isCancel) { onRename: function(event, treeId, treeNode, isCancel) {
const url = `${this.treeSetting.nodeUrl}${this.currentNodeId}/` const url = `${this.treeSetting.nodeUrl}${this.currentNodeId}/`

View File

@ -8,6 +8,7 @@
:setting="treeSetting" :setting="treeSetting"
class="auto-data-ztree" class="auto-data-ztree"
@urlChange="handleUrlChange" @urlChange="handleUrlChange"
@showNodeInfoDialog="showNodeInfoDialog"
> >
<div slot="rMenu" slot-scope="{data}"> <div slot="rMenu" slot-scope="{data}">
<slot name="rMenu" :data="data" /> <slot name="rMenu" :data="data" />
@ -24,12 +25,19 @@
<ListTable ref="ListTable" :key="componentKey" :table-config="iTableConfig" :header-actions="headerActions" /> <ListTable ref="ListTable" :key="componentKey" :table-config="iTableConfig" :header-actions="headerActions" />
</div> </div>
</div> </div>
<Dialog width="30%" :title="this.$t('assets.NodeInformation')" :visible.sync="nodeInfoDialog.show" :show-cancel="false" :show-confirm="false">
<el-row v-for="item in nodeInfoDialog.items" :key="'card-' + item.key" :gutter="10" class="item">
<el-col :span="6"><div class="item-label"><label>{{ item.label }}: </label></div></el-col>
<el-col :span="18"><div class="item-text">{{ item.value }}</div></el-col>
</el-row>
</Dialog>
</div> </div>
</el-collapse-transition> </el-collapse-transition>
</template> </template>
<script> <script>
import AutoDataZTree from '../AutoDataZTree' import AutoDataZTree from '../AutoDataZTree'
import Dialog from '@/components/Dialog'
import ListTable from '../ListTable' import ListTable from '../ListTable'
import IBox from '../IBox' import IBox from '../IBox'
export default { export default {
@ -37,7 +45,8 @@ export default {
components: { components: {
ListTable, ListTable,
AutoDataZTree, AutoDataZTree,
IBox IBox,
Dialog
}, },
props: { props: {
...ListTable.props, ...ListTable.props,
@ -59,8 +68,11 @@ export default {
return { return {
iTableConfig: this.tableConfig, iTableConfig: this.tableConfig,
iShowTree: this.showTree, iShowTree: this.showTree,
componentKey: 0 componentKey: 0,
nodeInfoDialog: {
show: false,
items: []
}
} }
}, },
watch: { watch: {
@ -79,12 +91,21 @@ export default {
}, },
getSelectedNodes: function() { getSelectedNodes: function() {
return this.$refs.AutoDataZTree.getSelectedNodes() return this.$refs.AutoDataZTree.getSelectedNodes()
},
showNodeInfoDialog(node) {
this.nodeInfoDialog.show = true
this.nodeInfoDialog.items = [
{ key: 'id', label: 'ID', value: node.id },
{ key: 'name', label: this.$t('assets.Name'), value: node.name },
{ key: 'fullName', label: this.$t('assets.FullName'), value: node.full_value },
{ key: 'key', label: this.$t('assets.Key'), value: node.key }
]
} }
} }
} }
</script> </script>
<style scoped> <style lang="scss" scoped>
.mini-button{ .mini-button{
width: 12px; width: 12px;
float: right; float: right;
@ -108,4 +129,11 @@ export default {
overflow: auto; overflow: auto;
/*border-right: solid 1px red;*/ /*border-right: solid 1px red;*/
} }
.el-row {
margin-bottom: 20px;
&:last-child {
margin-bottom: 0;
}
}
</style> </style>

View File

@ -29,6 +29,9 @@
"": "" "": ""
}, },
"assets": { "assets": {
"FullName": "全称",
"Key": "键",
"NodeInformation": "节点信息",
"Action": "动作", "Action": "动作",
"AutoGenerateKey": "自动生成密钥", "AutoGenerateKey": "自动生成密钥",
"UnselectedAssets":"未选择资产", "UnselectedAssets":"未选择资产",
@ -248,6 +251,7 @@
"DropConfirmMsg": "你想移动节点: {src} 到 {dst} 下吗?" "DropConfirmMsg": "你想移动节点: {src} 到 {dst} 下吗?"
}, },
"updateErrorMsg": "更新失败", "updateErrorMsg": "更新失败",
"getErrorMsg": "获取失败",
"updateSelected": "更新所选", "updateSelected": "更新所选",
"updateSuccessMsg": "更新成功", "updateSuccessMsg": "更新成功",
"Disable": "禁用", "Disable": "禁用",

View File

@ -29,6 +29,9 @@
"": "" "": ""
}, },
"assets": { "assets": {
"FullName": "Full name",
"Key": "Key",
"NodeInformation": "Node information",
"Action": "Action", "Action": "Action",
"NoInputCommand": "No input command", "NoInputCommand": "No input command",
"UnselectedAssets":"Unselected assets", "UnselectedAssets":"Unselected assets",
@ -244,6 +247,7 @@
"Empty": "Empty", "Empty": "Empty",
"Loading": "Loading" "Loading": "Loading"
}, },
"getErrorMsg": "Get failed",
"updateErrorMsg": "Update failed", "updateErrorMsg": "Update failed",
"updateSelected": "Update selected", "updateSelected": "Update selected",
"updateSuccessMsg": "Update success", "updateSuccessMsg": "Update success",