import { getAirlineAcregApi } from 'mocp/api/electronicBill'
import { formData } from './add.compositions'
import { nextTick } from 'vue'

export const changeAcreg = async (acreg) => {
    if (!acreg) return
    const res = await getAirlineAcregApi({ acreg }, { loading: true })
    if (res.code == 200) {
        if (res.data?.aircaraftoperator) {
            formData.aircaraftoperator = res.data.aircaraftoperator
        }
        if (res.data?.actype) {
            formData.model = res.data.actype
        }
        if (res.data?.flightNo) {
            formData.flightNoIn = res.data.flightNo
        }
    } else {
        uni.$mocpMessage.error(res.message)
    }
}
export const changeOvernightAfPf = (value) => {
    if (value == '1') {
        nextTick(() => {
            formData.overnightService = '1'
            formData.overnightRoutineInspection = '1'
            formData.overnightFlightRelease = '1'
            formData.overnightPfService = '1'
            formData.overnightPfRoutineInspection = '1'
            formData.overnightPfFlightRelease = '1'
        })
    }
}
