<template>
    <global-page :padding="24" title="运行决策详情">
        <template v-if="details">
            <view class="details">
                <view class="details-header">
                    <view class="details-header-left">
                        <custom-state :value="useGetDictByValue('md_state', details.state)" :size="32"></custom-state>
                        <global-text-status
                            class="txt"
                            dictkey="md_isValid"
                            :value="details.mcoDirectorDecisionState == '1' && details.decisionState == '1' ? '1' : '0'"
                            :size="32"
                        ></global-text-status>
                    </view>
                    <view class="details-header-right">
                        <global-icon icon="mind-mapping"></global-icon>
                        <global-field class="txt" label="编号:" :value="details.decisionNumber" style="margin-left: 8rpx"></global-field>
                    </view>
                </view>
                <view class="details-body">
                    <view class="details-body-box">
                        <view class="details-body-field">
                            <global-field label="机号:" :value="details.machineNumber || '-'"></global-field>
                            <global-field label="机型:" :value="details.model || '-'"></global-field>
                        </view>
                        <view class="details-body-field">
                            <global-field
                                label="航司:"
                                :value="useGetDictByValue('', details.aviation, { data: getAirlineSelect() }) || '-'"
                            ></global-field>
                            <global-field label="航站:" :value="baseStore.getTerminalObject[details.terminal] || '-'"></global-field>
                        </view>
                        <view class="details-body-field">
                            <global-field
                                label="日期:"
                                :value="timeStampFormat(details.dateTime, { format: 'YYYY/MM/DD HH:mm' }) || '-'"
                            ></global-field>
                            <global-field label="航班号:" :value="details.flight || '-'"></global-field>
                        </view>
                        <view class="details-body-field">
                            <global-field
                                label="预计起飞时间:"
                                :value="timeStampFormat(details.takeOff, { format: 'YYYY/MM/DD HH:mm' }) || '-'"
                            ></global-field>
                            <global-field
                                label="运行决策类型:"
                                :value="getParamNameByValue('OperationalDecisionType', details.technicalType) || '-'"
                            ></global-field>
                        </view>
                    </view>
                    <view class="details-body-wrap">
                        <view class="details-body-list">
                            <view class="details-body-item">
                                <view class="title">故障描述</view>
                                <view class="content">
                                    {{ details.faultDescription || '无' }}
                                </view>
                            </view>
                            <view class="details-body-item">
                                <view class="title">邮件/电话记录</view>
                                <view class="content">{{ details.phone || '无' }}</view>
                            </view>
                            <view class="details-body-item">
                                <view class="title">附件</view>
                                <global-upload :fileList="getFileList" :showUpload="false"></global-upload>
                            </view>
                        </view>
                    </view>
                </view>
            </view>
            <custom-card-details
                title="MOC主任意见"
                showfooter
                :idcard="details.mcoDirectorUpdateName"
                :calendar="details.mcoDirectorUpdateTime"
                edit
                @handleAdd="handleAdd('edit-mco-director')"
            >
                <custom-card-details-item label="MOC主任" :value="details.mcoDirectorName || '-'"></custom-card-details-item>
                <custom-card-details-item
                    label="MOC主任意见"
                    :value="useGetDictByValue('md_decisionState', details.mcoDirectorDecisionState) || '-'"
                ></custom-card-details-item>
                <custom-card-details-item label="MOC主任意见描述" :value="details.mcoDirectorOpinion || '-'"></custom-card-details-item>
            </custom-card-details>
            <custom-card-details
                title="公司值班经理意见"
                showfooter
                :idcard="details.approverUpdateName"
                :calendar="details.approverUpdateTime"
                edit
                @handleAdd="handleAdd('edit-approver')"
            >
                <custom-card-details-item label="公司值班经理" :value="details.approverName || '-'"></custom-card-details-item>
                <custom-card-details-item
                    label="公司值班经理意见"
                    :value="useGetDictByValue('md_decisionState', details.decisionState) || '-'"
                ></custom-card-details-item>
                <custom-card-details-item label="公司值班经理意见描述" :value="details.decisionOpinion || '-'"></custom-card-details-item>
            </custom-card-details>
            <view class="time-list">
                <view class="time-item">
                    <global-field label="填报人:" :value="details.filledBy"></global-field>
                    <global-field label="填报时间:" :value="timeStampFormat(details.filledTime, { format: 'YYYY/MM/DD HH:mm' })"></global-field>
                </view>
                <view class="time-item">
                    <global-field label="关闭人:" :value="details.closeBy || '-'"></global-field>
                    <global-field label="关闭时间:" :value="timeStampFormat(details.closeTime, { format: 'YYYY/MM/DD HH:mm' }) || '-'"></global-field>
                </view>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import useMoveDecisionStore from 'mocp/store/move-decision'
import useBaseStore from 'mocp/store/base'
import { storeToRefs } from 'pinia'
import { timeStampFormat } from 'mocp/utils/tool'
import { getParamNameByValue } from 'mocp/hooks/use-params/useParams'
import { getAirlineSelect } from 'mocp/utils/permission'

const baseStore = useBaseStore()
const moveDecisionStore = useMoveDecisionStore()
const { details, getFileList } = storeToRefs(moveDecisionStore)
//跳转
const handleAdd = (path) => {
    uni.$mocpJump.navigateTo(`/panel/move-decision/${path}`)
}
</script>
<style lang="scss" scoped>
@import './constants/details.scss';
</style>
