<template>
    <global-page-swiper title="考核记录" refresherEnabled loadingMoreEnabled :tabList="tabList" :api="getRqmListApi" ref="paging" :padding="24">
        <template #="{ dataList }">
            <view class="item" v-for="item in dataList" :key="item.id" @tap="goDetails(item)">
                <view class="item-title">
                    <view class="desc">
                        <view class="type">{{ item.status == 1 ? 'OPEN' : 'ClOSE' }}</view>
                        <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" :type="item.eventType == 1 ? 'success' : 'warning'" :count="item.score"></custom-score>
                </view>
                <view class="item-content u-line-3">
                    {{ item.eventMsg || '暂无内容~' }}
                </view>
            </view>
        </template>
    </global-page-swiper>
</template>

<script setup>
import { ref } from 'vue'
import { getRqmListApi } from 'mocp/api/appraisal-record'
import { onLoad, onUnload } from '@dcloudio/uni-app'
import useAppraisalRecordStore from 'mocp/store/appraisal-record'

const tabList = ref([
    { name: 'OPEN', value: 1 },
    { name: 'CLOSE', value: 0 },
    { name: '全部', value: -1 }
])
//跳转
const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/appraisal-record/details', {
        id: data.id
    })
}
//加载下拉框数据
const appraisalRecordStore = useAppraisalRecordStore()
onLoad(() => {
    appraisalRecordStore.getRqmOptions()
})
//刷新
const paging = ref()
uni.$on('appraisalRecordReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('appraisalRecordReload')
})
</script>
<style lang="scss" scoped>
@import './constants/list.scss';
</style>
