<template>
  <div>
    <div class="titleBox">
      <PageTitle title="预警列表"></PageTitle>
    </div>
    <!-- 搜索 -->
    <div ref="searchBox">
      <Search :searchArr="searchConfiger" @submit="onSearch" />
    </div>
    <!-- 表格 -->
    <div class="tabBox">
      <MyTable
        :tableData="pageData.tableData"
        :tableColumn="pageData.tableColumn"
        :tableHeight="pageData.tableHeight"
        :key="pageData.keyCount"
        :tableConfiger="pageData.tableConfiger"
        :controlsWidth="pageData.controlsWidth"
      >
        <template #image="{ row }">
          <img :src="row.image" alt="">
        </template>
        <template #controls="{ row }">
          <el-button type="primary"  size="small" >详情</el-button >
        </template>
      </MyTable>
      <Pages
        @changeNo="changeNo"
        @changeSize="changeSize"
        :tableHeight="pageData.tableHeight"
        :pageConfiger="{
          ...pageData.pageConfiger,
          total: pageData.total
        }"
      ></Pages>
    </div>
  </div>
</template>

<script setup>
import { ElMessage } from "element-plus";
import PageTitle from "@/components/aboutTable/PageTitle.vue";
import MyTable from "@/components/aboutTable/MyTable.vue";
import Pages from "@/components/aboutTable/Pages.vue";
import Search from "@/components/aboutTable/Search.vue";
import { qcckGet, qcckPost, qcckDelete } from "@/api/qcckApi.js";
import { reactive, ref, onMounted, getCurrentInstance } from "vue";

const { proxy } = getCurrentInstance();

const searchBox = ref(); //搜索框

const searchConfiger = ref([
  {
    label: "所属部门",
    prop: "department",
    placeholder: "请选择所属部门",
    showType: "department"
  },
]);

const pageData = reactive({
  tableData: [
    {image:'',yjnr:'xxxj街道抢劫xxx',hjdz:'sssss',jzdz:'22222'}
  ],
  keyCount: 0,
  tableConfiger: {
    rowHieght: 61,
    showSelectType: "null",
    loading: false
  },
  total: 0,
  pageConfiger: {
    pageSize: 20,
    pageCurrent: 1
  },
  controlsWidth: 120,
  tableColumn: [
    { label: "预警图片", prop: "image" ,showSolt:true},
    { label: "预警内容", prop: "yjnr" },
    { label: "户籍地址", prop: "hjdz" },
    { label: "居住地址", prop: "jzdz" },
  ]
});
onMounted(() => {
  getList();
  tabHeightFn();
});

// 搜索
const onSearch = (val) => {
  queryFrom.value = { ...val };
  pageData.pageConfiger.pageCurrent = 1;
  getList();
};

const changeNo = (val) => {
  pageData.pageConfiger.pageNum = val;
  getList();
};

const changeSize = (val) => {
  pageData.pageConfiger.pageSize = val;
  getList();
};

// 获取列表
const getList = () => {
 
};

// 表格高度计算
const tabHeightFn = () => {
  pageData.tableHeight = window.innerHeight - searchBox.value.offsetHeight - 250;
  window.onresize = function () {
    tabHeightFn();
  };
};
</script>

<style lang="scss" scoped>
.checkbox-group {
  display: flex;
  gap: 20px;
}

.basic-info {
  display: flex;
  gap: 15px;

  .avatar {
    width: 80px;
    height: 80px;
    overflow: hidden;
    border-radius: 4px;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }

  .info-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
}

.control-buttons {
  display: flex;
  gap: 10px;
}
</style>
