|
|
@ -70,8 +70,12 @@ |
|
|
|
区域标注 |
|
|
|
</el-button> |
|
|
|
</ul> |
|
|
|
<div v-if="activeIndex == 0" class="venue-preview"> |
|
|
|
<img :src="imageFloorUrl" :onerror="defaultImg" alt=""> |
|
|
|
<div v-show="activeIndex == 0" class="venue-preview"> |
|
|
|
<!-- <MarkCover v-if="currentMarkData && currentMarkData.signPoint" ref="markRefs2" :is-canvas-show="true" :current-mark-data="currentMarkData" :image-floor-url="imageFloorUrl" /> --> |
|
|
|
<div v-show="currentMarkData && currentMarkData.signPoint"> |
|
|
|
<canvas id="canvasPreview" :width="width" :height="height" /> |
|
|
|
</div> |
|
|
|
<img v-if="currentMarkData && !currentMarkData.signPoint" :src="imageFloorUrl" :onerror="defaultImg" alt=""> |
|
|
|
</div> |
|
|
|
<div v-if="activeIndex == 1" class="venue-preview"> |
|
|
|
<img :src="imageRegionUrl" :onerror="defaultImg" alt=""> |
|
|
@ -135,11 +139,11 @@ |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<!-- 标注 --> |
|
|
|
<el-dialog class="mark-dialog" :close-on-click-modal="false" :append-to-body="true" :title="titleMark" :visible.sync="markVisible"> |
|
|
|
<el-dialog class="mark-dialog" :close-on-click-modal="false" :append-to-body="true" :title="titleMark" :visible.sync="markVisible" :before-close="handleCloseDialog"> |
|
|
|
<span class="dialog-right-top" /> |
|
|
|
<span class="dialog-left-bottom" /> |
|
|
|
<div class="setting-dialog"> |
|
|
|
<MarkCover :current-mark-data="currentMarkData" :image-floor-url="imageFloorUrl" /> |
|
|
|
<MarkCover ref="markRefs" :current-mark-data="currentMarkData" :image-floor-url="imageFloorUrl" /> |
|
|
|
</div> |
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
@ -157,6 +161,7 @@ import MarkCover from '@/views/components/mark.vue' |
|
|
|
import Sortable from 'sortablejs' |
|
|
|
import { mapGetters } from 'vuex' |
|
|
|
import defaultImg from '@/assets/images/system/default-img.jpg' |
|
|
|
import { fabric } from 'fabric' |
|
|
|
|
|
|
|
const defaultForm = { id: null, floorId: null, regionName: null, regionCode: null, regionDescription: null, regionMap: null, signPoint: null } |
|
|
|
export default { |
|
|
@ -175,6 +180,7 @@ export default { |
|
|
|
mixins: [presenter(), header(), form(defaultForm), crud()], |
|
|
|
data() { |
|
|
|
return { |
|
|
|
canvasPreview: {}, |
|
|
|
floorOptions: [], |
|
|
|
labelName: '区域地图', |
|
|
|
permission: { |
|
|
@ -201,7 +207,11 @@ export default { |
|
|
|
sortVisible: false, // 排序dialog |
|
|
|
markVisible: false, // 区域标注 |
|
|
|
titleMark: '区域标注', |
|
|
|
currentMarkData: null |
|
|
|
currentMarkData: null, |
|
|
|
|
|
|
|
width: 900, |
|
|
|
height: 600, |
|
|
|
drawWidth: 2 // 笔触宽度 |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
@ -210,6 +220,14 @@ export default { |
|
|
|
'baseApi' |
|
|
|
]) |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
width() { |
|
|
|
this.canvasPreview.setWidth(this.width) |
|
|
|
}, |
|
|
|
height() { |
|
|
|
this.canvasPreview.setHeight(this.height) |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
[CRUD.HOOK.beforeRefresh]() { |
|
|
|
this.getLibraryFloorListAll() |
|
|
@ -237,12 +255,15 @@ export default { |
|
|
|
clickRowHandler(row) { |
|
|
|
this.$refs.table.clearSelection() |
|
|
|
this.$refs.table.toggleRowSelection(row) |
|
|
|
|
|
|
|
// http://192.168.99.67:12010/api/fileRelevant/getImg?imgId=f6d3ecea-0456-4429-ba77-1a4921d5c806 |
|
|
|
|
|
|
|
this.currentMarkData = row |
|
|
|
if (this.activeIndex === 0) { |
|
|
|
if (row.floorMap) { |
|
|
|
this.imageFloorUrl = this.baseApi + '/api/fileRelevant/getImg?imgId=' + row.floorMap |
|
|
|
if (row.signPoint) { |
|
|
|
const drawinfo = JSON.parse(row.signPoint) |
|
|
|
this.initCanvasPreview(drawinfo) |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.imageFloorUrl = this.defaultImg |
|
|
|
} |
|
|
@ -256,9 +277,13 @@ export default { |
|
|
|
}, |
|
|
|
changeActiveTab(data) { |
|
|
|
this.activeIndex = data |
|
|
|
console.log(this.crud.selections) |
|
|
|
if (this.crud.selections.length === 1) { |
|
|
|
// if (this.canvasPreview) { |
|
|
|
// this.canvasPreview.clear() |
|
|
|
// this.canvasPreview.dispose() |
|
|
|
// } |
|
|
|
if (this.crud.selections[0].floorMap) { |
|
|
|
this.currentMarkData = this.crud.selections[0] |
|
|
|
this.imageFloorUrl = this.baseApi + '/api/fileRelevant/getImg?imgId=' + this.crud.selections[0].floorMap |
|
|
|
} else { |
|
|
|
this.imageFloorUrl = this.defaultImg |
|
|
@ -268,6 +293,14 @@ export default { |
|
|
|
} else { |
|
|
|
this.imageRegionUrl = this.defaultImg |
|
|
|
} |
|
|
|
|
|
|
|
if (this.activeIndex === 0) { |
|
|
|
if (this.crud.selections[0].signPoint) { |
|
|
|
console.log('1111') |
|
|
|
const drawinfo = JSON.parse(this.crud.selections[0].signPoint) |
|
|
|
this.initCanvasPreview(drawinfo) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
async handleMark() { |
|
|
@ -339,6 +372,88 @@ export default { |
|
|
|
this.$message({ message: '保存成功', type: 'success', offset: 8 }) |
|
|
|
this.crud.refresh() |
|
|
|
}) |
|
|
|
}, |
|
|
|
handleCloseDialog() { |
|
|
|
// this.$refs.markRefs.canvas.clear() |
|
|
|
// this.$refs.markRefs.canvas.dispose() |
|
|
|
this.markVisible = false |
|
|
|
}, |
|
|
|
initCanvasPreview(drawinfo) { |
|
|
|
this.canvasPreview = new fabric.Canvas('canvasPreview', { |
|
|
|
skipTargetFind: false, |
|
|
|
selectable: false, |
|
|
|
selection: false |
|
|
|
}) |
|
|
|
|
|
|
|
this.canvasPreview.selectionColor = 'rgba(0,0,0,0.05)' |
|
|
|
this.loadDrawPreview(drawinfo) |
|
|
|
this.canvasPreview.on('mouse:wheel', this.mouse) |
|
|
|
}, |
|
|
|
// 鼠标滚轮放大缩小 |
|
|
|
mouse(e) { |
|
|
|
if (undefined === e) return |
|
|
|
let zoom = (e.e.deltaY > 0 ? -0.1 : 0.1) + this.canvasPreview.getZoom() |
|
|
|
zoom = Math.max(0.8, zoom) |
|
|
|
// 最小为原来的1/10 |
|
|
|
zoom = Math.min(3, zoom) |
|
|
|
// 最大是原来的3倍 |
|
|
|
const zoomPoint = new fabric.Point(e.e.pageX, e.e.pageY) |
|
|
|
this.canvasPreview.zoomToPoint(zoomPoint, zoom) |
|
|
|
}, |
|
|
|
// 回显详情信息 |
|
|
|
loadDrawPreview(drawinfo) { |
|
|
|
const self = this |
|
|
|
const pointGroup = drawinfo.pointInfo |
|
|
|
const imgInfo = drawinfo.imgInfo |
|
|
|
imgInfo.src = self.imageFloorUrl |
|
|
|
// 加载底图 |
|
|
|
fabric.util.enlivenObjects([imgInfo], objects => { |
|
|
|
objects.forEach(o => { |
|
|
|
o.selectable = false |
|
|
|
o.hasControls = false |
|
|
|
o.centeredScaling = false |
|
|
|
self.canvasPreview.add(o) |
|
|
|
}) |
|
|
|
// 处理多边形绘制回显操作 |
|
|
|
pointGroup.forEach(async(item, index) => { |
|
|
|
if (item.pointInfo !== '') { |
|
|
|
const polygon = new fabric.Polygon(item.pointInfo, { |
|
|
|
name: item.name, |
|
|
|
stroke: 'rgba(196,43, 1, 1)', |
|
|
|
strokeWidth: self.drawWidth, |
|
|
|
fill: 'rgba(196,43, 1, 0.3)', |
|
|
|
opacity: 1, |
|
|
|
selectable: false, |
|
|
|
hasBorders: false, |
|
|
|
hasControls: false, |
|
|
|
originX: 'left', // 设置原点为左上角 |
|
|
|
originY: 'top' // 设置原点为左上角 |
|
|
|
}) |
|
|
|
polygon.index = index |
|
|
|
self.canvasPreview.add(polygon) |
|
|
|
|
|
|
|
polygon.on('mousedown', function(e) { |
|
|
|
console.log('Rect ' + (index + 1) + ' clicked', e) |
|
|
|
console.log('e.target.name', e.target.name) |
|
|
|
}) |
|
|
|
|
|
|
|
polygon.on('mouseover', function(e) { |
|
|
|
console.log('e', e) |
|
|
|
console.log('e.target', e.target) |
|
|
|
console.log('e.target.name', e.target.name) |
|
|
|
this.set({ opacity: 0.3, hoverCursor: 'pointer' }) |
|
|
|
self.canvasPreview.renderAll() |
|
|
|
}) |
|
|
|
|
|
|
|
// 监听鼠标移出事件 |
|
|
|
polygon.on('mouseout', function() { |
|
|
|
this.set({ opacity: 1 }) |
|
|
|
self.canvasPreview.renderAll() |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
self.canvasPreview.renderAll() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|