Skip to content

Commit 0435e1e

Browse files
committed
refactor: use lodash's cloneDeep to prevent mutation of params in onEnd function
1 parent 7eeb42c commit 0435e1e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ui/src/views/paragraph/index.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ import { MsgSuccess, MsgConfirm } from '@/utils/message'
175175
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
176176
import permissionMap from '@/permission'
177177
import { t } from '@/locales'
178+
import {cloneDeep} from "lodash";
178179
const route = useRoute()
179180
const {
180181
params: { id, documentId },
@@ -351,7 +352,12 @@ function openGenerateDialog(row?: any) {
351352
}
352353
353354
function onEnd(event?: any, params?: any, index?: number) {
354-
const obj =params ?? {
355+
// console.log('onEnd', event, params, index)
356+
const p = cloneDeep(params)
357+
if (p) {
358+
p.new_position = p.new_position + 1 // 由于拖拽时会将当前段落位置作为新位置,所以需要加1
359+
}
360+
const obj = p ?? {
355361
paragraph_id: paragraphDetail.value[event.newIndex].id, // 当前拖动的段落ID
356362
new_position: paragraphDetail.value[event.newIndex + 1].position, // 新位置的段落位置
357363
}

0 commit comments

Comments
 (0)