闪变编辑框微调

This commit is contained in:
caozehui
2026-06-11 09:28:26 +08:00
parent 195b58d798
commit b31efb9ede
3 changed files with 49 additions and 6 deletions

View File

@@ -0,0 +1,10 @@
export interface FlickerData {
flickerValue: string | null
fchagFre: string
fchagValue: string
waveType: string
waveFluType: string
fdutyCycle: number
}
export function normalizeFlickerData(flickerData: Partial<FlickerData> | null | undefined): FlickerData

View File

@@ -0,0 +1,27 @@
const DEFAULT_WAVE_TYPE = 'CPM'
const DEFAULT_WAVE_FLU_TYPE = 'SQU'
const DEFAULT_DUTY_CYCLE = 50
export function normalizeFlickerData(flickerData) {
const normalized = {
flickerValue: flickerData?.flickerValue ?? null,
fchagFre: flickerData?.fchagFre ?? '',
fchagValue: flickerData?.fchagValue ?? '',
waveType: flickerData?.waveType ?? DEFAULT_WAVE_TYPE,
waveFluType: flickerData?.waveFluType ?? DEFAULT_WAVE_FLU_TYPE,
fdutyCycle: flickerData?.fdutyCycle ?? DEFAULT_DUTY_CYCLE
}
const isBackendEmptyState =
normalized.flickerValue == null &&
normalized.fchagFre === '1' &&
normalized.fchagValue === '2.724'
if (isBackendEmptyState) {
normalized.fchagFre = ''
normalized.fchagValue = ''
}
return normalized
}

View File

@@ -80,7 +80,8 @@
</template>
<script setup lang="ts">
import { onMounted, ref, computed } from 'vue'
import { computed, watch } from 'vue'
import { normalizeFlickerData } from './flickerData.js'
const props = defineProps({
childForm: {
type: [Array, Object] as any,
@@ -359,16 +360,21 @@ const changeWaveType = e => {
}
const form: any = computed({
get() {
if (props.childForm[0].flickerData.flickerValue == null) {
props.childForm[0].flickerData.fchagValue = ''
props.childForm[0].flickerData.fchagFre = ''
}
return props.childForm
},
set(value) {}
})
onMounted(() => {})
watch(
() => props.childForm[0],
channel => {
if (!channel) {
return
}
channel.flickerData = normalizeFlickerData(channel.flickerData)
},
{ immediate: true }
)
</script>
<style scoped>