<template>
    <global-page
        ref="paging"
        :api="getRsDataList2Api"
        :padding="24"
        :params="searchData"
        auto
        isDataList
        loadingMoreEnabled
        navRightIcon="saixuan-01"
        navRightType="icon"
        refresherEnabled
        showNavRight
        title="运行调查"
        @handleRightClick="handleRightClick"
    >
        <template #default="{ item }">
            <view class="item" @tap="goDetails(item)">
                <view class="item-title">
                    <view class="left">
                        <custom-state :value="useGetDictByValue('os_isOpen', item.isOpen)"></custom-state>
                    </view>
                    <view class="right">
                        <text class="txt u-line-1" v-if="item.ac">{{ item.ac }}</text>
                        <text class="txt u-line-1" v-if="item.acType">{{ item.acType }}</text>
                        <text class="txt u-line-1" v-if="item.acOwn">{{ item.acOwn }}</text>
                        <text class="txt u-line-1" v-if="item.acTerminal">{{ item.acTerminal }}</text>
                    </view>
                </view>
                <view class="item-content u-line-3">
                    {{ item.eventMsg || '无' }}
                </view>
                <view class="item-footer">
                    <view class="label">
                        <global-icon icon="calendar"></global-icon>
                        <text class="txt">
                            {{ timeStampFormat(item.proposedTime) }}
                        </text>
                    </view>
                    <view class="label u-line-1">
                        <global-icon icon="idcard"></global-icon>
                        <text class="txt">提出人:{{ item.proposer || '-' }}</text>
                    </view>
                </view>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import { onUnload } from '@dcloudio/uni-app'
import { ref } from 'vue'
import useOperationalSurveyStore from 'mocp/store/operationalSurvey'
import { getRsDataList2Api } from 'mocp/api/operationalSurvey'
import { timeStampFormat } from 'mocp/utils/tool'

//跳转
const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/operationalSurvey/details', {
        workbenchId: data.workbenchId
    })
}
//加载下拉框数据
const operationalSurveyStore = useOperationalSurveyStore()
const { searchData } = storeToRefs(operationalSurveyStore)
//筛选
const handleRightClick = () => {
    uni.$mocpJump.navigateTo('/panel/operationalSurvey/search')
}
const paging = ref()
uni.$on('operationalSurveyReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('operationalSurveyReload')
})
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
