<template>
    <global-page
        title="技术评估"
        isDataList
        refresherEnabled
        loadingMoreEnabled
        auto
        ref="paging"
        :params="searchParams"
        showNavRight
        navRightType="icon"
        navRightIcon="saixuan-01"
        @handleRightClick="handleRightClick"
        :api="getTechnicalEvaluationApi"
        :padding="24"
    >
        <template #="{ dataList }">
            <view class="item" v-for="item in dataList" :key="item.id" @tap="goDetails(item)">
                <view class="item-title">
                    <view class="left">
                        <custom-state :value="useGetDictByValue('te_state', item.state)"></custom-state>
                    </view>
                    <view class="right">
                        <view class="label">
                            <global-field class="txt" label="机号:" :value="item.ac || '-'"></global-field>
                        </view>
                        <view class="label">
                            <global-field class="txt" label="机型:" :value="item.model || '-'"></global-field>
                        </view>
                    </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">
                            {{ 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 { onUnload } from '@dcloudio/uni-app'
import { getTechnicalEvaluationApi } from 'mocp/api/technology-evaluation'

//跳转
const technologyEvaluationStore = useTechnologyEvaluationStore()
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 searchParams = ref()
const paging = ref()
uni.$on('technologyEvaluationReload', ({ params }) => {
    if (params) {
        searchParams.value = params
    }
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('technologyEvaluationReload')
})
</script>
<style lang="scss" scoped>
@import './constants/list.scss';
</style>
