Yuyan.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <script lang="ts" setup>
  2. import {onMounted, onUnmounted, reactive, ref} from 'vue'
  3. import RightFrame from '@/components/RightFrame.vue'
  4. import Card01 from '@/components/card/Card01.vue'
  5. import StripeTable from '@/components/StripeTable.vue'
  6. import {Operate, Point, View} from "@/utils/tdInstruction";
  7. import StationRightButtonGroup from "@/components/StationRightButtonGroup.vue";
  8. import {useBasinStore} from "@/stores/basin";
  9. import {getYuyanDataList, getYuyanFanganList} from "@/api/yuyan";
  10. import {convertDate, removeDuplicates} from "@/utils/date";
  11. import {useTimeScrollbarStore} from "@/stores/timeScrollbar";
  12. import {extractList} from "@/utils/list";
  13. import {formatd} from "@/utils/ruoyi";
  14. import {stationList} from "@/assets/js/station"
  15. import {slopeCalculation} from "@/utils/slopeCalculation";
  16. const timeScrollbarStore = useTimeScrollbarStore()
  17. const basinStore = useBasinStore()
  18. const tableColumns = [
  19. // {
  20. // label: '监测点',
  21. // prop: 'DD_NAME',
  22. // width: '150px',
  23. // showOverflowTooltip: true,
  24. // convertFn: (data) => data ? data.trim() : ''
  25. // },
  26. {label: '方案', prop: 'DD_NAME', showOverflowTooltip: true}
  27. ]
  28. const tableData = reactive([])
  29. const yuyanData = ref([])
  30. /**
  31. * 监测点列表
  32. */
  33. async function getMonitoringPoint() {
  34. getYuyanFanganList().then(res => {
  35. tableData.push(...res.data)
  36. })
  37. }
  38. /**
  39. * @param row
  40. */
  41. function handleCurrentChange(row) {
  42. getYuyanDataList(row.ID).then(res => {
  43. yuyanData.value = res.data.map(item => {
  44. return {
  45. ...item,
  46. YMDHM: convertDate(item.YMDHM)
  47. }
  48. })
  49. let timeList = removeDuplicates(yuyanData.value.map(y => y.YMDHM))
  50. timeScrollbarStore.setTimeScrollbarShow(true)
  51. timeScrollbarStore.setMax(timeList.length)
  52. const timeObj = extractList(timeList, 4)
  53. for (let key in timeObj) {
  54. timeObj[key] = {
  55. style: {
  56. color: '#00c7e3',
  57. 'text-shadow': '0 0 4px #32003C'
  58. },
  59. label: formatd(timeObj[key], 'yyyy年MM月dd日hh时')
  60. }
  61. }
  62. timeScrollbarStore.setMarks(timeObj)
  63. timeScrollbarStore.sliderlTooltip = (value: number) => {
  64. const date = timeList[value]
  65. const list = yuyanData.value.filter(y => y.YMDHM.getTime() === date.getTime())
  66. const data = list.map(d => {
  67. let station = stationList.find(s => s.id === d.STCD)
  68. if (!station) {
  69. console.log(`未找到${d.STCD}`)
  70. }
  71. return {
  72. id: d.STCD,
  73. name: `${station.name}`,
  74. value: `${(d.DATA).toFixed(2)}`,
  75. type: "水文站",
  76. x: station.lgtd,
  77. y: station.lttd
  78. }
  79. })
  80. const res = slopeCalculation(data);
  81. Operate.strategyMap(res.direction, res.slope);
  82. Point.addPoint(data.map(a => {
  83. return {'id': a.id, 'name': `${a.value}\n${a.name}`, 'type': a.type, 'x': a.x, 'y': a.y}
  84. }), '水文站')
  85. return formatd(date, 'yyyy年MM月dd日hh时')
  86. }
  87. })
  88. }
  89. onMounted(() => {
  90. // 监测点列表
  91. getMonitoringPoint()
  92. // 太湖视角
  93. View.changeView()
  94. })
  95. onUnmounted(() => {
  96. Operate.strategyMap("", "", false)
  97. timeScrollbarStore.close()
  98. basinStore.setLabelState2('水文站', false)
  99. })
  100. </script>
  101. <template>
  102. <right-frame>
  103. <template #leftModule>
  104. <card01 title="预报方案">
  105. <stripe-table :columns="tableColumns" :data="tableData" :show-header="false"
  106. @row-click="handleCurrentChange"></stripe-table>
  107. </card01>
  108. </template>
  109. <template #btnGroup>
  110. <station-right-button-group></station-right-button-group>
  111. </template>
  112. </right-frame>
  113. </template>