|
@@ -6,6 +6,7 @@ import { useRoute } from 'vue-router';
|
|
|
import { initSelectScorePartModal, setting_modal } from '../setting';
|
|
|
import { getImage } from '../images/music';
|
|
|
import btn5 from '../images/btn-5.png';
|
|
|
+import Draggable from 'vuedraggable';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'setting-pc-modal',
|
|
@@ -25,6 +26,8 @@ export default defineComponent({
|
|
|
win: route.query.win,
|
|
|
activeBeat: ''
|
|
|
});
|
|
|
+ // 拖拽临时数据
|
|
|
+ const tempDragData = ref<any>({});
|
|
|
|
|
|
return () => (
|
|
|
<div
|
|
@@ -46,33 +49,57 @@ export default defineComponent({
|
|
|
styles.small
|
|
|
]}>
|
|
|
{item.map((child: any, jIndex: number) => (
|
|
|
- <div
|
|
|
- class={[styles.beat, child.selected ? styles.active : '']}
|
|
|
- draggable={false}
|
|
|
- onDragenter={(e: any) => {
|
|
|
- e.preventDefault();
|
|
|
+ <Draggable
|
|
|
+ modelValue={[child]}
|
|
|
+ itemKey="index"
|
|
|
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
+ // @ts-ignore
|
|
|
+ group={{
|
|
|
+ name: 'description',
|
|
|
+ pull: 'clone',
|
|
|
+ put: true
|
|
|
}}
|
|
|
- onDragover={(e: any) => {
|
|
|
- e.preventDefault();
|
|
|
+ animation={200}
|
|
|
+ sort={false}
|
|
|
+ componentData={{
|
|
|
+ draggable: 'row-nav',
|
|
|
+ itemKey: 'index',
|
|
|
+ tag: 'div',
|
|
|
+ pull: 'clone',
|
|
|
+ put: true,
|
|
|
+ animation: 200,
|
|
|
+ group: 'description'
|
|
|
}}
|
|
|
- onDrop={(e: any) => {
|
|
|
- let dropItem = e.dataTransfer.getData('text');
|
|
|
- dropItem = dropItem ? JSON.parse(dropItem) : {};
|
|
|
- console.log(e, 'event', dropItem);
|
|
|
+ onChange={(evt: any) => {
|
|
|
+ console.log('111', evt);
|
|
|
+ tempDragData.value = evt.added || '';
|
|
|
+ }}
|
|
|
+ onAdd={() => {
|
|
|
+ const added = tempDragData.value?.element || {};
|
|
|
// 判断是否有数据
|
|
|
- if (dropItem.url) {
|
|
|
+ if (added.url && added.sourceFrom === 'setting-modal') {
|
|
|
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;
|
|
|
+ child.url = added.url;
|
|
|
+ child.index = added.index;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
}}
|
|
|
+ onStart={(evt: any) => {
|
|
|
+ console.log(evt, 'eweew');
|
|
|
+ evt.from.classList.add('onstart');
|
|
|
+ tempDragData.value = {};
|
|
|
+ }}
|
|
|
+ onEnd={(evt: any) => {
|
|
|
+ console.log(evt, 'eweew');
|
|
|
+ evt.from.classList.remove('onstart');
|
|
|
+ tempDragData.value = {};
|
|
|
+ }}
|
|
|
onClick={(e: any) => {
|
|
|
e.stopPropagation();
|
|
|
if (setting_modal.scorePart[i][jIndex].selected) {
|
|
@@ -80,11 +107,56 @@ export default defineComponent({
|
|
|
} else {
|
|
|
initSelectScorePartModal(i, jIndex);
|
|
|
}
|
|
|
- }}>
|
|
|
- <div class={styles.imgSection}>
|
|
|
- <img src={getImage(child.url)} />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ }}
|
|
|
+ class={[styles.beat, child.selected ? styles.active : '']}>
|
|
|
+ {/* <div
|
|
|
+ class={[styles.beat, child.selected ? styles.active : '']}
|
|
|
+ draggable={false}
|
|
|
+ onDragenter={(e: any) => {
|
|
|
+ e.preventDefault();
|
|
|
+ }}
|
|
|
+ onDragover={(e: any) => {
|
|
|
+ e.preventDefault();
|
|
|
+ }}
|
|
|
+ onDrop={(e: any) => {
|
|
|
+ let dropItem = e.dataTransfer.getData('text');
|
|
|
+ dropItem = dropItem ? JSON.parse(dropItem) : {};
|
|
|
+ console.log(e, 'event', dropItem);
|
|
|
+ // 判断是否有数据
|
|
|
+ if (dropItem.url) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ onClick={(e: any) => {
|
|
|
+ e.stopPropagation();
|
|
|
+ if (setting_modal.scorePart[i][jIndex].selected) {
|
|
|
+ initSelectScorePartModal();
|
|
|
+ } else {
|
|
|
+ initSelectScorePartModal(i, jIndex);
|
|
|
+ }
|
|
|
+ }}> */}
|
|
|
+ {{
|
|
|
+ item: (element: any) => {
|
|
|
+ const item = element.element;
|
|
|
+ return (
|
|
|
+ <div data-id={item.key} class={styles.imgSection}>
|
|
|
+ <img src={getImage(child.url)} />
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }}
|
|
|
+
|
|
|
+ {/* </div> */}
|
|
|
+ </Draggable>
|
|
|
))}
|
|
|
</div>
|
|
|
))}
|