fix: 修复attrs透传会触发两次select事件 (#138)

This commit is contained in:
dayou 2024-05-23 11:39:09 +08:00 committed by sudoooooo
parent 0b0f78a3ed
commit 8ce6dc7607
2 changed files with 8 additions and 8 deletions

View File

@ -10,7 +10,6 @@
> >
<template #item="{ element, index }"> <template #item="{ element, index }">
<QuestionWrapper <QuestionWrapper
v-bind="$attrs"
:ref="`questionWrapper-${element.field}`" :ref="`questionWrapper-${element.field}`"
:moduleConfig="element" :moduleConfig="element"
:qIndex="element.qIndex" :qIndex="element.qIndex"
@ -18,15 +17,15 @@
:isSelected="currentEditOne === index" :isSelected="currentEditOne === index"
:isLast="index + 1 === questionDataList.length" :isLast="index + 1 === questionDataList.length"
@select="handleSelect" @select="handleSelect"
@changeSeq="handleChangeSeq"
> >
<QuestionContainerB <QuestionContainerB
v-bind="$attrs"
:type="element.type" :type="element.type"
:moduleConfig="element" :moduleConfig="element"
:indexNumber="element.indexNumber" :indexNumber="element.indexNumber"
:isSelected="currentEditOne === index" :isSelected="currentEditOne === index"
:readonly="true" :readonly="true"
@select="handleSelect" @change="handleChange"
></QuestionContainerB> ></QuestionContainerB>
</QuestionWrapper> </QuestionWrapper>
</template> </template>
@ -60,9 +59,9 @@ export default defineComponent({
} }
} }
}, },
emits: ['change', 'select', 'changeSeq'],
setup(props, { emit }) { setup(props, { emit }) {
const store = useStore() const store = useStore()
const renderData = computed({ const renderData = computed({
get () { get () {
return filterQuestionPreviewData(props.questionDataList) return filterQuestionPreviewData(props.questionDataList)
@ -72,8 +71,12 @@ export default defineComponent({
} }
}) })
const handleSelect = (index) => { const handleSelect = (index) => {
console.log('materialGroup-handleSelect', index)
emit('select', index) emit('select', index)
} }
const handleChange = (data) => {
emit('change', data)
}
const handleChangeSeq = (data) => { const handleChangeSeq = (data) => {
emit('changeSeq', data) emit('changeSeq', data)
} }
@ -102,6 +105,7 @@ export default defineComponent({
DND_GROUP, DND_GROUP,
renderData, renderData,
handleSelect, handleSelect,
handleChange,
handleChangeSeq, handleChangeSeq,
checkMove, checkMove,
checkEnd, checkEnd,

View File

@ -75,14 +75,10 @@ export default defineComponent({
const onChange = (data) => { const onChange = (data) => {
emit('change', data) emit('change', data)
} }
const onClick = () => {
emit('select', props.indexNumber)
}
return { return {
props, props,
BlockComponent, BlockComponent,
onClick,
onBlur, onBlur,
onFocus, onFocus,
onChange, onChange,