<template>
    <global-page :padding="24" title="技术分析详情">
        <template v-if="details">
            <view class="mocp-cell">
                <up-cell-group>
                    <up-cell title="发起时间" :value="timeStampFormat(details.proposedTime, { format: 'YYYY/MM/DD HH:mm' }) || '-'" />
                    <up-cell title="发起席位" :value="baseStore.getSeat(details.seat)" />
                    <up-cell title="机号" :value="details.ac || '-'" />
                    <up-cell title="机型" :value="details.acType || '-'" />
                    <up-cell title="航司" :value="details.acOwn || '-'" />
                    <up-cell title="航站" :value="baseStore.getTerminalObject[details.acTerminal] || '-'" />
                    <up-cell title="专业" :value="getParamNameByValue('MajorCategory', details.majorClass)" />
                    <up-cell title="TA章节" :value="details.ataChapter || '-'" />
                    <up-cell title="故障标签" :value="details.faultTag || '-'" />
                    <up-cell title="故障代码" :value="details.faultCode || '-'" />
                    <up-cell title="是否机队TOP故障" :value="useGetDictByValue('ta_teamTop', details.teamTop) || '-'" />
                    <up-cell title="前两年同类延误次数" :value="details.delayB2 || '-'" />
                    <up-cell title="前一年同类延误次数" :value="details.delayB1 || '-'" />
                </up-cell-group>
            </view>
            <view class="mocp-cell">
                <up-cell-group>
                    <up-cell title="左发件号" :value="details.leftEngPartNo || '-'" />
                    <up-cell title="左发序号" :value="details.leftEngSerialNo || '-'" />
                    <up-cell title="左发装机时间" :value="timeStampFormat(details.leftEngInstallTime, { format: 'YYYY/MM/DD HH:mm' }) || '-'" />
                    <up-cell title="左发飞行小时" :value="details.leftEngFlyTime || '-'" />
                    <up-cell title="左发飞行循环" :value="details.leftEngFlyLoop || '-'" />
                    <up-cell title="右发件号" :value="details.rightEngPartNo || '-'" />
                    <up-cell title="右发序号" :value="details.rightEngSerialNo || '-'" />
                    <up-cell title="右发装机时间" :value="timeStampFormat(details.rightEngInstallTime, { format: 'YYYY/MM/DD HH:mm' }) || '-'" />
                    <up-cell title="右发飞行小时" :value="details.rightEngFlyTime || '-'" />
                    <up-cell title="右发飞行循环" :value="details.rightEngFlyLoop || '-'" />
                </up-cell-group>
            </view>
            <view class="mocp-cell">
                <up-collapse :value="['1', '2', '3', '4', '5', '6']">
                    <up-collapse-item title="事件简述" name="1">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <up-cell title="内容" :label="details.eventMsg || '-'" />
                                <up-cell title="相关附件">
                                    <template #label>
                                        <view style="margin-top: 16rpx">
                                            <global-upload :fileList="details.eventFiles" :showUpload="false"></global-upload>
                                        </view>
                                    </template>
                                </up-cell>
                            </up-cell-group>
                        </view>
                    </up-collapse-item>
                    <view class="mocp-title">
                        故障历史
                        <global-button type="text" @tap="navigateTo('/panel/technicalAnalysis/historicalFault')">点击查看</global-button>
                    </view>
                    <up-collapse-item title="处置经过" name="2">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <up-cell title="内容" :label="details.dispose || '-'" />
                                <up-cell title="相关附件">
                                    <template #label>
                                        <view style="margin-top: 16rpx">
                                            <global-upload :fileList="details.disposeFiles" :showUpload="false"></global-upload>
                                        </view>
                                    </template>
                                </up-cell>
                            </up-cell-group>
                        </view>
                    </up-collapse-item>
                    <view class="mocp-title">
                        部件信息
                        <global-button type="text" @tap="navigateTo('/panel/technicalAnalysis/partList')">点击查看</global-button>
                    </view>
                    <view class="mocp-title">
                        同类事件
                        <global-button type="text" @tap="navigateTo('/panel/technicalAnalysis/similarEvents')">点击查看</global-button>
                    </view>
                    <up-collapse-item title="故障原因分析" name="3">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.failAnalysisList" :key="index">
                                    <up-cell title="内容" :label="item.content || '-'" />
                                    <up-cell title="相关附件">
                                        <template #label>
                                            <view style="margin-top: 16rpx">
                                                <global-upload :fileList="item.files" :showUpload="false"></global-upload>
                                            </view>
                                        </template>
                                    </up-cell>
                                </template>
                            </up-cell-group>
                        </view>
                    </up-collapse-item>
                    <up-collapse-item title="厂家技术文件及改进措施" name="4">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.factoryImproveList" :key="index">
                                    <up-cell title="标题" :value="item.title || '-'" />
                                    <up-cell title="ATA章节" :value="item.ataChapter || '-'" />
                                    <up-cell title="故障标签" :value="item.faultTag || '-'" />
                                    <up-cell title="内容" :label="item.content || '-'" />
                                    <up-cell title="相关附件">
                                        <template #label>
                                            <view style="margin-top: 16rpx">
                                                <global-upload :fileList="item.files" :showUpload="false"></global-upload>
                                            </view>
                                        </template>
                                    </up-cell>
                                </template>
                            </up-cell-group>
                        </view>
                    </up-collapse-item>
                    <up-collapse-item title="当前管控措施和进展" name="5">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.currentProgressList" :key="index">
                                    <up-cell title="标题" :value="item.title || '-'" />
                                    <up-cell title="ATA章节" :value="item.ataChapter || '-'" />
                                    <up-cell title="故障标签" :value="item.faultTag || '-'" />
                                    <up-cell title="内容" :label="item.content || '-'" />
                                    <up-cell title="相关附件">
                                        <template #label>
                                            <view style="margin-top: 16rpx">
                                                <global-upload :fileList="item.files" :showUpload="false"></global-upload>
                                            </view>
                                        </template>
                                    </up-cell>
                                </template>
                            </up-cell-group>
                        </view>
                    </up-collapse-item>
                    <up-collapse-item title="总结" name="6">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <up-cell title="内容" :label="details.summary || '-'" />
                                <up-cell title="相关附件">
                                    <template #label>
                                        <view style="margin-top: 16rpx">
                                            <global-upload :fileList="details.summaryFiles" :showUpload="false"></global-upload>
                                        </view>
                                    </template>
                                </up-cell>
                            </up-cell-group>
                        </view>
                    </up-collapse-item>
                </up-collapse>
            </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 { onLoad } from '@dcloudio/uni-app'
