<template>
  <div class="RoadNetworkMonitoring">
    <!-- 搜索栏 -->
    <div class="filter">
      <div class="filter-btn">
        <ButtonGradient @click.native="handleExport">
          <template #prefix>
            <img src="@screen/images/export.svg" />
          </template>
          导出
        </ButtonGradient>
        <ButtonGradient @click="onRefresh" class="refresh-btn">
          <template #prefix>
            <img src="./images/refresh.svg" />
          </template>
          刷新
        </ButtonGradient>
      </div>

      <InputSearch
        style="width: 402px"
        :formList="searchFormList"
        :formConfigOptions="{ dFormData: { eventState: '0' } }"
        @handleSearch="handleSearch"
      />
    </div>

    <!-- 内容 -->
    <div class="body">
      <ManualWarningCard
        v-for="(item, index) in data"
        :key="index"
        :cardData="item"
      />
    </div>

    <!-- 分页 -->
    <div class="footer">
      <Pagination
        @current-change="initData"
        @size-change="onSizeChange"
        width="'100%'"
        :page-sizes="[12, 16, 20, 30, 50]"
        :page-size="searchData.pageSize"
        :current-page.sync="searchData.pageNum"
        layout="total, sizes, prev, pager, next"
        :total="total"
      >
      </Pagination>
    </div>
  </div>
</template>

<script>
import ButtonGradient from "@screen/components/Buttons/ButtonGradient.vue";
import Pagination from "@screen/components/Pagination.vue";
import InputSearch from "@screen/components/InputSearch/index.vue";
import ManualWarningCard from "@screen/components/ManualWarningCard/index.vue";
import { perceivedEventsList } from "@/api/manualWarning/index.js";
// import EventDispatchDialog from "./EventDispatchDialog/index";
import { searchFormList } from "./data";
import request from "@/utils/request";

const directionMapping = {
  1: "菏泽方向",
  2: "双向",
  3: "济南方向",
};

export default {
  name: "RoadNetworkMonitoring",
  components: {
    Pagination,
    ManualWarningCard,
    InputSearch,
    Pagination,
    ButtonGradient,
  },
  data() {
    return {
      searchFormList,
      detailDialogFormData: {},
      total: 0,
      data: [],
      eventId: "0",
      searchData: {
        pageSize: 16,
        pageNum: 1,
        warningSource: "6",
      },
    };
  },
  created() {
    this.initData();
  },
  methods: {
    // 导出
    handleExport() {
      this.$message.warning("待开发");
    },
    // 刷新
    onRefresh() {},
    initData() {
      perceivedEventsList(this.searchData).then((res) => {
        if (res.code != 200) return Message.error(res?.msg);
        this.total = res.total;
        res.rows.forEach((it) => {
          it.source = "非机预警";
          it.stringDirection = directionMapping[it.direction] || it.direction;
          it.otherConfig = JSON.parse(it.otherConfig);
        });
        this.data = res.rows;
        console.log("darta", this.data);
      });
      // request({
      //   // url: `/dc/system/event/dispatchEventList`,
      //   url: "/dc/system/event/list",
      //   method: "get",
      //   params: this.searchData,
      // }).then((result) => {
      //   if (result.code != 200) return Message.error(result?.msg);
      //   this.total = result.total;
      //   result.rows.forEach((it) => {
      //     it.stringDirection = directionMapping[it.direction] || it.direction;
      //   });
      //   this.data = result.rows;
      // });
    },
    onSizeChange(pageSize) {},
    getStateCardBind(item) {},

    firstBtnClick(id) {},
    handleSearch(data) {},
  },
};
</script>

<style lang="scss" scoped>
.RoadNetworkMonitoring {
  padding: 21px;

  height: 100%;
  display: flex;
  flex-direction: column;
  z-index: 6;

  .filter {
    height: 38px;
    display: flex;
    // justify-content: flex-end;
    justify-content: space-between;
    .filter-btn {
      width: 150px;
      justify-content: space-between;
      display: flex;
    }
  }

  .body {
    flex: 1;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 20px;
    // grid-row-gap: 9px;
    // grid-column-gap: 9px;
    grid-auto-rows: min-content;
  }

  .footer {
    margin-top: 15px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
</style>
