perf: 【IoT 物联网】场景联动 nextTick 优化使用 await nextTick()

pull/808/head
puhui999 2025-08-07 17:49:20 +08:00
parent 5b38c9c394
commit f3d1989832
4 changed files with 21 additions and 30 deletions

View File

@ -237,10 +237,6 @@ const handleSubmit = async () => {
// //
submitLoading.value = true submitLoading.value = true
try { try {
// 使
console.log('提交数据:', formData.value)
// API
if (isEdit.value) { if (isEdit.value) {
// //
await RuleSceneApi.updateRuleScene(formData.value) await RuleSceneApi.updateRuleScene(formData.value)
@ -299,13 +295,12 @@ const initFormData = () => {
} }
// //
watch(drawerVisible, (visible) => { watch(drawerVisible, async (visible) => {
if (visible) { if (visible) {
initFormData() initFormData()
// //
nextTick(() => { await nextTick()
formRef.value?.clearValidate() formRef.value?.clearValidate()
})
} }
}) })

View File

@ -200,7 +200,7 @@ const handleTriggerTypeChange = (type: number) => {
} }
// //
const addSubGroup = () => { const addSubGroup = async () => {
if (!trigger.value.conditionGroups) { if (!trigger.value.conditionGroups) {
trigger.value.conditionGroups = [] trigger.value.conditionGroups = []
} }
@ -211,11 +211,10 @@ const addSubGroup = () => {
} }
// 使 nextTick // 使 nextTick
nextTick(() => { await nextTick()
if (trigger.value.conditionGroups) { if (trigger.value.conditionGroups) {
trigger.value.conditionGroups.push([]) trigger.value.conditionGroups.push([])
} }
})
} }
const removeSubGroup = (index: number) => { const removeSubGroup = (index: number) => {

View File

@ -107,7 +107,7 @@ const subGroup = useVModel(props, 'modelValue', emit)
const maxConditions = computed(() => props.maxConditions || 3) const maxConditions = computed(() => props.maxConditions || 3)
// //
const addCondition = () => { const addCondition = async () => {
// subGroup.value // subGroup.value
if (!subGroup.value) { if (!subGroup.value) {
subGroup.value = [] subGroup.value = []
@ -128,11 +128,10 @@ const addCondition = () => {
} }
// 使 nextTick // 使 nextTick
nextTick(() => { await nextTick()
if (subGroup.value) { if (subGroup.value) {
subGroup.value.push(newCondition) subGroup.value.push(newCondition)
} }
})
} }
const removeCondition = (index: number) => { const removeCondition = (index: number) => {

View File

@ -462,25 +462,23 @@ const handleDataDisplay = (value: string) => {
// //
watch( watch(
() => localValue.value, () => localValue.value,
(newValue, oldValue) => { async (newValue, oldValue) => {
// //
if (newValue === oldValue) return if (newValue === oldValue) return
// 使 nextTick tick // 使 nextTick tick
nextTick(() => { await nextTick()
handleDataDisplay(newValue || '') handleDataDisplay(newValue || '')
})
}, },
{ immediate: true } { immediate: true }
) )
// //
onMounted(() => { onMounted(async () => {
nextTick(() => { await nextTick()
if (localValue.value) { if (localValue.value) {
handleDataDisplay(localValue.value) handleDataDisplay(localValue.value)
} }
})
}) })
// //