提交 5145b193 authored 作者: wangjiahao's avatar wangjiahao

refactor:切换矩阵式与悬浮时建议优化

上级 16c901e6
...@@ -1603,7 +1603,7 @@ export default { ...@@ -1603,7 +1603,7 @@ export default {
style.height = height style.height = height
style.rotate = this.rotate style.rotate = this.rotate
// this.hasMove = true // this.hasMove = true
// console.log('recordMatrixCurShadowStyle:t1:' + t1 + ';mw:' + this.curCanvasScale.matrixStyleWidth + ';width:' + width) console.log('recordMatrixCurShadowStyle:t1:' + JSON.stringify(style))
this.$store.commit('setShapeStyle', style) this.$store.commit('setShapeStyle', style)
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
@onResizing="onResizing" @onResizing="onResizing"
@elementMouseDown="containerMouseDown" @elementMouseDown="containerMouseDown"
@amRemoveItem="removeItem(item._dragId)" @amRemoveItem="removeItem(item._dragId)"
@amAddItme="addItemBox(item)" @amAddItem="addItemBox(item)"
@linkJumpSet="linkJumpSet(item)" @linkJumpSet="linkJumpSet(item)"
> >
<!-- <span style="position:relative;left: 0px;top:0px">--> <!-- <span style="position:relative;left: 0px;top:0px">-->
...@@ -338,6 +338,7 @@ function recalcCellWidth() { ...@@ -338,6 +338,7 @@ function recalcCellWidth() {
} }
function init() { function init() {
console.log('init')
this.cellWidth = this.baseWidth + this.baseMarginLeft this.cellWidth = this.baseWidth + this.baseMarginLeft
this.cellHeight = this.baseHeight + this.baseMarginTop this.cellHeight = this.baseHeight + this.baseMarginTop
this.yourList = this.getList() this.yourList = this.getList()
...@@ -357,7 +358,6 @@ function init() { ...@@ -357,7 +358,6 @@ function init() {
recalcCellWidth.call(this) recalcCellWidth.call(this)
resetPositionBox.call(this) resetPositionBox.call(this)
let i = 0 let i = 0
// console.log('initList:' + JSON.stringify(vm.yourList)) // console.log('initList:' + JSON.stringify(vm.yourList))
const timeid = setInterval(function() { const timeid = setInterval(function() {
...@@ -376,6 +376,7 @@ function init() { ...@@ -376,6 +376,7 @@ function init() {
} }
function resizePlayer(item, newSize) { function resizePlayer(item, newSize) {
// console.log('resizePlayer')
const vm = this const vm = this
removeItemFromPositionBox(item) removeItemFromPositionBox(item)
...@@ -424,6 +425,7 @@ function resizePlayer(item, newSize) { ...@@ -424,6 +425,7 @@ function resizePlayer(item, newSize) {
* @param {any} position * @param {any} position
*/ */
function checkItemPosition(item, position) { function checkItemPosition(item, position) {
// console.log('checkItemPosition-info' + JSON.stringify(item))
position = position || {} position = position || {}
position.x = position.x || item.x position.x = position.x || item.x
position.y = position.y || item.y position.y = position.y || item.y
...@@ -469,6 +471,7 @@ function checkItemPosition(item, position) { ...@@ -469,6 +471,7 @@ function checkItemPosition(item, position) {
* @param {any} position * @param {any} position
*/ */
function movePlayer(item, position) { function movePlayer(item, position) {
// console.log('movePlayer')
const vm = this const vm = this
removeItemFromPositionBox(item) removeItemFromPositionBox(item)
...@@ -483,7 +486,7 @@ function movePlayer(item, position) { ...@@ -483,7 +486,7 @@ function movePlayer(item, position) {
item.x = position.x item.x = position.x
item.y = position.y item.y = position.y
// console.log('checkItemPosition3')
checkItemPosition.call(this, item, position) checkItemPosition.call(this, item, position)
emptyTargetCell.call(this, item) emptyTargetCell.call(this, item)
...@@ -520,11 +523,13 @@ function removeItem(index) { ...@@ -520,11 +523,13 @@ function removeItem(index) {
} }
function addItem(item, index) { function addItem(item, index) {
// console.log('addItem')
if (index < 0) { if (index < 0) {
index = this.yourList.length index = this.yourList.length
} }
item._dragId = index item._dragId = index
// console.log('checkItemPosition4')
checkItemPosition.call(this, item, { checkItemPosition.call(this, item, {
x: item.x, x: item.x,
y: item.y y: item.y
...@@ -652,6 +657,7 @@ function changeItemCoord(item) { ...@@ -652,6 +657,7 @@ function changeItemCoord(item) {
* @param {any} item * @param {any} item
*/ */
function emptyTargetCell(item) { function emptyTargetCell(item) {
// console.log('emptyTargetCell')
const vm = this const vm = this
const belowItems = findBelowItems(item) const belowItems = findBelowItems(item)
...@@ -708,6 +714,7 @@ function moveItemDown(item, size) { ...@@ -708,6 +714,7 @@ function moveItemDown(item, size) {
y: item.y + size y: item.y + size
} }
setPlayerPosition.call(this, item, targetPosition) setPlayerPosition.call(this, item, targetPosition)
// console.log('checkItemPosition1')
checkItemPosition.call(this, item, targetPosition) checkItemPosition.call(this, item, targetPosition)
addItemToPositionBox.call(this, item) addItemToPositionBox.call(this, item)
...@@ -1458,6 +1465,7 @@ export default { ...@@ -1458,6 +1465,7 @@ export default {
infoBox.oldSizeY = item.sizey infoBox.oldSizeY = item.sizey
}, },
onMouseUp(e) { onMouseUp(e) {
// console.log('onMouseUp')
const vm = this const vm = this
if (_.isEmpty(vm.infoBox)) return if (_.isEmpty(vm.infoBox)) return
if (vm.infoBox.cloneItem) { if (vm.infoBox.cloneItem) {
...@@ -1626,6 +1634,7 @@ export default { ...@@ -1626,6 +1634,7 @@ export default {
}, 100) }, 100)
}, },
addItemBox(item) { addItemBox(item) {
// console.log('addItemBox:' + JSON.stringify(item))
this.yourList.push(item) this.yourList.push(item)
this.$nextTick(function() { this.$nextTick(function() {
......
...@@ -3,6 +3,7 @@ import toast from '@/components/canvas/utils/toast' ...@@ -3,6 +3,7 @@ import toast from '@/components/canvas/utils/toast'
import generateID from '@/components/canvas/utils/generateID' import generateID from '@/components/canvas/utils/generateID'
import { deepCopy } from '@/components/canvas/utils/utils' import { deepCopy } from '@/components/canvas/utils/utils'
import { chartCopy } from '@/api/chart/chart' import { chartCopy } from '@/api/chart/chart'
import { uuid } from 'vue-uuid'
export default { export default {
state: { state: {
...@@ -46,11 +47,14 @@ export default { ...@@ -46,11 +47,14 @@ export default {
if (data.type === 'view') { if (data.type === 'view') {
chartCopy(data.propValue.viewId).then(res => { chartCopy(data.propValue.viewId).then(res => {
const newView = deepCopy(data) const newView = deepCopy(data)
newView.id = uuid.v1()
newView.propValue.viewId = res.data newView.propValue.viewId = res.data
store.commit('addComponent', { component: newView }) store.commit('addComponent', { component: newView })
}) })
} else { } else {
store.commit('addComponent', { component: deepCopy(data) }) const newCop = deepCopy(data)
newCop.id = uuid.v1()
store.commit('addComponent', { component: newCop })
} }
if (state.isCut) { if (state.isCut) {
state.copyData = null state.copyData = null
......
...@@ -813,7 +813,7 @@ export default { ...@@ -813,7 +813,7 @@ export default {
} }
}, },
canvasScroll(event) { canvasScroll(event) {
console.log('testTop' + event.target.scrollTop) // console.log('testTop' + event.target.scrollTop)
this.scrollLeft = event.target.scrollLeft this.scrollLeft = event.target.scrollLeft
this.scrollTop = event.target.scrollTop this.scrollTop = event.target.scrollTop
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论