2022-03-15 17:49:02 +08:00
|
|
|
|
<template>
|
|
|
|
|
<sketch-rule
|
2022-08-21 14:42:31 +08:00
|
|
|
|
v-if="configShow"
|
2022-03-15 17:49:02 +08:00
|
|
|
|
:thick="thick"
|
|
|
|
|
:scale="scale"
|
2022-08-21 14:42:31 +08:00
|
|
|
|
:width="canvasBox().width"
|
|
|
|
|
:height="canvasBox().height"
|
2022-03-15 17:49:02 +08:00
|
|
|
|
:startX="startX"
|
|
|
|
|
:startY="startY"
|
|
|
|
|
:lines="lines"
|
|
|
|
|
></sketch-rule>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2022-11-05 21:16:34 +08:00
|
|
|
|
import { ref, toRefs, computed, watch, nextTick, onBeforeUnmount } from 'vue'
|
2022-03-15 17:49:02 +08:00
|
|
|
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
|
|
|
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
2022-11-05 21:16:34 +08:00
|
|
|
|
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
|
2022-03-15 17:49:02 +08:00
|
|
|
|
|
|
|
|
|
const chartEditStore = useChartEditStore()
|
2022-11-05 21:16:34 +08:00
|
|
|
|
const chartLayoutStore = useChartLayoutStore()
|
2022-03-15 17:49:02 +08:00
|
|
|
|
const designStore = useDesignStore()
|
|
|
|
|
|
|
|
|
|
const { width, height } = toRefs(chartEditStore.getEditCanvasConfig)
|
2022-11-05 21:16:34 +08:00
|
|
|
|
const { scale, lockScale } = toRefs(chartEditStore.getEditCanvas)
|
|
|
|
|
const { getLayers, getCharts, getDetails } = toRefs(chartLayoutStore)
|
2022-03-15 17:49:02 +08:00
|
|
|
|
|
2022-08-21 14:42:31 +08:00
|
|
|
|
const configShow = ref(true)
|
|
|
|
|
|
2022-03-15 17:49:02 +08:00
|
|
|
|
// x轴标尺开始的坐标数值
|
2022-08-21 14:42:31 +08:00
|
|
|
|
const startX = -10
|
2022-03-15 17:49:02 +08:00
|
|
|
|
// y轴标尺开始的坐标数值
|
2022-08-21 14:42:31 +08:00
|
|
|
|
const startY = -10
|
2022-03-15 17:49:02 +08:00
|
|
|
|
// 标尺的厚度
|
|
|
|
|
const thick = 20
|
|
|
|
|
// 初始化水平标尺上的参考线
|
|
|
|
|
const lines = {
|
|
|
|
|
h: [],
|
|
|
|
|
v: []
|
|
|
|
|
}
|
2022-08-19 10:02:09 +08:00
|
|
|
|
|
2022-08-21 14:42:31 +08:00
|
|
|
|
const canvasBox = () => {
|
|
|
|
|
const layoutDom = document.getElementById('go-chart-edit-layout')
|
|
|
|
|
if (layoutDom) {
|
|
|
|
|
return {
|
|
|
|
|
height: layoutDom.clientHeight - 40,
|
|
|
|
|
width: layoutDom.clientWidth
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
width: width.value,
|
|
|
|
|
height: height.value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-19 10:02:09 +08:00
|
|
|
|
// 颜色
|
|
|
|
|
const themeColor = computed(() => {
|
|
|
|
|
return designStore.getAppTheme
|
|
|
|
|
})
|
|
|
|
|
|
2022-08-21 14:42:31 +08:00
|
|
|
|
// 处理标尺重制大小
|
2022-11-05 21:16:34 +08:00
|
|
|
|
const ruleChangeHandle = () => {
|
|
|
|
|
configShow.value = false
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
configShow.value = true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ruleChangeHandleTimeOut = () => {
|
|
|
|
|
if (lockScale.value) {
|
2022-08-21 14:42:31 +08:00
|
|
|
|
setTimeout(() => {
|
2022-11-05 21:16:34 +08:00
|
|
|
|
ruleChangeHandle()
|
|
|
|
|
}, 500)
|
2022-08-21 14:42:31 +08:00
|
|
|
|
}
|
2022-11-05 21:16:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => scale.value,
|
|
|
|
|
() => ruleChangeHandle()
|
2022-08-21 14:42:31 +08:00
|
|
|
|
)
|
2022-11-05 21:16:34 +08:00
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => getLayers.value,
|
|
|
|
|
() => ruleChangeHandleTimeOut()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => getCharts.value,
|
|
|
|
|
() => ruleChangeHandleTimeOut()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => getDetails.value,
|
|
|
|
|
() => ruleChangeHandleTimeOut()
|
|
|
|
|
)
|
|
|
|
|
|
2022-03-15 17:49:02 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
2022-03-15 19:06:19 +08:00
|
|
|
|
/* 使用 SCSS 会报错,直接使用最基础的 CSS 进行修改,
|
|
|
|
|
此库有计划 Vue3 版本,但是开发的时候还没发布 */
|
|
|
|
|
|
2022-05-06 20:29:35 +08:00
|
|
|
|
#mb-ruler {
|
2022-08-21 14:42:31 +08:00
|
|
|
|
top: 0;
|
2022-05-06 20:29:35 +08:00
|
|
|
|
left: 0;
|
|
|
|
|
}
|
2022-08-21 14:42:31 +08:00
|
|
|
|
/* 适配底部的工具栏不遮盖 */
|
|
|
|
|
#mb-ruler .v-container {
|
|
|
|
|
height: calc(100% - 65px) !important;
|
|
|
|
|
}
|
2022-03-15 17:49:02 +08:00
|
|
|
|
/* 横线 */
|
|
|
|
|
#mb-ruler .v-container .lines .line {
|
2022-03-16 11:22:22 +08:00
|
|
|
|
/* 最大缩放 200% */
|
2022-08-21 14:42:31 +08:00
|
|
|
|
width: 200vw !important;
|
2022-03-15 17:49:02 +08:00
|
|
|
|
border-top: 1px dashed v-bind('themeColor') !important;
|
|
|
|
|
}
|
|
|
|
|
#mb-ruler .v-container .indicator {
|
|
|
|
|
border-bottom: 1px dashed v-bind('themeColor') !important;
|
|
|
|
|
}
|
|
|
|
|
/* 竖线 */
|
|
|
|
|
#mb-ruler .h-container .lines .line {
|
2022-03-16 11:22:22 +08:00
|
|
|
|
/* 最大缩放 200% */
|
2022-08-21 14:42:31 +08:00
|
|
|
|
height: 200vh !important;
|
2022-03-15 17:49:02 +08:00
|
|
|
|
border-left: 1px dashed v-bind('themeColor') !important;
|
|
|
|
|
}
|
|
|
|
|
#mb-ruler .h-container .indicator {
|
|
|
|
|
border-left: 1px dashed v-bind('themeColor') !important;
|
|
|
|
|
}
|
|
|
|
|
/* 坐标数值背景颜色 */
|
|
|
|
|
#mb-ruler .indicator .value {
|
|
|
|
|
background-color: rgba(0, 0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
/* 删除按钮 */
|
|
|
|
|
#mb-ruler .line .del {
|
|
|
|
|
padding: 0;
|
|
|
|
|
color: v-bind('themeColor');
|
|
|
|
|
font-size: 26px;
|
|
|
|
|
font-weight: bolder;
|
|
|
|
|
}
|
2022-05-06 20:29:35 +08:00
|
|
|
|
|
2022-08-21 14:42:31 +08:00
|
|
|
|
#mb-ruler .corner {
|
|
|
|
|
border-width: 0 !important;
|
2022-03-15 17:49:02 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|