dialogCom copy.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <el-dialog
  3. :title="dialogTitle"
  4. v-model="dialogVisible"
  5. width="800px"
  6. @close="closeDialog()"
  7. @open="open"
  8. >
  9. <div style="width: 100%; height: 400px">
  10. <!-- <inner-line-chart></inner-line-chart> -->
  11. <div shadow="never" class="homeBoxCard" v-loading="loading">
  12. <div
  13. style="height:300px"
  14. ref="lineChartBanlance"
  15. id="lineChartBanlance"
  16. />
  17. </div>
  18. </div>
  19. </el-dialog>
  20. </template>
  21. <script>
  22. // import { useStore } from 'vuex'
  23. import { defineComponent, ref, watchEffect, onMounted } from 'vue'
  24. // import * as api from '@/api/siteManage/watchDog.js'
  25. // import { ElMessage } from 'element-plus'
  26. import * as echarts from 'echarts'
  27. // import innerLineChart from './innerLineChart.vue'
  28. export default defineComponent({
  29. name: 'DialogCom',
  30. components: {
  31. // innerLineChart,
  32. },
  33. emits: ['closeDialog'],
  34. props: {
  35. flag: Boolean,
  36. dialogTitle: String,
  37. itemInfo: Object,
  38. },
  39. setup(props, context) {
  40. // let lineChartBanlance = ref(null)
  41. context
  42. const dialogVisible = ref(false)
  43. const siteList = ref([])
  44. function echarts2() {
  45. alert('000')
  46. // 新建一个promise对象
  47. let newPromise = new Promise((resolve) => {
  48. resolve()
  49. })
  50. //然后异步执行echarts的初始化函数
  51. newPromise.then(() => {
  52. alert('promise')
  53. // 此dom为echarts图标展示dom
  54. let myChart = echarts.init(document.getElementById('lineChartBanlance'))
  55. myChart.setOption({
  56. color: ['#1187FF'],
  57. legend: {
  58. bottom: '0',
  59. data: ['电流不平衡度'],
  60. },
  61. tooltip: {
  62. trigger: 'axis',
  63. axisPointer: { type: 'cross' },
  64. },
  65. grid: {
  66. left: '20',
  67. right: '40',
  68. top: '40',
  69. bottom: '30',
  70. containLabel: true,
  71. },
  72. xAxis: {
  73. axisLabel: {
  74. color: '#444',
  75. fontSize: 14,
  76. },
  77. /*改变xy轴颜色*/
  78. axisLine: {
  79. lineStyle: {
  80. color: '#444',
  81. width: 1, //这里是为了突出显示加上的
  82. },
  83. },
  84. boundaryGap: false,
  85. // data: electricChart2.value.dataTime,
  86. data: [1, 2, 3, 4, 5, 6, 7, 8],
  87. },
  88. yAxis: {
  89. name: '%',
  90. nameTextStyle: {
  91. color: 'black',
  92. fontSize: 10,
  93. },
  94. type: 'value',
  95. axisTick: {
  96. show: true, //去除刻度线
  97. },
  98. axisLabel: {
  99. color: 'black', // 文本颜色
  100. },
  101. axisLine: {
  102. show: true, // 去除轴线
  103. lineStyle: {
  104. color: 'black',
  105. },
  106. },
  107. splitNumber: 5,
  108. splitLine: {
  109. show: true,
  110. lineStyle: {
  111. color: '#9d9d9d',
  112. },
  113. },
  114. },
  115. series: [
  116. {
  117. name: '电流不平衡度',
  118. type: 'line',
  119. symbolSize: 7,
  120. smooth: false,
  121. // data: electricChart2.value.elBalun,
  122. data: [1, 2, 3, 4, 5, 6, 7, 8],
  123. markLine: {
  124. //最大值和最小值
  125. data: [
  126. {
  127. yAxis: 30,
  128. label: {
  129. position: 'middle',
  130. formatter: '严重三项不平衡',
  131. },
  132. lineStyle: {
  133. width: 2,
  134. color: '#FF5D1D',
  135. },
  136. },
  137. {
  138. yAxis: 14,
  139. label: {
  140. position: 'middle',
  141. formatter: '不平衡度',
  142. },
  143. lineStyle: {
  144. width: 2,
  145. color: '#f2e251',
  146. },
  147. },
  148. ],
  149. },
  150. },
  151. ],
  152. })
  153. window.addEventListener('resize', () => {
  154. myChart.resize()
  155. })
  156. })
  157. }
  158. // open(): Dialog弹窗打开之前做的事
  159. const open = () => {
  160. // setTimeout(echarts2(), 1000)
  161. echarts2()
  162. }
  163. // 关闭弹框
  164. const closeDialog = () => {
  165. context.emit('closeDialog', false)
  166. dialogVisible.value = false
  167. }
  168. watchEffect((fn) => {
  169. fn
  170. dialogVisible.value = props.flag
  171. })
  172. onMounted(() => {
  173. // setTimeout(function(){
  174. // },3000)
  175. })
  176. return {
  177. closeDialog,
  178. dialogVisible,
  179. siteList,
  180. echarts2,
  181. open,
  182. }
  183. },
  184. })
  185. </script>
  186. <style scoped lang="scss">
  187. </style>