<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 }">
                <up-swipe-action>
                    <up-swipe-action-item
                        @click="handleDelete(item)"
                        :options="[
                            {
                                text: '移除',
                                style: {
                                    backgroundColor: '#f53f3f'
                                }
                            }
                        ]"
                    ></up-swipe-action-item>
                </up-swipe-action>
                <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: baseStore.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">
                                {{ Day(item.dateTime).format('YYYY/MM/DD') }}
                            </text>
                        </view>
                    </view>
                </view>
            </template>
        </global-page>
    </up-collapse-item>
</template>

<script setup>
import useBaseStore from 'mocp/store/base'
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'

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

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