<template>
    <global-page
        title="考核记录"
        isDataList
        refresherEnabled
        loadingMoreEnabled
        :params="searchParams"
        :api="getRqmListApi"
        auto
        ref="paging"
        :padding="24"
        showNavRight
        navRightType="icon"
        navRightIcon="saixuan-01"
        @handleRightClick="handleRightClick"
    >
        <template #="{ dataList }">
            <view class="item" v-for="item in dataList" :key="item.id" @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" :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>
</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 goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/appraisal-record/details', {
        id: data.id
    })
}
//加载下拉框数据
const appraisalRecordStore = useAppraisalRecordStore()
onLoad(() => {
    appraisalRecordStore.getRqmOptions()
})
//筛选
const handleRightClick = () => {
    uni.$mocpJump.navigateTo('/panel/appraisal-record/search')
}
//刷新
const searchParams = ref()
const paging = ref()
uni.$on('appraisalRecordReload', ({ params }) => {
    if (params) {
        searchParams.value = params
    }
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('appraisalRecordReload')
})
</script>
<style lang="scss" scoped>
@import './constants/list.scss';
</style>
