<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="aog_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('AOG管理-AOG列表')"
                    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('AOG管理-AOG列表')"
                    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('AOG管理-AOG列表')"
                    filter
                ></global-picker>
            </up-form-item>
            <up-form-item label="专业类别" prop="major" :borderBottom="true">
                <global-picker pickAlign="right" v-model="formData.major" clearable paramsType="MajorCategory"></global-picker>
            </up-form-item>
            <up-form-item label="AOG级别" prop="aogLevel" :borderBottom="true">
                <global-picker
                    pickAlign="right"
                    v-model="formData.aogLevel"
                    clearable
                    :options="[
                        { value: 0, label: '红' },
                        { value: 1, label: '黄' },
                        { value: 2, label: '绿' }
                    ]"
                ></global-picker>
            </up-form-item>
            <up-form-item label="发生日期" :borderBottom="true">
                <global-calendar
                    pickAlign="right"
                    v-model:startTime="formData.happenDateStart"
                    v-model:endTime="formData.happenDateEnd"
                    clearable
                ></global-calendar>
            </up-form-item>
            <up-form-item label="AOG启动日期" :borderBottom="true">
                <global-calendar
                    pickAlign="right"
                    v-model:startTime="formData.aogStartTimeStart"
                    v-model:endTime="formData.aogStartTimeEnd"
                    clearable
                ></global-calendar>
            </up-form-item>
            <up-form-item label="发生地点" prop="happenAddr" :borderBottom="true">
                <global-picker pickAlign="right" v-model="formData.happenAddr" clearable :options="getTerminalSelect()" filter></global-picker>
            </up-form-item>
            <up-form-item label="故障描述" prop="faultDesc" :borderBottom="true">
                <up-input v-model="formData.faultDesc" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
            </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 useAogStore from 'mocp/store/aog'
import { getAirlineSelect, getTerminalSelect, getTypeSelect } from 'mocp/utils/permission'

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