index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <script setup name="prepare">
  2. import searchCop from './components/search.vue'
  3. import excelCop from '@/components/excel.vue'
  4. import treeCop from '@/components/tree.vue'
  5. // import tableCop from './components/table.vue'
  6. import { ElMessage } from 'element-plus';
  7. import { onMounted, ref, onActivated } from 'vue'
  8. import CurrentScatterChart from './components/current-scatter-chart.vue'
  9. import request from '@/api/axios.js'
  10. import {baseURL, socketURL} from '@/api/axios.js'
  11. import dayjs from 'dayjs';
  12. /**配置参数 */
  13. const tableHeight = ref(window.innerHeight - 160 + 'px')
  14. const treeHeight = ref(window.innerHeight - 160 + 'px') //tree高度
  15. const excelHeight = ref(window.innerHeight - 160 + 'px') //excel高度
  16. /**excel 开始 */
  17. const excelList = ref([])
  18. const funExcelChange = async (obj) => { //点击excel项时
  19. funSubmit({ids: obj.id})
  20. }
  21. /**tree 开始 */
  22. const treeData = ref([])
  23. const actTreeNode = ref(null) //当前激活的treeNode
  24. const funRepeatMap = (arr, type) => {
  25. return arr.map(o => {
  26. if (o.children) {
  27. const findIndex = o.children.findIndex(p => !!p.type)
  28. if (findIndex !== -1) {
  29. o.childs = o.children
  30. o.children = []
  31. if(!actTreeNode.value && type === 'prepare'){ //判断当且仅有process获取tree时 赋值
  32. actTreeNode.value = o
  33. }
  34. }
  35. }
  36. return {
  37. ...o,
  38. children: o.children?.length ? funRepeatMap(o.children, type) : []
  39. }
  40. })
  41. }
  42. const funGetTree = async () => {
  43. const res = await request.get("/power/prepare/tree")
  44. treeData.value = funRepeatMap(res.data, 'prepare')
  45. excelList.value = []
  46. if(actTreeNode.value){
  47. funCurrentChange({current: actTreeNode.value, currentNode: null})
  48. const child = actTreeNode.value.childs[0]
  49. const obj = {
  50. id: child.id,
  51. interval: child.interval,
  52. path: child.path,
  53. prepareid: child.prepareid,
  54. station: child.station,
  55. time: child.time,
  56. type: child.type,
  57. windturbine: child.windturbine,
  58. name: child.path.substring(child.path.indexOf(child.station + '_') + (child.station + '_').length)
  59. }
  60. funExcelChange(obj)
  61. }
  62. }
  63. const funCurrentChange = ({ current, currentNode }) => {
  64. if (current.childs) {
  65. excelList.value = current.childs.map(o => {
  66. return {
  67. id: o.id,
  68. interval: o.interval,
  69. path: o.path,
  70. prepareid: o.prepareid,
  71. station: o.station,
  72. time: o.time,
  73. type: o.type,
  74. windturbine: o.windturbine,
  75. name: o.path.substring(o.path.indexOf(o.station + '_') + (o.station + '_').length)
  76. }
  77. })
  78. } else {
  79. excelList.value = []
  80. }
  81. }
  82. /**table 开始 */
  83. const tableShowId = ref('')
  84. const tableName = ref('')
  85. const tableColumn = ref([])
  86. const tableLoading = ref(false)
  87. const tableData = ref([])
  88. /**tab */
  89. const activeTab = ref('1')
  90. /**chart Data */
  91. const xAxisData = ref([])
  92. const chartRef = ref() //chart 的ref
  93. const seriesData = ref([])
  94. const dataSet = ref('')
  95. const funChartSelect = async (batch) => {
  96. return false
  97. }
  98. /**submit */
  99. const funSubmit = async (params) => {
  100. // const res = await request.get('/agc/deviate', { params: params })
  101. const res = await request.get('/blade/angle', { params: params })
  102. if(res.code !== 200){
  103. return false
  104. }
  105. const tsArr = res.data.time
  106. let yp1 = [], yp2 = [], yp3 = []
  107. res.data.angle.forEach(val => {
  108. yp1 = val.yp1
  109. yp2 = val.yp2
  110. yp3 = val.yp3
  111. });
  112. xAxisData.value = tsArr
  113. seriesData.value = [
  114. {
  115. name: "叶片一",
  116. type: "line",
  117. symbol: "line", //设定为实心点
  118. symbolSize: 0, //设定实心点的大小
  119. smooth: false, //这个是把线变成曲线
  120. data: yp1,
  121. xAxisIndex: 0,
  122. },
  123. {
  124. name: "叶片二",
  125. type: "line",
  126. symbol: "line", //设定为实心点
  127. symbolSize: 0, //设定实心点的大小
  128. smooth: false, //这个是把线变成曲线
  129. data: yp2,
  130. xAxisIndex: 0,
  131. },
  132. {
  133. name: "叶片三",
  134. type: "line",
  135. symbol: "line", //设定为实心点
  136. symbolSize: 0, //设定实心点的大小
  137. smooth: false, //这个是把线变成曲线
  138. data: yp3,
  139. xAxisIndex: 0,
  140. },
  141. ]
  142. }
  143. /**created */
  144. // funGetTree()
  145. /**mounted */
  146. onMounted(() => {
  147. tableHeight.value = window.innerHeight - 160 + 'px'
  148. excelHeight.value = window.innerHeight - 160 + 'px'
  149. treeHeight.value = window.innerHeight - 160 + 'px'
  150. window.addEventListener('resize', () => {
  151. tableHeight.value = window.innerHeight - 160 + 'px'
  152. excelHeight.value = window.innerHeight - 160 + 'px'
  153. treeHeight.value = window.innerHeight - 160 + 'px'
  154. })
  155. })
  156. /**activated */
  157. onActivated(() => {
  158. funGetTree()
  159. // funSubmit()
  160. })
  161. </script>
  162. <template>
  163. <div class="bg-white py-[10px] px-[10px] relative">
  164. <!-- <search-cop v-show="false" class="mb-[20px] shadow rounded-[6px] shadow-blue-500" @submit="funSubmit">
  165. </search-cop> -->
  166. <div class="relative shadow rounded-[6px] shadow-blue-500 px-[10px] pt-[20px] pb-[10px]">
  167. <div class="text-[14px] absolute top-[-7px] text-[#838383] left-[20px]">数据展示</div>
  168. <el-row :gutter="10">
  169. <el-col :span="5">
  170. <tree-cop :data="treeData" :height="treeHeight" @currentChange="funCurrentChange" @refresh="funGetTree">
  171. </tree-cop>
  172. </el-col>
  173. <el-col :span="3">
  174. <excel-cop :data="excelList" :height="excelHeight" @excelChange="funExcelChange"></excel-cop>
  175. </el-col>
  176. <el-col :span="16">
  177. <div class="px-[10px] shadow rounded-[6px] shadow-blue-500 ">
  178. <CurrentScatterChart ref="chartRef" width="100%" :height="`calc( ${tableHeight})`" :chartTitle="''"
  179. :xAxisData="xAxisData" :yAxisData="{ splitLine: { show: false } }" :seriesData="seriesData"
  180. :showLegend="true" :brushSelected="false" :dataSet="dataSet" @getSelected="funChartSelect" />
  181. </div>
  182. </el-col>
  183. </el-row>
  184. </div>
  185. </div>
  186. </template>