<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 }">
                <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="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'

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