<template>
    <global-page-swiper title="考核记录" refresherEnabled loadingMoreEnabled :tabList="tabList" :api="getRqmListApi" ref="paging">
        <template #="{ dataList }">
            <view class="list">
                <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>
                        <global-score v-if="item.score != -1" :type="item.eventType == 1 ? 'success' : 'warning'" :count="item.score"></global-score>
                    </view>
                    <view class="item-content">
                        {{ item.eventMsg || '暂无内容~' }}
                    </view>
                </view>
            </view>
        </template>
    </global-page-swiper>
</template>

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

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