|
@@ -141,6 +141,7 @@ export default {
|
|
|
mounted() {
|
|
|
this.$nextTick(function () {
|
|
|
const rootDiv = document.querySelector('.btstopology');
|
|
|
+ console.log("初始化的容器大小", rootDiv.offsetWidth, rootDiv.offsetHeight)
|
|
|
if (rootDiv) {
|
|
|
this.mainData.pageWidth = rootDiv.offsetWidth
|
|
|
this.mainData.pageHeight = rootDiv.offsetHeight
|
|
@@ -226,7 +227,14 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
hGetDataBaseParam() {
|
|
|
- this.getBtsBaseParamList()
|
|
|
+ this.$nextTick(function () {
|
|
|
+ const rootDiv = document.querySelector('.btstopology');
|
|
|
+ if (rootDiv) {
|
|
|
+ this.mainData.pageWidth = rootDiv.offsetWidth
|
|
|
+ this.mainData.pageHeight = rootDiv.offsetHeight
|
|
|
+ }
|
|
|
+ this.getBtsBaseParamList()
|
|
|
+ })
|
|
|
},
|
|
|
openAddBaseParamDlg() {
|
|
|
this.dialogData.editData.isUpdate = false
|
|
@@ -237,9 +245,20 @@ export default {
|
|
|
this.dialogData.editData.show = false
|
|
|
},
|
|
|
hGetBaseParam() {
|
|
|
- this.getBtsBaseParamList()
|
|
|
+ this.$nextTick(function () {
|
|
|
+ const rootDiv = document.querySelector('.btstopology');
|
|
|
+ if (rootDiv) {
|
|
|
+ this.mainData.pageWidth = rootDiv.offsetWidth
|
|
|
+ this.mainData.pageHeight = rootDiv.offsetHeight
|
|
|
+ }
|
|
|
+ this.getBtsBaseParamList()
|
|
|
+ })
|
|
|
},
|
|
|
getBtsBaseParamList() {//获得基站基本参数数据
|
|
|
+ //重置比例尺
|
|
|
+ this.mainData.coordScaleX = 15;
|
|
|
+ this.mainData.coordScaleY = 15;
|
|
|
+
|
|
|
let search = {}
|
|
|
let itemId = 0
|
|
|
|
|
@@ -262,16 +281,20 @@ export default {
|
|
|
//查询数据
|
|
|
this.tableData.listData.loading = true
|
|
|
getBtsBaseParamList(param).then((res) => {
|
|
|
- this.tableData.listData.items = res.data
|
|
|
+ this.tableData.listData.items = res.data || []
|
|
|
this.tableData.listData.loading = false
|
|
|
-
|
|
|
- resultData = this.findMinCoordValue(this.tableData.listData.items);
|
|
|
-
|
|
|
- //重新设置画布大小
|
|
|
- this.reSetCanvasSize(resultData.gap)
|
|
|
-
|
|
|
- //画基站散点图
|
|
|
- this.drawScatterChart(this.tableData.listData.items, resultData.offset)
|
|
|
+ if (this.tableData.listData.items.length > 0) {
|
|
|
+ resultData = this.findMinCoordValue(this.tableData.listData.items);
|
|
|
+ //重新设置画布大小
|
|
|
+ this.reSetCanvasSize(resultData.gap)
|
|
|
+ //画基站散点图
|
|
|
+ this.drawScatterChart(this.tableData.listData.items, resultData.offset)
|
|
|
+ } else {
|
|
|
+ // 清空画布
|
|
|
+ const canvas = this.$refs.scatterChart
|
|
|
+ const ctx = canvas.getContext('2d')
|
|
|
+ ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
|
+ }
|
|
|
}).catch(() => {
|
|
|
this.tableData.listData.loading = false
|
|
|
})
|
|
@@ -281,54 +304,59 @@ export default {
|
|
|
let minX = Infinity, maxX = -Infinity
|
|
|
let minY = Infinity, maxY = -Infinity
|
|
|
|
|
|
- //找出基站坐标的最大最小值
|
|
|
+ // 找出基站坐标的最大最小值
|
|
|
dataList.forEach(point => {
|
|
|
minX = Math.min(minX, point.coord_x)
|
|
|
maxX = Math.max(maxX, point.coord_x)
|
|
|
minY = Math.min(minY, point.coord_y)
|
|
|
maxY = Math.max(maxY, point.coord_y)
|
|
|
})
|
|
|
- if (minX > 0) {//修正坐标
|
|
|
- minX = 0
|
|
|
- }
|
|
|
- if (maxX < 0) {//修正坐标
|
|
|
- maxX = 0
|
|
|
- }
|
|
|
- if (minY > 0) {//修正坐标
|
|
|
- minY = 0
|
|
|
- }
|
|
|
- if (maxY < 0) {//修正坐标
|
|
|
- maxY = 0
|
|
|
- }
|
|
|
- this.mainData.btsMaxY = maxY//保存基站最大Y坐标值
|
|
|
|
|
|
- // 偏移量计算,将负坐标上移或者右移
|
|
|
+ // 修正坐标边界
|
|
|
+ minX = minX > 0 ? 0 : minX
|
|
|
+ maxX = maxX < 0 ? 0 : maxX
|
|
|
+ minY = minY > 0 ? 0 : minY
|
|
|
+ maxY = maxY < 0 ? 0 : maxY
|
|
|
+
|
|
|
+ this.mainData.btsMaxY = maxY
|
|
|
+
|
|
|
+ // 局部比例尺变量
|
|
|
+ let coordScaleX = this.mainData.coordScaleX
|
|
|
+ let coordScaleY = this.mainData.coordScaleY
|
|
|
+
|
|
|
+ // 正确计算Y方向偏移量(与X方向逻辑一致)
|
|
|
let offset = {
|
|
|
- xOffset: minX < 0 ? (-minX / this.mainData.coordScaleX + 50) : 50,
|
|
|
- //yOffset: minY < 0 ? (-minY / this.mainData.coordScaleY + 50) : 50
|
|
|
- yOffset: 50
|
|
|
+ xOffset: minX < 0 ? (-minX / coordScaleX + 50) : 50,
|
|
|
+ yOffset: minY < 0 ? (-minY / coordScaleY + 50) : 50
|
|
|
}
|
|
|
- this.mainData.offset = offset//保存偏移值
|
|
|
|
|
|
- // 计算画布在X轴和Y轴的间隔
|
|
|
+ // 计算画布间隔
|
|
|
let gap = {
|
|
|
- gapX: ((maxX - minX) / (this.mainData.coordScaleX)) + 2 * offset.xOffset,
|
|
|
- gapY: ((maxY - minY) / (this.mainData.coordScaleY)) + 2 * offset.yOffset
|
|
|
+ gapX: ((maxX - minX) / coordScaleX) + 2 * offset.xOffset,
|
|
|
+ gapY: ((maxY - minY) / coordScaleY) + 2 * offset.yOffset
|
|
|
}
|
|
|
|
|
|
- console.log("画布长宽", gap.gapX, gap.gapY)
|
|
|
-
|
|
|
+ // 仅当X方向间隔小于400时才调整X比例尺
|
|
|
if (gap.gapX < 400) {
|
|
|
- this.mainData.coordScaleX = 3
|
|
|
- offset.xOffset = minX < 0 ? (-minX / this.mainData.coordScaleX + 50) : 50
|
|
|
- gap.gapX = ((maxX - minX) / (this.mainData.coordScaleX)) + 2 * offset.xOffset
|
|
|
+ coordScaleX = 3
|
|
|
+ // 重新计算X偏移
|
|
|
+ offset.xOffset = minX < 0 ? (-minX / coordScaleX + 50) : 50
|
|
|
+ gap.gapX = ((maxX - minX) / coordScaleX) + 2 * offset.xOffset
|
|
|
}
|
|
|
|
|
|
- if (gap.minY < 200) {
|
|
|
- this.mainData.coordScaleX = 3
|
|
|
- gap.gapY = ((maxY - minY) / (this.mainData.coordScaleY)) + 2 * offset.yOffset
|
|
|
+ // 仅当Y方向间隔小于400时才调整Y比例尺
|
|
|
+ if (gap.gapY < 400) {
|
|
|
+ coordScaleY = 3
|
|
|
+ // 重新计算Y偏移
|
|
|
+ offset.yOffset = minY < 0 ? (-minY / coordScaleY + 50) : 50
|
|
|
+ gap.gapY = ((maxY - minY) / coordScaleY) + 2 * offset.yOffset
|
|
|
}
|
|
|
|
|
|
+ // 更新主数据比例尺
|
|
|
+ this.mainData.coordScaleX = coordScaleX
|
|
|
+ this.mainData.coordScaleY = coordScaleY
|
|
|
+ this.mainData.offset = offset
|
|
|
+
|
|
|
return { offset, gap }
|
|
|
}
|
|
|
}
|