<!--
 * @Descripttion: 新生儿探视列表卡片组件
 * @Company: 思宏科技
 * @version: v1.0
 * @Author: zhouxin
 * @Date: 2022-05-07 11:03:20
 * @LastEditors: zhangzhuobin 1093998108@qq.com
-->
<template>
  <view class="newborn-box">
    <view v-if="newbornlist.length > 0">
      <view
        v-for="(item, index) in newbornlist"
        :key="index"
        class="newborn-list"
        @click="handleNav(item, index)"
      >
        <view>
          <view class="time-status-box">
            <view class="left">
              {{ item.visitTime }}
            </view>
            <view
              class="right"
              :class="['status', 'color-' + item.visitState]"
            >{{ visitStateEnumeration[item.visitState] }}</view>
          </view>
          <view class="newborn-item">
            <view class="left">医院名称:</view>
            <view class="right">{{ hospitalName }}</view>
          </view>
          <view class="newborn-item">
            <view class="left">住院号:</view>
            <view class="right">{{ item.admissionNum }}</view>
            <!-- <view class="right">{{ handleBabyName(item.motherName, item.sex) }}</view> -->

          </view>
          <view class="newborn-item">
            <view class="left">父亲:</view>
            <view class="right">{{ item.fatherName }}</view>
          </view>
          <view class="newborn-item">
            <view class="left">母亲:</view>
            <view class="right">{{ item.motherName }}</view>
          </view>
          <view class="newborn-item">
            <view class="left">申请时间:</view>
            <view class="right">{{ item.createTime }}</view>
          </view>
        </view>
        <u-icon name="arrow-right" color="#cacaca" size="32" />
      </view>
    </view>
  </view>
</template>

<script>
import { visitStateEnumeration } from '@/utils/public-enumeration'

import dayjs from 'dayjs'

export default {
  props: {
    newbornlist: {
      type: [Array],
      default() {
        return []
      }
    }
  },
  data() {
    return {
      // day.js时间转换方法
      dayjs,
      // 是否弹出选择窗口状态
      showStatus: false,
      // 远程状态枚举
      visitStateEnumeration,
      hospitalName: uni.getStorageSync('exactaddress')
    }
  },
  computed: {
  },
  methods: {
    /**
     * item:卡片的数据
     */
    handleNav(item) {
      console.log(item, '卡片的数据')
      uni.navigateTo({ url: `/pages/babyVisit/applyBorn/applyBorn?id=${item.id}` })
    },
    //
    handleBabyName(name, sex) {
      return `${name}之${sex === 0 ? '子(男孩)' : '女(女孩)'}`
    }
  }
}
</script>

<style lang="scss" scoped>
@import 'styles/status-color.scss';
.newborn-box {
  padding-bottom: 100rpx;
  padding: 0 30rpx;
  .newborn-list {
    padding: 20rpx 0;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .time-status-box {
      display: flex;
      margin-bottom: 6rpx;
      .left {
        font-size: 32rpx;
        font-weight: bold;
        margin-right: 20rpx;
      }
      .right {
        // color: #f56e23;
      }
    }
    .newborn-item {
      display: flex;
      align-items: center;
      padding-top: 10rpx;
      color: #999;
      font-size: 28rpx;
      .msg {
        display: flex;
        align-items: center;
        margin-right: 20rpx;
      }
      .right {
        color: #333;
        margin-left: 20rpx;
      }
    }
  }
}
</style>
