<!-- 门诊患者缴费明细弹框 -->
<template>
  <view class="payment-popup" v-if="show">
    <!-- 遮罩层 -->
    <view class="mask" @click="handleClose"></view>
    
    <!-- 弹框内容 -->
    <view class="popup-content">
      <!-- 头部信息区域 -->
      <view class="popup-header">
        <view class="patient-name">{{ patientInfo.name || '未填写' }}</view>
        <view class="visit-info">
          <view class="info-item">就诊科室：{{ patientInfo.department || '未填写' }}</view>
          <view class="info-item">就诊医生：{{ patientInfo.doctor || '未填写' }}</view>
          <view class="info-item">就诊时间：{{ patientInfo.time || '未填写' }}</view>
        </view>
      </view>
      
      <!-- 分隔线 -->
      <view class="divider"></view>
      
      <!-- 缴费明细区域 -->
      <view class="detail-section">
        <view class="detail-title">缴费明细</view>
        
        <!-- 明细列表头部 -->
        <view class="detail-header">
          <view class="detail-col name-col">项目名称</view>
          <view class="detail-col price-col">金额</view>
          <view class="detail-col time-col">时间</view>
          <view class="detail-col status-col">状态</view>
        </view>
        
        <!-- 明细列表内容 -->
        <view class="detail-list">
          <view 
            class="detail-item" 
            v-for="(item, index) in paymentDetails" 
            :key="index">
            <view class="detail-col name-col">{{ item.itemName }}</view>
            <view class="detail-col price-col">¥{{ item.price }}</view>
            <view class="detail-col time-col">{{ item.billDate+' '+ item.billTime}}</view>
            <view v-if="item.paidStatusDesc === '已结算'" class="detail-col status-col">{{ item.paidStatusDesc }}</view>
			<view v-if="item.paidStatusDesc !== '已结算'" class="detail-col time-col">{{ item.paidStatusDesc }}</view>
          </view>
          
          <!-- 空状态 -->
          <view class="empty-state" v-if="paymentDetails.length === 0">
            暂无缴费明细
          </view>
        </view>
      </view>
      
      <!-- 底部操作区域 -->
      <view class="popup-footer">
        <button class="close-btn" @click="handleClose">关闭</button>
      </view>
    </view>
  </view>
</template>

<script setup>
import { defineProps } from 'vue'

// 定义组件接收的参数
const props = defineProps({
  // 是否显示弹框
  show: {
    type: Boolean,
    default: false
  },
  // 患者信息
  patientInfo: {
    type: Object,
    default: () => ({
      name: '',       // 姓名
      department: '', // 就诊科室
      doctor: '',     // 就诊医生
      time: ''        // 就诊时间
    })
  },
  // 缴费明细数组
  paymentDetails: {
    type: Array,
    default: () => []
  }
})

// 定义 emits 事件
const emit = defineEmits(['close'])

// 关闭弹框
const handleClose = () => {
  emit('close')
}
</script>

<style scoped>
.payment-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
}

.mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
}

.popup-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #fff;
  border-radius: 16rpx 16rpx 0 0;
  max-height: 80vh;
  overflow-y: auto;
}

.popup-header {
  padding: 30rpx;
}

.patient-name {
  font-size: 36rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 20rpx;
}

.visit-info {
  display: flex;
  flex-wrap: wrap;
  gap: 20rpx 40rpx;
}

.info-item {
  font-size: 28rpx;
  color: #666;
  line-height: 1.5;
}

.divider {
  height: 1px;
  background-color: #f5f5f5;
  margin: 0 30rpx;
}

.detail-section {
  padding: 15rpx 30rpx;
}

.detail-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 20rpx;
}

.detail-header, .detail-item {
  display: flex;
  align-items: center;
  padding: 20rpx 0;
  border-bottom: 1px solid #f5f5f5;
}

.detail-header {
  font-weight: bold;
  color: #666;
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-col {
  font-size: 28rpx;
  text-align: center;
}

.name-col {
  flex: 3;
  text-align: left;
}

.price-col, .time-col {
  flex: 2;
}

.status-col {
  flex: 2;
  color: #f53f3f;
}

.empty-state {
  padding: 60rpx 0;
  text-align: center;
  color: #999;
  font-size: 28rpx;
}

.popup-footer {
  padding: 30rpx;
  border-top: 1px solid #f5f5f5;
}

.close-btn {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  background-color: #007aff;
  color: #fff;
  font-size: 32rpx;
  border-radius: 8rpx;
}
</style>