dialogCom.vue 4.8 KB

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