<template>
  <view
    class="card-shadow bg-white rounded-19rpx p-base space-y-10rpx"
    @click.stop="onClick"
  >
    <view class="flex items-center justify-between">
      <view class="text-30rpx">{{ item.name }}</view>
      <view
        :style="{
          color: statusFun(item.taskable.status, item.taskable_type, 'color'),
        }"
        class="text-24rpx"
        >{{ statusFun(item.taskable.status, item.taskable_type, 'name') }}</view
      >
    </view>
    <view class="text-24rpx text-hex-999999">
      任务时间：{{ timeFormat(item.start_at, 'yyyy年mm月dd日') }} -
      {{ timeFormat(item.end_at, 'yyyy年mm月dd日') }}
    </view>
  </view>
</template>
<script setup>
import { computed } from 'vue'
import statusFun from '@/utils/status'
import { timeFormat } from '@climblee/uv-ui/libs/function/index'
const props = defineProps({
  item: Object,
})

const onClick = () => {
  console.log(props.item)
  const type = props.item.taskable_type
  const { status } = props.item.taskable
  let url
  if (type === 'task_hygienes') {
    if (status === 2 || status == 4) {
      url = `/pages/task/task_hygienes_submit?id=${props.item.id}`
    } else {
      url = `/pages/task/detail?id=${props.item.id}`
    }
  } else if (type === 'task_ledgers') {
    url = `/pages/task/${type}_submit?id=${props.item.id}`
  }
  uni.navigateTo({
    url: url,
  })
}

const onTask = (e) => {
  const type = props.item.taskable_type
  uni.navigateTo({
    url: `/pages/task/${type}_submit?id=${props.item.id}`,
  })
}
</script>
