refactor: remove redundant emit calls in selector components since v-model handles updates

This commit is contained in:
DarkPhoenix2704
2025-08-01 06:47:05 +00:00
parent 8c179ba6b9
commit 459c7ecb61
4 changed files with 4 additions and 19 deletions

View File

@@ -36,7 +36,6 @@ const isOpenAggregationSelectDropdown = ref(false)
const handleValueUpdate = (value: any) => {
const stringValue = String(value)
modelValue.value = stringValue
emit('update:value', stringValue)
}
const column = ref<ColumnType | null>(null)
@@ -121,9 +120,8 @@ watch(aggregationList, (newAggregationList) => {
// Check if current value exists in the new aggregation list
if (modelValue.value && !newAggregationListMap.has(modelValue.value)) {
// Current value is not in the list, emit null to clear it
// Current value is not in the list, set null to clear it
modelValue.value = undefined
emit('update:value', undefined)
return
}
@@ -132,7 +130,6 @@ watch(aggregationList, (newAggregationList) => {
const newAggregationValue = newAggregationList[0]?.value
modelValue.value = newAggregationValue
emit('update:value', newAggregationValue)
}
}
}, { immediate: true })

View File

@@ -37,7 +37,6 @@ const isOpenColumnSelectDropdown = ref(false)
const handleValueUpdate = (value: any) => {
const stringValue = String(value)
modelValue.value = stringValue
emit('update:value', stringValue)
}
const columnList = computedAsync(async () => {
@@ -92,9 +91,8 @@ watch(columnList, (newColumnList) => {
// Check if current value exists in the new column list
if (modelValue.value && !newColumnListMap.has(modelValue.value)) {
// Current value is not in the list, emit null to clear it
// Current value is not in the list, set null to clear it
modelValue.value = undefined
emit('update:value', undefined)
return
}
@@ -108,10 +106,8 @@ watch(columnList, (newColumnList) => {
if (columnObj && columnObj.ncItemDisabled && columnObj.value === newColumnList[0]?.value) {
const selectedValue = newColumnList.find((column) => !column.ncItemDisabled)?.value || newColumnList[0]?.value
modelValue.value = selectedValue
emit('update:value', selectedValue)
} else {
modelValue.value = newColumnId
emit('update:value', newColumnId)
}
}
}

View File

@@ -37,7 +37,6 @@ const isOpenTableSelectDropdown = ref(false)
const handleValueUpdate = (value: any) => {
const stringValue = String(value)
modelValue.value = stringValue
emit('update:value', stringValue)
}
const tableList = computedAsync(async () => {
@@ -85,9 +84,8 @@ watch(tableList, (newTableList) => {
// Check if current value exists in the new table list
if (modelValue.value && !newTableListMap.has(modelValue.value)) {
// Current value is not in the list, emit null to clear it
// Current value is not in the list, set null to clear it
modelValue.value = null
emit('update:value', null)
return
}
@@ -100,10 +98,8 @@ watch(tableList, (newTableList) => {
if (tableObj && tableObj.ncItemDisabled && tableObj.value === newTableList[0]?.value) {
const selectedValue = newTableList.find((table) => !table.ncItemDisabled)?.value || newTableList[0]?.value
modelValue.value = selectedValue
emit('update:value', selectedValue)
} else {
modelValue.value = newTableId
emit('update:value', newTableId)
}
}
}

View File

@@ -40,7 +40,6 @@ const isOpenViewSelectDropdown = ref(false)
const handleValueUpdate = (value: any) => {
const stringValue = String(value)
modelValue.value = stringValue
emit('update:value', stringValue)
}
const viewList = computedAsync(async () => {
@@ -97,9 +96,8 @@ watch(viewList, (newViewList) => {
// Check if current value exists in the new view list
if (modelValue.value && !newViewListMap.has(modelValue.value)) {
// Current value is not in the list, emit null to clear it
// Current value is not in the list, set null to clear it
modelValue.value = undefined
emit('update:value', undefined)
return
}
@@ -113,10 +111,8 @@ watch(viewList, (newViewList) => {
if (viewObj && viewObj.ncItemDisabled && viewObj.value === newViewList[0]?.value) {
const selectedValue = newViewList.find((view) => !view.ncItemDisabled)?.value || newViewList[0]?.value
modelValue.value = selectedValue
emit('update:value', selectedValue)
} else {
modelValue.value = newViewId
emit('update:value', newViewId)
}
}
}