<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">
      <div/>
      <div>
        <van-button
          v-if="!['2'].includes(props.item.recipientConfirmStatus) && !props.item.agentUserId"
          type="primary"
          size="small"
          beautify
          @tap.stop="onTransfer">转交</van-button>
        <van-button
          v-if="!['2'].includes(props.item.recipientConfirmStatus)"
          style="margin-left:1rem;"
          type="primary"
          size="small"
          beautify
          @tap.stop="onConfirm">确认交接</van-button>
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
@marginTop: 0.8rem;
.list-item {
  margin-top: 1.2rem;
  background-color: #fff;
  border-radius: 24rpx;
  padding: 1.6rem 1.8rem @marginTop;
  font-size: 1.4rem;
  box-shadow: 0 4rpx 40rpx  rgba(64, 103, 251, 0.14);
  &__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    &-title {
      flex: 1;
      display: flex;
      align-items: center;
      overflow: hidden;
      &-firstword {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-right: 0.6rem;
        width: 2.6rem;
        height: 2.6rem;
        font-size: 1rem;
        color: #fff;
        background-color: var(--van-primary-color);
        border-radius: 0.6rem;
      }
      &-label {
        flex: 1;
        overflow: hidden;
        font-size: 1.4rem;
        color: #333;
        font-weight: bold;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
    &-time {
      margin-left: 0.6rem;
      color: #999;
      font-size: 1.2rem;
    }
  }
  &__address {
    display: flex;
    margin-top: @marginTop;
    color: #999;
    :deep(.tag-label) {
      font-size: 1.4rem;
    }
  }
  &__date {
    margin-top: @marginTop;
    display: flex;
    justify-content: space-between;
    color: #999;
  }
  &__days {
    margin-top: @marginTop;
    color: #999;
  }
  &__detail {
    margin-top: @marginTop;
    display: flex;
    color: #999;
    &-content {
      flex: 1;
      overflow: hidden;
      word-break: break-all;
    }
  }
  &__status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: @marginTop;
  }
}
</style>
