From c60e56e2b6ceb633c6b10f5dc52e3da88129ad70 Mon Sep 17 00:00:00 2001
From: 陈泽平 <chenzeping>
Date: 星期五, 21 五月 2021 17:35:41 +0800
Subject: [PATCH] 管线分析相关功能问题修改

---
 src/components/panel/topicSearch/SewersSelect/AnalysisChoose/CrossSectional.vue |  276 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 232 insertions(+), 44 deletions(-)

diff --git a/src/components/panel/topicSearch/SewersSelect/AnalysisChoose/CrossSectional.vue b/src/components/panel/topicSearch/SewersSelect/AnalysisChoose/CrossSectional.vue
index c6c5206..ddfc644 100644
--- a/src/components/panel/topicSearch/SewersSelect/AnalysisChoose/CrossSectional.vue
+++ b/src/components/panel/topicSearch/SewersSelect/AnalysisChoose/CrossSectional.vue
@@ -1,59 +1,247 @@
 <template>
-  <div class="connectivity">
-    <el-row>
-      <el-button type="primary" size="mini">缁樺埗绾挎</el-button>
-      <el-button type="primary" size="mini">鎴柇闈㈠垎鏋�</el-button>
-      <el-button type="primary" size="mini">娓呴櫎</el-button>
-    </el-row>
-    <el-card class="box-card">
-      <span class="clearfix">绠$嚎鏌ヨ缁撴灉</span>
-      <el-table
-          :data="tableData"
-          style="width: 100%">
-        <el-table-column
-            prop="date"
-            label="绠$嚎鍚嶇О"
-            width="180">
-        </el-table-column>
-        <el-table-column
-            prop="name"
-            label="绠$嚎绫诲瀷"
-            width="180">
-        </el-table-column>
-        <el-table-column
-            prop="address"
-            label="鎿嶄綔">
-        </el-table-column>
-      </el-table>
-      <span class="clearfix">鏂潰鍥�</span>
-      <div class="cross-section">
-        <span>鏆傛棤鏁版嵁</span>
-      </div>
-    </el-card>
-  </div>
+    <div class="connectivity">
+        <el-row>
+            <el-button type="primary" @click="drawLine" size="mini" title="鍦板浘涓婄粯鍒惰杩涜鍒嗘瀽鎴柇闈㈢殑绾�">缁樺埗绾挎</el-button>
+            <el-button type="primary" @click="jdmQuery" size="mini" title="鎴柇闈㈠垎鏋�">鎴柇闈㈠垎鏋�</el-button>
+            <el-button type="primary" @click="jdmClear" size="mini" title="娓呴櫎鎴柇闈㈠垎鏋愮粨鏋�">娓呴櫎</el-button>
+        </el-row>
+        <div slot="header" class="fixed-style">
+            <span>绠℃鏌ヨ缁撴灉</span>
+        </div>
+        <el-table class="tableBox" :data="tableData" height="150" max-height="200" highlight-current-row
+                  style="width: 100%" size="mini">
+            <el-table-column v-for="(item, index) in listLabel" :key="index" :prop="item.prop"
+                             :label="item.label" :show-overflow-tooltip="true" min-width="100"></el-table-column>
+        </el-table>
+        <span class="fixed-style">鏂潰鍥�</span>
+        <span v-show="!myChartShow"
+              style="color: #909399;font-size: 12px;height: 200px;display: block;text-align: center;line-height: 200px">鏆傛棤鏁版嵁</span>
+        <div v-show="myChartShow" id="echarts_box" ref="myChart" style="width:350px;height:200px;margin: 0 auto"></div>
+    </div>
 </template>
 
 <script>