import { computed } from 'vue'
import { getParamNameByValue } from 'mocp/hooks/use-params/useParams'
import { navigateTo } from 'mocp/utils/jump'
import useTechnicalAnalysisStore from 'mocp/store/technicalAnalysis'

const query = defineProps(['workbenchId'])
const baseStore = useBaseStore()
const technicalAnalysisStore = useTechnicalAnalysisStore()
onLoad(() => {
    technicalAnalysisStore.setState('workbenchId', query.workbenchId)
    technicalAnalysisStore.getTaData2()
})
const { details } = storeToRefs(technicalAnalysisStore)
</script>
<style lang="scss" scoped>
.mocp-cell {
    background: #fff;
    margin-bottom: 16rpx;
}
.mocp-title {
    padding: 12rpx 32rpx 12rpx 32rpx;
    background-color: #f7f8fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mocp-subTitle {
    padding: 24rpx 32rpx 0 32rpx;
    color: $mocp-text-5;
    font-size: 28rpx;
}
:deep(.u-collapse-item) {
    .u-cell {
        background: #f7f8fa;
    }
    .u-collapse-item__content {
        .u-cell {
            background: #fff;
        }
    }
    .u-collapse-item__content__text {
        padding: 0;
    }
    .u-cell__title {
        color: $mocp-text-5;
    }
}
</style>
