Lin Qilong преди 1 седмица
родител
ревизия
d0849a8e32
променени са 7 файла, в които са добавени 102 реда и са изтрити 91 реда
  1. 2 2
      src/assets/js/station.ts
  2. 0 20
      src/stores/app.ts
  3. 0 6
      src/stores/legend.ts
  4. 0 5
      src/stores/typhoon.ts
  5. 23 0
      src/utils/index.ts
  6. 69 50
      src/views/Waves.vue
  7. 8 8
      src/views/Yuyan.vue

+ 2 - 2
src/assets/js/station.ts

@@ -35,8 +35,8 @@ export const stationList = [
     name: '夹浦',
     lgtd: "119.938890",
     lttd: "31.106388",
-    wrz: 3.70,
-    grz: 4.30,
+    wrz: 3.80,
+    grz: 4.65,
     damel: 7.492,
   },
   {

+ 0 - 20
src/stores/app.ts

@@ -65,26 +65,6 @@ export const useAppStore = defineStore('app', () => {
     bus.emit('horizontal-expand', value)
   }
 
-  // 路由监听
-  watch(() => route.path, path => {
-    // 切换底图 三维、MAP
-    changeFloorTypeByPath(path)
-    // 获取主页面
-    for (let type of homePageList) {
-      if (path.indexOf(`/${type}/`) > -1) {
-        homePage.value = type
-        hasEnterSthouse.value = false
-        break
-      }
-    }
-
-    if (path.indexOf(`/sthouse/`) > -1) {
-      hasEnterSthouse.value = true
-    }
-
-  }, {deep: true, immediate: true})
-
-
   /**
    * 底板回调监听
    */

+ 0 - 6
src/stores/legend.ts

@@ -170,12 +170,6 @@ export const useLegendStore = defineStore('legend', () => {
     legendData.value = null
   }
 
-  // 路由监听
-  watch(() => route.path, path => {
-
-  }, {deep: true, immediate: true})
-
-
   return {
     showLegend,
     closeLegend,

+ 0 - 5
src/stores/typhoon.ts

@@ -17,11 +17,6 @@ export const useTyphoonStore = defineStore('typhoon', () => {
     isRadar.value = value
   }
 
-  // 路由监听
-  watch(() => route.path, path => {
-
-  }, {deep: true, immediate: true})
-
   return {
     isTyphoon,
     setTyphoon,

+ 23 - 0
src/utils/index.ts

@@ -56,3 +56,26 @@ export function objectMerge(target: any, source: any) {
   })
   return target
 }
+
+
+export function checkValueWithRetry(getValue: () => never, callback: (value: never) => void, maxAttempts = 3, delay = 2000) {
+  let attempts = 0;
+
+  function check() {
+    const value = getValue(); // 通过函数获取最新值
+    debugger
+    if (value !== undefined && value !== null && value !== '') {
+      callback(value);
+    } else if (attempts < maxAttempts) {
+      attempts++;
+      setTimeout(check, delay);
+    } else {
+      console.error('Value not found after retries');
+    }
+  }
+
+  check();
+}
+
+
+

+ 69 - 50
src/views/Waves.vue

@@ -2,7 +2,6 @@
 import { computed, onMounted, onUnmounted, ref } from 'vue'
 import RightFrame from '@/components/RightFrame.vue'
 import Card01 from '@/components/card/Card01.vue'
-import StripeTable from '@/components/StripeTable.vue'
 import { Operate } from '@/utils/tdInstruction'
 import StationRightButtonGroup from '@/components/StationRightButtonGroup.vue'
 import { getYuyanDataList, getYuyanFanganList } from '@/api/yuyan'
@@ -11,32 +10,21 @@ import { useTimeScrollbarStore } from '@/stores/timeScrollbar'
 import { extractList } from '@/utils/list'
 import { formatd } from '@/utils/ruoyi'
 import { getStationByName } from '@/assets/js/station'
-import { useAppStore } from '@/stores/app'
 import { useStationStore } from '@/stores/station'
 import bus from '@/utils/bus'
-import { useRoute, useRouter } from 'vue-router'
+import { useRoute } from 'vue-router'
 import { getHydrologicStation } from '@/api/station.js'
+import { checkValueWithRetry } from '@/utils/index.js'
 
 const route = useRoute()
-const router = useRouter()
-const appStore = useAppStore()
 const stationStore = useStationStore()
 const station = computed(() => getStationByName(stationStore.stnm))
 const timeScrollbarStore = useTimeScrollbarStore()
-const tableColumns = [
-  // {
-  //   label: '监测点',
-  //   prop: 'DD_NAME',
-  //   width: '150px',
-  //   showOverflowTooltip: true,
-  //   convertFn: (data) => data ? data.trim() : ''
-  // },
-  { label: '方案', prop: 'DD_NAME', showOverflowTooltip: true },
-]
 const tableData = ref([])
 const yuyanData = ref([])
+const yuyanId = ref(route.params.yuyanId)
 const startTime = new Date()
-startTime.setDate(startTime.getDate() - 3)
+startTime.setDate(startTime.getDate() - 90)
 const value2 = ref([startTime, new Date()])
 const shortcuts = [
   {
@@ -68,7 +56,7 @@ const shortcuts = [
   },
 ]
 const isYuyan = computed(() => {
-  return route.params.yuyanId && route.params.timeIndex
+  return !!yuyanId.value && !!route.params.timeIndex
 })
 
 /**
@@ -79,10 +67,9 @@ async function getMonitoringPoint() {
     formatd(value2.value[0], 'yyyy-MM-dd hh:mm:ss'),
     formatd(value2.value[1], 'yyyy-MM-dd hh:mm:ss'),
   ).then(res => {
-    tableData.value = res.data //.filter(item => item.DD_DISTRIBY === '55')
-
-    if (isYuyan) {
-      handleCurrentChange({ ID: route.params.yuyanId })
+    tableData.value = res.data.filter(item => item.DD_DISTRIBY === '55')
+    if (isYuyan.value) {
+      handleCurrentChange(yuyanId.value)
     }
   })
 }
@@ -90,8 +77,8 @@ async function getMonitoringPoint() {
 /**
  * @param row
  */
-function handleCurrentChange(row) {
-  getYuyanDataList(row.ID).then(res => {
+function handleCurrentChange(id) {
+  getYuyanDataList(id).then(res => {
     yuyanData.value = res.data.map(item => {
       return {
         ...item,
@@ -149,7 +136,7 @@ function getWavesByWaterLevel(value: number) {
   if (value >= 4) {
     waves = 1
   } else if (value >= 3) {
-    waves = ((value - 3) / 2).toFixed(1)
+    waves = ((value - 3)).toFixed(1)
   } else if (value >= 1) {
     waves = 0
   }
@@ -157,26 +144,30 @@ function getWavesByWaterLevel(value: number) {
 }
 
 onMounted(async () => {
-  if (!station.value) {
-    router.push('/')
-  }
-  // 监测点列表
-  getMonitoringPoint()
-
-  if (!isYuyan.value) {
-    await getHydrologicStation().then(res => {
-      const data = res.data.filter((d: any) => station.value.stcd === d.stcd)
-      debugger
-      if (data[0]) {
-        Operate.setWaterLevel(
-          station.value.stcd,
-          data[0].z,
-          getWavesByWaterLevel(data[0].z),
-        )
+  checkValueWithRetry(
+    () => station.value,
+    () => {
+      if (!isYuyan.value) {
+        getHydrologicStation().then(res => {
+          const data = res.data.filter(
+            (d: any) => station.value.stcd === d.stcd,
+          )
+          if (data[0]) {
+            Operate.setWaterLevel(
+              station.value.stcd,
+              data[0].z,
+              getWavesByWaterLevel(data[0].z),
+            )
+          }
+        })
+      } else {
+        // 预案列表
+        getMonitoringPoint()
       }
-    })
-  } else {
-  }
+    },
+    10,
+    2000,
+  )
 })
 
 /**
@@ -206,7 +197,7 @@ onUnmounted(() => {
     <template #leftModule>
       <card01 v-if="isYuyan" style="height: 40%" title="预报方案">
         <template #sec_header>
-          <div style="float: right; margin-right: 60px">
+          <div style="float: right; margin-right: 40px">
             <el-date-picker
               v-model="value2"
               :shortcuts="shortcuts"
@@ -219,12 +210,17 @@ onUnmounted(() => {
             />
           </div>
         </template>
-        <stripe-table
-          :columns="tableColumns"
-          :data="tableData"
-          :show-header="false"
-          @row-click="handleCurrentChange"
-        ></stripe-table>
+        <div class="yuan_list">
+          <div
+            v-for="(item, index) in tableData"
+            :key="index"
+            :class="{ active: yuyanId === item.ID }"
+            class="yuan_item"
+            @click="handleCurrentChange(item.ID)"
+          >
+            {{ item.DD_NAME }}
+          </div>
+        </div>
       </card01>
       <card01
         v-if="
@@ -243,3 +239,26 @@ onUnmounted(() => {
     </template>
   </right-frame>
 </template>
+<style lang="scss" scoped>
+.yuan_list {
+  width: 100%;
+  height: 100%;
+  overflow-y: auto;
+
+  .yuan_item {
+    padding: 8px;
+    cursor: pointer;
+    color: #9ee6f8;
+
+    &:nth-child(even) {
+      background-color: rgba(0, 249, 255, 0.3);
+    }
+
+    &:hover,
+    &.active {
+      background-color: rgba(0, 0, 0, 0.8);
+      color: #fff;
+    }
+  }
+}
+</style>

+ 8 - 8
src/views/Yuyan.vue

@@ -291,7 +291,7 @@ function handleCurrentChange(id) {
         data.map(a => {
           if (maxName && a.name === maxName) {
             return {
-              id: a.id,
+              id: a.name,
               name: `${a.value}\n${a.name}`,
               type: a.type,
               x: a.x,
@@ -302,7 +302,7 @@ function handleCurrentChange(id) {
 
           if (minName && a.name === minName) {
             return {
-              id: a.id,
+              id: a.name,
               name: `${a.value}\n${a.name}`,
               type: a.type,
               x: a.x,
@@ -312,7 +312,7 @@ function handleCurrentChange(id) {
           }
 
           return {
-            id: a.id,
+            id: a.name,
             name: `${a.value}\n${a.name}`,
             type: a.type,
             x: a.x,
@@ -327,7 +327,7 @@ function handleCurrentChange(id) {
           data.map(a => {
             if (maxName && a.name === maxName) {
               return {
-                id: a.id,
+                id: a.name,
                 name: `${a.value}\n${a.name}`,
                 type: a.type,
                 x: a.x,
@@ -338,7 +338,7 @@ function handleCurrentChange(id) {
 
             if (minName && a.name === minName) {
               return {
-                id: a.id,
+                id: a.name,
                 name: `${a.value}\n${a.name}`,
                 type: a.type,
                 x: a.x,
@@ -348,7 +348,7 @@ function handleCurrentChange(id) {
             }
 
             return {
-              id: a.id,
+              id: a.name,
               name: `${a.value}\n${a.name}`,
               type: a.type,
               x: a.x,
@@ -382,7 +382,7 @@ bus.on('handle_ue_response', data => {
     Point.addPoint(
       stationList.map(a => {
         return {
-          id: a.id,
+          id: a.name,
           name: `${a.name}`,
           type: '水文站',
           x: a.lgtd,
@@ -405,7 +405,7 @@ onUnmounted(() => {
     <template #leftModule>
       <card01 style="height: 30%" title="预报方案">
         <template #sec_header>
-          <div style="float: right; margin-right: 60px">
+          <div style="float: right; margin-right: 40px">
             <el-date-picker
               v-model="value2"
               :shortcuts="shortcuts"