<template>
  <el-card class="box-card">
    <div class="content">
      <byTable
        :source="sourceList.data"
        :pagination="sourceList.pagination"
        :config="config"
        :loading="loading"
        :searchConfig="searchConfig"
        highlight-current-row
        @get-list="getList">
      </byTable>
    </div>
  </el-card>
</template>

<script setup>
import byTable from "/src/components/byTable/index";
import { computed, ref } from "vue";

const { proxy } = getCurrentInstance();
const loading = ref(false);
const sourceList = ref({
  data: [],
  pagination: {
    total: 0,
    pageNum: 1,
    pageSize: 10,
    corporationId: "",
    keyword: "",
  },
});
const searchConfig = computed(() => {
  return [
    {
      type: "input",
      prop: "keyword",
      label: "关键词",
    },
  ];
});
const config = computed(() => {
  return [
    {
      attrs: {
        label: "消息类型",
        prop: "type",
        width: "200",
      },
      render() {
        return "消息提醒";
      },
    },
    {
      attrs: {
        label: "消息内容",
        prop: "title",
      },
    },
    {
      attrs: {
        label: "发送时间",
        prop: "createTime",
        width: "200",
      },
    },
  ];
});
const getList = async (req) => {
  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  loading.value = true;
  proxy.post("/pushInfo/page", sourceList.value.pagination).then((res) => {
    sourceList.value.data = res.rows;
    sourceList.value.pagination.total = res.total;
    setTimeout(() => {
      loading.value = false;
    }, 200);
  });
};
getList();
</script>

<style lang="scss" scoped>
.tenant {
  padding: 20px;
}
</style>
