|
@@ -14,9 +14,17 @@
|
|
|
|
|
|
<div class="tableMainClass scrollbarcustom" v-show="isShowMainPannle">
|
|
|
<div class="">
|
|
|
- <el-table :data="tableData" style="width: 2000px">
|
|
|
+ <el-table :data="tableData" style="width: 2000px" @row-click="fly">
|
|
|
<el-table-column v-for="(item, index) in attrArr" v-if="duizhao[item.prop]" :prop="item.prop"
|
|
|
- :label="duizhao[item.prop] ? duizhao[item.prop] : item.prop" :key="index"></el-table-column>
|
|
|
+ :label="duizhao[item.prop] ? duizhao[item.prop] : item.prop" :key="index" :width="index === 0 ? '60' : ''" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <!-- 判断是否为class_name并且不存在时显示默认值 -->
|
|
|
+ <span v-if="item === 'class_name' && !scope.row[item.prop]">变化区域</span>
|
|
|
+ <!-- 判断item是否为area,并格式化为两位小数 -->
|
|
|
+ <span v-if="scope.row[item.prop] && item === 'area'">{{ scope.row[item.prop].toFixed(2) }}</span>
|
|
|
+ <span v-else>{{ scope.row[item.prop] }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
</el-table>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -29,11 +37,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-
|
|
|
+import primitiveLayerManager from "../../lib/PrimitiveLayerManager";
|
|
|
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ attrArr: ['gid', 'id', 'area', 'class_name'],
|
|
|
isShowMainPannle: true,
|
|
|
duizhao: {
|
|
|
adname: "县名",
|
|
@@ -48,16 +57,28 @@ export default {
|
|
|
entityname: "类型",
|
|
|
id: "id",
|
|
|
typename: 'Poi类型'
|
|
|
- }
|
|
|
-
|
|
|
+ },
|
|
|
+ centroid: '',
|
|
|
+ number: 6,
|
|
|
+ dataAreaSum: 0, // 初始化为0
|
|
|
};
|
|
|
},
|
|
|
+ created() { },
|
|
|
props: ['attrArr', 'tableData'],
|
|
|
mounted() {
|
|
|
console.log(this.attrArr);
|
|
|
console.log(this.tableData);
|
|
|
-
|
|
|
+ this.calculateTotalArea();
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ // 监听tableData的变化,如果tableData发生变化,则重新计算总面积
|
|
|
+ tableData: {
|
|
|
+ handler() {
|
|
|
+ this.calculateTotalArea();
|
|
|
+ },
|
|
|
+ deep: true, // 深度监听,确保监听到tableData中的对象变化
|
|
|
+ }
|
|
|
+ },
|
|
|
components: {
|
|
|
|
|
|
},
|
|
@@ -102,6 +123,62 @@ export default {
|
|
|
this.$parent.isShowResultPannle = false
|
|
|
},
|
|
|
|
|
|
+ fly(row) {
|
|
|
+ const dataShow = JSON.parse(row.st_asgeojson);
|
|
|
+ this.centroid = dataShow.type === 'MultiPolygon'
|
|
|
+ ? this.calculateCentroid(dataShow.coordinates[0][0])
|
|
|
+ : this.calculateCentroid(dataShow.coordinates[0]);
|
|
|
+ primitiveLayerManager.removeLayerChange('Highlightline');
|
|
|
+ // 突出点击的对象
|
|
|
+ primitiveLayerManager._addSingleLine(this.centroid.line, 'Highlightline');
|
|
|
+ // 定位
|
|
|
+ this.flyTo(this.centroid.centroidX, this.centroid.centroidY);
|
|
|
+ },
|
|
|
+ calculateCentroid(points) {
|
|
|
+ let calculateData = {
|
|
|
+ sumX: 0,
|
|
|
+ sumY: 0,
|
|
|
+ line: [],
|
|
|
+ centroidX: 0,
|
|
|
+ centroidY: 0
|
|
|
+ };
|
|
|
+ const numPoints = points.length;
|
|
|
+ // for循环求和
|
|
|
+ for (let i = 0; i < numPoints; i++) {
|
|
|
+ calculateData.sumX += points[i][0];
|
|
|
+ calculateData.sumY += points[i][1];
|
|
|
+ calculateData.line.push(points[i][0]);
|
|
|
+ calculateData.line.push(points[i][1]);
|
|
|
+ }
|
|
|
+ // 计算平均数
|
|
|
+ calculateData.centroidX = calculateData.sumX / numPoints;
|
|
|
+ calculateData.centroidY = calculateData.sumY / numPoints;
|
|
|
+ return calculateData;
|
|
|
+ },
|
|
|
+ flyTo(lon, lat) {
|
|
|
+ viewer.camera.flyTo({
|
|
|
+ destination: Cesium.Cartesian3.fromDegrees(lon, lat, 600),
|
|
|
+ duration: 2,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ closePannle() {
|
|
|
+ this.$bus.emit("TubanInfShow", {
|
|
|
+ isShow: false
|
|
|
+ });
|
|
|
+ },
|
|
|
+ calculateTotalArea() {
|
|
|
+ // 计算area字段的总和,保留小数点后两位
|
|
|
+ this.dataAreaSum = this.tableData.reduce((sum, row) => {
|
|
|
+ return sum + (row.area || 0); // 如果row.area存在,累加到sum,否则不加
|
|
|
+ }, 0).toFixed(2); // 保留两位小数
|
|
|
+ },
|
|
|
+ // 判断是否有表格内容,没有就显示xxx
|
|
|
+ caseTypeNamesFormat(row) {
|
|
|
+ let showProp = null
|
|
|
+ row.caseTypeNames ? showProp = row.caseTypeNames : showProp = '---'
|
|
|
+ return showProp
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -128,6 +205,14 @@ export default {
|
|
|
margin-left: 9px;
|
|
|
}
|
|
|
|
|
|
+.numberData {
|
|
|
+ float: left;
|
|
|
+ line-height: 36px;
|
|
|
+ /* color: #66cffa; */
|
|
|
+ margin-right: 20px;
|
|
|
+ /* margin-left: 20px; */
|
|
|
+}
|
|
|
+
|
|
|
.layerMenu {
|
|
|
width: 100%;
|
|
|
height: 36px;
|