<template>
    <global-page :padding="24" title="技术评估详情">
        <view class="details" v-if="details">
            <view class="details-header">
                <view class="details-header-top">
                    <custom-state :value="useGetDictByValue('te_state', details.state)" :size="48"></custom-state>
                </view>
                <view class="details-header-center">
                    <global-icon icon="mind-mapping"></global-icon>
                    <global-field class="txt" label="编号:" :value="details.num" style="margin-left: 8rpx"></global-field>
                </view>
                <view class="details-header-bottom">
                    <global-field label="关闭人:" :value="details.closeBy || '-'"></global-field>
                    <global-field label="关闭时间:" :value="details.closeTime || '-'"></global-field>
                </view>
            </view>
            <up-collapse :value="getDefaultCollapse">
                <up-collapse-item title="客户管控技术支援工程师完成初始评估" name="update-technology">
                    <view class="details-body">
                        <view class="details-body-list">
                            <view class="details-body-item">
                                <global-field label="机号:" :value="details.ac || '-'"></global-field>
                                <global-field label="机型:" :value="details.model || '-'"></global-field>
                            </view>
                            <view class="details-body-item">
                                <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-item">
                                <global-field
                                    label="日期:"
                                    :value="details.dateTime ? Day(details.dateTime).format('YYYY/MM/DD') : '-'"
                                ></global-field>
                                <global-field label="ATA章节:" :value="details.ata || '-'"></global-field>
                            </view>
                        </view>
                        <view class="details-body-list">
                            <view class="details-body-cell">
                                <view class="title">缺陷描述</view>
                                <view class="label">{{ details.description || '无' }}</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">缺陷处理方案简要描述</view>
                                <view class="label">{{ details.handleOption || '无' }}</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">放行前维护要求</view>
                                <view class="label">{{ details.demand || '无' }}</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">运行/操作限制</view>
                                <view class="label">{{ details.controls || '无' }}</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">评估结论</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">1、缺陷对飞机重要系统/结构的影响</view>
                                <view class="label">{{ details.influence || '无' }}</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">2、缺陷的扩展可能造成的潜在影响</view>
                                <view class="label">{{ details.latent || '无' }}</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">3、历史上对类似缺陷的处理经验, 包括厂家已发布的超出持续适航文件范围的技术支援类文件</view>
                                <view class="label">{{ details.experience || '无' }}</view>
                            </view>
                            <view class="details-body-item border-top padding-x">
                                <global-field label="授权工程师:" :value="details.accredit || '-'"></global-field>
                                <global-field
                                    label="日期:"
                                    :value="details.accreditTime ? Day(details.accreditTime).format('YYYY/MM/DD') : '-'"
                                ></global-field>
                            </view>
                        </view>
                        <view class="details-body-item" style="padding-top: 16rpx; margin-bottom: 0">
                            <global-field label="生成人:" :value="details.creationName || '-'"></global-field>
                            <global-field label="生成时间:" :value="details.creationTime || '-'"></global-field>
                        </view>
                        <view class="details-body-footer" style="margin-bottom: 0">
                            <view></view>
                            <global-field label="邮件发送时间:" :value="details.mailTime || '-'"></global-field>
                        </view>
                    </view>
                </up-collapse-item>
                <up-collapse-item title="第二类超出持续适航文件的缺陷，需完成工程评估" name="add-engineering">
                    <view class="details-body">
                        <view class="details-body-list">
                            <view class="details-body-item">
                                <global-field label="授权工程师:" :value="details.estimateEngineerName || '-'"></global-field>
                                <view class="details-edit" @tap.stop="handleEdit('add-engineering')">编辑</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">工程评估</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">1、缺陷对飞机重要系统/结构的影响</view>
                                <view class="label">{{ details.estimateEffect || '无' }}</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">2、缺陷的扩展可能造成的潜在影响</view>
                                <view class="label">{{ details.estimatePotential || '无' }}</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">3、历史上对类似缺陷的处理经验, 包括厂家已发布的超出持续适航文件范围的技术支援类文件</view>
                                <view class="label">{{ details.estimateHandle || '无' }}</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">评估结论</view>
                                <view class="label">{{ getParamNameByValue('EvaluateEstimateType', details.estimateType) || '无' }}</view>
                            </view>
                        </view>
                        <view class="details-body-footer" style="margin-top: 16rpx">
                            <global-field label="保存人:" :value="details.estimateName || '-'"></global-field>
                            <global-field label="保存时间:" :value="details.estimateTime || '-'"></global-field>
                        </view>
                    </view>
                </up-collapse-item>
                <up-collapse-item title="经理或授权人意见" name="add-opinion">
                    <view class="details-body">
                        <view class="details-body-list">
                            <view class="details-body-item">
                                <global-field label="机队经理或其授权人:" :value="details.otherFullName || '-'"></global-field>
                                <view class="details-edit" @tap="handleEdit('add-opinion')">编辑</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">机队经理或其授权人意见</view>
                                <view class="label">{{ useGetDictByValue('te_opinionType', details.opinionType) || '无' }}</view>
                            </view>
                        </view>
                        <view class="details-body-footer" style="margin-top: 16rpx">
                            <global-field label="保存人:" :value="details.opinionName || '-'"></global-field>
                            <global-field label="保存时间:" :value="details.opinionTime || '-'"></global-field>
                        </view>
                    </view>
                </up-collapse-item>
                <up-collapse-item title="厂家提供技术支援文件" name="add-support-file">
                    <view class="details-body">
                        <view class="details-body-list">
                            <view class="details-body-cell" style="margin-top: 0; display: flex; justify-content: space-between">
                                <view class="title">文件编号</view>
                                <view class="details-edit" @tap="handleEdit('add-support-file')">编辑</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">非持续适航文件</view>
                                <view class="label">
                                    {{ getParamNameByValue('EvaluateNonFileType', details.nonFileType, { isArray: true }) || '无' }}
                                </view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">非持续适航描述</view>
                                <view class="label">
                                    {{ details.nonName || '无' }}
                                </view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">持续适航文件</view>
                                <view class="label">
                                    {{ getParamNameByValue('EvaluateFileType', details.fileType, { isArray: true }) || '无' }}
                                </view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">持续适航描述</view>
                                <view class="label">
                                    {{ details.fileTypeName || '无' }}
                                </view>
                            </view>
                            <view class="details-body-item">
                                <global-field
                                    label="批准类别:"
                                    :value="getParamNameByValue('EvaluateRatifyType', details.ratifyType, { isArray: true }) || '无'"
                                ></global-field>
                            </view>
                        </view>
                        <view class="details-body-footer" style="margin-top: 16rpx">
                            <global-field label="保存人:" :value="details.fileName || '-'"></global-field>
                            <global-field label="保存时间:" :value="details.fileTime || '-'"></global-field>
                        </view>
                    </view>
                </up-collapse-item>
                <up-collapse-item title="客户工程授权人意见" name="add-ratify">
                    <view class="details-body">
                        <view class="details-body-list">
                            <view class="details-body-item">
                                <global-field label="客户工程授权人:" :value="details.customFullName || '-'"></global-field>
                                <view class="details-edit" @tap="handleEdit('add-ratify')">编辑</view>
                            </view>
                            <view class="details-body-cell">
                                <view class="title">客户工程授权人意见</view>
                                <view class="label">{{ useGetDictByValue('te_customType', details.customType) }}</view>
                            </view>
                        </view>
                        <view class="details-body-footer" style="margin-top: 16rpx">
                            <global-field label="保存人:" :value="details.approver || '-'"></global-field>
                            <global-field label="保存时间:" :value="details.approverTime || '-'"></global-field>
                        </view>
                    </view>
                </up-collapse-item>
            </up-collapse>
        </view>
    </global-page>
