<template>
    <up-collapse-item :title="`技术评估（${getTechnologyEvaluationNum}）`" v-if="getTechnologyEvaluationNum > 0">
        <global-page
            :fixed="false"
            :height="height"
            :showNavbar="false"
            :custom="false"
            isDataList
            refresherEnabled
            loadingMoreEnabled
            :api="getTechnicalEvaluationToDoApi"
            @handleQuery="handleQuery"
            auto
        >
            <template #default="{ item }">
                <view class="item" @tap="goDetails(item)">
                    <view class="item-title">
                        <view class="left">
                            <custom-state :value="useGetDictByValue('te_state', item.state)"></custom-state>
                        </view>
                        <view class="right">
                            <text class="txt u-line-1" v-if="item.ac">{{ item.ac }}</text>
                            <text class="txt u-line-1" v-if="item.model">{{ item.model }}</text>
                            <text class="txt u-line-1" v-if="item.aviation">
                                {{ useGetDictByValue('', item.aviation, { data: getAirlineSelect() }) }}
                            </text>
                        </view>
                    </view>
                    <view class="item-content u-line-3">
                        {{ item.description || '无' }}
                    </view>
                    <view class="item-footer">
                        <view class="label">
                            <global-icon icon="calendar"></global-icon>
                            <text class="txt">
                                {{ item.dateTime ? Day(item.dateTime).format('YYYY/MM/DD') : '-' }}
                            </text>
                        </view>
                    </view>
                </view>
            </template>
        </global-page>
    </up-collapse-item>
</template>

<script setup>
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import Day from 'mocp/utils/dayjs'
import useTechnologyEvaluationStore from 'mocp/store/technology-evaluation'
import { getTechnicalEvaluationToDoApi } from 'mocp/api/my-toDo'
import useMyToDoStore from 'mocp/store/my-toDo'
import { storeToRefs } from 'pinia'
import { checkPermi, getAirlineSelect } from 'mocp/utils/permission'

const myToDoStore = useMyToDoStore()
const { getTechnologyEvaluationNum } = storeToRefs(myToDoStore)

const ps = defineProps({
    height: {
        type: String,
        default: ''
    }
})
//跳转
const technologyEvaluationStore = useTechnologyEvaluationStore()
const goDetails = (data) => {
    if (checkPermi('/technologyEvaluation')) {
        uni.$mocpJump.navigateTo('/panel/technology-evaluation/details', { id: data.id }).then(() => {
            technologyEvaluationStore.setState('details', data)
        })
    }
}
const handleQuery = ({ res }) => {
    myToDoStore.setState('technologyEvaluationNum', parseInt(res.data.total) || 0)
}
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
