<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="aem_state"></global-picker>
            </up-form-item>
            <up-form-item label="航站" prop="terminalCode" :borderBottom="true">
                <global-picker
                    pickAlign="right"
                    v-model="formData.terminalCode"
                    clearable
                    :options="getTerminalSelect('航站管理-航站质量管理')"
                    filter
                ></global-picker>
            </up-form-item>
            <up-form-item label="责任单位" prop="repairUnit" :borderBottom="true">
                <global-picker v-model="formData.repairUnit" pickAlign="right" :options="repairUnitList" 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="接报日期" :borderBottom="true">
                <global-calendar
                    pickAlign="right"
                    v-model:startTime="formData.occurrenceTimeStart"
                    v-model:endTime="formData.occurrenceTimeEnd"
                    clearable
                ></global-calendar>
            </up-form-item>
            <up-form-item label="是否延误" prop="delay" :borderBottom="true">
                <global-picker
                    v-model="formData.delay"
                    pickAlign="right"
                    :options="[
                        { label: '是', value: '1' },
                        { label: '否', value: '0' }
                    ]"
                    clearable
                ></global-picker>
            </up-form-item>
            <up-form-item label="类别" prop="category" :borderBottom="true">
                <global-picker v-model="formData.category" pickAlign="right" paramsType="EventCategory" clearable></global-picker>
            </up-form-item>
            <up-form-item label="扣分范围" :borderBottom="true">
                <view style="display: flex; align-items: center">
                    <up-input type="number" v-model="formData.pointsDeductionL" placeholder="请输入" clearable></up-input>
                    <text style="margin: 0 20rpx">-</text>
                    <up-input type="number" v-model="formData.pointsDeductionH" placeholder="请输入" clearable></up-input>
                </view>
            </up-form-item>
            <up-form-item label="事件性质" prop="eventProperty" :borderBottom="true">
                <global-picker v-model="formData.eventProperty" pickAlign="right" paramsType="EventProperty" clearable></global-picker>
            </up-form-item>
            <up-form-item label="处理人" prop="handledBy" :borderBottom="true">
                <up-input v-model="formData.handledBy" inputAlign="right" border="none" placeholder="请输入" clearable></up-input>
            </up-form-item>
            <up-form-item label="审核状态" prop="reviewedState" :borderBottom="true">
                <global-picker v-model="formData.reviewedState" pickAlign="right" clearable dictkey="aem_auditListSelect"></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 useAbnormalEventManageStore from 'mocp/store/abnormalEventManage'
import { getAirlineSelect, getTerminalSelect } from 'mocp/utils/permission'

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