<script setup lang="ts">
import { ref } from "vue";
import contentConfig from "./config/content.config";
import searchConfig from "./config/search.config";
import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import InvoiceModal from "./components/invoice-modal.vue";
import { useRouter } from "vue-router";
import { usePermission } from "/@/hooks/core/usePermission";

const PageName = "sendOrderInvoiceRelive";
const baseUrl = "/postSupplierOrder/sendOrderInvoiceReliveDetail";
// const invStatus = ["3", "4", "5", "6", "9", "10", "12"];

const { push } = useRouter();

const invoiceModalRef = ref<InstanceType<typeof InvoiceModal>>(null);

// { code: "024", name: "撤销对账回票申请" },
const { hasPermissionWithCode } = usePermission(PageName);

const hooks: PageHooks = {
  pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig)
};

const events: PageEvents = {
  content: {
    preview: ({ returnCode }) => push(`${baseUrl}?id=${returnCode}`),
    create: () => push(baseUrl)
  }
};
</script>

<template>
  <PageAuth :pageName="PageName">
    <PageContainer
      :hooks="hooks"
      :events="events"
      :contentConfig="contentConfig"
      :search-config="searchConfig"
    >
      <template #content_action="row">
        <ElButton
          v-if="hasPermissionWithCode('020')"
          link
          type="primary"
          :icon="useRenderIcon('scaletooriginal')"
          @click="() => invoiceModalRef.onDisplay(row)"
        />
      </template>
    </PageContainer>

    <InvoiceModal ref="invoiceModalRef" />
  </PageAuth>
</template>
