|
@@ -12,7 +12,7 @@
|
|
|
<SvgIcon name="zoom-"/>
|
|
|
</div>
|
|
|
</el-tooltip>
|
|
|
- <el-dropdown :teleported="false" :popper-options="{
|
|
|
+ <el-dropdown :teleported="false" placement="top" :popper-options="{
|
|
|
modifiers: [
|
|
|
{
|
|
|
name: 'offset',
|
|
@@ -44,18 +44,29 @@
|
|
|
</div>
|
|
|
<div class="history">
|
|
|
<el-tooltip content="撤销" effect="light" placement="top" :show-arrow="false">
|
|
|
- <div class="__hover-bg" :class="{__disabled: !state.history.canUndo}" @click="onUndo">
|
|
|
+ <div class="__hover-bg" :class="{__disabled: !state.history.canUndo}" @click="onUndo(1)">
|
|
|
<SvgIcon name="back"/>
|
|
|
</div>
|
|
|
</el-tooltip>
|
|
|
<el-tooltip content="重做" effect="light" placement="top" :show-arrow="false">
|
|
|
- <div class="__hover-bg" :class="{__disabled: !state.history.canRedo}" @click="onRedo">
|
|
|
+ <div class="__hover-bg" :class="{__disabled: !state.history.canRedo}" @click="onRedo(1)">
|
|
|
<SvgIcon name="back" rotate="180"/>
|
|
|
</div>
|
|
|
</el-tooltip>
|
|
|
-<!-- <div class="__hover-bg">-->
|
|
|
-<!-- <SvgIcon name="history"/>-->
|
|
|
-<!-- </div>-->
|
|
|
+ <el-popover :show-arrow="false">
|
|
|
+ <template #reference>
|
|
|
+ <div class="__hover-bg">
|
|
|
+ <SvgIcon name="history"/>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <div class="history">
|
|
|
+ <div>变更历史</div>
|
|
|
+ <div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ 变更心事
|
|
|
+ </div>
|
|
|
+ </el-popover>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -161,9 +172,9 @@ const state: any = reactive({
|
|
|
isInitEdges: false,
|
|
|
zoom: 1,
|
|
|
history: {
|
|
|
- isInit: false,
|
|
|
canUndo: false,
|
|
|
canRedo: false,
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
const ref_chart = ref()
|
|
@@ -283,8 +294,10 @@ const initWatch = () => {
|
|
|
state.graph.on('scale', ({ sx, sy, ox, oy }) => {
|
|
|
state.zoom = sx
|
|
|
})
|
|
|
- state.graph.on('history:change', () => {
|
|
|
+ state.graph.on('history:change', (p) => {
|
|
|
if (state.isInitEdges) {
|
|
|
+ console.log(123)
|
|
|
+ console.log(p)
|
|
|
state.history.canRedo = state.graph.canRedo()
|
|
|
state.history.canUndo = state.graph.canUndo()
|
|
|
}
|
|
@@ -318,14 +331,18 @@ const graphZoom = (z) => {
|
|
|
state.graph.zoomToFit({ maxScale: 1 })
|
|
|
}
|
|
|
}
|
|
|
-const onUndo = () => {
|
|
|
- if (state.history.canUndo) {
|
|
|
- state.graph.undo()
|
|
|
+const onUndo = (step) => {
|
|
|
+ for (let i = 1; i <= step; i++) {
|
|
|
+ if (state.history.canUndo) {
|
|
|
+ state.graph.undo()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-const onRedo = () => {
|
|
|
- if (state.history.canRedo) {
|
|
|
- state.graph.redo()
|
|
|
+const onRedo = (step) => {
|
|
|
+ for (let i = 1; i <= step; i++) {
|
|
|
+ if (state.history.canRedo) {
|
|
|
+ state.graph.redo()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
watch(() => props.data, (n) => {
|