index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <script setup lang="ts">
  2. import { reactive, ref } from "vue";
  3. import { useRouter } from "vue-router";
  4. import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
  5. import NotOrderImportModal from "./components/NotOrderImportModal/index.vue"
  6. import OrderImportModal from "./components/OrderImportModal/index.vue"
  7. import { notOrderTemplate } from "./components/NotOrderImportModal/columns-config"
  8. import { orderTemplate } from "./components/OrderImportModal/columns-config"
  9. import { useRenderIcon } from "/@/components/ReIcon/src/hooks"
  10. import contentConfig from "./config/content.config";
  11. import searchConfig from "./config/search.config";
  12. import { utils, writeFile } from "xlsx";
  13. const PageName = "inOutManager";
  14. const router = useRouter();
  15. const state = reactive({ orderImportVisible: false, notOrderImportVisible: false })
  16. const hooks: PageHooks = { pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig) };
  17. const pageContentRef = ref(null)
  18. const events: PageEvents = {
  19. content: {
  20. create: () => router.push('/invoiceInOut/productManagerDetail'),
  21. preview: ({ id }) => router.push("/invoiceInOut/inOutManagerDetail?id=" + id)
  22. }
  23. };
  24. function onDownload(type = 'notOrder'){
  25. const data = type === 'notOrder' ? notOrderTemplate : orderTemplate
  26. const title = type === 'notOrder' ? '非订单商品模板.xlsx' : '订单商品模板.xlsx'
  27. const workBook = utils.book_new();
  28. const workSheet = utils.json_to_sheet(data);
  29. utils.book_append_sheet(workBook, workSheet, "sheet");
  30. writeFile(workBook, title, { bookType: "xlsx" });
  31. }
  32. </script>
  33. <template>
  34. <PageAuth :pageName="PageName">
  35. <PageContainer
  36. :hooks="hooks"
  37. :events="events"
  38. :searchConfig="searchConfig"
  39. :contentConfig="contentConfig"
  40. :get-content-ref="ref => pageContentRef = ref"
  41. >
  42. <template #content_header>
  43. <ElDropdown>
  44. <ElButton
  45. size="small"
  46. type="primary"
  47. style="margin-right: 10px;margin-top:1px"
  48. :icon="useRenderIcon('arrow-up-line')"
  49. >商品导入
  50. </ElButton>
  51. <template #dropdown>
  52. <ElDropdownMenu>
  53. <ElDropdownItem @click="state.orderImportVisible = true">订单商品</ElDropdownItem>
  54. <ElDropdownItem @click="state.notOrderImportVisible = true">非订单商品</ElDropdownItem>
  55. </ElDropdownMenu>
  56. </template>
  57. </ElDropdown>
  58. <ElDropdown>
  59. <ElButton
  60. size="small"
  61. style="margin-right: 10px;margin-top:1px"
  62. :icon="useRenderIcon('arrow-down-line')"
  63. >商品导入模板下载</ElButton>
  64. <template #dropdown>
  65. <ElDropdownMenu>
  66. <ElDropdownItem @click="onDownload('order')">订单商品</ElDropdownItem>
  67. <ElDropdownItem @click="onDownload('notOrder')">非订单商品</ElDropdownItem>
  68. </ElDropdownMenu>
  69. </template>
  70. </ElDropdown>
  71. </template>
  72. <template #content_action>
  73. <ElTooltip content="取消操作" placement="top">
  74. <ElButton
  75. :icon="useRenderIcon('delete')"
  76. type="danger"
  77. link
  78. />
  79. </ElTooltip>
  80. </template>
  81. </PageContainer>
  82. <OrderImportModal
  83. v-model:visible="state.orderImportVisible"
  84. @refresh="pageContentRef?.onSearch()"
  85. />
  86. <NotOrderImportModal
  87. v-model:visible="state.notOrderImportVisible"
  88. @refresh="pageContentRef?.onSearch()"
  89. />
  90. </PageAuth>
  91. </template>