<template>
    <global-page-search @reset="handleReset" @confirm="handleConfirm">
        <up-form labelPosition="left" labelWidth="auto">
            <up-form-item label="状态" prop="isOpen" :borderBottom="true">
                <global-picker v-model="formData.isOpen" pickAlign="right" clearable dictkey="mae_isOpen"></global-picker>
            </up-form-item>
            <up-form-item label="航站" prop="acTerminal" :borderBottom="true">
                <global-picker
                    pickAlign="right"
                    v-model="formData.acTerminal"
                    clearable
                    :options="getTerminalSelect('机械不正常事件')"
                    filter
                ></global-picker>
            </up-form-item>
            <up-form-item label="航司" prop="acOwn" :borderBottom="true">
                <global-picker
                    v-model="formData.acOwn"
                    pickAlign="right"
                    :options="getAirlineSelect('机械不正常事件')"
                    clearable
                    filter
                ></global-picker>
            </up-form-item>
            <up-form-item label="机型" prop="acType" :borderBottom="true">
                <global-picker
                    v-model="formData.acType"
                    pickAlign="right"
                    :options="getTypeSelect('机械不正常事件')"
                    clearable
                    filter
                ></global-picker>
            </up-form-item>
            <up-form-item label="机号" prop="ac" :borderBottom="true">
                <global-picker pickAlign="right" v-model="formData.ac" :options="deviceNumList" clearable filter></global-picker>
            </up-form-item>
            <up-form-item label="发起日期" :borderBottom="true">
                <global-calendar
                    pickAlign="right"
                    v-model:startTime="formData.startTime"
                    v-model:endTime="formData.stopTime"
                    clearable
                ></global-calendar>
            </up-form-item>
            <up-form-item label="发起席位" prop="seat" :borderBottom="true">
                <global-picker
                    pickAlign="right"
                    v-model="formData.seat"
                    :options="operationalSurveyStore.selectList.allSeatSelect"
                    label-field="seatName"
                    value-field="id"
                    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 useOperationalSurveyStore from 'mocp/store/operationalSurvey'
import { getAirlineSelect, getTerminalSelect, getTypeSelect } from 'mocp/utils/permission'

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