|
@@ -29,14 +29,14 @@ import OrganizationAdd from './organizationAdd.vue'
|
|
|
import {
|
|
|
getOrganizationAndEmployeeTree,
|
|
|
// getOrganizationAtlasEmployee,
|
|
|
- importOrganization,
|
|
|
+ // importOrganization,
|
|
|
exportOrganization,
|
|
|
- downloadOrganization,
|
|
|
+ // downloadOrganization,
|
|
|
deleteOrganization
|
|
|
} from '@/api/system'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import {
|
|
|
- upload,
|
|
|
+ // upload,
|
|
|
download
|
|
|
} from '@/utils/elementUploadAndDownload'
|
|
|
export default {
|
|
@@ -53,7 +53,6 @@ export default {
|
|
|
{ label: '删除', prop: 'delete' }
|
|
|
],
|
|
|
nodes: null,
|
|
|
- loading: false,
|
|
|
importLoading: false,
|
|
|
exportLoading: false,
|
|
|
downloadLoading: false,
|
|
@@ -103,10 +102,8 @@ export default {
|
|
|
mounted () {
|
|
|
this.$nextTick(async () => {
|
|
|
this.graph = this.$refs.eCharts.onInit()
|
|
|
- this.graph.showLoading()
|
|
|
this.seriesData = await this.onInit()
|
|
|
this.graph.setOption(this.option)
|
|
|
- this.graph.hideLoading()
|
|
|
this.graph.on('click', (params) => {
|
|
|
const data = getData(params.data.id, this.seriesData)
|
|
|
if (params.event.target.type === 'tspan') {
|
|
@@ -130,6 +127,14 @@ export default {
|
|
|
this.graph.on('treeroam', (event) => {
|
|
|
this.contextMenuShow = false
|
|
|
})
|
|
|
+ this.graph.on('contextmenu', (params) => {
|
|
|
+ params.event.event.preventDefault()
|
|
|
+ if (params.event.target.type === 'tspan') {
|
|
|
+ const data = getData(params.data.id, this.seriesData)
|
|
|
+ this.nodes = data
|
|
|
+ this.onGraphHandles(params.event.event)
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
function getData (id, data) {
|
|
@@ -156,7 +161,7 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
async onInit () {
|
|
|
- this.loading = true
|
|
|
+ this.graph.showLoading()
|
|
|
try {
|
|
|
const { data } = await getOrganizationAndEmployeeTree({})
|
|
|
return changeChildToChildren(data)
|
|
@@ -172,7 +177,7 @@ export default {
|
|
|
this.$message.error(error)
|
|
|
return {}
|
|
|
} finally {
|
|
|
- this.loading = false
|
|
|
+ this.graph.hideLoading()
|
|
|
}
|
|
|
},
|
|
|
onGraphHandles (e) {
|
|
@@ -196,17 +201,21 @@ export default {
|
|
|
this.$confirm('是否删除该项', '提示').then(async () => {
|
|
|
try {
|
|
|
await deleteOrganization({
|
|
|
- organizationNo: nodes.id
|
|
|
+ organizationNo: nodes.id,
|
|
|
+ organizationName: nodes.name
|
|
|
})
|
|
|
this.$message.success('删除成功')
|
|
|
- const data = await this.initData()
|
|
|
- this.drawGraph(data)
|
|
|
+ this.onRefresh()
|
|
|
} catch (error) {
|
|
|
this.$message.error(error)
|
|
|
}
|
|
|
}).catch(_ => {})
|
|
|
},
|
|
|
- onRefresh () {},
|
|
|
+ // 重新渲染
|
|
|
+ async onRefresh () {
|
|
|
+ this.seriesData = await this.onInit()
|
|
|
+ this.graph.setOption(this.option)
|
|
|
+ },
|
|
|
onMenuClick (prop) {
|
|
|
if (prop === 'edit') {
|
|
|
this.editTag(this.nodes)
|
|
@@ -215,20 +224,8 @@ export default {
|
|
|
this.onDelete(this.nodes)
|
|
|
}
|
|
|
},
|
|
|
- async onImport (response) {
|
|
|
- this.importLoading = true
|
|
|
- const check = await upload(importOrganization, response.file)
|
|
|
- if (check) {
|
|
|
- const graphData = await this.onInit()
|
|
|
- await this.renderGraph(graphData)
|
|
|
- this.onSetClose(graphData.nodes)
|
|
|
- }
|
|
|
- this.importLoading = false
|
|
|
- },
|
|
|
async editTag (nodes) {
|
|
|
- this.loading = true
|
|
|
- await this.$refs.organizationEditRefs.open(nodes)
|
|
|
- this.loading = false
|
|
|
+ this.$refs.organizationEditRefs.open(nodes)
|
|
|
},
|
|
|
onAdd () {
|
|
|
this.$refs.organizationAddRefs.open()
|
|
@@ -237,12 +234,22 @@ export default {
|
|
|
this.exportLoading = true
|
|
|
await download(exportOrganization)
|
|
|
this.exportLoading = false
|
|
|
- },
|
|
|
- async onDownload () {
|
|
|
- this.downloadLoading = true
|
|
|
- await download(downloadOrganization)
|
|
|
- this.downloadLoading = false
|
|
|
}
|
|
|
+ // async onImport (response) {
|
|
|
+ // this.importLoading = true
|
|
|
+ // const check = await upload(importOrganization, response.file)
|
|
|
+ // if (check) {
|
|
|
+ // const graphData = await this.onInit()
|
|
|
+ // await this.renderGraph(graphData)
|
|
|
+ // this.onSetClose(graphData.nodes)
|
|
|
+ // }
|
|
|
+ // this.importLoading = false
|
|
|
+ // },
|
|
|
+ // async onDownload () {
|
|
|
+ // this.downloadLoading = true
|
|
|
+ // await download(downloadOrganization)
|
|
|
+ // this.downloadLoading = false
|
|
|
+ // }
|
|
|
}
|
|
|
}
|
|
|
</script>
|