<template>
    <global-page :padding="24" title="机械延误详情">
        <template v-if="details">
            <view class="mocp-cell">
                <up-cell-group>
                    <up-cell title="事件分类" :value="useGetDictByValue('mae_eventType', details.eventType) || '-'" />
                    <up-cell title="运行事件" :value="useGetDictByValue('mae_runEvent', details.runEvent) || '-'" />
                    <up-cell title="加入日报" :value="useGetDictByValue('mae_joinDaily', details.joinDaily)" />
                    <up-cell title="发生航站" :value="baseStore.getTerminalObject[details.happenStn] || '-'" />
                    <up-cell title="发生区域" :value="occurArea[details.occurArea] || '-'" />
                    <up-cell title="生成日报日期" :value="timeStampFormat(details.dailyOpenDate, { format: 'YYYY/MM/DD' }) || '-'" />
                    <up-cell title="关闭日报日期" :value="timeStampFormat(details.dailyCloseDate, { format: 'YYYY/MM/DD' }) || '-'" />
                    <up-cell title="始发航站" :value="baseStore.getTerminalObject[details.startStn] || '-'" />
                    <view class="mocp-title">进出港</view>
                    <view class="mocp-subTitle">进港</view>
                    <up-cell title="保障阶段" :value="assurePhase[details.assurePhaseIn] || '-'" />
                    <up-cell title="航班日期" :value="timeStampFormat(details.flightDateIn, { format: 'YYYY/MM/DD' }) || '-'" />
                    <up-cell title="进港航班号" :value="details.flightNoIn || '-'" />
                    <up-cell title="起飞航站" :value="baseStore.getTerminalObject[details.depStnIn] || '-'" />
                    <up-cell title="落地航站" :value="baseStore.getTerminalObject[details.arrStnIn] || '-'" />
                    <view class="mocp-subTitle">出港</view>
                    <up-cell title="保障阶段" :value="assurePhase[details.assurePhaseOut] || '-'" />
                    <up-cell title="航班日期" :value="timeStampFormat(details.flightDateOut, { format: 'YYYY/MM/DD' }) || '-'" />
                    <up-cell title="出港航班号" :value="details.flightNoOut || '-'" />
                    <up-cell title="起飞航站" :value="baseStore.getTerminalObject[details.depStnOut] || '-'" />
                    <up-cell title="落地航站" :value="baseStore.getTerminalObject[details.arrStnOut] || '-'" />
                    <up-cell title="延误定性" :value="delayNature[details.delayNature] || '-'" />
                    <up-cell title="起飞延误分钟" :value="details.dur1 || '-'" />
                    <up-cell title="延误属性" :value="delayProperty[details.delayProperty] || '-'" />
                    <up-cell title="顺延班次" :value="details.postponedShift > 0 ? details.postponedShift : '-'" />
                    <up-cell title="取消班次" :value="details.cancelNo > 0 ? details.cancelNo : '-'" />
                </up-cell-group>
            </view>
            <view class="mocp-cell">
                <up-cell-group>
                    <template v-if="details.occur == 0">
                        <up-cell title="发生阶段" value="进港航班" />
                        <up-cell title="运行阶段" :value="runPhase[details.runPhaseIn] || '-'" />
                    </template>
                    <template v-else-if="details.occur == 1">
                        <up-cell title="发生阶段" value="出港航班" />
                        <up-cell title="运行阶段" :value="runPhase[details.runPhaseOut] || '-'" />
                    </template>
                    <template v-else>
                        <up-cell title="发生阶段" value="-" />
                        <up-cell title="运行阶段" value="-" />
                    </template>
                    <up-cell title="内容" :label="details.occurMsg || '-'" />
                    <up-cell title="故障描述" :label="details.faultMsg || '-'" />
                    <up-cell title="处理措施" :label="details.handleMsg || '-'" />
                    <up-cell title="处理措施文件">
                        <template #label>
                            <view style="margin-top: 16rpx">
                                <global-upload :fileList="details.handleFile" :showUpload="false"></global-upload>
                            </view>
                        </template>
                    </up-cell>
                </up-cell-group>
            </view>
            <view class="mocp-cell">
                <up-cell-group>
                    <template v-if="details.fly == 0">
                        <up-cell title="航班运行影响" value="进港航班" />
                        <up-cell title="航班影响" :value="flightImpact[details.flightImpactIn]" />
                    </template>
                    <template v-else-if="details.fly == 1">
                        <up-cell title="航班运行影响" value="出港航班" />
                        <up-cell title="航班影响" :value="flightImpact[details.flightImpactOut]" />
                    </template>
                    <template v-else>
                        <up-cell title="航班运行影响" value="-" />
                        <up-cell title="航班影响" value="-" />
                    </template>
                    <up-cell title="内容" :label="details.flyMsg || '-'" />
                    <up-cell title="其他运行影响" :label="details.otherMsg || '-'" />
                </up-cell-group>
            </view>
            <view class="mocp-cell">
                <up-cell-group>
                    <up-cell title="填报人" :value="details.openUsernameL || '-'" />
                    <up-cell title="填报时间" :value="timeStampFormat(details.openTimeL) || '-'" />
                    <up-cell title="关闭人" :value="details.closeUsername || '-'" />
                    <up-cell title="关闭时间" :value="timeStampFormat(details.closeTime) || '-'" />
                </up-cell-group>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import useBaseStore from 'mocp/store/base'
import { timeStampFormat } from 'mocp/utils/tool'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import useMechanicalAbnormalEventsStore from 'mocp/store/mechanicalAbnormalEvents'
import { onLoad } from '@dcloudio/uni-app'

const query = defineProps(['id'])
const baseStore = useBaseStore()
const {
    rcOptions: { occurArea, assurePhase, delayNature, delayProperty, runPhase, flightImpact }
} = useBaseStore()
const mechanicalAbnormalEventsStore = useMechanicalAbnormalEventsStore()
onLoad(() => {
    mechanicalAbnormalEventsStore.setState('workbenchId', query.workbenchId)
    mechanicalAbnormalEventsStore.getMeData()
})
const { details } = storeToRefs(mechanicalAbnormalEventsStore)
</script>
<style lang="scss" scoped>
.mocp-cell {
    background: #fff;
    margin-bottom: 16rpx;
}
.mocp-title {
    padding: 24rpx 32rpx 24rpx 32rpx;
    background-color: $mocp-fill-1;
}
.mocp-subTitle {
    padding: 24rpx 32rpx 0 32rpx;
    font-weight: bold;
}
</style>
