riku
2025-03-05 b79c0124a44b7af9c3c55c5e19617dd4de162497
污染溯源模块编写中
已修改2个文件
144 ■■■■■ 文件已修改
src/api/index.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/scene/SceneSearch.vue 140 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/index.js
@@ -10,8 +10,8 @@
}
if (debug) {
  // ip1 = 'http://192.168.0.110:8084/';
  ip1 = 'http://192.168.1.8:8084/';
  ip1 = 'http://192.168.0.110:8084/';
  // ip1 = 'http://192.168.1.8:8084/';
}
const $http = axios.create({
src/components/scene/SceneSearch.vue
@@ -15,6 +15,25 @@
    width="400px"
  >
    <template #default>
      <div v-show="nextPage">
        <div>
          <el-text size="small" type="warning">
            共计{{ sceneStore.sceneList.length }}个点位,其中{{
              sceneTypeSummary
            }}
          </el-text>
        </div>
        <!-- <div v-for="(t, i) in closestScene" :key="i"> -->
        <el-text
          v-for="(t, i) in closestScene"
          :key="i"
          size="small"
          type="warning"
        >
          {{ t }}
        </el-text>
        <!-- </div> -->
        <!-- <el-row> 共计{{ sceneStore.sceneList.length }}个点位,其中 </el-row> -->
      <el-row class="scene-table">
        <!-- <el-col :span="20"> -->
        <el-table
@@ -62,10 +81,19 @@
        </el-table>
        <!-- </el-col> -->
      </el-row>
      </div>
      <div v-show="!nextPage">
        <el-button
          @click="nextPage = false"
          type="primary"
          class="el-button-custom p-events-auto"
          >返回</el-button
        >
      </div>
    </template>
    <template #footer>
      <el-row justify="start" align="middle" class="p-b-2 one-row">
        <el-text size="small" type="warning">搜索范围</el-text>
      <!-- <el-row justify="start" align="middle" class="p-b-2 one-row"> -->
      <!-- <el-text size="small" type="warning">搜索范围</el-text>
        <el-input
          class="input-radius m-h-2"
          size="small"
@@ -74,8 +102,9 @@
        />
        <el-text size="small" type="warning">
          公里以内,结果{{ sceneStore.sceneList.length }}条</el-text
        >
      </el-row>
        > -->
      <!-- </el-row> -->
    </template>
  </CardDialog>
</template>
@@ -87,8 +116,32 @@
import { useSceneStore } from '@/stores/scene';
import { useToolboxStore } from '@/stores/toolbox';
import MapUtil from '@/utils/map/util';
import calculate from '@/utils/map/calculate';
let layer = undefined;
const devices = [
  {
    name: '程桥站',
    typeId: 20,
    type: 'type',
    longitude: 121.362928,
    latitude: 31.192925
  },
  {
    name: '华阳站',
    typeId: 20,
    type: '市控点',
    longitude: 121.424603,
    latitude: 31.223644
  },
  {
    name: '仙霞站',
    typeId: 19,
    type: '国控点',
    longitude: 121.394775,
    latitude: 31.203982
  }
];
export default {
  setup() {
@@ -103,7 +156,8 @@
    return {
      dialogVisible: false,
      onConfirm: undefined,
      showSceneTypes: []
      showSceneTypes: [],
      nextPage: false
    };
  },
  computed: {
@@ -126,6 +180,57 @@
          return this.showSceneTypes.indexOf(v.type) != -1;
        });
      }
    },
    // 搜索结果场景类型统计
    sceneTypeSummary() {
      const typeMap = new Map();
      this.sceneStore.sceneList.forEach((s) => {
        if (!typeMap.has(s.type)) {
          typeMap.set(s.type, []);
        }
        typeMap.get(s.type).push(s);
      });
      let summary = '';
      typeMap.forEach((v, k) => {
        summary += `${k}${v.length}个、`;
      });
      summary = summary.slice(0, summary.length - 1);
      return summary;
    },
    // 计算距离给定点位最近的场景
    closestScene() {
      let txt = [];
      devices.forEach((d) => {
        let minDistance, scene;
        this.sceneStore.sceneList.forEach((s) => {
          const dis = calculate.getDistance(
            s.longitude,
            s.latitude,
            d.longitude,
            d.latitude
          );
          if (!minDistance || dis < minDistance) {
            minDistance = dis;
            scene = s;
          }
          if (!s.closestDevice || dis < s.closestDevice.dis) {
            s.closestDevice = {
              name: d.name,
              dis: dis
            };
          }
        });
        if (minDistance) {
          minDistance = Math.round(minDistance);
        }
        if (scene) {
          txt.push(`距${d.name}最近的为${scene.name},距离${minDistance}米;`);
        }
      });
      return txt;
    }
  },
  watch: {
@@ -177,6 +282,7 @@
      }
    },
    handleRowClick(row, col, event) {
      this.nextPage = true;
      MapUtil.setCenter([row.longitude, row.latitude], true);
    },
    filterHandler(value, row, column) {
@@ -203,4 +309,28 @@
/* .ff-content-medium .ff-border-top {
  padding: 0px 0px var(--bevel-length-2) 0px;
} */
::v-deep .el-table {
  --el-table-bg-color: transparent;
  --el-table-row-hover-bg-color: var(--select_color);
  --el-table-current-row-bg-color: var(--select_color);
  /* --el-table-current-row-bg-color: #7dff5d96; */
  --el-table-text-color: var(--font-color);
}
::v-deep .t-row {
  cursor: pointer;
  background-color: transparent !important;
}
.t-cell {
}
.t-header-row {
}
::v-deep .t-header-cell {
  background-color: var(--bg-color-2) !important;
  color: white !important;
}
</style>