sceneSVG.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="svgDataDiv" ref="svgDataDiv">
  3. <svg-visual @click="handleClick" :total="total"></svg-visual>
  4. <eventDrawer ref="eventDrawer" @close="closeDrawer"></eventDrawer>
  5. </div>
  6. </template>
  7. <script>
  8. import svgVisual from './components/svgVisual.vue'
  9. import eventDrawer from "./drawer/eventDrawer";
  10. export default {
  11. components: {
  12. svgVisual,
  13. eventDrawer
  14. },
  15. props: {
  16. searchOption:{
  17. type:Object,
  18. default:()=>{
  19. return {}
  20. }
  21. }
  22. },
  23. data() {
  24. return {
  25. //应用场景对应事件总数量
  26. total: {},
  27. };
  28. },
  29. watch: {
  30. searchOption:{
  31. handler(newValue, oldValue) {//这里的第一个参数是改变后的值,第二个参数是原来的值
  32. this.getScenarioTotal()
  33. },
  34. immediate: true
  35. }
  36. },
  37. computed: {
  38. scenario(){
  39. return this.$store.state.dictMessage.scenario
  40. }
  41. },
  42. created() {},
  43. async mounted() {
  44. //获取块的最大宽高
  45. this.getDivWidth()
  46. //获取应用场景对应事件总数量
  47. await this.getScenarioTotal()
  48. },
  49. methods: {
  50. //获取块的最大宽高
  51. getDivWidth(){
  52. let width = this.$refs.svgDataDiv.clientWidth
  53. let height = this.$refs.svgDataDiv.clientHeight
  54. var maxHeight = 0
  55. var maxWidth = 0
  56. var rand = 1322.078125/642.09375
  57. if(width>height){
  58. if(height * rand > width){
  59. maxHeight = Math.floor(width/rand)
  60. }else{
  61. maxHeight = height
  62. }
  63. maxWidth = maxHeight * rand
  64. }else{
  65. if(width * rand > height){
  66. maxWidth = Math.floor(height/rand)
  67. }else{
  68. maxWidth = width
  69. }
  70. maxHeight = Math.floor(maxWidth / rand)
  71. }
  72. this.$refs.svgDataDiv.style.width = maxWidth + 'px'
  73. this.$refs.svgDataDiv.style.height = maxHeight + 'px'
  74. },
  75. // 应用场景对应事件总数量
  76. async getScenarioTotal() {
  77. var params = {
  78. "current": 1,
  79. "size": 10,
  80. "searchQuery": this.$commonJS.objectToString(this.searchOption),
  81. "orderDTOList": [
  82. {
  83. "orderBy": "createTime",
  84. "orderType": 1
  85. }
  86. ],
  87. "groupBy": "scenarioNames"
  88. }
  89. await this.$api.groupEvent(params).then(res => {
  90. if (res.code == 200) {
  91. this.total=res.data.data.values
  92. }
  93. }).catch(err => {
  94. this.total = []
  95. })
  96. },
  97. // 详情及清单按钮事件
  98. handleClick(data) {
  99. const { title, type } = data
  100. switch (type) {
  101. case 0:
  102. if(Object.keys(this.searchOption).length>0){
  103. this.$emit('toFlowPath',title)
  104. break;
  105. }
  106. this.$router.push({
  107. path: `/visual/${encodeURIComponent(title)}`,
  108. })
  109. break
  110. case 1:
  111. var scenarioId = this.scenario.find(item=>{
  112. return item.name == title
  113. }).id
  114. this.$refs.eventDrawer.open(title, [scenarioId])
  115. break
  116. }
  117. },
  118. //关闭弹窗
  119. closeDrawer(){
  120. //获取应用场景对应事件总数量
  121. this.getScenarioTotal()
  122. },
  123. },
  124. };
  125. </script>
  126. <style lang="scss" scoped>
  127. .svgDataDiv {
  128. // max-height: calc(100% - 163px);
  129. width: 100%;
  130. height: 100%;
  131. margin: 0px auto 0;
  132. display: flex;
  133. flex-direction: row;
  134. justify-content: center;
  135. max-width: 1420px;
  136. }
  137. </style>