<template>
    <global-page-swiper title="考核记录" refresherEnabled loadingMoreEnabled :tabList="tabList" :api="getRqmListApi">
        <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">{{ showData(item.appraisee) }}</view>
                            <view class="place">{{ showData(item.department) }}</view>
                        </view>
                        <score-details v-if="item.score > 0" :type="item.eventType == 1 ? 'success' : 'warning'">{{ item.score }}</score-details>
                    </view>
                    <view class="item-content">
                        {{ item.eventMsg || '暂无内容~' }}
                    </view>
                </view>
            </view>
        </template>
    </global-page-swiper>
</template>

<script setup>
import { ref } from 'vue'
import { getRqmListApi, getRqmOptionsApi } from '@/api/appraisal-record'
import { onLoad } from '@dcloudio/uni-app'
import { showData } from '@/utils/tool'

const tabList = ref([
    { name: 'OPEN', value: 1 },
    { name: 'CLOSE', value: 0 },
    { name: '全部', value: -1 }
])
//跳转
const goDetails = (data) => {
    uni.navigateTo({
        url: 'details',
        success: () => {
            uni.$emit('appraisalRecordDetials', data)
        }
    })
}
//获取选项数据
const appraisee = ref([])
const department = ref([])
const examineType = ref([])
const getRqmOptions = async () => {
    const res = await getRqmOptionsApi()
    if (res.code == 200) {
        appraisee.value = res.data.appraisee || []
        department.value = res.data.department || []
        examineType.value = res.data.examineType || []
    } else {
        uni.$message.showToast(res.message)
    }
}
onLoad(() => {
    getRqmOptions()
})
</script>
<style lang="scss" scoped>
@import './constants/list.scss';
</style>
