<script setup lang="ts">
import { PageSearch, usePageSearch } from "/@/components/PageSearch";
import { PageContent } from "/@/components/PageContent";
import searchFormConfig from "./config/search.config";
import contentConfig from "./config/content.config";
import { useRouter } from "vue-router";

defineOptions({
  name: "capitalPool"
});

const { push } = useRouter();

function searchCallback({ timer }) {
  const [start, end] = timer;

  const result = {
    start,
    end
  };

  return {
    result,
    deleteProps: ["timer"]
  };
}

const { pageContentRef, handleResetClick, handleSearchClick } =
  usePageSearch(searchCallback);

function toDetail(logNo: string) {
  push({
    path: "/InvoiceSales/capitalPoolDetail",
    query: {
      id: logNo
    }
  });
}
</script>

<template>
  <div class="main role">
    <PageSearch
      :form-config="searchFormConfig"
      @search-btn-click="handleSearchClick"
      @reset-btn-click="handleResetClick"
    />
    <PageContent
      ref="pageContentRef"
      :content-config="contentConfig"
      @preview-btn-click="({ logNo }) => toDetail(logNo)"
    />
  </div>
</template>

<style scoped lang="scss">
:deep(.el-dropdown-menu__item i) {
  margin: 0;
}
</style>
