|
@@ -28,15 +28,15 @@
|
|
|
@mousedown="handleMouseDown"
|
|
|
>
|
|
|
<ComponentBand
|
|
|
- v-for="(elementBand, idx) in getElementBands"
|
|
|
+ v-for="(elementBandCode, idx) in getElementBandCodes"
|
|
|
:key="idx"
|
|
|
:ref="getComponentBandRef(idx)"
|
|
|
:is-first="idx === 0"
|
|
|
:index="idx"
|
|
|
- :band-name="elementBand.name"
|
|
|
- :band-code="elementBand.code"
|
|
|
- :band-height="elementBand.height"
|
|
|
- :used-height="getUsedHeight(elementBand)"
|
|
|
+ :band-name="getElementBand(elementBandCode)?.name"
|
|
|
+ :band-code="elementBandCode"
|
|
|
+ :band-height="getElementBandFormStore(elementBandCode)?.band?.height"
|
|
|
+ :used-height="getUsedHeight(elementBandCode)"
|
|
|
@changeElementBandTop="changeElementBandTop"/>
|
|
|
|
|
|
<!-- 选中区域 -->
|
|
@@ -50,7 +50,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 菜单-->
|
|
|
- <EditorMenu />
|
|
|
+ <EditorMenu/>
|
|
|
<!--<Context ref="contextmenu" :theme="contextTheme">-->
|
|
|
<!-- <ContextItem-->
|
|
|
<!-- v-for="item in contextMenu"-->
|
|
@@ -72,11 +72,11 @@ import Big from 'big.js'
|
|
|
import {mapActions, mapState} from "pinia";
|
|
|
import {globalStore, ruleStore, modeStore} from "@/store";
|
|
|
import eventBus from "@/utils/eventBus";
|
|
|
-import CONSTANT from '@/utils/constant'
|
|
|
+import Constant from '@/utils/constant'
|
|
|
import commonMixin from '@/mixin/commonMixin'
|
|
|
import {isPreventDrop} from '@/utils/html-util'
|
|
|
+import ElementUtils from '@/utils/ElementUtils'
|
|
|
import {elementBands} from "@/components/config/globalConfig"
|
|
|
-// import {Context, ContextItem, directive} from '@/components/yvan-context'
|
|
|
import {getComponentRotatedStyle, getShapeStyle} from '@/utils/style-util'
|
|
|
import Area from '@/components/yvan-editor/Area.vue'
|
|
|
import SketchRuler from '../sketch-ruler/sketchRuler.vue'
|
|
@@ -86,23 +86,18 @@ import ComponentBand from '@/components/yvan-editor/ComponentBand.vue'
|
|
|
import EditorCoordinate from '@/components/yvan-editor/EditorCoordinate.vue'
|
|
|
import ComponentAdjuster from '@/components/yvan-editor/ComponentAdjuster.vue'
|
|
|
|
|
|
-const {MIN_SCALE, MAX_SCALE} = CONSTANT
|
|
|
+const {MIN_SCALE, MAX_SCALE} = Constant
|
|
|
|
|
|
let elementUsedHeight = 0;
|
|
|
|
|
|
export default {
|
|
|
name: 'yvan-print-designer-editor',
|
|
|
- // directives: {
|
|
|
- // contextmenu: directive
|
|
|
- // },
|
|
|
mixins: [commonMixin],
|
|
|
components: {
|
|
|
Area,
|
|
|
EditorMenu,
|
|
|
EditorLine,
|
|
|
SketchRuler,
|
|
|
- // Context,
|
|
|
- // ContextItem,
|
|
|
ComponentBand,
|
|
|
EditorCoordinate,
|
|
|
ComponentAdjuster,
|
|
@@ -148,12 +143,14 @@ export default {
|
|
|
height: 0,
|
|
|
isShowArea: false,
|
|
|
svgFilterAttrs: ['width', 'height', 'top', 'left', 'rotate'],
|
|
|
+ elementBands,
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(globalStore, {
|
|
|
componentData: (state) => state.componentData,
|
|
|
curComponent: (state) => state.curComponent,
|
|
|
+ curElementBands: (state) => state.elementBands,
|
|
|
editor: (state) => state.editor,
|
|
|
pageConfig: (state) => state.pageConfig
|
|
|
}),
|
|
@@ -164,119 +161,6 @@ export default {
|
|
|
needReDrawRuler: (state) => state.needReDrawRuler,
|
|
|
showRuler: (state) => state.showRuler,
|
|
|
}),
|
|
|
- contextTheme() {
|
|
|
- return this.isNightMode ? 'dark' : 'default'
|
|
|
- },
|
|
|
- contextMenu() {
|
|
|
- if (!this.curComponent) {
|
|
|
- return [
|
|
|
- {
|
|
|
- code: 'paste',
|
|
|
- icon: 'fa fa-paste',
|
|
|
- label: '粘贴',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- globalStore().paste(true)
|
|
|
- globalStore().recordSnapshot()
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- if (this.curComponent.isLock) {
|
|
|
- const curComponent = this.curComponent
|
|
|
- return [
|
|
|
- {
|
|
|
- code: 'unlock',
|
|
|
- icon: 'fa fa-unlock',
|
|
|
- label: '解锁',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- globalStore().unlock({curComponent})
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- const curComponent = this.curComponent
|
|
|
- return [
|
|
|
- {
|
|
|
- code: 'copy',
|
|
|
- icon: 'fa fa-copy',
|
|
|
- label: '复制',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- globalStore().copy()
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- code: 'cut',
|
|
|
- icon: 'fa fa-cut',
|
|
|
- label: '剪切',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- globalStore().cut()
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- code: 'del',
|
|
|
- icon: 'fa fa-trash',
|
|
|
- label: '删除',
|
|
|
- status: 'danger',
|
|
|
- event: () => {
|
|
|
- globalStore().deleteComponent(globalStore().curComponentIndex)
|
|
|
- globalStore().recordSnapshot()
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- code: 'lock',
|
|
|
- icon: 'fa fa-lock',
|
|
|
- label: '锁定',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- globalStore().lock({curComponent})
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- code: 'top',
|
|
|
- icon: 'fa fa-angle-double-up',
|
|
|
- label: '置顶',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- // this.$store.commit('printTemplateModule/topComponent')
|
|
|
- // this.$store.commit('printTemplateModule/recordSnapshot')
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- code: 'bottom',
|
|
|
- icon: 'fa fa-angle-double-down',
|
|
|
- label: '置底',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- // this.$store.commit('printTemplateModule/bottomComponent')
|
|
|
- // this.$store.commit('printTemplateModule/recordSnapshot')
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- code: 'up',
|
|
|
- icon: 'fa fa-arrow-circle-up',
|
|
|
- label: '上移',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- // this.$store.commit('printTemplateModule/upComponent')
|
|
|
- // this.$store.commit('printTemplateModule/recordSnapshot')
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- code: 'down',
|
|
|
- icon: 'fa fa-arrow-circle-down',
|
|
|
- label: '下移',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- // this.$store.commit('printTemplateModule/downComponent')
|
|
|
- // this.$store.commit('printTemplateModule/recordSnapshot')
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
scale() {
|
|
|
return new Big(this.realScale).div(new Big(5)).toNumber()
|
|
|
},
|
|
@@ -307,12 +191,28 @@ export default {
|
|
|
return this.showRight ? 'width: calc(100% - 315px - 315px);' : 'width: calc(100% - 95px - 95px);'
|
|
|
},
|
|
|
getElementBands() {
|
|
|
- return elementBands.filter(band => band.isDefaultShow);
|
|
|
- }
|
|
|
+ const distElementBands = [];
|
|
|
+ this.curElementBands.forEach((value, bandCode) => {
|
|
|
+ distElementBands.push({
|
|
|
+ code: bandCode,
|
|
|
+ height: value?.band?.height
|
|
|
+ })
|
|
|
+ });
|
|
|
+ return distElementBands;
|
|
|
+ },
|
|
|
+ getElementBandCodes() {
|
|
|
+ return globalStore().getElementBandCodes();
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(ruleStore, ['setReDrawRuler', 'setScale']),
|
|
|
getShapeStyle,
|
|
|
+ getElementBand(bandCode) {
|
|
|
+ return elementBands.findLast(elementBand => elementBand.code === bandCode);
|
|
|
+ },
|
|
|
+ getElementBandFormStore(bandCode) {
|
|
|
+ return ElementUtils.getElementBandFromStore(bandCode);
|
|
|
+ },
|
|
|
handleMouseDown(e) {
|
|
|
// 如果没有选中组件 在画布上点击时需要调用 e.preventDefault() 防止触发 drop 事件
|
|
|
if (!this.curComponent || isPreventDrop(this.curComponent.component)) {
|
|
@@ -503,17 +403,19 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
getComponentBandRef(idx) {
|
|
|
- // return `componentBandRef_${idx}`;
|
|
|
return `componentBandRef`;
|
|
|
},
|
|
|
- getUsedHeight(elementBand) {
|
|
|
+ getUsedHeight(elementBandCode) {
|
|
|
+ if (ElementUtils.isFirstElementBandCode(elementBandCode)) {
|
|
|
+ elementUsedHeight = 0;
|
|
|
+ }
|
|
|
+ const elementBand = ElementUtils.getElementBandFromStore(elementBandCode);
|
|
|
const resultUsedHeight = elementUsedHeight;
|
|
|
- elementUsedHeight = resultUsedHeight + elementBand.height;
|
|
|
+ elementUsedHeight = Number(resultUsedHeight) + Number(elementBand?.band?.height ?? 0)
|
|
|
return resultUsedHeight;
|
|
|
},
|
|
|
changeElementBandTop({currentElementBand, changeHeight, movePos, index}) {
|
|
|
if (movePos === 'bottomLine') {
|
|
|
- console.log(' >>> bottomLine')
|
|
|
const componentBandRefs = this.$refs.componentBandRef;
|
|
|
for (let i in componentBandRefs) {
|
|
|
if (i <= index) {
|