|
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
|
<!--
* @Description: 工具栏
-->
<template>
<div class="operating-area">
<!-- 头部操作按钮区域 start -->
<!-- 操作左侧区域 start -->
<div class="left-btn-box">
<Tooltip v-for="item in toolbarsConfigs" :title="item.title" :key="item.icon">
<a @click="$emit(item.event)" class="toolbar-text">
<Icon :icon="item.icon" />
</a>
</Tooltip>
<Divider type="vertical" />
<Tooltip title="撤销">
<a :class="{ disabled: !canUndo }" :disabled="!canUndo" @click="undo">
<Icon icon="ant-design:undo-outlined" />
</a>
</Tooltip>
<Tooltip title="重做">
<a :class="{ disabled: !canRedo }" :disabled="!canRedo" @click="redo">
<Icon icon="ant-design:redo-outlined" />
</a>
</Tooltip>
</div>
</div>
<!-- 操作区域 start -->
</template>
<script lang="ts">
import { defineComponent, inject, reactive, toRefs } from 'vue';
import { UseRefHistoryReturn } from '@vueuse/core';
import { IFormConfig } from '../../../typings/v-form-component';
import { Tooltip, Divider } from 'ant-design-vue';
|
vben
authored
|
34
|
import Icon from '@/components/Icon/Icon.vue';
|
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
interface IToolbarsConfig {
type: string;
title: string;
icon: string;
event: string;
}
export default defineComponent({
name: 'OperatingArea',
components: {
Tooltip,
Icon,
Divider,
},
setup() {
const state = reactive<{
toolbarsConfigs: IToolbarsConfig[];
}>({
toolbarsConfigs: [
{
|
|
56
|
title: '预览-支持布局',
|
|
57
58
59
60
61
|
type: 'preview',
event: 'handlePreview',
icon: 'ant-design:chrome-filled',
},
{
|
|
62
|
title: '预览-不支持布局',
|
|
63
64
65
66
67
|
type: 'preview',
event: 'handlePreview2',
icon: 'ant-design:chrome-filled',
},
{
|
|
68
|
title: '导入JSON',
|
|
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
|
type: 'importJson',
event: 'handleOpenImportJsonModal',
icon: 'ant-design:import-outlined',
},
{
title: '生成JSON',
type: 'exportJson',
event: 'handleOpenJsonModal',
icon: 'ant-design:export-outlined',
},
{
title: '生成代码',
type: 'exportCode',
event: 'handleOpenCodeModal',
icon: 'ant-design:code-filled',
},
{
title: '清空',
type: 'reset',
event: 'handleClearFormItems',
icon: 'ant-design:clear-outlined',
},
],
});
const historyRef = inject('historyReturn') as UseRefHistoryReturn<IFormConfig, IFormConfig>;
const { undo, redo, canUndo, canRedo } = historyRef;
return { ...toRefs(state), undo, redo, canUndo, canRedo };
},
});
</script>
<style lang="less" scoped>
//noinspection CssUnknownTarget
@import url('../styles/variable.less');
.operating-area {
display: flex;
align-content: center;
|
vben
authored
|
108
109
110
|
justify-content: space-between;
height: @operating-area-height;
padding: 0 12px;
|
|
111
|
padding-left: 30px;
|
vben
authored
|
112
113
114
115
|
border-bottom: 2px solid @border-color;
font-size: 16px;
line-height: @operating-area-height;
text-align: left;
|
|
116
117
118
|
a {
margin: 0 5px;
|
vben
authored
|
119
|
color: #666;
|
|
120
121
122
123
124
125
126
127
128
129
130
131
|
&.disabled,
&.disabled:hover {
color: #ccc;
}
&:hover {
color: @primary-color;
}
> span {
padding-left: 2px;
|
vben
authored
|
132
|
font-size: 14px;
|
|
133
134
135
136
|
}
}
}
</style>
|