fix(metaComponent): fix #79 metaListItems dragging not working (#86)

This commit is contained in:
chilingling 2023-11-16 18:13:27 -08:00 committed by GitHub
parent ac4b52ce13
commit d1dd2c56b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -1,6 +1,6 @@
<template>
<div>
<meta-list-items class="list" :optionsList="children">
<meta-list-items class="list" :optionsList="children" @dragEnd="dragEnd">
<template #content="{ data }">
<div class="item-text">
<div class="tiny-input">
@ -67,7 +67,21 @@ export default {
useHistory().addHistory()
}
return { children, addChildren, delChildren }
const dragEnd = (params = {}) => {
const { oldIndex, newIndex } = params?.moved || {}
if (oldIndex === undefined || newIndex === undefined) {
return
}
const list = schemaChildren
const spliceItem = list.splice(oldIndex, 1)
list.splice(newIndex, 0, ...spliceItem)
children.value = [...list]
}
return { children, addChildren, delChildren, dragEnd }
}
}
</script>

View File

@ -118,8 +118,8 @@ export default {
emit('deleteItem', params)
}
const dragEnd = () => {
emit('changeItem')
const dragEnd = (value) => {
emit('dragEnd', value)
}
const editItem = (params) => {