|
@@ -43,6 +43,7 @@ import useDrag from '@/hooks/useDrag';
|
|
|
import useDragGuidance from '@/hooks/useDrag/useDragGuidance';
|
|
|
import { state as stateData } from '@/state';
|
|
|
import SettingPcModal from './setting-pc-modal';
|
|
|
+import Draggable from 'vuedraggable';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'tempo-practice',
|
|
@@ -90,6 +91,8 @@ export default defineComponent({
|
|
|
dataJson: {} as any,
|
|
|
playPos: (route.query.imagePos || 'left') as 'left' | 'right' // 数字课堂老师端上课 镜像字段
|
|
|
});
|
|
|
+ // 拖拽临时数据
|
|
|
+ const tempDragData = ref<any>({});
|
|
|
// 返回
|
|
|
const goback = (e: any) => {
|
|
|
e.stopPropagation();
|
|
@@ -146,6 +149,21 @@ export default defineComponent({
|
|
|
handleStop();
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+ /** 播放切换 */
|
|
|
+ const handlePlay2 = async () => {
|
|
|
+ const playState = getSettingValue('playState');
|
|
|
+ const playType = getSettingValue('playType');
|
|
|
+
|
|
|
+ if (playState === 'pause') {
|
|
|
+ updateSettingValue('playState', 'play');
|
|
|
+ if (playType === 'beat') {
|
|
|
+ await handleStartTick(state.settingStatus);
|
|
|
+ } else {
|
|
|
+ await handleStartBeat(state.settingStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
/** 播放类型 */
|
|
|
const handlePlayType = () => {
|
|
|
handleStop();
|
|
@@ -195,7 +213,7 @@ export default defineComponent({
|
|
|
|
|
|
if (ev.data.api === 'setPlayState') {
|
|
|
if (ev.data.data) {
|
|
|
- handlePlay();
|
|
|
+ handlePlay2();
|
|
|
} else {
|
|
|
handleStop();
|
|
|
}
|
|
@@ -396,37 +414,55 @@ export default defineComponent({
|
|
|
styles.small
|
|
|
]}>
|
|
|
{item.map((child: any, jIndex: number) => (
|
|
|
- <div
|
|
|
- class={[
|
|
|
- styles.beat,
|
|
|
- child.selected ? styles.active : '',
|
|
|
- state.settingStatus && styles.disabledChange
|
|
|
- ]}
|
|
|
- // draggable={true}
|
|
|
- // onDragenter={(e: any) => {
|
|
|
- // e.preventDefault();
|
|
|
- // }}
|
|
|
- // onDragover={(e: any) => {
|
|
|
- // e.preventDefault();
|
|
|
- // }}
|
|
|
- // onDrop={(e: any) => {
|
|
|
- // let dropItem = e.dataTransfer.getData('text');
|
|
|
- // dropItem = dropItem ? JSON.parse(dropItem) : {};
|
|
|
- // // 判断是否有数据
|
|
|
- // if (dropItem.url) {
|
|
|
- // handleStop();
|
|
|
- // setting_modal.scorePart.forEach(
|
|
|
- // (part: Array<any>, ci: number) => {
|
|
|
- // part.forEach((child: any, cj: number) => {
|
|
|
- // if (i === ci && jIndex === cj) {
|
|
|
- // child.url = dropItem.url;
|
|
|
- // child.index = dropItem.index;
|
|
|
- // }
|
|
|
- // });
|
|
|
- // }
|
|
|
- // );
|
|
|
- // }
|
|
|
- // }}
|
|
|
+ <Draggable
|
|
|
+ modelValue={[child]}
|
|
|
+ itemKey="index"
|
|
|
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
+ // @ts-ignore
|
|
|
+ group={{
|
|
|
+ name: 'description',
|
|
|
+ pull: 'clone',
|
|
|
+ put: true
|
|
|
+ }}
|
|
|
+ animation={200}
|
|
|
+ sort={false}
|
|
|
+ componentData={{
|
|
|
+ draggable: 'row-nav',
|
|
|
+ itemKey: 'index',
|
|
|
+ tag: 'div',
|
|
|
+ pull: 'clone',
|
|
|
+ put: true,
|
|
|
+ animation: 200,
|
|
|
+ group: 'description'
|
|
|
+ }}
|
|
|
+ onChange={(evt: any) => {
|
|
|
+ tempDragData.value = evt.added || '';
|
|
|
+ }}
|
|
|
+ onAdd={() => {
|
|
|
+ const added = tempDragData.value?.element || {};
|
|
|
+ // 判断是否有数据
|
|
|
+ if (added.url && added.sourceFrom === 'setting-modal') {
|
|
|
+ handleStop();
|
|
|
+ setting_modal.scorePart.forEach(
|
|
|
+ (part: Array<any>, ci: number) => {
|
|
|
+ part.forEach((child: any, cj: number) => {
|
|
|
+ if (i === ci && jIndex === cj) {
|
|
|
+ child.url = added.url;
|
|
|
+ child.index = added.index;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ onStart={(evt: any) => {
|
|
|
+ evt.from.classList.add('onstart');
|
|
|
+ tempDragData.value = {};
|
|
|
+ }}
|
|
|
+ onEnd={(evt: any) => {
|
|
|
+ evt.from.classList.remove('onstart');
|
|
|
+ tempDragData.value = {};
|
|
|
+ }}
|
|
|
onClick={(e: any) => {
|
|
|
e.stopPropagation();
|
|
|
// 编辑时可以操作
|
|
@@ -438,44 +474,69 @@ export default defineComponent({
|
|
|
initSelectScorePartModal(i, jIndex);
|
|
|
}
|
|
|
}
|
|
|
- }}>
|
|
|
- {/* 编辑时不可上下切换 */}
|
|
|
- {!state.settingStatus && (
|
|
|
- <div class={styles.direction}>
|
|
|
- <div
|
|
|
- class={styles.up}
|
|
|
- style={{ cursor: 'pointer' }}
|
|
|
- onClick={() => {
|
|
|
- if (setting.playState === 'play') return;
|
|
|
- if (setting.tempo.length <= 1) {
|
|
|
- showToast('无法切换,请选择至少2种节奏型');
|
|
|
- return;
|
|
|
- }
|
|
|
- // const obj = randomScoreElement(child.index);
|
|
|
- const obj = elementDirection('up', child.index);
|
|
|
- child.index = obj.index;
|
|
|
- child.url = obj.url;
|
|
|
- }}></div>
|
|
|
- <div
|
|
|
- class={styles.down}
|
|
|
- style={{ cursor: 'pointer' }}
|
|
|
- onClick={() => {
|
|
|
- if (setting.playState === 'play') return;
|
|
|
- if (setting.tempo.length <= 1) {
|
|
|
- showToast('无法切换,请选择至少2种节奏型');
|
|
|
- return;
|
|
|
- }
|
|
|
- // const obj = randomScoreElement(child.index);
|
|
|
- const obj = elementDirection('down', child.index);
|
|
|
- child.index = obj.index;
|
|
|
- child.url = obj.url;
|
|
|
- }}></div>
|
|
|
- </div>
|
|
|
- )}
|
|
|
- <div class={styles.imgSection}>
|
|
|
- <img src={getImage(child.url)} />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ }}
|
|
|
+ class={[
|
|
|
+ styles.beat,
|
|
|
+ child.selected ? styles.active : '',
|
|
|
+ state.settingStatus && styles.disabledChange
|
|
|
+ ]}>
|
|
|
+ {{
|
|
|
+ item: (element: any) => {
|
|
|
+ const child = element.element;
|
|
|
+ const jIndex = element.index;
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ {/* 编辑时不可上下切换 */}
|
|
|
+ {!state.settingStatus && (
|
|
|
+ <div class={styles.direction}>
|
|
|
+ <div
|
|
|
+ class={styles.up}
|
|
|
+ style={{ cursor: 'pointer' }}
|
|
|
+ onClick={() => {
|
|
|
+ if (setting.playState === 'play') return;
|
|
|
+ if (setting.tempo.length <= 1) {
|
|
|
+ showToast(
|
|
|
+ '无法切换,请选择至少2种节奏型'
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // const obj = randomScoreElement(child.index);
|
|
|
+ const obj = elementDirection(
|
|
|
+ 'up',
|
|
|
+ child.index
|
|
|
+ );
|
|
|
+ child.index = obj.index;
|
|
|
+ child.url = obj.url;
|
|
|
+ }}></div>
|
|
|
+ <div
|
|
|
+ class={styles.down}
|
|
|
+ style={{ cursor: 'pointer' }}
|
|
|
+ onClick={() => {
|
|
|
+ if (setting.playState === 'play') return;
|
|
|
+ if (setting.tempo.length <= 1) {
|
|
|
+ showToast(
|
|
|
+ '无法切换,请选择至少2种节奏型'
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // const obj = randomScoreElement(child.index);
|
|
|
+ const obj = elementDirection(
|
|
|
+ 'down',
|
|
|
+ child.index
|
|
|
+ );
|
|
|
+ child.index = obj.index;
|
|
|
+ child.url = obj.url;
|
|
|
+ }}></div>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ <div class={styles.imgSection}>
|
|
|
+ <img src={getImage(child.url)} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ </Draggable>
|
|
|
))}
|
|
|
</div>
|
|
|
))}
|