<script setup lang="ts" name="HandoverConfirmListItem">
import { parseTime } from '@/common/utils/ruoyi'

const emit = defineEmits<{
  'transfer': [item: any]
  'confirm': [item: any]
}>()
const props = defineProps<{
  item: any
  recipient_confirm_status: any
  recipient_confirm_type: any
  audit_status: any
  userInfo: any
}>()

function onTransfer() {
  emit('transfer', props.item)
}
function onConfirm() {
  emit('confirm', props.item)
}
</script>

<template>
  <div class="list-item">
    <div class="list-item__top">
      <div class="list-item__top-title">
        <div class="list-item__top-title-firstword">{{ props.item.staffName.substr(0, 1) }}</div>
        <div class="list-item__top-title-label">{{ props.item.staffName }}提交的交接确认</div>
      </div>
      <div class="list-item__top-time">{{ parseTime(props.item.createTime, '{y}-{m}-{d}') }}</div>
    </div>
    <div class="list-item__detail">接收人/转交人：{{ props.item.recipientUser }}</div>
    <div class="list-item__detail">确认时间：{{ props.item.recipientConfirmTime }}</div>
    <div class="list-item__detail">离职日期：{{ props.item.departureDate }}</div>
    <div class="list-item__detail">确认状态：<DictTag :options="props.recipient_confirm_status" :value="props.item.recipientConfirmStatus" /></div>
    <div class="list-item__detail">
      <div>离职原因：</div>
      <div class="list-item__detail-content">{{ props.item.departureReason }}</div>
    </div>
    <van-divider v-if="!['2'].includes(props.item.recipientConfirmStatus) || !props.item.agentUserId" style="margin: 0.8rem 0;" />
    <div v-if="!['2'].includes(props.item.recipientConfirmStatus) || !props.item.agentUserId" class="list-item__status" style="display: flex;">
      
        <uv-button
          v-if="!['2'].includes(props.item.recipientConfirmStatus) && !props.item.agentUserId"
          type="primary"
          size="small"
          beautify
          @tap.stop="onTransfer">转交</uv-button>
        <uv-button
          v-if="!['2'].includes(props.item.recipientConfirmStatus)"
          style="margin-left:1rem;"
          type="primary"
          size="small"
          beautify
          @tap.stop="onConfirm">确认交接</uv-button>
    </div>
  </div>
</template>

<style lang="less" scoped>
@marginTop: 0.8rem;
.list-item {
  margin-top: 24rpx;
  background-color: #fff;
  border-radius: 24rpx;
  padding: 32rpx 36rpx 24rpx; /* 使用CSS变量处理动态marginTop */
  font-size: 28rpx;
  box-shadow: 0 4rpx 40rpx rgba(64, 103, 251, 0.14);
}

.list-item__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-item__top-title {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.list-item__top-title-firstword {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 12rpx;
  width: 52rpx;
  height: 52rpx;
  font-size: 20rpx;
  color: #fff;
  background-color: var(--van-primary-color);
  border-radius: 12rpx;
}

.list-item__top-title-label {
  flex: 1;
  overflow: hidden;
  font-size: 28rpx;
  color: #333;
  font-weight: bold;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.list-item__top-time {
  margin-left: 12rpx;
  color: #999;
  font-size: 24rpx;
}

.list-item__address {
  display: flex;
  margin-top: 24rpx;
  color: #999;
}

.list-item__address :deep(.tag-label) {
  font-size: 28rpx;
}

.list-item__date {
  margin-top: 24rpx;
  display: flex;
  justify-content: space-between;
  color: #999;
}

.list-item__days {
  margin-top: 24rpx;
  color: #999;
}

.list-item__detail {
  margin-top: 24rpx;
  display: flex;
  color: #999;
}

.list-item__detail-content {
  flex: 1;
  overflow: hidden;
  word-break: break-all;
}

.list-item__status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24rpx;
}
</style>
