|
@@ -1,5 +1,5 @@
|
|
|
import { Row, showToast } from "vant";
|
|
|
-import { defineComponent, onMounted, reactive } from "vue";
|
|
|
+import { defineComponent, onMounted, reactive, nextTick, ref } from "vue";
|
|
|
import state from "/src/state";
|
|
|
import request from "/src/utils/request";
|
|
|
import { getQuery } from "/src/utils/queryString";
|
|
@@ -8,8 +8,13 @@ import { Button, ButtonGroup, Icon, Switch, Tooltip } from "@varlet/ui";
|
|
|
import "@varlet/ui/es/tooltip/style";
|
|
|
import "@varlet/ui/es/button-group/style";
|
|
|
import "@varlet/ui/es/switch/style";
|
|
|
+import { storeData } from "/src/store";
|
|
|
+import rightHideIcon from './image/right_hide_icon.png';
|
|
|
|
|
|
let extStyleConfigJson: any = {};
|
|
|
+const clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
|
+const showToolBox = ref(true);
|
|
|
+
|
|
|
export const moveData = reactive({
|
|
|
/** 开启移动 */
|
|
|
open: false,
|
|
@@ -123,6 +128,7 @@ function getBox(ele: SVGAElement) {
|
|
|
export const filterMoveData = async () => {
|
|
|
const examSongId = state.examSongId;
|
|
|
if (examSongId) {
|
|
|
+ const fontSize = (window as any).fontSize
|
|
|
const list = moveData.modelList
|
|
|
.filter((n) => n.isMove)
|
|
|
.map((n) => {
|
|
@@ -132,6 +138,8 @@ export const filterMoveData = async () => {
|
|
|
isDelete: n.isDelete,
|
|
|
x: n.x,
|
|
|
y: n.y,
|
|
|
+ xRem: Math.abs(n.x / fontSize),
|
|
|
+ yRem: Math.abs(n.y / fontSize),
|
|
|
zoom: n.zoom,
|
|
|
w: moveData.sw,
|
|
|
type: n.type,
|
|
@@ -141,10 +149,10 @@ export const filterMoveData = async () => {
|
|
|
}
|
|
|
return item;
|
|
|
});
|
|
|
- if (!list.length) {
|
|
|
- showToast("请移动元素后再保存");
|
|
|
- return
|
|
|
- }
|
|
|
+ // if (!list.length) {
|
|
|
+ // showToast("请移动元素后再保存");
|
|
|
+ // return
|
|
|
+ // }
|
|
|
extStyleConfigJson[moveData.partIndex] = list;
|
|
|
console.log("🚀 ~ extStyleConfigJson", extStyleConfigJson)
|
|
|
const res = await request.post("/musicSheet/img", {
|
|
@@ -240,6 +248,7 @@ const renderSvgItem = (item: any) => {
|
|
|
|
|
|
/** 设置元素位置 */
|
|
|
function setModelPostion(item: any, x: number, y: number) {
|
|
|
+ // console.log(item)
|
|
|
if (item) {
|
|
|
const g = document.querySelector("#" + item.id)!;
|
|
|
const el: HTMLElement = document.querySelector(`[data-id=${item.id}]`)!;
|
|
@@ -247,8 +256,14 @@ function setModelPostion(item: any, x: number, y: number) {
|
|
|
g && g.removeAttribute("transform");
|
|
|
el && (el.style.transform = "");
|
|
|
} else {
|
|
|
- g && g.setAttribute("transform", `translate(${x / moveData.zoom}, ${y / moveData.zoom})`);
|
|
|
- el && (el.style.transform = `translate(${x}px, ${y}px)`);
|
|
|
+ /** 如果是app内嵌打开,需要通过rem转换 */
|
|
|
+ let tsX = x, tsY = y;
|
|
|
+ if (storeData.isApp && (item.xRem || item.yRem)) {
|
|
|
+ tsX = item.xRem * clientWidth/10
|
|
|
+ tsY = item.yRem * clientWidth/10
|
|
|
+ }
|
|
|
+ g && g.setAttribute("transform", `translate(${tsX / moveData.zoom}, ${tsY / moveData.zoom})`);
|
|
|
+ el && (el.style.transform = `translate(${tsX}px, ${tsY}px)`);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -394,19 +409,21 @@ export const renderForMoveData = () => {
|
|
|
}
|
|
|
const list = extStyleConfigJson?.[moveData.partIndex];
|
|
|
if (list && Array.isArray(list)) {
|
|
|
- console.log("🚀 ~ list", list);
|
|
|
- list.forEach((item: any) => {
|
|
|
- const index = moveData.modelList.findIndex((n: any) => n.id === item.id);
|
|
|
- if (index > -1) {
|
|
|
- moveData.modelList[index] = {
|
|
|
- ...moveData.modelList[index],
|
|
|
- ...item
|
|
|
- };
|
|
|
- renderSvgItem(moveData.modelList[index]);
|
|
|
- if (item.type === "vf-lineGroup") {
|
|
|
- renderLineGroup(moveData.modelList[index]);
|
|
|
+ nextTick(() => {
|
|
|
+ console.log("🚀 ~ list", list);
|
|
|
+ list.forEach((item: any) => {
|
|
|
+ const index = moveData.modelList.findIndex((n: any) => n.id === item.id);
|
|
|
+ if (index > -1) {
|
|
|
+ moveData.modelList[index] = {
|
|
|
+ ...moveData.modelList[index],
|
|
|
+ ...item
|
|
|
+ };
|
|
|
+ renderSvgItem(moveData.modelList[index]);
|
|
|
+ if (item.type === "vf-lineGroup") {
|
|
|
+ renderLineGroup(moveData.modelList[index]);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
};
|
|
@@ -427,37 +444,49 @@ export default defineComponent({
|
|
|
});
|
|
|
return () => (
|
|
|
<div class={[moveData.open ? "" : styles.moveDisabled]}>
|
|
|
- <div class={styles.toolBox} id="toolBox">
|
|
|
- <Switch v-model={moveData.open} />
|
|
|
- {moveData.open && (
|
|
|
- <>
|
|
|
- {moveData.tool.isAddAndSub && (
|
|
|
- <ButtonGroup size="small" elevation={false}>
|
|
|
- <Button onClick={() => handleAddAndSub('add')}>加</Button>
|
|
|
- <Button onClick={() => handleAddAndSub('sub')}>减</Button>
|
|
|
- </ButtonGroup>
|
|
|
- )}
|
|
|
- {/* <ButtonGroup size="small">
|
|
|
-
|
|
|
- <Button>
|
|
|
- <Icon name="arrow-down" style={{ transform: "rotate(-90deg)" }} />
|
|
|
+ <div id="toolBox">
|
|
|
+ <div class={[styles.toolBox, !showToolBox.value && styles.hideTool]} >
|
|
|
+ <Switch v-model={moveData.open} />
|
|
|
+ {moveData.open && (
|
|
|
+ <>
|
|
|
+ {moveData.tool.isAddAndSub && (
|
|
|
+ <ButtonGroup size="small" elevation={false}>
|
|
|
+ <Button onClick={() => handleAddAndSub('add')}>加</Button>
|
|
|
+ <Button onClick={() => handleAddAndSub('sub')}>减</Button>
|
|
|
+ </ButtonGroup>
|
|
|
+ )}
|
|
|
+ {/* <ButtonGroup size="small">
|
|
|
+
|
|
|
+ <Button>
|
|
|
+ <Icon name="arrow-down" style={{ transform: "rotate(-90deg)" }} />
|
|
|
+ </Button>
|
|
|
+ </ButtonGroup> */}
|
|
|
+ <Button size="small" onClick={handleUndo} disabled={undoData.undoList.length ? false : true}>
|
|
|
+ <Icon name="arrow-down" style={{ transform: "rotate(90deg)" }} />
|
|
|
</Button>
|
|
|
- </ButtonGroup> */}
|
|
|
- <Button size="small" onClick={handleUndo} disabled={undoData.undoList.length ? false : true}>
|
|
|
- <Icon name="arrow-down" style={{ transform: "rotate(90deg)" }} />
|
|
|
- </Button>
|
|
|
|
|
|
- <Button size="small" onClick={handleDeleteMoveNote} disabled={moveData.activeIndex > -1 ? false : true}>
|
|
|
- {moveData.modelList[moveData.activeIndex]?.isDelete ? '显示元素' : '删除元素'}
|
|
|
- </Button>
|
|
|
- <Button size="small" onClick={resetMoveNote}>
|
|
|
- 重置数据
|
|
|
- </Button>
|
|
|
- <Button size="small" type="primary" onClick={filterMoveData}>
|
|
|
- 保存数据
|
|
|
- </Button>
|
|
|
- </>
|
|
|
- )}
|
|
|
+ <Button size="small" onClick={handleDeleteMoveNote} disabled={moveData.activeIndex > -1 ? false : true}>
|
|
|
+ {moveData.modelList[moveData.activeIndex]?.isDelete ? '显示元素' : '删除元素'}
|
|
|
+ </Button>
|
|
|
+ <Button size="small" onClick={resetMoveNote}>
|
|
|
+ 重置数据
|
|
|
+ </Button>
|
|
|
+ <Button size="small" type="primary" onClick={filterMoveData}>
|
|
|
+ 保存数据
|
|
|
+ </Button>
|
|
|
+ <Button size="small" type="primary" onClick={() => showToolBox.value = false}>
|
|
|
+ 收起
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ {
|
|
|
+ !showToolBox.value &&
|
|
|
+ <img
|
|
|
+ class={[styles.rightHideIcon, !showToolBox.value ? styles.rightIconShow : '']}
|
|
|
+ src={rightHideIcon}
|
|
|
+ onClick={() => showToolBox.value = true } />
|
|
|
+ }
|
|
|
</div>
|
|
|
{moveData.modelList.map((item: any, index: number) => {
|
|
|
return (
|