闪变编辑框微调
This commit is contained in:
10
frontend/src/views/machine/testScript/components/flickerData.d.ts
vendored
Normal file
10
frontend/src/views/machine/testScript/components/flickerData.d.ts
vendored
Normal 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
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref, computed } from 'vue'
|
import { computed, watch } from 'vue'
|
||||||
|
import { normalizeFlickerData } from './flickerData.js'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
childForm: {
|
childForm: {
|
||||||
type: [Array, Object] as any,
|
type: [Array, Object] as any,
|
||||||
@@ -359,16 +360,21 @@ const changeWaveType = e => {
|
|||||||
}
|
}
|
||||||
const form: any = computed({
|
const form: any = computed({
|
||||||
get() {
|
get() {
|
||||||
if (props.childForm[0].flickerData.flickerValue == null) {
|
|
||||||
props.childForm[0].flickerData.fchagValue = ''
|
|
||||||
props.childForm[0].flickerData.fchagFre = ''
|
|
||||||
}
|
|
||||||
return props.childForm
|
return props.childForm
|
||||||
},
|
},
|
||||||
set(value) {}
|
set(value) {}
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {})
|
watch(
|
||||||
|
() => props.childForm[0],
|
||||||
|
channel => {
|
||||||
|
if (!channel) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
channel.flickerData = normalizeFlickerData(channel.flickerData)
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user