This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/project/L5/topologyTopTool.vue

161 lines
5.2 KiB
Vue
Raw Normal View History

<template>
2021-02-02 10:30:45 +08:00
<div class="tool-top" id="tool-top">
<div id="undo" :class="['top-tool-item',]" @click="undo"> <i class="nz-icon nz-icon-revoke" :title="'撤销'"/> </div>
<div id="redo" :class="['top-tool-item',]" @click="redo"> <i class="nz-icon nz-icon-revoke1" :title="'重做'"/> </div>
<!--<div> 保存为图片 </div>-->
2021-02-02 10:30:45 +08:00
<div class="top-tool-item" @click="del"> <i class="nz-icon nz-icon-delete"/> </div>
<div class="top-tool-item top-tool-item-scale">
2021-02-02 19:24:21 +08:00
<span class="scale-number">
<span class="scale-number-minus scale-number-symbol" @click="changeScale(-25)">-</span>
<el-popover
placement="bottom"
width="111"
2021-10-28 16:54:03 +08:00
trigger="hover"
2021-02-02 19:24:21 +08:00
class="scale-number-box"
2021-07-05 16:40:19 +08:00
popper-class="scale-number-popover no-style-class"
2021-02-02 19:24:21 +08:00
>
<div class="scale-num-pop" style=" width: 91px;min-width: 91px">
<div>缩放级别</div>
2021-02-02 19:24:21 +08:00
<div @click="scale(50)" :class="['scale-num-pop',scaleNum==50?'is-active':'']">50</div>
<div @click="scale(100)" :class="['scale-num-pop',scaleNum==100?'is-active':'']">100</div>
<div @click="scale(200)" :class="['scale-num-pop',scaleNum==200?'is-active':'']">200</div>
</div>
<span class="scale-number-content" slot="reference">{{scaleNum}}%</span>
</el-popover>
<span class="scale-number-add scale-number-symbol" @click="changeScale(25)">+</span>
</span>
2021-02-02 10:30:45 +08:00
</div>
<div class="top-tool-item top-tool-item-switch">
<label>{{$t('project.topology.grids')}}</label>
<el-switch
v-model="option.grid"
:active-value="true"
:inactive-value="false"
active-color="#ee9d3f"
@change="changeOption('grid')">
</el-switch>
</div>
<div class="top-tool-item top-tool-item-switch">
<label>{{$t('project.topology.rule')}}</label>
<el-switch
v-model="option.rule"
:active-value="true"
:inactive-value="false"
active-color="#ee9d3f"
@change="changeOption('rule')">
</el-switch>
</div>
</div>
</template>
<script>
2021-03-19 18:52:19 +08:00
import { getTopology } from '../../js/common'
2021-03-19 18:52:19 +08:00
export default {
name: 'topologyTopTool',
data () {
return {
option: {
lineName: 'curve',
lineWidth: 1,
fromArrow: '',
toArrow: 'triangleSolid',
scale: 100,
grid: false,
rule: false
},
scaleNum: 100,
penLineType: [
{ d: 'M5 14 a100,50 0 0,1 85,0', 'stroke-dasharray': '', name: 'curve' },
{ d: 'M5 8 l40 0 l0 12 l40 0', 'stroke-dasharray': '', name: 'polyline' },
{ d: 'M5 14 l85 0', 'stroke-dasharray': '', name: 'line' },
{ d: 'M5 20 C0,8 50,0 85,0', 'stroke-dasharray': '', name: 'mind' }
],
penLineFromTOArrow: [
{ d: 'M5 14 l85 0', points: '', fill: '', stroke: '', 'stroke-width': '', name: '' },
{ d: 'M5 14 l85 0', points: '5 14,20 9,20 19', fill: '#000000', stroke: '', 'stroke-width': '', name: 'triangleSolid' },
{ d: 'M5 14 l85 0', points: '5 14,20 9,20 19', fill: '#ffffff', stroke: '#000000', 'stroke-width': '1', name: 'triangle' },
{ d: 'M5 14 l85 0', fill: '#000000', stroke: '', 'stroke-width': '', cx: '10', cy: '14', r: '5', name: 'circleSolid' },
{ d: 'M5 14 l85 0', fill: '#ffffff', stroke: '#000000', 'stroke-width': '1', cx: '10', cy: '14', r: '5', name: 'circle' }
],
redoFlag: false
}
},
props: {
selection: {
type: Object,
require: true
},
index: {
type: Number,
require: true
},
toolShow: {
type: Object,
require: true
},
cachesIndex: {
type: Number,
require: true
}
},
mounted () {
2021-07-05 16:40:19 +08:00
const dataOption = getTopology(this.index).data
2021-03-19 18:52:19 +08:00
Object.keys(this.option).forEach(key => {
if (key === 'scale') {
this.scaleNum = (JSON.stringify(dataOption[key]) ? parseInt(dataOption[key] * 100) : this.scaleNum)
2021-03-19 18:52:19 +08:00
} else {
this.option[key] = (JSON.stringify(dataOption[key]) ? dataOption[key] : this.option[key])
}
2021-03-19 18:52:19 +08:00
})
},
methods: {
changeOption (key) {
getTopology(this.index).data[key] = this.option[key]
getTopology(this.index).render()
},
2021-03-19 18:52:19 +08:00
undo () { // 撤销
getTopology(this.index).undo()
},
redo () { // 重做
getTopology(this.index).redo()
},
centerView () { // 居中显示
getTopology(this.index).centerView()
},
fitView () { // 自适应画布大小
getTopology(this.index).fitView()
},
changeScale (num) {
this.scaleNum += num
if (this.scaleNum < 25) {
this.scaleNum = 25
}
if (this.scaleNum > 400) {
this.scaleNum = 400
}
2021-03-19 18:52:19 +08:00
this.scale(this.scaleNum)
},
2021-03-19 18:52:19 +08:00
scale (val) {
this.scaleNum = val
getTopology(this.index).scaleTo(val / 100)
},
2021-03-19 18:52:19 +08:00
del () {
const delObj = this.selection.pen ? this.selection.pen.id : this.selection.pens
this.$emit('del', delObj)
},
clear () {
const data = { ...getTopology(this.index).data }
data.pens = []
getTopology(this.index).open({})
},
toolShowChange (attr) {
this.$emit('toolShowChange', attr)
},
changeOpt (key, val) {
}
}
2021-03-19 18:52:19 +08:00
}
</script>