|
@@ -85,13 +85,13 @@
|
|
|
<script>
|
|
<script>
|
|
|
import Konva from 'konva'
|
|
import Konva from 'konva'
|
|
|
import {
|
|
import {
|
|
|
- getLotoMapInfo,
|
|
|
|
|
- getLotoInfo,
|
|
|
|
|
|
|
+ selectLotoMapById,
|
|
|
|
|
+ selectIsLotoStationById,
|
|
|
updateLoto,
|
|
updateLoto,
|
|
|
- unbundlePointPage
|
|
|
|
|
|
|
+ updatePointsBindingLoto
|
|
|
} from '@/api/mes/lotoStation/lotoStation'
|
|
} from '@/api/mes/lotoStation/lotoStation'
|
|
|
import { getIsIsolationPointPage } from '@/api/mes/spm/segregationPoint'
|
|
import { getIsIsolationPointPage } from '@/api/mes/spm/segregationPoint'
|
|
|
-import { getIsMapPointPage, selectIsMapPointById } from '@/api/system/mappoint'
|
|
|
|
|
|
|
+import { getIsMapPointPage, selectIsMapPointById, updateMapPointList } from '@/api/system/mappoint'
|
|
|
import { selectIsMapById } from '@/api/system/mapconfig'
|
|
import { selectIsMapById } from '@/api/system/mapconfig'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -124,7 +124,12 @@ export default {
|
|
|
height: '',//底图高
|
|
height: '',//底图高
|
|
|
x: '',//底图横坐标
|
|
x: '',//底图横坐标
|
|
|
y: '',//底图纵坐标
|
|
y: '',//底图纵坐标
|
|
|
- pointList:null,//接口给的所有点位数据
|
|
|
|
|
|
|
+ mapId: null,//地图Id
|
|
|
|
|
+ mapType: 2,//地图类型
|
|
|
|
|
+ pointList: null,//接口给的所有点位数据
|
|
|
|
|
+ newbindingPoints: [],//给地图点位界面更新的绑定隔离点
|
|
|
|
|
+ newmovePoints: [],//给地图点位界面更新位置
|
|
|
|
|
+ newunbindingPoints: []//给地图点位界面更新解绑数据
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
// watch: {
|
|
// watch: {
|
|
@@ -152,19 +157,19 @@ export default {
|
|
|
// },
|
|
// },
|
|
|
|
|
|
|
|
created() {
|
|
created() {
|
|
|
- this.getIsIsolationPointPage()
|
|
|
|
|
|
|
+ // this.getIsIsolationPointPage()
|
|
|
this.isInitialized = true
|
|
this.isInitialized = true
|
|
|
},
|
|
},
|
|
|
beforeRouteEnter(to, from, next) {
|
|
beforeRouteEnter(to, from, next) {
|
|
|
next((vm) => {
|
|
next((vm) => {
|
|
|
- vm.getIsIsolationPointPage()
|
|
|
|
|
|
|
+ // vm.getIsIsolationPointPage()
|
|
|
vm.addPointsToRightPointsBox()
|
|
vm.addPointsToRightPointsBox()
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
- this.getIsIsolationPointPage()
|
|
|
|
|
this.getInfo()
|
|
this.getInfo()
|
|
|
|
|
+ this.getIsIsolationPointPage()
|
|
|
this.addPointsToRightPointsBox()
|
|
this.addPointsToRightPointsBox()
|
|
|
})
|
|
})
|
|
|
console.log(this.$route.query.lotoId, 'lotoId')
|
|
console.log(this.$route.query.lotoId, 'lotoId')
|
|
@@ -175,9 +180,11 @@ export default {
|
|
|
const lotoId = this.$route.query.lotoId
|
|
const lotoId = this.$route.query.lotoId
|
|
|
const sopId = ''
|
|
const sopId = ''
|
|
|
const ticketId = ''
|
|
const ticketId = ''
|
|
|
- getLotoInfo(lotoId).then((response) => {
|
|
|
|
|
|
|
+ selectIsLotoStationById(lotoId).then((response) => {
|
|
|
console.log(response, '作业区域信息')
|
|
console.log(response, '作业区域信息')
|
|
|
this.form = response.data
|
|
this.form = response.data
|
|
|
|
|
+ this.mapId = response.data.mapId
|
|
|
|
|
+
|
|
|
// 获取不同底图 如地图或者柜子
|
|
// 获取不同底图 如地图或者柜子
|
|
|
selectIsMapById(response.data.mapId).then((response) => {
|
|
selectIsMapById(response.data.mapId).then((response) => {
|
|
|
console.log(response, '获取底图')
|
|
console.log(response, '获取底图')
|
|
@@ -186,13 +193,14 @@ export default {
|
|
|
this.height = response.data.height
|
|
this.height = response.data.height
|
|
|
this.x = response.data.x
|
|
this.x = response.data.x
|
|
|
this.y = response.data.y
|
|
this.y = response.data.y
|
|
|
- this.pointList=response.data.pointList
|
|
|
|
|
|
|
+ this.pointList = response.data.pointList
|
|
|
this.initKonva()
|
|
this.initKonva()
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 获取map-json
|
|
// 获取map-json
|
|
|
- getLotoMapInfo(lotoId, sopId, ticketId).then((response) => {
|
|
|
|
|
|
|
+ selectLotoMapById(lotoId, sopId, ticketId).then((response) => {
|
|
|
console.log(response, '作业区域预览接口调用')
|
|
console.log(response, '作业区域预览接口调用')
|
|
|
this.form.map = response.data
|
|
this.form.map = response.data
|
|
|
this.filterData = response.data
|
|
this.filterData = response.data
|
|
@@ -204,33 +212,45 @@ export default {
|
|
|
getIsIsolationPointPage(data).then((res) => {
|
|
getIsIsolationPointPage(data).then((res) => {
|
|
|
const data1 = res.data.records
|
|
const data1 = res.data.records
|
|
|
const data2 = this.filterData
|
|
const data2 = this.filterData
|
|
|
- console.log(data1, data2, '隔离点获取左侧列表啊哈哈哈哈')
|
|
|
|
|
|
|
+ console.log(data1, '该柜子或地图所有点', data2, '该柜子里json拿到的点位')
|
|
|
|
|
+
|
|
|
// 创建一个 Set 来存储 data2 中的 pointId
|
|
// 创建一个 Set 来存储 data2 中的 pointId
|
|
|
const data2PointIds = new Set(data2.map((item) => item.pointId))
|
|
const data2PointIds = new Set(data2.map((item) => item.pointId))
|
|
|
|
|
+
|
|
|
|
|
+ // 创建一个 Set 来存储 this.pointList 中的 pointId
|
|
|
|
|
+ const pointListIds = new Set(this.pointList.map((item) => item.pointId))
|
|
|
|
|
+
|
|
|
|
|
+ // 过滤掉 data2 和 this.pointList 中已经存在的点位
|
|
|
const filterData = data1.filter(
|
|
const filterData = data1.filter(
|
|
|
- (item) => !data2PointIds.has(item.pointId)
|
|
|
|
|
|
|
+ (item) => !data2PointIds.has(item.pointId) && !pointListIds.has(item.pointId)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- this.leftPoints = filterData.map((item) => {
|
|
|
|
|
- return {
|
|
|
|
|
- pointId: item.pointId,
|
|
|
|
|
- pointName: item.pointName,
|
|
|
|
|
- remark: item.remark,
|
|
|
|
|
- prePointId: item.prePointId,
|
|
|
|
|
- pointType: item.pointType,
|
|
|
|
|
- pointTypeName: item.pointTypeName,
|
|
|
|
|
- powerType: item.powerType,
|
|
|
|
|
- powerTypeName: item.powerTypeName,
|
|
|
|
|
- pointIcon: item.pointIcon,
|
|
|
|
|
- status: false,
|
|
|
|
|
- pointPicture: item.pointPicture,
|
|
|
|
|
- mapImg: null
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- this.addPointsToLeftPointsBox(filterData)
|
|
|
|
|
|
|
+ console.log(filterData, 'filterData-交叉数据')
|
|
|
|
|
+ //这里与pointList相同的数据就不渲染了 因为pointList会直接渲染出来的
|
|
|
|
|
+ // this.leftPoints = filterData.map((item) => {
|
|
|
|
|
+ // return {
|
|
|
|
|
+ // pointId: item.pointId,
|
|
|
|
|
+ // entityId: item.pointId,
|
|
|
|
|
+ // entityName: item.pointName,
|
|
|
|
|
+ // pointName: item.pointName,
|
|
|
|
|
+ // remark: item.remark,
|
|
|
|
|
+ // prePointId: item.prePointId,
|
|
|
|
|
+ // pointType: item.pointType,
|
|
|
|
|
+ // pointTypeName: item.pointTypeName,
|
|
|
|
|
+ // powerType: item.powerType,
|
|
|
|
|
+ // powerTypeName: item.powerTypeName,
|
|
|
|
|
+ // pointIcon: item.pointIcon,
|
|
|
|
|
+ // status: false,
|
|
|
|
|
+ // pointPicture: item.pointPicture,
|
|
|
|
|
+ // mapImg: null
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+ // this.addPointsToLeftPointsBox(filterData)
|
|
|
this.orgLeftPoints = res.data.records.map((item) => {
|
|
this.orgLeftPoints = res.data.records.map((item) => {
|
|
|
return {
|
|
return {
|
|
|
pointId: item.pointId,
|
|
pointId: item.pointId,
|
|
|
|
|
+ entityId: item.pointId,
|
|
|
|
|
+ entityName: item.pointName,
|
|
|
pointName: item.pointName,
|
|
pointName: item.pointName,
|
|
|
remark: item.remark,
|
|
remark: item.remark,
|
|
|
prePointId: item.prePointId,
|
|
prePointId: item.prePointId,
|
|
@@ -256,8 +276,9 @@ export default {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
- // 获取所有隔离点
|
|
|
|
|
|
|
+ // 获取未绑定的所有隔离点
|
|
|
getIsIsolationPointPage() {
|
|
getIsIsolationPointPage() {
|
|
|
|
|
+
|
|
|
// 拿到解绑的隔离点数据
|
|
// 拿到解绑的隔离点数据
|
|
|
const data1 = {
|
|
const data1 = {
|
|
|
current: 1,
|
|
current: 1,
|
|
@@ -267,6 +288,8 @@ export default {
|
|
|
getIsIsolationPointPage(data1).then((res) => {
|
|
getIsIsolationPointPage(data1).then((res) => {
|
|
|
this.rightPoints = res.data.records.map((item) => {
|
|
this.rightPoints = res.data.records.map((item) => {
|
|
|
return {
|
|
return {
|
|
|
|
|
+ entityId: item.pointId,
|
|
|
|
|
+ entityName: item.pointName,
|
|
|
pointId: item.pointId,
|
|
pointId: item.pointId,
|
|
|
pointName: item.pointName,
|
|
pointName: item.pointName,
|
|
|
remark: item.remark,
|
|
remark: item.remark,
|
|
@@ -278,11 +301,15 @@ export default {
|
|
|
pointIcon: item.pointIcon,
|
|
pointIcon: item.pointIcon,
|
|
|
status: false,
|
|
status: false,
|
|
|
pointPicture: item.pointPicture,
|
|
pointPicture: item.pointPicture,
|
|
|
- mapImg: null
|
|
|
|
|
|
|
+ mapImg: null,
|
|
|
|
|
+ mapId: this.mapId,
|
|
|
|
|
+ mapType: this.mapType
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
this.orgRightPoints = res.data.records.map((item) => {
|
|
this.orgRightPoints = res.data.records.map((item) => {
|
|
|
return {
|
|
return {
|
|
|
|
|
+ entityId: item.pointId,
|
|
|
|
|
+ entityName: item.pointName,
|
|
|
pointId: item.pointId,
|
|
pointId: item.pointId,
|
|
|
pointName: item.pointName,
|
|
pointName: item.pointName,
|
|
|
remark: item.remark,
|
|
remark: item.remark,
|
|
@@ -294,7 +321,9 @@ export default {
|
|
|
pointIcon: item.pointIcon,
|
|
pointIcon: item.pointIcon,
|
|
|
status: false,
|
|
status: false,
|
|
|
pointPicture: item.pointPicture,
|
|
pointPicture: item.pointPicture,
|
|
|
- mapImg: null
|
|
|
|
|
|
|
+ mapImg: null,
|
|
|
|
|
+ mapId: this.mapId,
|
|
|
|
|
+ mapType: this.mapType
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -343,6 +372,7 @@ export default {
|
|
|
map: mapData
|
|
map: mapData
|
|
|
}
|
|
}
|
|
|
console.log(formData, 'map')
|
|
console.log(formData, 'map')
|
|
|
|
|
+
|
|
|
updateLoto(formData).then((response) => {
|
|
updateLoto(formData).then((response) => {
|
|
|
console.log(response, '修改车间区域地图')
|
|
console.log(response, '修改车间区域地图')
|
|
|
this.$message({
|
|
this.$message({
|
|
@@ -351,13 +381,22 @@ export default {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ let dataMap = {
|
|
|
|
|
+ bindingPoints: this.leftPoints,
|
|
|
|
|
+ movePoints: JSON.parse(this.value),
|
|
|
|
|
+ unbindingPoints: this.rightPoints
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log(dataMap, '先拿到数据看看再说')
|
|
|
|
|
+ updateMapPointList(dataMap).then((res) => {
|
|
|
|
|
+ console.log(res, '拿到的新绑定数据')
|
|
|
|
|
+ })
|
|
|
const data = {
|
|
const data = {
|
|
|
bindingPointIds: this.bindingPointIds,
|
|
bindingPointIds: this.bindingPointIds,
|
|
|
lotoId: this.$route.query.lotoId,
|
|
lotoId: this.$route.query.lotoId,
|
|
|
unbindPointIds: this.unbindPointIds
|
|
unbindPointIds: this.unbindPointIds
|
|
|
}
|
|
}
|
|
|
console.log(data, '解绑与绑定数据参数')
|
|
console.log(data, '解绑与绑定数据参数')
|
|
|
- unbundlePointPage(data).then((res) => {
|
|
|
|
|
|
|
+ updatePointsBindingLoto(data).then((res) => {
|
|
|
console.log(res, '解绑接口返回值')
|
|
console.log(res, '解绑接口返回值')
|
|
|
this.bindingPointIds = []
|
|
this.bindingPointIds = []
|
|
|
this.unbindPointIds = []
|
|
this.unbindPointIds = []
|
|
@@ -495,6 +534,7 @@ export default {
|
|
|
this.layer.draw()
|
|
this.layer.draw()
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ // 绘制柜内所有点
|
|
|
renderGrid(imageSrc) {
|
|
renderGrid(imageSrc) {
|
|
|
this.selectedStates = [] // 用数组来存储选中状态
|
|
this.selectedStates = [] // 用数组来存储选中状态
|
|
|
this.rects = []
|
|
this.rects = []
|
|
@@ -505,8 +545,23 @@ export default {
|
|
|
this.selectedText = []
|
|
this.selectedText = []
|
|
|
|
|
|
|
|
// const positions = JSON.parse(this.value)
|
|
// const positions = JSON.parse(this.value)
|
|
|
- const positions=this.pointList
|
|
|
|
|
- console.log(positions,'positions')
|
|
|
|
|
|
|
+ const positions = this.pointList.map(item => ({
|
|
|
|
|
+ row: item.x, // 假设 row 是一个固定的值,如果不是,请根据实际情况调整
|
|
|
|
|
+ col: item.y, // 假设 col 是一个固定的值,如果不是,请根据实际情况调整
|
|
|
|
|
+ id: item.id,
|
|
|
|
|
+ pointId: item.entityId, // 假设 pointId 对应的是 entityId,如果不是,请根据实际情况调整
|
|
|
|
|
+ pointName: item.entityName, // 假设 pointName 对应的是 entityName,如果不是,请根据实际情况调整
|
|
|
|
|
+ entityId: item.entityId,
|
|
|
|
|
+ entityName: item.entityName,
|
|
|
|
|
+ mapId: item.mapId,
|
|
|
|
|
+ mapType: parseInt(item.mapType), // 假设 mapType 需要转换为数字类型
|
|
|
|
|
+ x: item.x, // 假设 x 需要转换为数字类型
|
|
|
|
|
+ y: item.y, // 假设 y 需要转换为数字类型
|
|
|
|
|
+ remark: item.remark,
|
|
|
|
|
+ pointIcon: item.pointIcon,
|
|
|
|
|
+ pointPicture: item.pointPicture
|
|
|
|
|
+ }))
|
|
|
|
|
+ console.log(positions, 'positions')
|
|
|
positions.forEach((pos, index) => {
|
|
positions.forEach((pos, index) => {
|
|
|
// console.log(pos,'单条数据');
|
|
// console.log(pos,'单条数据');
|
|
|
const x = pos.x * 50 // 每个单元格宽度为50
|
|
const x = pos.x * 50 // 每个单元格宽度为50
|
|
@@ -613,24 +668,24 @@ export default {
|
|
|
|
|
|
|
|
// 查找并删除对应的点数据
|
|
// 查找并删除对应的点数据
|
|
|
const indexToRemove = positions.findIndex(
|
|
const indexToRemove = positions.findIndex(
|
|
|
- (item) => item.pointName === labelText
|
|
|
|
|
|
|
+ (item) => item.entityName === labelText
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
if (indexToRemove !== -1) {
|
|
if (indexToRemove !== -1) {
|
|
|
// 从 positions 中移除并获取移动的点
|
|
// 从 positions 中移除并获取移动的点
|
|
|
// const movedPoint = positions.splice(indexToRemove, 1)[0];
|
|
// const movedPoint = positions.splice(indexToRemove, 1)[0];
|
|
|
- const movedPoint = positions.find((item) => item.pointName == labelText)
|
|
|
|
|
|
|
+ const movedPoint = positions.find((item) => item.entityName == labelText)
|
|
|
|
|
|
|
|
if (movedPoint) {
|
|
if (movedPoint) {
|
|
|
// 如果点位在物资柜外但不在右侧列表中,进行位置更新
|
|
// 如果点位在物资柜外但不在右侧列表中,进行位置更新
|
|
|
if (!isInCabinet && !isInRightBox) {
|
|
if (!isInCabinet && !isInRightBox) {
|
|
|
// 更新位置为新的列和行
|
|
// 更新位置为新的列和行
|
|
|
- const newCol = Math.round(groupPos.x / 50) // 四舍五入到最近的列
|
|
|
|
|
- const newRow = Math.round(groupPos.y / 50) // 四舍五入到最近的行
|
|
|
|
|
|
|
+ const newCol = Math.round(groupPos.y / 50) // 四舍五入到最近的列
|
|
|
|
|
+ const newRow = Math.round(groupPos.x / 50) // 四舍五入到最近的行
|
|
|
|
|
|
|
|
// 限制列和行的范围,防止超出网格边界
|
|
// 限制列和行的范围,防止超出网格边界
|
|
|
- const maxCols = Math.floor(1200 / 50) - 1 // 最大列索引
|
|
|
|
|
- const maxRows = Math.floor(860 / 50) - 1 // 最大行索引
|
|
|
|
|
|
|
+ const maxCols = Math.floor(860 / 50) - 1 // 最大列索引
|
|
|
|
|
+ const maxRows = Math.floor(1200 / 50) - 1 // 最大行索引
|
|
|
|
|
|
|
|
const boundedCol = Math.max(0, Math.min(newCol, maxCols)) // 限制列范围
|
|
const boundedCol = Math.max(0, Math.min(newCol, maxCols)) // 限制列范围
|
|
|
const boundedRow = Math.max(0, Math.min(newRow, maxRows)) // 限制行范围
|
|
const boundedRow = Math.max(0, Math.min(newRow, maxRows)) // 限制行范围
|
|
@@ -639,10 +694,15 @@ export default {
|
|
|
const updatedPosition = {
|
|
const updatedPosition = {
|
|
|
row: boundedRow,
|
|
row: boundedRow,
|
|
|
col: boundedCol,
|
|
col: boundedCol,
|
|
|
- pointId: movedPoint.pointId,
|
|
|
|
|
- pointName: movedPoint.pointName,
|
|
|
|
|
- remark: movedPoint.remark,
|
|
|
|
|
- prePointId: movedPoint.prePointId,
|
|
|
|
|
|
|
+ id: movedPoint.id,
|
|
|
|
|
+ pointId: movedPoint.entityId,
|
|
|
|
|
+ entityId: movedPoint.entityId,
|
|
|
|
|
+ entityName: movedPoint.entityName,
|
|
|
|
|
+ pointName: movedPoint.entityName,
|
|
|
|
|
+ mapId: this.mapId,
|
|
|
|
|
+ mapType: this.mapType,
|
|
|
|
|
+ x: boundedRow,
|
|
|
|
|
+ y: boundedCol,
|
|
|
pointType: movedPoint.pointType,
|
|
pointType: movedPoint.pointType,
|
|
|
pointTypeName: movedPoint.pointTypeName,
|
|
pointTypeName: movedPoint.pointTypeName,
|
|
|
powerType: movedPoint.powerType,
|
|
powerType: movedPoint.powerType,
|
|
@@ -668,7 +728,7 @@ export default {
|
|
|
// 确保点位没有被重复添加到 rightPoints 中
|
|
// 确保点位没有被重复添加到 rightPoints 中
|
|
|
if (
|
|
if (
|
|
|
!this.rightPoints.find(
|
|
!this.rightPoints.find(
|
|
|
- (point) => point.pointName == movedPoint.pointName
|
|
|
|
|
|
|
+ (point) => point.entityName == movedPoint.entityName
|
|
|
)
|
|
)
|
|
|
) {
|
|
) {
|
|
|
// console.log(isInRightBox,'进入右侧盒子');
|
|
// console.log(isInRightBox,'进入右侧盒子');
|
|
@@ -681,7 +741,7 @@ export default {
|
|
|
// 遍历 positions 数组
|
|
// 遍历 positions 数组
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
// 找到当前移动的元素
|
|
// 找到当前移动的元素
|
|
|
- if (positions[i].pointName === movedPoint.pointName) {
|
|
|
|
|
|
|
+ if (positions[i].entityName === movedPoint.entityName) {
|
|
|
// 使用 splice 删除该元素
|
|
// 使用 splice 删除该元素
|
|
|
positions.splice(i, 1)
|
|
positions.splice(i, 1)
|
|
|
|
|
|
|
@@ -695,10 +755,10 @@ export default {
|
|
|
this.rightPoints.push(movedPoint)
|
|
this.rightPoints.push(movedPoint)
|
|
|
|
|
|
|
|
// 将 pointId 添加到 unbindPointIds 数组
|
|
// 将 pointId 添加到 unbindPointIds 数组
|
|
|
- this.unbindPointIds.push(movedPoint.pointId)
|
|
|
|
|
|
|
+ this.unbindPointIds.push(movedPoint.entityId)
|
|
|
// 从 bindingPointIds 中移除该 pointId
|
|
// 从 bindingPointIds 中移除该 pointId
|
|
|
const bindingIndex = this.bindingPointIds.indexOf(
|
|
const bindingIndex = this.bindingPointIds.indexOf(
|
|
|
- movedPoint.pointId
|
|
|
|
|
|
|
+ movedPoint.entityId
|
|
|
)
|
|
)
|
|
|
if (bindingIndex !== -1) {
|
|
if (bindingIndex !== -1) {
|
|
|
this.bindingPointIds.splice(bindingIndex, 1)
|
|
this.bindingPointIds.splice(bindingIndex, 1)
|
|
@@ -708,12 +768,12 @@ export default {
|
|
|
// 如果是从物资柜内拿出来并移到柜外但不进入右侧列表
|
|
// 如果是从物资柜内拿出来并移到柜外但不进入右侧列表
|
|
|
else if (isInCabinet && !isInRightBox) {
|
|
else if (isInCabinet && !isInRightBox) {
|
|
|
// 更新位置并保存
|
|
// 更新位置并保存
|
|
|
- const newCol = Math.round(groupPos.x / 50) // 四舍五入到最近的列
|
|
|
|
|
- const newRow = Math.round(groupPos.y / 50) // 四舍五入到最近的行
|
|
|
|
|
|
|
+ const newCol = Math.round(groupPos.y / 50) // 四舍五入到最近的列
|
|
|
|
|
+ const newRow = Math.round(groupPos.x / 50) // 四舍五入到最近的行
|
|
|
|
|
|
|
|
// 限制列和行的范围,防止超出网格边界
|
|
// 限制列和行的范围,防止超出网格边界
|
|
|
- const maxCols = Math.floor(1200 / 50) - 1 // 最大列索引
|
|
|
|
|
- const maxRows = Math.floor(860 / 50) - 1 // 最大行索引
|
|
|
|
|
|
|
+ const maxCols = Math.floor(860 / 50) - 1 // 最大列索引
|
|
|
|
|
+ const maxRows = Math.floor(1200 / 50) - 1 // 最大行索引
|
|
|
|
|
|
|
|
const boundedCol = Math.max(0, Math.min(newCol, maxCols)) // 限制列范围
|
|
const boundedCol = Math.max(0, Math.min(newCol, maxCols)) // 限制列范围
|
|
|
const boundedRow = Math.max(0, Math.min(newRow, maxRows)) // 限制行范围
|
|
const boundedRow = Math.max(0, Math.min(newRow, maxRows)) // 限制行范围
|
|
@@ -722,8 +782,15 @@ export default {
|
|
|
const updatedPosition = {
|
|
const updatedPosition = {
|
|
|
row: boundedRow,
|
|
row: boundedRow,
|
|
|
col: boundedCol,
|
|
col: boundedCol,
|
|
|
- pointId: movedPoint.pointId,
|
|
|
|
|
- pointName: movedPoint.pointName,
|
|
|
|
|
|
|
+ id: movedPoint.id,
|
|
|
|
|
+ pointId: movedPoint.entityId,
|
|
|
|
|
+ pointName: movedPoint.entityName,
|
|
|
|
|
+ entityId: movedPoint.entityId,
|
|
|
|
|
+ entityName: movedPoint.entityName,
|
|
|
|
|
+ mapId: this.mapId,
|
|
|
|
|
+ mapType: this.mapType,
|
|
|
|
|
+ x: boundedRow,
|
|
|
|
|
+ y: boundedCol,
|
|
|
remark: movedPoint.remark,
|
|
remark: movedPoint.remark,
|
|
|
prePointId: movedPoint.prePointId,
|
|
prePointId: movedPoint.prePointId,
|
|
|
pointType: movedPoint.pointType,
|
|
pointType: movedPoint.pointType,
|
|
@@ -748,7 +815,7 @@ export default {
|
|
|
} else {
|
|
} else {
|
|
|
// 如果点不在 positions 中,从柜子移动到右侧
|
|
// 如果点不在 positions 中,从柜子移动到右侧
|
|
|
const rightIndex = this.rightPoints.findIndex(
|
|
const rightIndex = this.rightPoints.findIndex(
|
|
|
- (item) => item.pointName === labelText
|
|
|
|
|
|
|
+ (item) => item.entityName === labelText
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
if (rightIndex !== -1) {
|
|
if (rightIndex !== -1) {
|
|
@@ -758,12 +825,12 @@ export default {
|
|
|
// 如果点不在右侧列表中且不在物资柜中,更新位置
|
|
// 如果点不在右侧列表中且不在物资柜中,更新位置
|
|
|
if (!isInRightBox && !isInCabinet) {
|
|
if (!isInRightBox && !isInCabinet) {
|
|
|
// 更新位置为新的列和行
|
|
// 更新位置为新的列和行
|
|
|
- const newCol = Math.round(groupPos.x / 50) // 四舍五入到最近的列
|
|
|
|
|
- const newRow = Math.round(groupPos.y / 50) // 四舍五入到最近的行
|
|
|
|
|
|
|
+ const newCol = Math.round(groupPos.y / 50) // 四舍五入到最近的列
|
|
|
|
|
+ const newRow = Math.round(groupPos.x / 50) // 四舍五入到最近的行
|
|
|
|
|
|
|
|
// 限制列和行的范围,防止超出网格边界
|
|
// 限制列和行的范围,防止超出网格边界
|
|
|
- const maxCols = Math.floor(1200 / 50) - 1 // 最大列索引
|
|
|
|
|
- const maxRows = Math.floor(860 / 50) - 1 // 最大行索引
|
|
|
|
|
|
|
+ const maxCols = Math.floor(860 / 50) - 1 // 最大列索引
|
|
|
|
|
+ const maxRows = Math.floor(1200 / 50) - 1 // 最大行索引
|
|
|
|
|
|
|
|
const boundedCol = Math.max(0, Math.min(newCol, maxCols)) // 限制列范围
|
|
const boundedCol = Math.max(0, Math.min(newCol, maxCols)) // 限制列范围
|
|
|
const boundedRow = Math.max(0, Math.min(newRow, maxRows)) // 限制行范围
|
|
const boundedRow = Math.max(0, Math.min(newRow, maxRows)) // 限制行范围
|
|
@@ -772,8 +839,15 @@ export default {
|
|
|
const updatedPosition = {
|
|
const updatedPosition = {
|
|
|
row: boundedRow,
|
|
row: boundedRow,
|
|
|
col: boundedCol,
|
|
col: boundedCol,
|
|
|
- pointId: movedPoint.pointId,
|
|
|
|
|
- pointName: movedPoint.pointName,
|
|
|
|
|
|
|
+ id: movedPoint.id,
|
|
|
|
|
+ pointId: movedPoint.entityId,
|
|
|
|
|
+ pointName: movedPoint.entityName,
|
|
|
|
|
+ entityId: movedPoint.entityId,
|
|
|
|
|
+ entityName: movedPoint.entityName,
|
|
|
|
|
+ mapId: this.mapId,
|
|
|
|
|
+ mapType: this.mapType,
|
|
|
|
|
+ x: boundedRow,
|
|
|
|
|
+ y: boundedCol,
|
|
|
remark: movedPoint.remark,
|
|
remark: movedPoint.remark,
|
|
|
prePointId: movedPoint.prePointId,
|
|
prePointId: movedPoint.prePointId,
|
|
|
pointType: movedPoint.pointType,
|
|
pointType: movedPoint.pointType,
|
|
@@ -798,12 +872,12 @@ export default {
|
|
|
// 如果点从右侧拖拽到物资柜内
|
|
// 如果点从右侧拖拽到物资柜内
|
|
|
if (isInCabinet) {
|
|
if (isInCabinet) {
|
|
|
// 更新位置为新的列和行
|
|
// 更新位置为新的列和行
|
|
|
- const newCol = Math.round(groupPos.x / 50) // 四舍五入到最近的列
|
|
|
|
|
- const newRow = Math.round(groupPos.y / 50) // 四舍五入到最近的行
|
|
|
|
|
|
|
+ const newCol = Math.round(groupPos.y / 50) // 四舍五入到最近的列
|
|
|
|
|
+ const newRow = Math.round(groupPos.x / 50) // 四舍五入到最近的行
|
|
|
|
|
|
|
|
// 限制列和行的范围,防止超出网格边界
|
|
// 限制列和行的范围,防止超出网格边界
|
|
|
- const maxCols = Math.floor(1200 / 50) - 1 // 最大列索引
|
|
|
|
|
- const maxRows = Math.floor(860 / 50) - 1 // 最大行索引
|
|
|
|
|
|
|
+ const maxCols = Math.floor(860 / 50) - 1 // 最大列索引
|
|
|
|
|
+ const maxRows = Math.floor(1200 / 50) - 1 // 最大行索引
|
|
|
|
|
|
|
|
const boundedCol = Math.max(0, Math.min(newCol, maxCols)) // 限制列范围
|
|
const boundedCol = Math.max(0, Math.min(newCol, maxCols)) // 限制列范围
|
|
|
const boundedRow = Math.max(0, Math.min(newRow, maxRows)) // 限制行范围
|
|
const boundedRow = Math.max(0, Math.min(newRow, maxRows)) // 限制行范围
|
|
@@ -812,8 +886,15 @@ export default {
|
|
|
const updatedPosition = {
|
|
const updatedPosition = {
|
|
|
row: boundedRow,
|
|
row: boundedRow,
|
|
|
col: boundedCol,
|
|
col: boundedCol,
|
|
|
- pointId: movedPoint.pointId,
|
|
|
|
|
- pointName: movedPoint.pointName,
|
|
|
|
|
|
|
+ id: movedPoint.id,
|
|
|
|
|
+ pointId: movedPoint.entityId,
|
|
|
|
|
+ pointName: movedPoint.entityName,
|
|
|
|
|
+ entityId: movedPoint.entityId,
|
|
|
|
|
+ entityName: movedPoint.entityName,
|
|
|
|
|
+ mapId: this.mapId,
|
|
|
|
|
+ mapType: this.mapType,
|
|
|
|
|
+ x: boundedRow,
|
|
|
|
|
+ y: boundedCol,
|
|
|
remark: movedPoint.remark,
|
|
remark: movedPoint.remark,
|
|
|
prePointId: movedPoint.prePointId,
|
|
prePointId: movedPoint.prePointId,
|
|
|
pointType: movedPoint.pointType,
|
|
pointType: movedPoint.pointType,
|
|
@@ -833,21 +914,21 @@ export default {
|
|
|
// 确保点位没有被重复添加到 leftPoints 中
|
|
// 确保点位没有被重复添加到 leftPoints 中
|
|
|
if (
|
|
if (
|
|
|
!this.leftPoints.find(
|
|
!this.leftPoints.find(
|
|
|
- (point) => point.pointName === movedPoint.pointName
|
|
|
|
|
|
|
+ (point) => point.entityName === movedPoint.entityName
|
|
|
)
|
|
)
|
|
|
) {
|
|
) {
|
|
|
this.leftPoints.push(movedPoint)
|
|
this.leftPoints.push(movedPoint)
|
|
|
}
|
|
}
|
|
|
// 从 unbindPointIds 中移除该 pointId
|
|
// 从 unbindPointIds 中移除该 pointId
|
|
|
const unbindIndex = this.unbindPointIds.indexOf(
|
|
const unbindIndex = this.unbindPointIds.indexOf(
|
|
|
- movedPoint.pointId
|
|
|
|
|
|
|
+ movedPoint.entityId
|
|
|
)
|
|
)
|
|
|
if (unbindIndex !== -1) {
|
|
if (unbindIndex !== -1) {
|
|
|
this.unbindPointIds.splice(unbindIndex, 1)
|
|
this.unbindPointIds.splice(unbindIndex, 1)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 将 pointId 添加到 bindingPointIds 数组
|
|
// 将 pointId 添加到 bindingPointIds 数组
|
|
|
- this.bindingPointIds.push(movedPoint.pointId)
|
|
|
|
|
|
|
+ this.bindingPointIds.push(movedPoint.entityId)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -904,6 +985,7 @@ export default {
|
|
|
|
|
|
|
|
// 渲染每个点
|
|
// 渲染每个点
|
|
|
renderPoint(point) {
|
|
renderPoint(point) {
|
|
|
|
|
+
|
|
|
const x = point.col * 50 // 每个单元格宽度为50
|
|
const x = point.col * 50 // 每个单元格宽度为50
|
|
|
const y = point.row * 50 // 每个单元格高度为50
|
|
const y = point.row * 50 // 每个单元格高度为50
|
|
|
|
|
|
|
@@ -1031,6 +1113,7 @@ export default {
|
|
|
this.value = JSON.stringify(updatedData, null, 4)
|
|
this.value = JSON.stringify(updatedData, null, 4)
|
|
|
|
|
|
|
|
// console.log('Updated value after removal:', this.value)
|
|
// console.log('Updated value after removal:', this.value)
|
|
|
|
|
+ console.log('removePointFromJson', updatedData)
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 更新 JSON 中对应点的位置
|
|
// 更新 JSON 中对应点的位置
|
|
@@ -1043,8 +1126,12 @@ export default {
|
|
|
const updatedPosition = {
|
|
const updatedPosition = {
|
|
|
row: newRow,
|
|
row: newRow,
|
|
|
col: newCol,
|
|
col: newCol,
|
|
|
|
|
+ x: newRow,
|
|
|
|
|
+ y: newCol,
|
|
|
pointId: point.pointId,
|
|
pointId: point.pointId,
|
|
|
pointName: point.pointName,
|
|
pointName: point.pointName,
|
|
|
|
|
+ entityId: point.pointId,
|
|
|
|
|
+ entityName: point.pointName,
|
|
|
remark: point.remark,
|
|
remark: point.remark,
|
|
|
prePointId: point.prePointId,
|
|
prePointId: point.prePointId,
|
|
|
pointType: point.pointType,
|
|
pointType: point.pointType,
|
|
@@ -1075,9 +1162,9 @@ export default {
|
|
|
this.value = JSON.stringify(positions, null, 4)
|
|
this.value = JSON.stringify(positions, null, 4)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log('Updated value after update:', this.value)
|
|
|
|
|
|
|
+ // console.log('Updated value after update:', this.value)
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
|
|
+ // 解绑隔离点函数
|
|
|
addPointsToRightPointsBox(rightPointsBox) {
|
|
addPointsToRightPointsBox(rightPointsBox) {
|
|
|
if (this.rightPoints && this.rightPoints.length > 0) {
|
|
if (this.rightPoints && this.rightPoints.length > 0) {
|
|
|
const boxWidth = rightPointsBox.width()
|
|
const boxWidth = rightPointsBox.width()
|
|
@@ -1182,6 +1269,8 @@ export default {
|
|
|
row: row,
|
|
row: row,
|
|
|
col: col,
|
|
col: col,
|
|
|
pointId: point.pointId,
|
|
pointId: point.pointId,
|
|
|
|
|
+ entityId: point.entityId,
|
|
|
|
|
+ entityName: point.entityName,
|
|
|
pointName: point.pointName,
|
|
pointName: point.pointName,
|
|
|
remark: point.remark,
|
|
remark: point.remark,
|
|
|
prePointId: point.prePointId,
|
|
prePointId: point.prePointId,
|
|
@@ -1212,7 +1301,11 @@ export default {
|
|
|
) {
|
|
) {
|
|
|
// 进入右侧盒子区域
|
|
// 进入右侧盒子区域
|
|
|
console.log('进入右侧盒子区域')
|
|
console.log('进入右侧盒子区域')
|
|
|
-
|
|
|
|
|
|
|
+// 更新 point 对象的 col 和 row 值
|
|
|
|
|
+ point.row = col
|
|
|
|
|
+ point.col = row
|
|
|
|
|
+ point.x = col
|
|
|
|
|
+ point.y = row
|
|
|
// 如果之前已在右侧区域,需要移除值,并更新绑定点ID
|
|
// 如果之前已在右侧区域,需要移除值,并更新绑定点ID
|
|
|
const index = valueArray.findIndex(
|
|
const index = valueArray.findIndex(
|
|
|
(item) => item.pointId === point.pointId
|
|
(item) => item.pointId === point.pointId
|
|
@@ -1232,15 +1325,27 @@ export default {
|
|
|
|
|
|
|
|
// 将点重新添加到 rightPoints
|
|
// 将点重新添加到 rightPoints
|
|
|
this.rightPoints.push(point)
|
|
this.rightPoints.push(point)
|
|
|
- } else if (
|
|
|
|
|
- snappedX >= cabinetBounds.x &&
|
|
|
|
|
- snappedX <= cabinetBounds.x + cabinetBounds.width &&
|
|
|
|
|
- snappedY >= cabinetBounds.y &&
|
|
|
|
|
- snappedY <= cabinetBounds.y + cabinetBounds.height
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ // 这里的if判断是为了 移动在物资柜内部才做的操作 现在我只要离开右侧 就做这个操作
|
|
|
|
|
+ // if (
|
|
|
|
|
+ // snappedX >= cabinetBounds.x &&
|
|
|
|
|
+ // snappedX <= cabinetBounds.x + cabinetBounds.width &&
|
|
|
|
|
+ // snappedY >= cabinetBounds.y &&
|
|
|
|
|
+ // snappedY <= cabinetBounds.y + cabinetBounds.height
|
|
|
|
|
+ // )
|
|
|
|
|
+ else if (snappedX < rightBoxBounds.x ||
|
|
|
|
|
+ snappedX > rightBoxBounds.x + rightBoxBounds.width ||
|
|
|
|
|
+ snappedY < rightBoxBounds.y ||
|
|
|
|
|
+ snappedY > rightBoxBounds.y + rightBoxBounds.height
|
|
|
) {
|
|
) {
|
|
|
|
|
+
|
|
|
// 进入物资柜区域
|
|
// 进入物资柜区域
|
|
|
console.log('进入物资柜区域')
|
|
console.log('进入物资柜区域')
|
|
|
-
|
|
|
|
|
|
|
+ // 更新 point 对象的 col 和 row 值
|
|
|
|
|
+ point.row = col
|
|
|
|
|
+ point.col = row
|
|
|
|
|
+ point.x = col
|
|
|
|
|
+ point.y = row
|
|
|
// 检查点是否已经存在于 valueArray 中
|
|
// 检查点是否已经存在于 valueArray 中
|
|
|
const index = valueArray.findIndex(
|
|
const index = valueArray.findIndex(
|
|
|
(item) => item.pointId === point.pointId
|
|
(item) => item.pointId === point.pointId
|
|
@@ -1258,10 +1363,16 @@ export default {
|
|
|
this.rightPoints = this.rightPoints.filter(
|
|
this.rightPoints = this.rightPoints.filter(
|
|
|
(item) => item.pointId !== point.pointId
|
|
(item) => item.pointId !== point.pointId
|
|
|
)
|
|
)
|
|
|
|
|
+ this.leftPoints.push(point)
|
|
|
|
|
+ console.log(point, '左侧区域绑定柜子了')
|
|
|
} else {
|
|
} else {
|
|
|
// 未进入任何目标区域,保持原状态
|
|
// 未进入任何目标区域,保持原状态
|
|
|
console.log('未进入目标区域,保持原状态')
|
|
console.log('未进入目标区域,保持原状态')
|
|
|
-
|
|
|
|
|
|
|
+// 更新 point 对象的 col 和 row 值
|
|
|
|
|
+ point.row = col
|
|
|
|
|
+ point.col = row
|
|
|
|
|
+ point.x = col
|
|
|
|
|
+ point.y = row
|
|
|
// 如果点不在目标区域,从 valueArray 中移除
|
|
// 如果点不在目标区域,从 valueArray 中移除
|
|
|
// this.value = JSON.stringify(
|
|
// this.value = JSON.stringify(
|
|
|
// valueArray.filter((item) => item.pointId !== point.pointId),
|
|
// valueArray.filter((item) => item.pointId !== point.pointId),
|