|
@@ -16,7 +16,7 @@ export default {
|
|
|
name: 'MarkCanvas',
|
|
|
props: {
|
|
|
// 当前鼠标操作类型
|
|
|
- mouseStatus: {
|
|
|
+ status: {
|
|
|
type: String,
|
|
|
default: 'move',
|
|
|
required: true
|
|
@@ -28,12 +28,13 @@ export default {
|
|
|
},
|
|
|
//canvas绘制图片的数据(eg:添加表情包)
|
|
|
drawImgData: {
|
|
|
- type: [String, Object],
|
|
|
+ // type: [String, Object],
|
|
|
default: ''
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ imgData:undefined,
|
|
|
stage: undefined,
|
|
|
orgLayer: undefined,
|
|
|
markLayer: undefined,
|
|
@@ -49,7 +50,7 @@ export default {
|
|
|
x: 0,
|
|
|
y: 0
|
|
|
},
|
|
|
- // mouseStatus: 'move', //move:移动 rect:画矩形 resize:调整图形
|
|
|
+ mouseStatus: '', //move:移动 rect:画矩形 resize:调整图形
|
|
|
resizeBefore: '',
|
|
|
rect: undefined,
|
|
|
oval: undefined,
|
|
@@ -67,18 +68,12 @@ export default {
|
|
|
}
|
|
|
return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4())
|
|
|
},
|
|
|
- move(index) {
|
|
|
- this.activeIcon = index
|
|
|
+ move() {
|
|
|
this.mouseStatus = 'move'
|
|
|
},
|
|
|
- drawImg(imgIndex) {
|
|
|
- // this.activeIcon = imgIndex
|
|
|
- // this.curImg = new Image()
|
|
|
- // this.curImg.src = this.imgs[imgIndex]
|
|
|
- // this.curImg.onload = () => {
|
|
|
- // this.mouseStatus = 'img'
|
|
|
- // this.startImg({ x: 100, y: 100 })
|
|
|
- // }
|
|
|
+ drawImg() {
|
|
|
+ this.mouseStatus = 'img'
|
|
|
+ this.startImg({ x: 100, y: 100 })
|
|
|
},
|
|
|
startImg(current) {
|
|
|
let _this = this
|
|
@@ -86,7 +81,7 @@ export default {
|
|
|
id: this.uuid(),
|
|
|
draggable: false,
|
|
|
strokeScaleEnabled: false,
|
|
|
- image: _this.curImg,
|
|
|
+ image: _this.imgData ,
|
|
|
width: 80,
|
|
|
height: 80,
|
|
|
x: current.x,
|
|
@@ -113,8 +108,7 @@ export default {
|
|
|
this.stage.add(this.markLayer)
|
|
|
this.img = null
|
|
|
},
|
|
|
- drawText(index) {
|
|
|
- this.activeIcon = index
|
|
|
+ drawText() {
|
|
|
this.mouseStatus = 'text'
|
|
|
},
|
|
|
startText(current) {
|
|
@@ -212,8 +206,7 @@ export default {
|
|
|
this.markLayer.add(this.text)
|
|
|
this.stage.add(this.markLayer)
|
|
|
},
|
|
|
- drawLine(index) {
|
|
|
- this.activeIcon = index
|
|
|
+ drawLine() {
|
|
|
this.mouseStatus = 'line'
|
|
|
},
|
|
|
startLine(current) {
|
|
@@ -250,8 +243,7 @@ export default {
|
|
|
this.markLayer.add(this.line)
|
|
|
this.stage.add(this.markLayer)
|
|
|
},
|
|
|
- drawArrow(index) {
|
|
|
- this.activeIcon = index
|
|
|
+ drawArrow() {
|
|
|
this.mouseStatus = 'arrow'
|
|
|
},
|
|
|
// 绘制箭头
|
|
@@ -294,8 +286,7 @@ export default {
|
|
|
this.markLayer.add(this.arrow)
|
|
|
this.stage.add(this.markLayer)
|
|
|
},
|
|
|
- drawOval(index) {
|
|
|
- this.activeIcon = index
|
|
|
+ drawOval() {
|
|
|
this.mouseStatus = 'oval'
|
|
|
},
|
|
|
startOval(current) {
|
|
@@ -346,18 +337,8 @@ export default {
|
|
|
this.markLayer.add(this.oval)
|
|
|
this.stage.add(this.markLayer)
|
|
|
},
|
|
|
- drawIcon(index) {
|
|
|
- this.activeIcon = index
|
|
|
- },
|
|
|
- review(index) {
|
|
|
- this.activeIcon = index
|
|
|
- },
|
|
|
- cancelFull(index) {
|
|
|
- this.activeIcon = index
|
|
|
- },
|
|
|
//绘制矩形
|
|
|
- drawRect(index) {
|
|
|
- this.activeIcon = index
|
|
|
+ drawRect() {
|
|
|
this.mouseStatus = 'rect'
|
|
|
},
|
|
|
startRect(current) {
|
|
@@ -444,11 +425,6 @@ export default {
|
|
|
this.myScale()
|
|
|
}
|
|
|
},
|
|
|
- //还原比例
|
|
|
- restore() {
|
|
|
- this.scaleDefault = 1
|
|
|
- this.myScale()
|
|
|
- },
|
|
|
myScale() {
|
|
|
this.stage.children.forEach(item => {
|
|
|
item.scale({
|
|
@@ -582,8 +558,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
//清除所有批注
|
|
|
- clear(index) {
|
|
|
- this.activeIcon = index
|
|
|
+ clear() {
|
|
|
this.markLayer.removeChildren()
|
|
|
this.stage.add(this.markLayer)
|
|
|
}
|
|
@@ -640,7 +615,7 @@ export default {
|
|
|
bgImg: {
|
|
|
handler(n, o) {
|
|
|
this.$nextTick(() => {
|
|
|
- // this.restore()
|
|
|
+ this.restore()
|
|
|
this.orgLayer.removeChildren()
|
|
|
this.markLayer.removeChildren()
|
|
|
let imageObj = new Image()
|
|
@@ -667,6 +642,18 @@ export default {
|
|
|
},
|
|
|
immediate: true,
|
|
|
deep: true
|
|
|
+ },
|
|
|
+ drawImgData: {
|
|
|
+ handler(n, o) {
|
|
|
+ this.imgData = n
|
|
|
+ this.drawImg()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ status:{
|
|
|
+ handler(n,o){
|
|
|
+ this.mouseStatus = n
|
|
|
+ },
|
|
|
+ immediate:true
|
|
|
}
|
|
|
}
|
|
|
}
|