<template>
    <global-page-search @reset="handleReset" @confirm="handleConfirm">
        <up-form labelPosition="left" labelWidth="auto">
            <up-form-item label="机号" prop="ac" :borderBottom="true">
                <global-picker v-model="formData.ac" pickAlign="right" clearable :options="deviceNumList" filter />
            </up-form-item>

            <up-form-item label="机型" prop="acType" :borderBottom="true">
                <global-picker v-model="formData.acType" pickAlign="right" :options="getTypeSelect()" clearable filter />
            </up-form-item>

            <up-form-item label="航站" prop="terminal" :borderBottom="true">
                <global-picker pickAlign="right" v-model="formData.terminal" clearable :options="getTerminalSelect()" filter />
            </up-form-item>

            <up-form-item label="航司" prop="acOwn" :borderBottom="true">
                <global-picker v-model="formData.acOwn" pickAlign="right" :options="getAirlineSelect()" clearable filter />
            </up-form-item>

            <up-form-item label="航班号" prop="flightNo" :borderBottom="true">
                <global-picker v-model="formData.flightNo" pickAlign="right" :options="baseStore.selectList.flightNumList" clearable filter />
            </up-form-item>
        </up-form>
    </global-page-search>
</template>

<script setup>
import { ref } from 'vue'
import { storeToRefs } from 'pinia'
import { cloneDeep } from 'lodash'
import useBaseStore from 'mocp/store/base'
import useFlightSupportStore from 'mocp/store/flight-support'
import { getAirlineSelect, getTerminalSelect, getTypeSelect } from 'mocp/utils/permission'

//获取下拉框选项
const baseStore = useBaseStore()
const {
    selectList: { deviceNumList }
} = useBaseStore()

const flightSupportStore = useFlightSupportStore()
//获取查询表单数据
const { screenData } = storeToRefs(flightSupportStore)
const formData = ref(cloneDeep(screenData.value))

// 重置
const handleReset = () => {
    flightSupportStore.resetScreenForm()
    uni.$mocpJump.navigateBack()
    uni.$emit('screenReload')
}

// 提交
const handleConfirm = () => {
    flightSupportStore.setStateScreen(formData.value)
    uni.$mocpJump.navigateBack()
    uni.$emit('screenReload')
}
</script>
<style lang="scss" scoped></style>
