|
|
@@ -30,61 +30,55 @@
|
|
|
style="float: right; height: 33px; line-height: 2px; margin: 10px 0"
|
|
|
>重置
|
|
|
</el-button>
|
|
|
- <!-- <el-button
|
|
|
- v-no-more-click
|
|
|
- @click="view"
|
|
|
- type="primary"
|
|
|
- icon="el-icon-refresh"
|
|
|
- style="float: right; height: 33px; line-height: 2px"
|
|
|
- >刷新
|
|
|
- </el-button> -->
|
|
|
+
|
|
|
</div>
|
|
|
- <!-- <el-card class="box-card">
|
|
|
- <div slot="header" class="clearfix">
|
|
|
- <span style="font-size: 18px">地图预览</span>
|
|
|
- </div>
|
|
|
- <div style="height: 100%; padding-bottom: 10px">
|
|
|
- <el-input v-model="value" type="textarea" :rows="34"></el-input>
|
|
|
- </div>
|
|
|
- <div
|
|
|
- class="bottombtn"
|
|
|
- style="width: 100%; height: 35px; padding: 10px 0 0"
|
|
|
- >
|
|
|
- <el-button
|
|
|
- v-no-more-click
|
|
|
- @click="close"
|
|
|
- type="primary"
|
|
|
- icon="el-icon-close"
|
|
|
- style="float: right; height: 33px; line-height: 2px; margin: 0 10px"
|
|
|
- >关闭
|
|
|
- </el-button>
|
|
|
- <el-button
|
|
|
- v-no-more-click
|
|
|
- @click="save"
|
|
|
- type="primary"
|
|
|
- icon="el-icon-check"
|
|
|
- style="float: right; height: 33px; line-height: 2px; margin: 0 10px"
|
|
|
- >保存
|
|
|
- </el-button>
|
|
|
- <el-button
|
|
|
- v-no-more-click
|
|
|
- @click="reset"
|
|
|
- type="primary"
|
|
|
- icon="el-icon-setting"
|
|
|
- style="float: right; height: 33px; line-height: 2px; margin: 0 5px"
|
|
|
- >重置
|
|
|
- </el-button>
|
|
|
- <el-button
|
|
|
- v-no-more-click
|
|
|
- @click="view"
|
|
|
- type="primary"
|
|
|
- icon="el-icon-refresh"
|
|
|
- style="float: right; height: 33px; line-height: 2px"
|
|
|
- >刷新
|
|
|
- </el-button>
|
|
|
- </div>
|
|
|
- </el-card> -->
|
|
|
</div>
|
|
|
+<!-- <el-card class="box-card">-->
|
|
|
+<!-- <div slot="header" class="clearfix">-->
|
|
|
+<!-- <span style="font-size: 18px">地图预览</span>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- <div style="height: 100%; padding-bottom: 10px">-->
|
|
|
+<!-- <el-input v-model="value" type="textarea" :rows="34"></el-input>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- <div-->
|
|
|
+<!-- class="bottombtn"-->
|
|
|
+<!-- style="width: 100%; height: 35px; padding: 10px 0 0"-->
|
|
|
+<!-- >-->
|
|
|
+<!-- <el-button-->
|
|
|
+<!-- v-no-more-click-->
|
|
|
+<!-- @click="close"-->
|
|
|
+<!-- type="primary"-->
|
|
|
+<!-- icon="el-icon-close"-->
|
|
|
+<!-- style="float: right; height: 33px; line-height: 2px; margin: 0 10px"-->
|
|
|
+<!-- >关闭-->
|
|
|
+<!-- </el-button>-->
|
|
|
+<!-- <el-button-->
|
|
|
+<!-- v-no-more-click-->
|
|
|
+<!-- @click="save"-->
|
|
|
+<!-- type="primary"-->
|
|
|
+<!-- icon="el-icon-check"-->
|
|
|
+<!-- style="float: right; height: 33px; line-height: 2px; margin: 0 10px"-->
|
|
|
+<!-- >保存-->
|
|
|
+<!-- </el-button>-->
|
|
|
+<!-- <el-button-->
|
|
|
+<!-- v-no-more-click-->
|
|
|
+<!-- @click="reset"-->
|
|
|
+<!-- type="primary"-->
|
|
|
+<!-- icon="el-icon-setting"-->
|
|
|
+<!-- style="float: right; height: 33px; line-height: 2px; margin: 0 5px"-->
|
|
|
+<!-- >重置-->
|
|
|
+<!-- </el-button>-->
|
|
|
+<!-- <el-button-->
|
|
|
+<!-- v-no-more-click-->
|
|
|
+<!-- @click="view"-->
|
|
|
+<!-- type="primary"-->
|
|
|
+<!-- icon="el-icon-refresh"-->
|
|
|
+<!-- style="float: right; height: 33px; line-height: 2px"-->
|
|
|
+<!-- >刷新-->
|
|
|
+<!-- </el-button>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </el-card>-->
|
|
|
+
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -487,6 +481,7 @@ export default {
|
|
|
const positions = JSON.parse(this.value);
|
|
|
|
|
|
positions.forEach((pos, index) => {
|
|
|
+ // console.log(pos,'单条数据');
|
|
|
const x = pos.col * 50; // 每个单元格宽度为50
|
|
|
const y = pos.row * 50; // 每个单元格高度为50
|
|
|
const labelText = pos.pointName; // 对应的文字
|
|
|
@@ -596,7 +591,8 @@ export default {
|
|
|
|
|
|
if (indexToRemove !== -1) {
|
|
|
// 从 positions 中移除并获取移动的点
|
|
|
- const movedPoint = positions.splice(indexToRemove, 1)[0];
|
|
|
+ // const movedPoint = positions.splice(indexToRemove, 1)[0];
|
|
|
+ const movedPoint=positions.find((item) => item.pointName == labelText);
|
|
|
|
|
|
if (movedPoint) {
|
|
|
// 如果点位在物资柜外但不在右侧列表中,进行位置更新
|
|
|
@@ -614,30 +610,60 @@ export default {
|
|
|
|
|
|
// 更新点位数据
|
|
|
const updatedPosition = {
|
|
|
- ...movedPoint,
|
|
|
- col: boundedCol,
|
|
|
row: boundedRow,
|
|
|
+ col: boundedCol,
|
|
|
+ pointId: movedPoint.pointId,
|
|
|
+ pointName: movedPoint.pointName,
|
|
|
+ remark: movedPoint.remark,
|
|
|
+ prePointId: movedPoint.prePointId,
|
|
|
+ pointType: movedPoint.pointType,
|
|
|
+ pointTypeName: movedPoint.pointTypeName,
|
|
|
+ powerType: movedPoint.powerType,
|
|
|
+ powerTypeName: movedPoint.powerTypeName,
|
|
|
+ state: movedPoint.state,
|
|
|
+ pointIcon: movedPoint.pointIcon,
|
|
|
+ pointPicture: movedPoint.pointPicture,
|
|
|
+ mapImg: movedPoint.mapImg,
|
|
|
};
|
|
|
|
|
|
// 更新 positions 数组中的点位
|
|
|
- positions[indexToRemove] = updatedPosition;
|
|
|
+ const updatedPositionCopy = JSON.parse(JSON.stringify(updatedPosition));
|
|
|
+ positions[indexToRemove] = updatedPositionCopy;
|
|
|
+
|
|
|
+ console.log(updatedPositionCopy, positions[indexToRemove], 'updatedPosition');
|
|
|
this.value = JSON.stringify(positions, null, 4);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 如果从物资柜外移动到右侧列表
|
|
|
else if (isInRightBox) {
|
|
|
+ console.log(isInRightBox,'进入右侧盒子');
|
|
|
// 确保点位没有被重复添加到 rightPoints 中
|
|
|
if (
|
|
|
!this.rightPoints.find(
|
|
|
- (point) => point.pointName === movedPoint.pointName
|
|
|
+ (point) => point.pointName == movedPoint.pointName
|
|
|
)
|
|
|
) {
|
|
|
- // 从 positions 中删除该点
|
|
|
- const updatedPositions = positions.filter(
|
|
|
- (item) => item.pointName !== movedPoint.pointName
|
|
|
- );
|
|
|
- this.value = JSON.stringify(updatedPositions, null, 4);
|
|
|
-
|
|
|
+ // console.log(isInRightBox,'进入右侧盒子');
|
|
|
+ // // 从 positions 中删除该点
|
|
|
+ // const updatedPositions = positions.filter(
|
|
|
+ // (item) => item.pointName !== movedPoint.pointName
|
|
|
+ // );
|
|
|
+ // console.log(updatedPositions, 'updatedPositions');
|
|
|
+ // this.value = JSON.stringify(updatedPositions, null, 4);
|
|
|
+// 遍历 positions 数组
|
|
|
+ for (let i = 0; i < positions.length; i++) {
|
|
|
+ // 找到当前移动的元素
|
|
|
+ if (positions[i].pointName === movedPoint.pointName) {
|
|
|
+ // 使用 splice 删除该元素
|
|
|
+ positions.splice(i, 1);
|
|
|
+
|
|
|
+ console.log('Removed item:', movedPoint); // 输出被删除的元素
|
|
|
+ this.value = JSON.stringify(positions, null, 4); // 更新值
|
|
|
+
|
|
|
+ break; // 找到并删除后退出循环
|
|
|
+ }
|
|
|
+ }
|
|
|
// 将 movedPoint 添加到 rightPoints 数组
|
|
|
this.rightPoints.push(movedPoint);
|
|
|
|
|
|
@@ -667,18 +693,34 @@ export default {
|
|
|
|
|
|
// 更新点位数据
|
|
|
const updatedPosition = {
|
|
|
- ...movedPoint,
|
|
|
- col: boundedCol,
|
|
|
row: boundedRow,
|
|
|
+ col: boundedCol,
|
|
|
+ pointId: movedPoint.pointId,
|
|
|
+ pointName: movedPoint.pointName,
|
|
|
+ remark: movedPoint.remark,
|
|
|
+ prePointId: movedPoint.prePointId,
|
|
|
+ pointType: movedPoint.pointType,
|
|
|
+ pointTypeName: movedPoint.pointTypeName,
|
|
|
+ powerType: movedPoint.powerType,
|
|
|
+ powerTypeName: movedPoint.powerTypeName,
|
|
|
+ state: movedPoint.state,
|
|
|
+ pointIcon: movedPoint.pointIcon,
|
|
|
+ pointPicture: movedPoint.pointPicture,
|
|
|
+ mapImg: movedPoint.mapImg,
|
|
|
};
|
|
|
|
|
|
// 更新 positions 数组中的点位
|
|
|
- positions[indexToRemove] = updatedPosition;
|
|
|
+ // 使用深拷贝确保不影响原始数据
|
|
|
+ const updatedPositionCopy = JSON.parse(JSON.stringify(updatedPosition));
|
|
|
+ positions[indexToRemove] = updatedPositionCopy;
|
|
|
+
|
|
|
+ console.log(updatedPositionCopy, positions[indexToRemove], 'updatedPosition');
|
|
|
this.value = JSON.stringify(positions, null, 4);
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- // 如果点不在 positions 中,可能是从右侧列表移动回来
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 如果点不在 positions 中,从柜子移动到右侧
|
|
|
const rightIndex = this.rightPoints.findIndex(
|
|
|
(item) => item.pointName === labelText
|
|
|
);
|
|
|
@@ -702,14 +744,29 @@ export default {
|
|
|
|
|
|
// 更新点位数据
|
|
|
const updatedPosition = {
|
|
|
- ...movedPoint,
|
|
|
- col: boundedCol,
|
|
|
row: boundedRow,
|
|
|
+ col: boundedCol,
|
|
|
+ pointId: movedPoint.pointId,
|
|
|
+ pointName: movedPoint.pointName,
|
|
|
+ remark: movedPoint.remark,
|
|
|
+ prePointId: movedPoint.prePointId,
|
|
|
+ pointType: movedPoint.pointType,
|
|
|
+ pointTypeName: movedPoint.pointTypeName,
|
|
|
+ powerType: movedPoint.powerType,
|
|
|
+ powerTypeName: movedPoint.powerTypeName,
|
|
|
+ state: movedPoint.state,
|
|
|
+ pointIcon: movedPoint.pointIcon,
|
|
|
+ pointPicture: movedPoint.pointPicture,
|
|
|
+ mapImg: movedPoint.mapImg,
|
|
|
};
|
|
|
|
|
|
// 更新 positions 数组中的点位
|
|
|
- positions.push(updatedPosition);
|
|
|
+ const updatedPositionCopy = JSON.parse(JSON.stringify(updatedPosition));
|
|
|
+ positions[indexToRemove] = updatedPositionCopy;
|
|
|
+
|
|
|
+ console.log(updatedPositionCopy, positions[indexToRemove], 'updatedPosition');
|
|
|
this.value = JSON.stringify(positions, null, 4);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 如果点从右侧拖拽到物资柜内
|
|
|
@@ -727,9 +784,20 @@ export default {
|
|
|
|
|
|
// 更新点位数据
|
|
|
const updatedPosition = {
|
|
|
- ...movedPoint,
|
|
|
- col: boundedCol,
|
|
|
row: boundedRow,
|
|
|
+ col: boundedCol,
|
|
|
+ pointId: movedPoint.pointId,
|
|
|
+ pointName: movedPoint.pointName,
|
|
|
+ remark: movedPoint.remark,
|
|
|
+ prePointId: movedPoint.prePointId,
|
|
|
+ pointType: movedPoint.pointType,
|
|
|
+ pointTypeName: movedPoint.pointTypeName,
|
|
|
+ powerType: movedPoint.powerType,
|
|
|
+ powerTypeName: movedPoint.powerTypeName,
|
|
|
+ state: movedPoint.state,
|
|
|
+ pointIcon: movedPoint.pointIcon,
|
|
|
+ pointPicture: movedPoint.pointPicture,
|
|
|
+ mapImg: movedPoint.mapImg,
|
|
|
};
|
|
|
|
|
|
// 更新 positions 数组中的点位
|
|
|
@@ -786,7 +854,7 @@ export default {
|
|
|
const existingPoint = JSON.parse(this.value).find(
|
|
|
(item) => item.pointId == point.pointId
|
|
|
);
|
|
|
- console.log();
|
|
|
+
|
|
|
// 如果该点在 this.value 中,使用它的原始位置
|
|
|
if (existingPoint) {
|
|
|
point.row = existingPoint.row;
|
|
|
@@ -803,7 +871,6 @@ export default {
|
|
|
row++;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 渲染该点
|
|
|
this.renderPoint(point);
|
|
|
});
|
|
|
@@ -969,7 +1036,12 @@ export default {
|
|
|
(item) => item.pointId === point.pointId
|
|
|
);
|
|
|
if (index !== -1) {
|
|
|
- positions[index] = updatedPosition;
|
|
|
+ // positions[index] = updatedPosition;
|
|
|
+ // this.value = JSON.stringify(positions, null, 4);
|
|
|
+ const updatedPositionCopy = JSON.parse(JSON.stringify(updatedPosition));
|
|
|
+ positions[index] = updatedPositionCopy;
|
|
|
+
|
|
|
+ console.log(updatedPositionCopy, positions[index], 'updatedPosition');
|
|
|
this.value = JSON.stringify(positions, null, 4);
|
|
|
} else {
|
|
|
// 如果点位不在 this.value 中,则重新插入
|