<template>
    <global-page :padding="24" title="信息通报详情">
        <view class="mocp-cell">
            <up-cell-group v-if="details">
                <up-cell title="保留依据" :value="details?.releaseBasis || '-'" />
                <view
                    v-if="details?.releaseEnclosure?.length"
                    class="detailFaultDes">
                    <view class="title">保留依据附件</view>
                    <view class="content">
                        <global-upload
                            :fileList="details.releaseEnclosure"
                            typeField="type"
                            nameField="name"
                            :showUpload="false" />
                    </view>
                </view>

                <up-cell v-if="details?.takeOffM" title="每次起飞前OI/M项" value="是" />
                <up-cell v-if="details?.apu" title="APU限制" value="是" />
                <view
                    v-if="details?.executeAttachment?.length"
                    class="detailFaultDes">
                    <view class="title">执行M/OI项附件</view>
                    <view class="content">
                        <global-upload
                            :fileList="details.executeAttachment"
                            typeField="type"
                            nameField="name"
                            :showUpload="false" />
                    </view>
                </view>
                <view
                    v-if="details?.flightRestrict == 1"
                    class="detailFaultDes">
                    <view class="title">航班限制</view>
                    <view v-if="details?.seatRestriction" class="cell">
                        <text>座椅限制</text>
                        <text>{{ details.seatRestriction }}</text>
                    </view>
                    <view v-if="details?.seatDisable" class="cell">
                        <text>座椅禁用</text>
                        <text>{{ details.seatDisable }}</text>
                    </view>
                    <view v-if="details?.runRestrictValue" class="cell">
                        <text>运行限制</text>
                        <text>{{ details.runRestrictValue }}</text>
                    </view>
                </view>
                <up-cell title="保留类型:" :value="details.retentionTypeValue" />
            </up-cell-group>
        </view>

    </global-page>

</template>

<script setup>
import { ref, toRefs, watch } from 'vue'
import useInforDisclosureStore from 'mocp/store/inforDisclosure'
import { storeToRefs } from 'pinia'
import { cloneDeep } from 'lodash'
import { mocMapper } from 'mocp/utils/getFlightList'
import { getParamsByType } from 'mocp/hooks/use-params/useParams'

const inforDisclosure = useInforDisclosureStore()
const {releaseBasisDetails} = storeToRefs(inforDisclosure)
const details = ref()
watch(
    releaseBasisDetails,
    (value) => {
        if (value) {
            const msg = cloneDeep(value)
            console.log(msg)
            const retentionTypeList = getParamsByType('RetentionType')
            if (msg.executeAttachment) msg.executeAttachment = JSON.parse(msg.executeAttachment)
            if (msg.releaseEnclosure) msg.releaseEnclosure = JSON.parse(msg.releaseEnclosure)
            if (msg?.runRestrict?.length > 1) {
                msg.runRestrictValue = msg.runRestrict?.split(',')?.map(item => {
                    return mocMapper[item]
                })?.join(',')
            }
            if (msg?.retentionType) {
                const retentionTypeValue = retentionTypeList.find(item => item.value == msg?.retentionType)
                msg.retentionTypeValue = retentionTypeValue?.label || '-'
                console.log(msg.retentionType, retentionTypeList)
            }
            details.value = msg
            // RetentionType
            console.log('details', details.value)
        }
    },
    {immediate: true}
)


</script>
<style lang="scss" scoped>
@import '../work-assignment/constants/details.scss';
@import './constants/inforDisclosure.scss';
</style>
