<template>
  <div class="detail-container">
    <el-card shadow="hover">
      <el-descriptions title="基础信息" :column="3">
        <el-descriptions-item label="发生时间: ">{{
          detailData.event?.occurTime
        }}</el-descriptions-item>
        <el-descriptions-item label="发生地点: ">{{
          detailData.event?.occurLocation
        }}</el-descriptions-item>
        <el-descriptions-item label="线路编号: ">{{
          detailData.event?.routeNo
        }}</el-descriptions-item>
        <el-descriptions-item label="填报时间: ">{{
          detailData.event?.reportTime
        }}</el-descriptions-item>
        <el-descriptions-item label="填报人: ">{{
          detailData.event?.reporterName
        }}</el-descriptions-item>
        <el-descriptions-item label="所属区县: ">{{
          detailData.event?.district
        }}</el-descriptions-item>
        <el-descriptions-item label="所属服务站: ">{{
          detailData.event?.stationName
        }}</el-descriptions-item>
      </el-descriptions>
      <el-row :gutter="20" class="custom-row">
        <el-col :span="8">
          <div class="stake-item">
            <span class="label">起点桩号：</span>
            <span class="value">{{ detailData.event?.startStakeNo }}</span>
          </div>
        </el-col>

        <el-col :span="8">
          <div class="middle-column">
            <div class="disaster-mileage">
              受灾里程: {{ detailData.event?.disasterMileage }}
            </div>
            <div class="dash-line-container">
              <span class="dash-line"></span>
            </div>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="stake-item">
            <span class="label">止点桩号：</span>
            <span class="value">{{ detailData.event?.endStakeNo }}</span>
          </div>
        </el-col>
      </el-row>
    </el-card>
    <el-card shadow="hover">
      <el-descriptions title="处置情况" :column="3">
        <el-descriptions-item label="处置措施: ">{{
          detailData.event?.disposalMeasures
        }}</el-descriptions-item>
        <el-descriptions-item label="预计恢复时间: ">{{
          detailData.event?.expectRecoverTime
        }}</el-descriptions-item>
      </el-descriptions>
    </el-card>
    <el-card shadow="hover">
      <el-descriptions title="物资情况" :column="3">
        <el-descriptions-item label="投入人力: ">{{
          detailData.material?.inputManpower + "人次"
        }}</el-descriptions-item>
        <el-descriptions-item label="投入资金: ">{{
          detailData.material?.inputFunds + "万元"
        }}</el-descriptions-item>
        <el-descriptions-item label="投入设备: ">{{
          detailData.material?.inputEquipment + "台班"
        }}</el-descriptions-item>
        <el-descriptions-item
          v-for="(item, index) in detailData.materialUsageList"
          :key="index"
          :label="item.materialName + ': '"
          >{{ item.usageAmount + "" + item.materialUnit }}
        </el-descriptions-item>
      </el-descriptions>
      <el-divider />
      <el-descriptions title="通行情况" :column="3">
        <el-descriptions-item label="当前通行情况: ">{{
          {
            1: "正常通行",
            2: "限速通行",
            3: "封闭交通",
          }[detailData.traffic?.currentStatus] || "未知状态"
        }}</el-descriptions-item>
        <el-descriptions-item label="有无车辆滞留: ">{{
          {
            0: "无",
            1: "有",
          }[detailData.traffic?.hasStrandedVehicles] || "未知状态"
        }}</el-descriptions-item>
        <el-descriptions-item
          v-if="detailData.traffic?.hasStrandedVehicles === 1"
          label="滞留车辆数: "
          >{{
            detailData.traffic?.strandedVehicleCount + "辆"
          }}</el-descriptions-item
        >
        <el-descriptions-item label="实际恢复时间: ">{{
          detailData.traffic?.actualRecoverTime
        }}</el-descriptions-item>
      </el-descriptions>
      <el-divider />
      <el-descriptions title="现场情况" :column="3"> </el-descriptions>
      <el-image
        v-for="(item) in detailData.photos"
        :key="item.id"
        style="
          width: 100px;
          height: 100px;
          margin: 10px;
        "
        :src="item.photoUrl"
        :zoom-rate="1.2"
        :max-scale="7"
        :min-scale="0.2"
        :preview-src-list="[item.photoUrl]"
        show-progresss
        fit="cover"
      />
    </el-card>
  </div>
</template>

<script setup>
const props = defineProps({
  detailData: {
    type: Object,
    default: () => ({}),
  },
});
</script>

<style>
.detail-container {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.stake-item {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  height: 100%;
  padding-bottom: 8px;
}
.label {
  color: #606266;
  white-space: nowrap;
}
.value {
  color: #909399;
}
.custom-row {
  margin-top: 30px;
  text-align: center;
}
.middle-column {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}
.disaster-mileage {
  margin-bottom: 2px;
  color: #606266;
}
.dash-line-container {
  width: 100%;
  position: relative;
  margin-top: 4px;
}
.dash-line {
  display: block;
  width: 100%;
  height: 1px;
  background: repeating-linear-gradient(
    to right,
    #909399 0px,
    #909399 2px,
    transparent 2px,
    transparent 4px
  );
}
</style>