|
@@ -1198,21 +1198,18 @@ export default {
|
|
|
this.oldNum = value;
|
|
|
},
|
|
|
dragend() {
|
|
|
- if (this.oldNum != this.newNum) {
|
|
|
- let oldIndex = this.pageList.indexOf(this.oldNum);
|
|
|
- let newIndex = this.pageList.indexOf(this.newNum);
|
|
|
- let newItems = [...this.pageList];
|
|
|
- // 删除老的节点
|
|
|
- newItems.splice(oldIndex, 1);
|
|
|
- // 在列表中目标位置增加新的节点
|
|
|
- newItems.splice(newIndex, 0, this.oldNum);
|
|
|
- this.pageList = [...newItems];
|
|
|
- this.$message.success(this.$t('Slides.move_success_msg') )
|
|
|
- //如果拖动的是当前选中的item,就定位到该item
|
|
|
- if(this.oldNum.id===this.currentItem.id){
|
|
|
- this.changeCurrentItem(this.currentItem)
|
|
|
- }
|
|
|
+ let oldIndex = this.pageList.findIndex(_ => _.id ===this.oldNum.id);
|
|
|
+ let newIndex = this.pageList.findIndex(_ => _.id ===this.newNum.id);
|
|
|
+ // console.log(oldIndex,newIndex)
|
|
|
+
|
|
|
+ let tempOption = _.cloneDeep(this.pageList[newIndex])
|
|
|
+ if(oldIndex !== newIndex) {
|
|
|
+ this.$set(this.pageList, newIndex, this.pageList[oldIndex])
|
|
|
+ this.$set(this.pageList, oldIndex, tempOption)
|
|
|
+ this.$message.success(this.$t('Slides.move_success_msg') )
|
|
|
}
|
|
|
+
|
|
|
+ this.currentIndex = this.pageList.findIndex(_ => _.id ===this.currentItem.id);
|
|
|
},
|
|
|
dragenter(e,value) {
|
|
|
e.preventDefault()
|