<template>
    <global-page :padding="24" title="考核记录详情">
        <template v-if="details">
            <view class="details">
                <view class="details-header">
                    <view class="details-header-top">
                        <view class="left">
                            <custom-state :value="details.status == 1 ? 'OPEN' : 'CLOSE'" :size="32"></custom-state>
                            <global-text-status
                                class="txt"
                                dictkey="ar_isValid"
                                :value="
                                    (details.qualityOpinionType == 2 && details.opinionType == 2) ||
                                    (details.qualityOpinionType == 0 && details.opinionType == 2) ||
                                    (details.qualityOpinionType == 2 && details.opinionType == 0) ||
                                    (details.qualityOpinionType == 0 && details.opinionType == 0)
                                        ? '1'
                                        : '0'
                                "
                                :size="32"
                            ></global-text-status>
                        </view>
                        <custom-score
                            v-if="details.score != -1"
                            :type="details.eventType == 1 ? 'success' : 'warning'"
                            :count="details.score"
                        ></custom-score>
                    </view>
                    <view class="details-header-bottom">
                        <view class="left">
                            <view class="txt" v-if="details.ac">
                                <global-airline-image :code="details.acOwn">
                                    {{ details.ac }}
                                </global-airline-image>
                            </view>
                            <view class="txt u-line-1" v-if="details.acType">
                                {{ details.acType }}
                            </view>
                            <view class="txt u-line-1" v-if="details.acOwn">
                                {{ useGetDictByValue('', details.acOwn, { data: getAirlineSelect() }) }}
                            </view>
                        </view>
                        <view class="right">{{ timeStampFormat(details.eventTime, { format: 'YYYY/MM/DD' }) }}</view>
                    </view>
                </view>
                <view class="details-body">
                    <view class="details-body-top">
                        <view class="top">
                            <global-icon icon="mind-mapping"></global-icon>
                            <global-field class="txt u-line-1" label="事件来源:" :value="details.eventSource || ' -'"></global-field>
                        </view>
                        <view class="bottom" v-if="details.department != '-1' && details.appraisee != '-1'">
                            {{ details.department != '-1' ? details.department : '-' }}
                            <text class="txt">{{ details.appraisee != '-1' ? details.appraisee : '-' }}</text>
                        </view>
                    </view>
                    <view class="details-body-bottom">
                        {{ details.eventMsg || '-' }}
                    </view>
                </view>
                <view class="details-footer">
                    <view class="details-footer-top">
                        <global-icon icon="subscribed" color="#1D2129"></global-icon>
                        <text class="txt">{{ details.examineType != -1 ? details.examineType : '-' }}</text>
                    </view>
                    <view class="details-footer-center">{{ details.examineBasis || ' -' }}</view>
                    <view class="details-footer-bottom">
                        <view class="person-info">
                            <global-icon icon="idcard"></global-icon>
                            <global-field class="txt" label="当班人员：" :value="details.onDutyUser || '-'"></global-field>
                        </view>
                        <view class="person-info">
                            <global-icon icon="idcard"></global-icon>
                            <global-field class="txt" label="值班人员：" :value="details.dmName || '-'"></global-field>
                        </view>
                    </view>
                </view>
            </view>
            <custom-card-details
                title="公司值班经理意见"
                showfooter
                :idcard="details.dmName"
                :calendar="details.optionSaveTime"
                edit
                @handleAdd="handleAdd(0)"
            >
                <custom-card-details-item label="公司值班经理" :value="details.dmName || '-'"></custom-card-details-item>
                <custom-card-details-item
                    label="公司值班经理意见"
                    :value="details.opinionType != -1 ? useGetDictByValue('ar_opinionType', details.opinionType) : '-'"
                ></custom-card-details-item>
                <custom-card-details-item label="公司值班经理意见描述" :value="details.dmMsg || '-'"></custom-card-details-item>
            </custom-card-details>
            <custom-card-details
                title="品质中心经理意见"
                showfooter
                :idcard="details.qmName"
                :calendar="details.qualitySaveTime"
                edit
                @handleAdd="handleAdd(1)"
            >
                <custom-card-details-item label="品质中心经理" :value="details.qmName || '-'"></custom-card-details-item>
                <custom-card-details-item
                    label="品质中心经理意见"
                    :value="details.qualityOpinionType != -1 ? useGetDictByValue('ar_opinionType', details.qualityOpinionType) : '-'"
                ></custom-card-details-item>
                <custom-card-details-item label="品质中心经理意见描述" :value="details.qmMsg || '-'"></custom-card-details-item>
            </custom-card-details>
            <custom-card-details title="申诉状态" titleIcon="email" edit @handleAdd="editRqmData()">
                <view class="appeal-status">{{ useGetDictByValue('ar_appealInfo', details.appealInfo) }}</view>
                <global-upload :fileList="getFileList" :showUpload="false"></global-upload>
            </custom-card-details>
        </template>
    </global-page>
</template>

<script setup>
import { timeStampFormat } from 'mocp/utils/tool'
import useAppraisalRecordStore from 'mocp/store/appraisal-record'
import { storeToRefs } from 'pinia'
import { onLoad } from '@dcloudio/uni-app'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import { getAirlineSelect } from 'mocp/utils/permission'

const query = defineProps(['id'])
const appraisalRecordStore = useAppraisalRecordStore()
const { details, getFileList } = storeToRefs(appraisalRecordStore)
onLoad(() => {
    appraisalRecordStore.setState('id', query.id)
    appraisalRecordStore.getRqmDetails()
})
// 添加
const handleAdd = (isDuty) => {
    let params = {}
    let realName = ''
    if (isDuty == 0) {
        params = { id: details.value.id, isDuty, mid: details.value.dmUid, opinionType: details.value.opinionType, msg: details.value.dmMsg }
        realName = details.value.dmName
    } else {
        params = { id: details.value.id, isDuty, mid: details.value.qmUid, opinionType: details.value.qualityOpinionType, msg: details.value.qmMsg }
        realName = details.value.qmName
    }
    uni.$mocpJump.navigateTo('/panel/appraisal-record/edit-rqm-opinion').then(() => {
        uni.$emit('appraisalRecordOpinionEdit', params, realName)
    })
}
const editRqmData = () => {
    uni.$mocpJump.navigateTo('/panel/appraisal-record/edit-rqm-data')
}
</script>
<style lang="scss" scoped>
@import './constants/details.scss';
</style>
