728x90
Template
<tr
v-for="(diary, idx) in f_rec_diary_list"
:key="idx"
draggable="true"
@dragstart="drag_area(idx, 'M')"
@dragend="drag_end_area"
@dragover.prevent
@dragenter="drag_enter_area(idx)"
@drop="drop_area(idx, f_rec_diary_list)"
>
Data
data() {
return {
dragged_area_index: null,
hover_area_index: null,
dragged_item_index: null,
hover_item_index: null,
dragged_type: null,
};
},
Methods
drag_area(index, type) {
console.log("drag_area -> index", index, "type", type);
this.dragged_area_index = index;
this.dragged_type = type;
},
drag_enter_area(index) {
this.hover_area_index = index;
},
drag_end_area() {
this.hover_area_index = null;
},
async drop_area(drop_index, parent) {
if (this.dragged_type !== "M") {
return;
}
const dragged_item = parent.splice(this.dragged_area_index, 1)[0];
parent.splice(drop_index, 0, dragged_item);
console.log('parent', parent);
// Update seq_no values after reordering
for (let i = 0; i < parent.length; i++) {
parent[i].seq_no = i + 1;
}
console.log("dragged_item", dragged_item);
this.dragged_area_index = null;
this.hover_area_index = null;
this.dragged_type = null;
},
drag_item(index, type) {
this.dragged_item_index = index;
this.dragged_type = type;
},
drag_enter_item(index) {
this.hover_item_index = index;
},
drag_end_item() {
this.hover_item_index = null;
},
'Web Develop > Frameworks and Libraries' 카테고리의 다른 글
[Nuxt.js + Node.js] 백엔드에서 업로드한 정적파일을 프론트에서 참조하기 (0) | 2023.10.22 |
---|---|
[Nuxt / Node.js] Error occurred while trying to proxy request 날 시에 (0) | 2023.09.19 |
[NuxtJS] MathJax 수식 적용 (0) | 2023.06.12 |
[NodeJS] node-oracle 라이브러리 연동법 (0) | 2023.03.03 |
[Nuxt.js] 여러개의 체크박스에서 하나만 체크되게 하는 법 (0) | 2023.01.16 |