<template>
    <global-page
        title="技术评估"
        isDataList
        refresherEnabled
        loadingMoreEnabled
        auto
        ref="paging"
        :params="searchData"
        showNavRight
        navRightType="icon"
        navRightIcon="saixuan-01"
        @handleRightClick="handleRightClick"
        :api="getTechnicalEvaluationApi"
        :padding="24"
    >
        <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>
</template>

<script setup>
import { ref } from 'vue'
import Day from 'mocp/utils/dayjs'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import useTechnologyEvaluationStore from 'mocp/store/technology-evaluation'
import { storeToRefs } from 'pinia'
import { onUnload } from '@dcloudio/uni-app'
import { getTechnicalEvaluationApi } from 'mocp/api/technology-evaluation'
import { getAirlineSelect } from 'mocp/utils/permission'

//跳转
const technologyEvaluationStore = useTechnologyEvaluationStore()
const { searchData } = storeToRefs(technologyEvaluationStore)
const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/technology-evaluation/details', { id: data.id }).then(() => {
        technologyEvaluationStore.setState('details', data)
    })
}
//筛选
const handleRightClick = () => {
    uni.$mocpJump.navigateTo('/panel/technology-evaluation/search')
}
//刷新
const paging = ref()
uni.$on('technologyEvaluationReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('technologyEvaluationReload')
})
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
