<template>
    <global-page
        title="布置工作"
        isDataList
        refresherEnabled
        loadingMoreEnabled
        auto
        ref="paging"
        :params="searchData"
        :api="getArrangeWorkListApi"
        :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="left">
                        <custom-state :value="item.state == 1 ? 'OPEN' : 'CLOSE'"></custom-state>
                        <view class="txt u-line-1">{{ item.seat }}</view>
                    </view>
                    <view class="right u-line-1">{{ getParamNameByValue('LayoutWorkType', item.workType) }}</view>
                </view>
                <view class="item-content u-line-3">
                    {{ item.taskDescribe }}
                </view>
                <view class="item-footer">
                    <view class="label">
                        <global-icon icon="calendar"></global-icon>
                        <text class="txt">
                            {{ timeStampFormat(item.startTime, { format: 'YYYY/MM/DD' }) }}
                            -
                            {{ timeStampFormat(item.feedbackTime, { format: 'YYYY/MM/DD' }) }}
                        </text>
                    </view>
                    <view class="label">
                        <global-icon icon="idcard"></global-icon>
                        <text class="txt">提出人:{{ item.presenter || '-' }}</text>
                    </view>
                </view>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { timeStampFormat } from 'mocp/utils/tool'
import { getArrangeWorkListApi } from 'mocp/api/assign-work'
import useAssignWorkStore from 'mocp/store/assign-work'
import { onLoad, onUnload } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { storeToRefs } from 'pinia'
import { getParamNameByValue } from 'mocp/hooks/use-params/useParams'

//加载下拉框数据
const assignWorkStore = useAssignWorkStore()
onLoad(() => {
    assignWorkStore.getSeatUnit()
})
//跳转
const { searchData } = storeToRefs(assignWorkStore)
const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/assign-work/details', { id: data.id })
}
//筛选
const handleRightClick = () => {
    uni.$mocpJump.navigateBack()
}
//刷新
const paging = ref()
uni.$on('assignWorkReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('assignWorkReload')
})
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
