<template>
    <global-page
        title="布置工作"
        isDataList
        refresherEnabled
        loadingMoreEnabled
        auto
        ref="paging"
        :params="searchParams"
        :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">{{ baseStore.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 useBaseStore from 'mocp/store/base'
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'

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