<template>
  <div class="home">
    <van-nav-bar title="冰雪灾害" fixed left-arrow @click-left="onClickLeft" />

    <van-cell-group>
      <van-cell title="当前站点" :value="yhzDetail.mc" />
    </van-cell-group>

    <div class="content">
      <van-cell-group>
        <van-cell
          title="基本信息"
          style="font-size: 18px; font-weight: bold; line-height: inherit"
        >
        </van-cell>
        <van-cell :title="'发生时间： ' + eventDetailData?.event?.occurTime"> </van-cell>
        <van-cell :title="'发生地点： ' + eventDetailData?.event?.occurLocation"> </van-cell>
        <van-cell :title="'起点桩号： ' + eventDetailData?.event?.startStakeNo"> </van-cell>
        <van-cell :title="'止点桩号： ' + eventDetailData?.event?.endStakeNo"> </van-cell>
        <van-cell :title="'受灾里程： ' + eventDetailData?.event?.disasterMileage"> </van-cell>
        <van-cell :title="'填报人： ' + eventDetailData?.event?.reporterName"> </van-cell>
        <van-cell :title="'填报时间： ' + eventDetailData?.event?.reportTime"> </van-cell>
      </van-cell-group>
      <van-cell-group>
        <van-cell
          title="处置情况"
          style="font-size: 18px; font-weight: bold; line-height: inherit"
        >
        </van-cell>
        <van-cell :title="'处置措施： ' + eventDetailData?.event?.disposalMeasures"> </van-cell>
        <van-cell :title="'预计恢复时间： ' + eventDetailData?.event?.expectRecoverTime"> </van-cell>
      </van-cell-group>
      <van-cell-group>
        <van-cell
          title="实施情况"
          style="font-size: 18px; font-weight: bold; line-height: inherit"
        >
        </van-cell>
        <van-cell :title="'投入人力： ' + eventDetailData?.material?.inputManpower"> </van-cell>
        <van-cell :title="'投入资金： ' + eventDetailData?.material?.inputFunds"> </van-cell>
        <van-cell :title="'投入设备： ' + eventDetailData?.material?.inputEquipment"> </van-cell>
      </van-cell-group>
    </div>
  </div>
</template>
    
    <script setup>
import "vant/es/toast/style";
import "vant/es/popup/style";
import { ref, onMounted, toRaw, reactive } from "vue";
import { useRouter, useRoute } from "vue-router";
import { showToast, showLoadingToast } from "vant";
import { request } from "../../../../shared/utils/request";

const router = useRouter();
const route = useRoute();

const yhzDetail = ref({});
const event = ref();
const eventDetailData = ref({}); // 冰雪事件详情数据

// 获取冰雪事件详情数据
const getEventDetailData = async () => {
  try {
    const res = await request({
      url: `/snow-ops-platform/event/getById?id=${event.value.id}`,
      method: "GET",
    });
    if (res.code === "00000") {
      eventDetailData.value = res.data;
    } else {
      throw new Error(res.message);
    }
  } catch (error) {
    showToast({
      message: error.message,
      type: "fail",
    });
  }
};

onMounted(() => {
  const data = JSON.parse(decodeURIComponent(route.params.data));
  yhzDetail.value = data.yhzDetail;
  event.value = data.event;
  getEventDetailData();
});

const onClickLeft = () => {
  router.push({
    name: "IceEventManage",
    params: { data: encodeURIComponent(JSON.stringify(yhzDetail.value)) },
  });
};
</script>
    
    <style scoped>
.home {
  padding-top: var(--van-nav-bar-height); /* 自动匹配导航栏高度 */
}

.content {
  padding: 16px;
}

.grid {
  margin-top: 16px;
}

.btn {
  margin-top: 24px;
}

.status-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  color: white;
  font-size: 12px;
}
.status-good {
  background-color: #07c160;
}
.status-warning {
  background-color: #ff976a;
}
.status-danger {
  background-color: #ee0a24;
}
</style>
    