<template>
    <up-collapse-item :title="`考核记录（${getAppraisalRecordNum}）`" v-if="getAppraisalRecordNum > 0">
        <global-page
            :fixed="false"
            :height="height"
            :showNavbar="false"
            :custom="false"
            isDataList
            refresherEnabled
            loadingMoreEnabled
            :params="{
                userId: userStore.userInfo?.id
            }"
            :api="getRqmListForMobileApi"
            @handleQuery="handleQuery"
            auto
        >
            <template #default="{ item }">
                <view class="item" @tap="goDetails(item)">
                    <view class="item-title">
                        <view class="desc">
                            <custom-state :value="item.status == 1 ? 'OPEN' : 'CLOSE'"></custom-state>
                            <view class="txt">{{ item.appraisee != '-1' ? item.appraisee : '' }}</view>
                            <view class="place">{{ item.department != '-1' ? item.department : '' }}</view>
                        </view>
                        <custom-score v-if="item.score != -1" :count="item.score" :type="item.eventType == 1 ? 'success' : 'warning'"></custom-score>
                    </view>
                    <view class="item-content u-line-3">
                        {{ item.eventMsg || '无' }}
                    </view>
                </view>
            </template>
        </global-page>
    </up-collapse-item>
</template>

<script setup>
import { getRqmListForMobileApi } from 'mocp/api/my-toDo'
import useUserStore from 'mocp/store/user'
import useMyToDoStore from 'mocp/store/my-toDo'
import { storeToRefs } from 'pinia'
import { checkPermi } from 'mocp/utils/permission'

const userStore = useUserStore()
const myToDoStore = useMyToDoStore()
const { getAppraisalRecordNum } = storeToRefs(myToDoStore)
const ps = defineProps({
    height: {
        type: String,
        default: ''
    }
})
//跳转
const goDetails = (data) => {
    if (checkPermi('/AppraisalRecord')) {
        uni.$mocpJump.navigateTo('/panel/appraisal-record/details', {
            id: data.id
        })
    }
}
const handleQuery = ({ res }) => {
    myToDoStore.setState('appraisalRecordNum', parseInt(res.total) || 0)
}
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
