<!--通话记录卡片组件-->
<template>
  <view class="call-record-card">
    <view class="call-header">
      <view class="call-time">{{ formatCallTime(record.call_time) }}</view>
      <view class="call-duration">{{ formatDuration(record.duration) }}</view>
    </view>
    
    <view class="call-info">
      <view class="info-row">
        <text class="info-label">通话类型：</text>
        <text class="info-value">{{ getCallType(record.call_type) }}</text>
      </view>
      <view class="info-row" v-if="record.caller_name">
        <text class="info-label">拨打人员：</text>
        <text class="info-value">{{ record.caller_name }}</text>
      </view>
      <view class="info-row" v-if="record.phone_number">
        <text class="info-label">通话号码：</text>
        <text class="info-value">{{ record.phone_number }}</text>
      </view>
    </view>
    
    <view class="call-notes" v-if="record.notes">
      <text class="notes-label">通话备注：</text>
      <text class="notes-content">{{ record.notes }}</text>
    </view>
  </view>
</template>

<script>
export default {
  name: 'CallRecordCard',
  props: {
    record: {
      type: Object,
      required: true
    }
  },
  methods: {
    formatCallTime(time) {
      if (!time) return '未知时间'
      return this.$util.formatToDateTime(time, 'Y-m-d H:i')
    },
    
    formatDuration(duration) {
      if (!duration || duration <= 0) return '0秒'
      
      const minutes = Math.floor(duration / 60)
      const seconds = duration % 60
      
      if (minutes > 0) {
        return `${minutes}分${seconds}秒`
      }
      return `${seconds}秒`
    },
    
    getCallType(type) {
      const typeMap = {
        1: '呼出',
        2: '呼入',
        3: '未接'
      }
      return typeMap[type] || '未知'
    }
  }
}
</script>

<style lang="less" scoped>
.call-record-card {
  background-color: #1a1a1a;
  border-radius: 15rpx;
  padding: 25rpx;
  margin-bottom: 20rpx;
  border: 1rpx solid #333;
}

.call-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
  
  .call-time {
    color: white;
    font-size: 26rpx;
    font-weight: bold;
  }
  
  .call-duration {
    color: #29d3b4;
    font-size: 22rpx;
    background-color: rgba(41, 211, 180, 0.2);
    padding: 6rpx 15rpx;
    border-radius: 15rpx;
  }
}

.call-info {
  .info-row {
    display: flex;
    align-items: center;
    margin-bottom: 15rpx;
    
    .info-label {
      color: #999;
      font-size: 22rpx;
      width: 150rpx;
      flex-shrink: 0;
    }
    
    .info-value {
      color: white;
      font-size: 22rpx;
      flex: 1;
    }
  }
}

.call-notes {
  margin-top: 15rpx;
  padding-top: 15rpx;
  border-top: 1rpx solid #333;
  
  .notes-label {
    color: #999;
    font-size: 22rpx;
    display: block;
    margin-bottom: 8rpx;
  }
  
  .notes-content {
    color: white;
    font-size: 22rpx;
    line-height: 1.5;
    word-break: break-all;
  }
}
</style>