dialogChartOne.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <el-dialog
  3. :title="dialogTitle"
  4. v-model="dialogVisible"
  5. width="800px"
  6. @close="closeDialog()"
  7. >
  8. <div style="width: 100%">
  9. <inner-line-chart2 v-if="type=='elBalun'||type=='vtBalun'||type=='iaLoad'||type=='ibLoad'||type=='icLoad'"></inner-line-chart2>
  10. <inner-line-chart></inner-line-chart>
  11. </div>
  12. </el-dialog>
  13. </template>
  14. <script>
  15. import { useStore } from 'vuex'
  16. import { defineComponent, ref, watchEffect, onMounted, watch } from 'vue'
  17. import innerLineChart from './innerLineChart'
  18. import innerLineChart2 from './innerLineChart2'
  19. export default defineComponent({
  20. name: 'DialogChartOne',
  21. components: {
  22. innerLineChart,
  23. innerLineChart2
  24. },
  25. emits: ['closeDialog'],
  26. props: {
  27. flag: Boolean,
  28. dialogTitle: String,
  29. itemInfo: Object,
  30. echartsAllData: Array,
  31. echartsTitle: String,
  32. },
  33. setup(props, context) {
  34. context
  35. const store = useStore()
  36. const dialogVisible = ref(false)
  37. const type = ref('')
  38. const getData = async () => {
  39. type.value = store.state.chartType
  40. }
  41. // 关闭弹框
  42. const closeDialog = () => {
  43. context.emit('closeDialog', false)
  44. dialogVisible.value = false
  45. }
  46. watchEffect((fn) => {
  47. fn
  48. dialogVisible.value = props.flag
  49. })
  50. const writeValue = (val) => {
  51. val
  52. getData()
  53. }
  54. //监听变化
  55. watch(
  56. () => store.state.chartType,
  57. (newVal, oldVal, clear) => {
  58. // 执行异步任务,并得到关闭异步任务的 id
  59. let id = writeValue(newVal, oldVal)
  60. // 如果 watch 监听被重复执行了,则会先清除上次未完成的异步任务
  61. clear(() => clearTimeout(id))
  62. },
  63. { lazy: true }
  64. )
  65. onMounted(() => {})
  66. return {
  67. closeDialog,
  68. dialogVisible,
  69. type
  70. }
  71. },
  72. })
  73. </script>
  74. <style scoped lang="scss">
  75. </style>