index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="monitor-site flex">
  3. <!-- 左侧内容 -->
  4. <div class="h-full flex-basis-385px p-10px">
  5. <SiteFilter @submit="refreshTree" />
  6. <SiteTree class="w-full h-50em scroll-auto" :tree-data="treeData" @select="focusOnSite" />
  7. </div>
  8. <!-- 右侧内容 主要内容 -->
  9. <div class="h-full flex-grow-1 flex flex-col relative">
  10. <IFrame class="w-full h-full" :frame-src="monitorSiteOperationUrl" @message="handleMessage" />
  11. <SiteForm class="absolute w-full bg-#0960bd33 p-10px" :site="selectedSite" />
  12. </div>
  13. </div>
  14. </template>
  15. <script setup lang="ts">
  16. import SiteTree from './components/siteTree.vue';
  17. import SiteFilter from './components/siteFilter.vue';
  18. import SiteForm from './components/siteForm.vue';
  19. import { onMounted, ref } from 'vue';
  20. import {
  21. MonitorSiteTreeParams,
  22. MonitorSiteTreeNode,
  23. MonitorSite,
  24. } from '@/api/sys/model/monitorModel';
  25. import {
  26. getMonitorSiteTree,
  27. postMonitorOperation,
  28. monitorSiteOperationUrl,
  29. handleMonitorOperation,
  30. } from '@/api/sys/monitor';
  31. import IFrame from '@/views/sys/iframe/index.vue';
  32. // 测点树相关,包含了刷新、请求的内容
  33. const treeData = ref<MonitorSiteTreeNode>();
  34. function refreshTree(params: MonitorSiteTreeParams) {
  35. getMonitorSiteTree(params).then((r) => {
  36. if (r.code === 200) treeData.value = r.data;
  37. });
  38. }
  39. // 选中的测点
  40. const selectedSite = ref<MonitorSite>();
  41. // 测点操作(iframe)相关,包括下发指令及处理消息
  42. // 聚焦到测点上
  43. function focusOnSite(site: MonitorSite) {
  44. selectedSite.value = site;
  45. postMonitorOperation({
  46. clickType: 'treePoint',
  47. id: site.mineCode,
  48. data: {},
  49. type: 'treeSensor',
  50. from: 'tank',
  51. });
  52. }
  53. function handleMessage(msg: any) {
  54. handleMonitorOperation(msg, (d) => {
  55. console.log(d);
  56. });
  57. }
  58. onMounted(() => {
  59. refreshTree({});
  60. });
  61. defineExpose({
  62. treeData,
  63. monitorSiteOperationUrl,
  64. selectedSite,
  65. refreshTree,
  66. focusOnSite,
  67. });
  68. </script>
  69. <style scoped>
  70. .monitor-site {
  71. width: 100%;
  72. margin-top: 88px;
  73. }
  74. </style>