智慧园区前端大屏
linwe
2024-11-22 5221bb4832912e7e494b76e4fdf64eb0c98fce50
代码优化
5 files modified
148 ■■■■ changed files
src/pages/layout/components/scomponents/layersControl.vue 73 ●●●●● patch | view | raw | blame | history
src/views/companyInfo/components/box/dataContent.vue 2 ●●● patch | view | raw | blame | history
src/views/companyInfo/components/box/fireTrend.vue 51 ●●●● patch | view | raw | blame | history
src/views/rs/components/box/dataContent.vue 16 ●●●● patch | view | raw | blame | history
src/views/space/components/box/dataContent.vue 6 ●●●● patch | view | raw | blame | history
src/pages/layout/components/scomponents/layersControl.vue
@@ -456,6 +456,28 @@
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy.png',
        showPanel: false,
        layerName: 'fxyOrdinary',
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
          destroy()
          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
          window.$viewer.addLayer(addPupoLayers[attrParams.name])
          let iconEl = `<div class="marsBlueGradientPnl">
            <li>${attrParams.firmName || ''}</li>
            <li>${attrParams.riskLevelName || ''}</li>
            </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, 64),
            `<div class="public-map-popup-three">
                    ${iconEl}
                  </div>`
          )
          let incident = () => {
            destroy()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
        }
      },
      {
        id: '4-2',
@@ -472,6 +494,51 @@
        backgroundIcon: VITE_APP_BASE + 'img/mapicon/fxy.png',
        showPanel: false,
        layerName: 'fxyLarger',
        incident: (e) => {
          const { attrParams } = e.overlay
          // 删除
          destroy()
          // if (!attrParams.imageUrl) {
          //   return
          // }
          // addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
          // window.$viewer.addLayer(addPupoLayers[attrParams.name])
          // let iconEl = `<div class="marsBlueGradientPnl">
          //         <div>${attrParams.fullName}</div>
          //         <img src="${attrParams.imageUrl}" width="160" height="160" />
          //       </div>`
          // let divIcon = new DC.DivIcon(
          //   new DC.Position(attrParams.lng, attrParams.lat, 64),
          //   `<div class="public-map-popup-two">
          //           ${iconEl}
          //         </div>`
          // )
          // let incident = () => {
          //   destroy()
          // }
          // divIcon.on(DC.MouseEventType.CLICK, incident)
          // addPupoLayers[attrParams.name].addOverlay(divIcon)
          // 删除
          destroy()
          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
          window.$viewer.addLayer(addPupoLayers[attrParams.name])
          let iconEl = `<div class="marsBlueGradientPnl">
            <li>${attrParams.firmName || ''}</li>
            <li>${attrParams.riskLevelName || ''}</li>
            </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, 64),
            `<div class="public-map-popup-three">
                    ${iconEl}
                  </div>`
          )
          let incident = () => {
            destroy()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
        }
      }
    ]
  },
@@ -675,7 +742,7 @@
          window.addTileLayers[item.layerName] = new DC.VectorLayer(item.layerName)
          window.$viewer.addLayer(window.addTileLayers[item.layerName])
          function computeCircle (radius) {
          function computeCircle(radius) {
            var positions = []
            for (var i = 0; i < 360; i++) {
              var radians = DC.Math.toRadians(i)
@@ -718,7 +785,7 @@
  })
}
function findObjectById (data, id) {
function findObjectById(data, id) {
  // 遍历数据数组
  for (let i = 0; i < data.length; i++) {
    const item = data[i]
@@ -784,7 +851,7 @@
// });
// 销毁
function destroy () {
function destroy() {
  let arr = Object.keys(addPupoLayers)
  arr.filter(i => i != 'hgyq').forEach(i => {
    addPupoLayers[i] && window.$viewer.removeLayer(addPupoLayers[i])
src/views/companyInfo/components/box/dataContent.vue
@@ -69,7 +69,7 @@
                            iconEl = `<div class="marsBlueGradientPnl"> <div>${i.name}</div>  </div>`
                        }
                        let divIcon = new DC.DivIcon(
                            new DC.Position(i.lng, i.lat, 0), `<div class="public-map-popup ${'yjc-box'}"> ${iconEl} </div>`
                            new DC.Position(i.lng, i.lat, 64), `<div class="public-map-popup ${'yjc-box'}"> ${iconEl} </div>`
                        )
                        divIcon.attrParams = i
src/views/companyInfo/components/box/fireTrend.vue
@@ -96,6 +96,7 @@
      picList.value = data.picList
      pages.total = data.total
      loading.value = false
      rowClick(tableData.value[0], '', '')
    })
    .catch((err) => {
      loading.value = false
@@ -117,7 +118,7 @@
    addTileLayers[row.name] = new DC.HtmlLayer(row.name)
    window.$viewer.addLayer(addTileLayers[row.name])
    let iconEl = `
                <div class="map-name">${row.name}</div>
                <div class="map-name">${'应急物资'}</div>
                <div class="map-icon">
                  <img src="${image.value}">
                </div>
