1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<template>
  <toolbar class="toolbar">
    <template>
      <toolbar-button command="undo" text="撤销"/>
      <toolbar-button command="redo" text="重做"/>
<!--      <toolbar-button command="copy" text="复制"/>-->
<!--      <toolbar-button command="paste" text="粘贴"/>-->
      <div class="split"></div>
    </template>
    <toolbar-button command="zoomIn" icon="zoom-in" text="放大"/>
    <toolbar-button command="zoomOut" icon="zoom-out" text="缩小"/>
    <toolbar-button command="autoZoom" icon="fit" text="自适应"/>
    <toolbar-button command="resetZoom" icon="actual-size" text="实际尺寸"/>
    <template>
      <div class="split"></div>
      <!-- <toolbar-button command="toBack" icon="to-back" text="向下一层" /> -->
      <!-- <toolbar-button command="toFront" icon="to-front" text="向上一层" /> -->
      <!-- <toolbar-button command="addGroup" icon="group" text="编组" /> -->
      <!-- <toolbar-button command="unGroup" icon="ungroup" text="取消编组" /> -->
      <toolbar-button command="selectAll" icon="select-all" text="全选"/>
      <toolbar-button command="multiSelect" icon="select" text="框选"/>
      <div v-if="disabledBtn" class="split"></div>
      <toolbar-button  command="delete" text="删除"/>
      <toolbar-button  command="clear" icon="clear" text="清空画布"/>
    </template>
    <template>
      <div class="split"></div>
      <toolbar-button
        command="downloadImage"
        icon="image"
        text="下载图像"
      />
    </template>
    <!--    <el-button>{{this.$store}}</el-button>-->
    <el-button :disabled="!disabledBtn" icon="el-icon-check" plain size="small" type="success"
               @click="saveClickHandler">保存
    </el-button>
    <el-button :disabled="!disabledBtn" icon="el-icon-close" plain size="small" type="danger"
               @click="removeClickHandler">取消
    </el-button>
    <!-- right toolbar button -->
    <!--  <div class="pull-right">-->
    <!--      <toolbar-button-->
    <!--        command="generateData"-->
    <!--        icon="save"-->
    <!--        text="生成数据"-->
    <!--        label="保存数据"-->
    <!--      />-->
    <!--    </div>-->
  </toolbar>
</template>
 
<script>
import {Toolbar} from 'vue-flowchart-editor'
import ToolbarButton from './ToolbarButton'
 
export default {
  name: 'FlowToolbar',
 
  components: {
    Toolbar,
    ToolbarButton,
  },
 
  props: ['chartData', 'toggleReadOnly'],
  created() {
 
  },
  computed: {
    disabledBtn() {
      return this.$store.state.flow.methodBtn;
    }
  },
 
  methods: {
    // 取消按钮点击
    removeClickHandler() {
      this.$confirm("您确认执行取消操作?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$store.dispatch('updateMethodBtn', false);
        this.$store.dispatch('typeChange', '');
        console.log(this.$s)
        // this.$emit('reset-tree'); // 触发父组件重置
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
 
    // 保存按钮点击事件
    saveClickHandler(){
      this.$emit('handler-save');
    },
  },
}
</script>
 
<style lang="scss" scoped>
.toolbar {
  display: flex;
  align-items: center;
  height: 27px;
 
  .split {
    width: 10px;
    height: 100%;
    border-right: 1px solid #eee;
    margin-right: 10px;
  }
 
  .pull-right {
    display: flex;
    align-items: center;
    margin-left: auto;
  }
 
  .command {
    margin-right: 15px;
    display: flex;
    color: #333;
 
    i {
      display: block;
      width: 27px;
      height: 27px;
      margin: 0 6px;
      padding-top: 10px;
      text-align: center;
      border: 1px solid #fff;
      cursor: pointer;
    }
 
    span {
      display: block;
      font-size: 12px;
      padding-top: 10px;
      margin-left: -6px;
      padding-right: 6px;
      line-height: 20px;
      cursor: pointer;
    }
 
    &:hover {
      color: #1890ff;
    }
  }
 
  .disable {
    color: rgba(0, 0, 0, 0.25);
 
    i {
      cursor: not-allowed;
    }
 
    span {
      cursor: not-allowed;
    }
 
    &:hover {
      color: rgba(0, 0, 0, 0.25);
    }
  }
}
</style>