<template>
  <el-dialog
    v-model="dialogVisible"
    title="车型信息"
    width="800px"
    :close-on-click-modal="false"
    :modal-append-to-body="false"
  >
    <div class="car-model-info">
      <div class="info-content">
        <div class="text-info">
          <h3>{{ carModel.name }}</h3>
          <p class="description">{{ carModel.description }}</p>
          <div class="specs">
            <div class="spec-item" v-for="(spec, key) in carModel.specifications" :key="key">
              <span class="label">{{ key }}:</span>
              <span class="value">{{ spec }}</span>
            </div>
          </div>
        </div>
        <div class="image-info">
          <img :src="carModel.image" :alt="carModel.name" class="car-image" />
        </div>
      </div>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="closeDialog">关闭</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, defineProps, defineEmits } from 'vue';

const props = defineProps({
  modelValue: Boolean,
  carModel: {
    type: Object,
    required: true
  }
});

const emit = defineEmits(['update:modelValue']);

const dialogVisible = computed({
  get: () => props.modelValue,
  set: (val) => emit('update:modelValue', val)
});

const closeDialog = () => {
  dialogVisible.value = false;
};
</script>

<style scoped lang="scss">
.car-model-info {
  padding: 20px;
  
  .info-content {
    display: flex;
    gap: 30px;
    
    .text-info {
      flex: 1;
      
      h3 {
        margin: 0 0 15px 0;
        font-size: 20px;
        color: #333;
      }
      
      .description {
        color: #666;
        line-height: 1.6;
        margin-bottom: 20px;
      }
      
      .specs {
        .spec-item {
          margin-bottom: 10px;
          
          .label {
            font-weight: bold;
            margin-right: 10px;
            color: #333;
          }
          
          .value {
            color: #666;
          }
        }
      }
    }
    
    .image-info {
      width: 400px;
      
      .car-image {
        width: 100%;
        height: auto;
        border-radius: 8px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
      }
    }
  }
}

.dialog-footer {
  text-align: right;
  padding-top: 20px;
}
</style> 