<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="ATA章节" :value="details.ataChapter || '-'" />
                    <up-cell title="故障标签" :value="details.faultTag || '-'" />
                    <up-cell title="故障代码" :value="details.faultCode || '-'" />
                    <up-cell title="是否机队TOP故障" :value="useGetDictByValue('ee_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>
                    <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/engineeringEvaluation/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/engineeringEvaluation/partList')">点击查看</global-button>
                    </view>
                    <view class="mocp-title">
                        同类事件
                        <global-button type="text" @tap="navigateTo('/panel/engineeringEvaluation/similarEvents')">点击查看</global-button>
                    </view>
                    <up-collapse-item title="系统原理" name="3" v-if="details.systemPrincipleList?.length">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.systemPrincipleList" :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="4" v-if="details.failAnalysisList?.length">
                        <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="5" v-if="details.fleetSituationList?.length">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.fleetSituationList" :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="6" v-if="details.globalSituationList?.length">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.globalSituationList" :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="7" v-if="details.partSituationList?.length">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.partSituationList" :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="8" v-if="details.factoryImproveList?.length">
                        <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="9" v-if="details.currentProgressList?.length">
                        <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="实时监控与DAR监控" name="10" v-if="details.darMonitorList?.length">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.darMonitorList" :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="11" v-if="details.airlineExperienceList?.length">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.airlineExperienceList" :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="12" v-if="details.assessMeasureList?.length">
                        <view class="mocp-cell">
                            <up-cell-group>
                                <template v-for="(item, index) in details.assessMeasureList" :key="index">
                                    <up-cell title="标题" :value="item.title || '-'" />
                                    <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>
                                    <up-cell title="是否需要生成跟踪" :value="useGetDictByValue('ee_isTrace', item.isTrace) || '-'" />
                                    <template v-if="item.isTrace == 1">
                                        <up-cell title="完成时限" :value="timeStampFormat(item.limitTime) || '-'" />
                                        <up-cell title="完成情况" :value="useGetDictByValue('ee_completeStatus', item.completeStatus) || '-'" />
                                        <up-cell title="填报人" :value="item.uname || '-'" />
                                        <up-cell title="备注" :label="item.remark || '-'" />
                                    </template>
                                </template>
                            </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 { getParamNameByValue } from 'mocp/hooks/use-params/useParams'
import { navigateTo } from 'mocp/utils/jump'
import useEngineeringEvaluationStore from 'mocp/store/engineeringEvaluation'

const query = defineProps(['workbenchId'])
const baseStore = useBaseStore()
const engineeringEvaluationStore = useEngineeringEvaluationStore()
onLoad(() => {
    engineeringEvaluationStore.setState('workbenchId', query.workbenchId)
    engineeringEvaluationStore.getPaData2()
})
const { details } = storeToRefs(engineeringEvaluationStore)
</script>
<style lang="scss" scoped>
.mocp-cell {
    background: #fff;
    margin-bottom: 16rpx;
}
.mocp-title {
    padding: 12rpx 32rpx 12rpx 32rpx;
    background-color: $mocp-fill-1;
    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: $mocp-fill-1;
    }
    .u-collapse-item__content {
        .u-cell {
            background: #fff;
        }
    }
    .u-collapse-item__content__text {
        padding: 0;
    }
    .u-cell__title {
        color: $mocp-text-5;
    }
}
</style>