</template>

<script setup>
import Day from 'mocp/utils/dayjs'
import useTechnologyEvaluationStore from 'mocp/store/technology-evaluation'
import { storeToRefs } from 'pinia'
import useBaseStore from 'mocp/store/base'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import { computed } from 'vue'
import { getParamNameByValue } from 'mocp/hooks/use-params/useParams'
import { getAirlineSelect } from 'mocp/utils/permission'

const technologyEvaluationStore = useTechnologyEvaluationStore()
const { details } = storeToRefs(technologyEvaluationStore)
const baseStore = useBaseStore()
//获取默认展开项
const getDefaultCollapse = computed(() => {
    const defaultCollapse = ['update-technology']
    if (details.value?.estimateTime) {
        defaultCollapse.push('add-engineering')
    }
    if (details.value?.opinionTime) {
        defaultCollapse.push('add-opinion')
    }
    if (details.value?.fileTime) {
        defaultCollapse.push('add-support-file')
    }
    if (details.value?.approverTime) {
        defaultCollapse.push('add-ratify')
    }
    return defaultCollapse
})
//点击编辑
const handleEdit = (path) => {
    uni.$mocpJump.navigateTo('/panel/technology-evaluation/' + path)
}
</script>
<style lang="scss" scoped>
@import './constants/details.scss';
</style>
