<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="md_state"></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="valid" :borderBottom="true">
                <global-picker
                    v-model="formData.valid"
                    pickAlign="right"
                    :options="[
                        { label: '有效', value: '1' },
                        { label: '无效', value: '0' }
                    ]"
                    clearable
                ></global-picker>
            </up-form-item>
            <up-form-item label="决策结果" prop="decisionState" :borderBottom="true">
                <global-picker
                    v-model="formData.decisionState"
                    pickAlign="right"
                    :options="[
                        { label: '同意', value: '1' },
                        { label: '不同意', value: '0' }
                    ]"
                    clearable
                ></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="machineNumber" :borderBottom="true">
                <global-picker pickAlign="right" v-model="formData.machineNumber" :options="deviceNumList" clearable filter></global-picker>
            </up-form-item>
            <up-form-item label="日期" :borderBottom="true">
                <global-calendar
                    pickAlign="right"
                    v-model:startTime="formData.startDateTime"
                    v-model:endTime="formData.endDateTime"
                    clearable
                ></global-calendar>
            </up-form-item>
        </up-form>
    </global-page-search>
</template>

<script setup>
import useBaseStore from 'mocp/store/base'
import useMoveDecisionStore from 'mocp/store/move-decision'
import { storeToRefs } from 'pinia'
import { cloneDeep } from 'lodash'
import { ref } from 'vue'
import { getAirlineSelect, getTerminalSelect } from 'mocp/utils/permission'

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