@@ -130,30 +131,30 @@
    )
    divIcon.attrParams = row
    let incident = (e) => {
      // const { attrParams } = e.overlay
      // // 删除
      // destroyPupoLayers()
      // if (picList.value.length == 0) {
      //   return
      // }
      // console.log('点击了', picList.value.length)
      // addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
      // window.$viewer.addLayer(addPupoLayers[attrParams.name])
      // let iconEl = `<div class="marsBlueGradientPnl">
      //       <div>${attrParams.fullName}</div>
      //       <img src="${picList.value[0].link}" />
      //           </div>`
      // let divIcon = new DC.DivIcon(
      //   new DC.Position(attrParams.lng, attrParams.lat, 64),
      //   `<div class="public-map-popup-two">
      //               ${iconEl}
      //             </div>`
      // )
      // let incident = () => {
      //   destroyPupoLayers()
      // }
      // divIcon.on(DC.MouseEventType.CLICK, incident)
      // addPupoLayers[attrParams.name].addOverlay(divIcon)
      const { attrParams } = e.overlay
      // 删除
      destroyPupoLayers()
      if (picList.value.length == 0) {
        return
      }
      console.log('点击了', picList.value.length)
      addPupoLayers['企业应急物资'] = new DC.HtmlLayer('企业应急物资')
      window.$viewer.addLayer(addPupoLayers['企业应急物资'])
      let iconEl = `<div class="marsBlueGradientPnl">
            <div>${attrParams.firmName}</div>
            <img src="${picList.value[0].link}" />
                </div>`
      let divIcon = new DC.DivIcon(
        new DC.Position(attrParams.lng, attrParams.lat, 64),
        `<div class="public-map-popup-two">
                    ${iconEl}
                  </div>`
      )
      let incident = () => {
        destroyPupoLayers()
      }
      divIcon.on(DC.MouseEventType.CLICK, incident)
      addPupoLayers['企业应急物资'].addOverlay(divIcon)
    }
    divIcon.on(DC.MouseEventType.CLICK, incident)
src/views/rs/components/box/dataContent.vue
@@ -52,7 +52,7 @@
const tableData = ref([])
const pages = {
  page: 1,
  pageSize: 10,
  pageSize: 20,
  total: 0,
}
@@ -104,7 +104,7 @@
  loading.value = true
  getList({
    ...param,
    riskLevel: curSelectTabType.riskLevel
    // riskLevel: curSelectTabType.riskLevel
  })
    .then((res) => {
      const data = res.data.data
@@ -166,7 +166,7 @@
// 重置分页数据
const resetPage = () => {
  pages.page = 1
  pages.pageSize = 10
  pages.pageSize = 20
  pages.total = 0
}
@@ -188,7 +188,7 @@
  console.log(item, 12312)
  if (curSelect.value) EventBus.emit('restHandleDelChange', `4-${curSelect.value}`)
  curSelect.value = item.value
  EventBus.emit('restHandleCheckChange', `4-${item.value}`)
  EventBus.emit('restHandleCheckChange', `4`)
  EventBus.emit('rsTabChange', item.value)
}
@@ -208,7 +208,7 @@
onUnmounted(() => {
  EventBus.off('rsTabChange', spaceTabChange)
  if (curSelect.value) EventBus.emit('restHandleDelChange', `4-${curSelect.value}`)
  if (curSelect.value) EventBus.emit('restHandleDelChange', `4`)
  destroyPupoLayers()
})
@@ -225,7 +225,7 @@
<template>
  <div class="w100 h0 flex-1 flex f-d-c">
    <global-search :options="options" @searchBtn="searchBtn" @resetBtn="resetBtn" ref="SeachBarCondition"></global-search>
    <div class="cur-container">
    <!-- <div class="cur-container">
      <div class="tablist">
        <div class="cursor-p" :class="{ on: showOn(item) }" v-for="item, index in resData.data" :key="index"
          @click="tabClick(item)">
@@ -234,7 +234,7 @@
          </div>
        </div>
      </div>
    </div>
    </div> -->
    <div class="h0 flex-1 table-content" ref="TableContent" v-loading="loading"
      element-loading-background="rgba(46, 81, 136, 0.9)">
      <el-table @row-click="rowClick" border :data="tableData" :height="curTableHeight" style="width: 100%">
@@ -245,7 +245,7 @@
        </el-table-column>
        <el-table-column align="center" show-overflow-tooltip prop="firmName" label="企业名称" />
        <el-table-column align="center" show-overflow-tooltip prop="name" label="名称" />
        <!-- <el-table-column align="center" show-overflow-tooltip prop="category" label="类别" width="92" /> -->
        <el-table-column align="center" show-overflow-tooltip prop="riskLevelName" label="级别" width="72" />
        <!-- <el-table-column align="center" show-overflow-tooltip prop="mainProduct" label="主要产品" width="112" /> -->
        <!-- <el-table-column align="center" width="62" label="操作">
          <template #default="scope">
src/views/space/components/box/dataContent.vue
@@ -202,9 +202,9 @@
            {{ (pages.page - 1) * pages.pageSize + $index + 1 }}
          </template>
        </el-table-column>
        <el-table-column align="center" show-overflow-tooltip prop="firmName" label="企业名称" />
        <el-table-column align="center" show-overflow-tooltip prop="name" label="名称" />
        <el-table-column align="center" prop="mainFuncName" label="作用" width="62" />
        <el-table-column show-overflow-tooltip prop="firmName" label="企业名称" />
        <el-table-column show-overflow-tooltip prop="name" label="名称" width="100" />
        <el-table-column prop="mainFuncName" label="作用" width="55" />
        <!-- <el-table-column align="center" width="62" label="操作">
          <template #default="scope">
            <el-button link type="primary" size="small" :disabled="scope.row.lng == ''" @click="rowClick(scope.row)">