<template>
    <global-page-search @reset="handleReset" @confirm="handleConfirm">
        <up-form labelPosition="left" labelWidth="auto">
            <up-form-item label="状态" prop="state" :borderBottom="true">
                <global-picker v-model="formData.state" pickAlign="right" clearable dictkey="wa_state"></global-picker>
            </up-form-item>
            <up-form-item label="机号" prop="machineNumber" :borderBottom="true">
                <global-picker pickAlign="right" v-model="formData.machineNumber" :options="deviceNumList" clearable filter></global-picker>
            </up-form-item>
            <up-form-item label="机型" prop="model" :borderBottom="true">
                <global-picker
                    v-model="formData.model"
                    pickAlign="right"
                    :options="getTypeSelect('技术支援-支援申请')"
                    clearable
                    filter
                ></global-picker>
            </up-form-item>
            <up-form-item label="航司" prop="aviation" :borderBottom="true">
                <global-picker
                    v-model="formData.aviation"
                    pickAlign="right"
                    :options="getAirlineSelect('技术支援-支援申请')"
                    clearable
                    filter
                ></global-picker>
            </up-form-item>
            <up-form-item label="航站" prop="terminal" :borderBottom="true">
                <global-picker
                    pickAlign="right"
                    v-model="formData.terminal"
                    clearable
                    :options="getTerminalSelect('技术支援-支援申请')"
                    filter
                ></global-picker>
            </up-form-item>
            <up-form-item label="专业" prop="specialty" :borderBottom="true">
                <global-picker v-model="formData.specialty" pickAlign="right" paramsType="MajorCategory" clearable></global-picker>
            </up-form-item>
            <up-form-item label="发动机型号" prop="engineModel" :borderBottom="true">
                <global-picker v-model="formData.engineModel" pickAlign="right" :options="baseStore.getEngineSelect" clearable filter></global-picker>
            </up-form-item>
        </up-form>
    </global-page-search>
</template>

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

//获取下拉框选项
const baseStore = useBaseStore()
const {
    selectList: { deviceNumList }
} = useBaseStore()
const supportApplicationStore = useSupportApplicationStore()
//获取查询表单数据
const { searchData } = storeToRefs(supportApplicationStore)
const formData = ref(cloneDeep(searchData.value))
const handleReset = () => {
    supportApplicationStore.resetForm()
    uni.$mocpJump.navigateTo('/panel/support-application/list')
    uni.$emit('supportApplicationReload')
}
const handleConfirm = () => {
    supportApplicationStore.setState('searchData', formData.value)
    uni.$mocpJump.navigateTo('/panel/support-application/list')
    uni.$emit('supportApplicationReload')
}
</script>
<style lang="scss" scoped></style>
