<template>
  <div class="dialog-body-container">
    <el-form inline :model="searchForm" class="search-form">
      <el-form-item label="所在地区：">
        <el-select v-model="searchForm.city_id" size="small">
          <el-option
            v-for="city in cities"
            :label="city.name"
            :value="city.id"
            :key="city.id"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="工程名称：">
        <el-input v-model="searchForm.project_name" size="small" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleSearch" size="small"
          >查询</el-button
        >
      </el-form-item>
    </el-form>
    <DialogApiDataTable
      :has-index="true"
      ref="table"
      :columns="columns"
      :parameters="searchForm"
      :api="api"
    >
      <template #regulation_score="{ data }">
        <span
          :style="{
            color: data.regulation_score < warningNum[2] ? '#f86262' : '',
          }"
        >
          {{ data.regulation_score }}
        </span>
      </template>
      <!-- <template #noise_status="{ data }"> </template> -->
    </DialogApiDataTable>
  </div>
</template>
<script>
import { getProjectList, getMapData } from "@/api/dataStatis";

export default {
  name: "WarningMsg",
  props: {
    projectId: {
      type: [String, Number],
      default: "",
    },
  },
  data() {
    return {
      searchForm: {},
      columns: [
        {
          label: "工程名称",
          prop: "project_name",
          minWidth: "300px",
          align: "left",
        },
        { label: "所属地区", prop: "city_name" },
        {
          label: "政府监管得分",
          prop: "regulation_score",
          hasSlot: true,
          sortable: true,
        },
      ],
      api: getProjectList,
      cities: [],
      warningNum: window.warningNum,
    };
  },
  mounted() {
    getMapData().then((res) => {
      this.cities = res.data;
    });
  },
  methods: {
    handleSearch() {
      this.$refs.table.getData();
    },
    openPdf(url) {
      window.open(url);
    },
  },
};
</script>
  <style lang="less" scoped>
.search-form {
  margin: 20px 0 0px 0;
}

.blue {
  color: #0178ff;
  &:hover {
    cursor: pointer;
  }
}
.dialog-body-container {
  display: flex;
  flex-direction: column;
  // height: 100%;
  height: calc(100% - 20px);
}
::v-deep .data-table-out{
  height: calc(100% - 70px);
}
</style>