|
@@ -3,7 +3,7 @@
|
|
|
<div id="canvas-container">
|
|
|
<canvas id="myCanvas"></canvas>
|
|
|
</div>
|
|
|
- <div id="distribution-drap" class="distribution-drap" @mousedown="dragStart" @touchstart="dragStart">
|
|
|
+ <div id="distribution-drap" v-if="isEdit" class="distribution-drap" @mousedown="dragStart" @touchstart="dragStart">
|
|
|
<div class="distribution-drap-title">
|
|
|
<div id="title" class="distribution-drap-title-content">房间设置</div>
|
|
|
</div>
|
|
@@ -69,7 +69,8 @@
|
|
|
floorPlanSize: {
|
|
|
width: '',
|
|
|
height: ''
|
|
|
- }
|
|
|
+ },
|
|
|
+ isEdit:true
|
|
|
}
|
|
|
},
|
|
|
beforeDestroy() {
|
|
@@ -96,6 +97,14 @@
|
|
|
this.roomData = {};
|
|
|
this.form.color = 'rgba(52, 114, 211, 0.6)';
|
|
|
}
|
|
|
+ if (this.canvas) {
|
|
|
+ if (this.roomData.position) {
|
|
|
+ this.position = this.roomData.position;
|
|
|
+ this.form.color = this.roomData.roomColor;
|
|
|
+ this.initRenderRoom();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.target.floorPlanSize) {
|
|
|
this.floorPlanSize = JSON.parse(this.target.floorPlanSize);
|
|
|
this.createCanvas();
|
|
@@ -105,6 +114,26 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ update(list,isEdit) {
|
|
|
+ let room = this.canvas.getObjects().filter(node => node.roomId);
|
|
|
+ this.canvas.remove(...room);
|
|
|
+ this.isEdit = isEdit;
|
|
|
+ if (isEdit) this.initRenderRoom();
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ if (list[i].dataValue) {
|
|
|
+ let roomData = JSON.parse(list[i].dataValue);
|
|
|
+ const box = new fabric.Polygon(roomData.position, {
|
|
|
+ fill: roomData.roomColor,
|
|
|
+ stroke: 'rgba(113, 179, 255, 1.0)',
|
|
|
+ strokeWidth: 1,
|
|
|
+ selectable: false,
|
|
|
+ roomId: list[i].roomId
|
|
|
+ });
|
|
|
+ this.canvas.add(box);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.canvas.renderAll();
|
|
|
+ },
|
|
|
initSize() {
|
|
|
let box = document.getElementById('fabricContainer');
|
|
|
if (!box) return;
|
|
@@ -318,6 +347,8 @@
|
|
|
}
|
|
|
},
|
|
|
initRenderRoom() {
|
|
|
+ let room = this.canvas.getObjects().filter(node => node.roomId);
|
|
|
+ this.canvas.remove(...room)
|
|
|
const box = new fabric.Polygon(this.position, {
|
|
|
fill: this.form.color,
|
|
|
stroke: 'rgba(113, 179, 255, 1.0)',
|
|
@@ -376,7 +407,12 @@
|
|
|
|
|
|
return coordinates;
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ roomId() {
|
|
|
+ this.init();
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
</script>
|
|
|
|