+import eventBus from '../../../../../eventBus'
+import mapApi from '../../../../../api/mapApi'
+import DrawLine from '../../../../plugin/DrawLine'
+
 export default {
   name: 'CrossSectional',
   data () {
     return {
-      tableData: []
+      // 鐢ㄤ簬缁樺埗妯柇闈㈢嚎娈�
+      measure: null,
+      // 瀹氫箟 echarts瀵硅薄
+      myChart: null,
+      // 鐢ㄤ簬鍒ゆ柇echarts鍥捐〃鐨勬樉绀轰笌闅愯棌
+      myChartShow: false,
+      // 鐢ㄤ簬瀹氫箟鎺ユ敹妯柇闈㈡暟鎹�
+      hdmParam: null,
+      // 妯柇闈� 绠℃鏌ヨ缁撴灉 鐨則able琛ㄦ牸鏁版嵁
+      tableData: [],
+      // table 琛ㄦ牸瀹氫箟鐨勫瓧娈�
+      listLabel: [
+        {
+          label: '浠嬭川绫诲瀷',
+          prop: 'mediumtype'
+        },
+        {
+          label: '鏂潰(缁忓害)',
+          prop: 'x'
+        },
+        {
+          label: '鏂潰(绾害)',
+          prop: 'y'
+        },
+        {
+          label: '鏂潰楂樼▼(m)',
+          prop: 'z'
+        },
+        {
+          label: '闂磋窛(m)',
+          prop: 'spacing'
+        }
+      ]
+    }
+  },
+  mounted () {
+    // 鍒濆鍖杄charts鍥捐〃
+    this.myChart = this.$echarts.init(this.$refs.myChart)
+    // 浣跨敤 DrwLine鏂规硶
+    eventBus.$on('draw-hdm-line', (points) => {
+      this.getHdmPoint(points)
+    })
+    eventBus.$on('tabData-change', (obj) => {
+      if (obj) {
+        this.jdmClear()
+      }
+    })
+  },
+  methods: {
+    // 妯柇闈㈡竻闄�
+    jdmClear () {
+      this.hdmParam = null
+      this.tableData = []
+      this.option = []
+      this.myChartShow = false
+      this.myChart.clear()
+      if (this.measure != null) {
+        this.measure.destory()
+      }
+    },
+    // 妯柇闈� 绾挎缁樺埗
+    drawLine () {
+      if (this.measure === null) {
+        this.measure = new DrawLine(window.map)
+      }
+      this.measure.destory()
+      this.measure.init()
+    },
+    // 缁樺埗鐨勬í鏂潰 绾挎鏁版嵁鑾峰彇
+    async getHdmPoint (line) {
+      // 妯柇闈㈡暟鎹�
+      this.hdmParam = {
+        x1: line[0].lng,
+        y1: line[0].lat,
+        x2: line[1].lng,
+        y2: line[1].lat
+      }
+    },
+    // 妯柇闈� 鏁版嵁璇锋眰
+    async jdmQuery () {
+      this.tableData = []
+      if (this.hdmParam == null) {
+        this.$message('璇峰厛鍦ㄥ湴鍥句笂缁樺埗鎴柇绾�')
+        return false
+      }
+      // 宸茬粯鍒剁嚎鍥� 杩涜缁樺埗妯柇闈㈡暟鎹垎鏋�
+      const res = await mapApi.getCrossSection(this.hdmParam)
+      // // 璋冪敤鏁版嵁澶勭悊鏂规硶
+      // this.dealWithData(res)
+      // table鏁版嵁澶勭悊
+      const dataPoint = res.data.point
+      // 瀛樺偍闂磋窛list
+      const spacingList = res.data.pointInterval.reverse()
+      for (let i = 0; i < dataPoint.length; i++) {
+        const obj = {
+          mediumtype: dataPoint[i].pipelines.extraData.mediumtype,
+          x: parseFloat(dataPoint[i].crossPoint3D.x).toFixed(8),
+          y: parseFloat(dataPoint[i].crossPoint3D.y).toFixed(8),
+          z: parseFloat(dataPoint[i].crossPoint3D.z).toFixed(2),
+          spacing: spacingList[i - 1],
+          startpointz: dataPoint[i].pipelines.extraData.startpointz,
+          diameter: dataPoint[i].pipelines.extraData.diameter
+        }
+        this.tableData.push(obj)
+      }
+      // 璋冪敤鏁版嵁澶勭悊鏂规硶
+      this.dealWithData(this.tableData)
+    },
+    // 瀵硅幏鍙栧埌鐨勬暟鎹繘琛屽鐞�
+    dealWithData (dataList) {
+      console.log(dataList)
+      // const dataPoint = e.data.point
+      // const spacingList = e.data.pointInterval.reverse()
+      // const dataList = []
+      // for (let i = 0; i < dataPoint.length; i++) {
+      //   const obj = {
+      //     mediumtype: dataPoint[i].pipelines.extraData.mediumtype,
+      //     startpointz: dataPoint[i].pipelines.extraData.startpointz,
+      //     diameter: dataPoint[i].pipelines.extraData.diameter,
+      //     spacing: spacingList[i - 1],
+      //     x: parseFloat(dataPoint[i].crossPoint3D.x).toFixed(8),
+      //     y: parseFloat(dataPoint[i].crossPoint3D.y).toFixed(8),
+      //     z: parseFloat(dataPoint[i].crossPoint3D.z).toFixed(2)
+      //   }
+      //   dataList.push(obj)
+      // }
+      // 妯悜鍧愭爣鏁版嵁
+      const xAxisData = []
+      const dataObj = []
+      for (let i = 0; i < dataList.length; i++) {
+        xAxisData.push(dataList[i].mediumtype)
+        // if (dataList[i].mediumtype === '闆ㄦ按') {
+        //   dataObj.color = 'red'
+        // }
+        dataObj.push(dataList[i].startpointz)
+      }
+      this.selectRow(xAxisData, dataObj)
+    },
+    // 妯柇闈㈢粯鍒跺畬鎴愬悗 杩涜妯柇闈㈡暟鎹垎鏋� 杩涜鍥捐〃灞曠ず
+    selectRow (xAxisData, dataObj) {
+      const option = {
+        tooltip: {
+          trigger: 'axis'
+        },
+        // legend: {
+        //   data: []
+        // },
+        grid: {
+          left: '3%',
+          right: '4%',
+          bottom: '3%',
+          containLabel: true
+        },
+        xAxis: {
+          type: 'category',
+          splitLine: {
+            lineStyle: {
+              type: 'dashed'
+            },
+            show: true
+          },
+          axisLine: {
+            lineStyle: {
+              color: '#fff',
+              width: 2
+            }
+          },
+          // data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
+          data: xAxisData,
+          axisLabel: {
+            interval: 0,
+            textStyle: {
+              color: '#fff'
+            },
+            margin: 20
+          }
+        },
+        yAxis: {
+          axisLine: {
+            lineStyle: {
+              color: '#fff',
+              width: 2
+            }
+          },
+          axisPointer: {
+            snap: true
+          },
+          splitLine: {
+            show: false
+          },
+          type: 'value',
+          axisLabel: {
+            interval: 0,
+            textStyle: {
+              color: '#fff'
+            }
+          }
+        },
+        series: [
+          {
+            type: 'scatter',
+            data: dataObj
+          }
+        ]
+      }
+      this.myChartShow = true
+      this.myChart.clear()
+      this.myChart.setOption(option)
     }
   }
 }
 </script>
 
 <style lang="less" scoped>
-.cross-section {
-  background: rgba(0, 16, 30, 0.5);
-  border: 0.00521rem solid @color;
-  box-shadow: 0 0 0.03rem @color;
-  color: #ffffff;
-  width: 100%;
-  height: 50px;
-  border-radius: 3px;
-  text-align: center;
-  line-height: 50px;
-}
+
 </style>

--
Gitblit v1.8.0