index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. import { useUserInfo } from "/@/hooks/core/useUser";
  14. import { httpDelete } from "/@/api/invoiceInOut/inOutManager";
  15. import { useTask } from "/@/hooks/core";
  16. import { ElButton, ElMessage } from "element-plus";
  17. const PageName = "inOutManager";
  18. const router = useRouter();
  19. const state = reactive({ orderImportVisible: false, notOrderImportVisible: false })
  20. const hooks: PageHooks = { pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig) };
  21. const pageContentRef = ref(null)
  22. const { isSuperUser } = useUserInfo()
  23. const selection = ref([])
  24. const deleteTask = useTask({ success(){
  25. ElMessage.success('取消成功')
  26. pageContentRef?.value.onSearch()
  27. } })
  28. const events: PageEvents = {
  29. content: {
  30. create: () => router.push('/invoiceInOut/inManagerDetail'),
  31. preview: ({ id }) => router.push("/invoiceInOut/inManagerDetail?id=" + id)
  32. }
  33. };
  34. function onDownload(type = 'notOrder'){
  35. const data = type === 'notOrder' ? notOrderTemplate : orderTemplate
  36. const title = type === 'notOrder' ? '非订单商品模板.xlsx' : '订单商品模板.xlsx'
  37. const workBook = utils.book_new();
  38. const workSheet = utils.json_to_sheet(data);
  39. utils.book_append_sheet(workBook, workSheet, "sheet");
  40. writeFile(workBook, title, { bookType: "xlsx" });
  41. }
  42. function handleRefresh() {
  43. if (selection.value.length === 0) {
  44. ElMessage.warning('请选择至少一条状态为 "待审核" 或 "异常" 的数据')
  45. return
  46. }
  47. const isStatusNotOk = selection.value.some(({ status }) => status != '1' && status != '4')
  48. if (isStatusNotOk) {
  49. ElMessage.warning('只能选择状态为 "待审核" 或 "异常" 的数据')
  50. return
  51. }
  52. deleteTask.run(httpDelete({ id: selection.value.map(({ id }) => id) }))
  53. }
  54. </script>
  55. <template>
  56. <PageAuth :pageName="PageName">
  57. <PageContainer
  58. :hooks="hooks"
  59. :events="events"
  60. :searchConfig="searchConfig"
  61. :contentConfig="contentConfig"
  62. :get-content-ref="ref => pageContentRef = ref"
  63. @content-select-change="selects => selection = selects"
  64. >
  65. <template #content_header>
  66. <ElButton
  67. style="margin-right: 10px"
  68. size="small"
  69. type="primary"
  70. @click="handleRefresh"
  71. >批量取消</ElButton>
  72. <ElDropdown v-if="!isSuperUser">
  73. <ElButton
  74. size="small"
  75. type="primary"
  76. style="margin-right: 10px;margin-top:1px"
  77. :icon="useRenderIcon('arrow-up-line')"
  78. >商品导入
  79. </ElButton>
  80. <template #dropdown>
  81. <ElDropdownMenu>
  82. <ElDropdownItem @click="state.orderImportVisible = true">订单商品</ElDropdownItem>
  83. <ElDropdownItem @click="state.notOrderImportVisible = true">非订单商品</ElDropdownItem>
  84. </ElDropdownMenu>
  85. </template>
  86. </ElDropdown>
  87. <ElDropdown>
  88. <ElButton
  89. size="small"
  90. style="margin-right: 10px;margin-top:1px"
  91. :icon="useRenderIcon('arrow-down-line')"
  92. >商品导入模板下载</ElButton>
  93. <template #dropdown>
  94. <ElDropdownMenu>
  95. <ElDropdownItem @click="onDownload('order')">订单商品</ElDropdownItem>
  96. <ElDropdownItem @click="onDownload('notOrder')">非订单商品</ElDropdownItem>
  97. </ElDropdownMenu>
  98. </template>
  99. </ElDropdown>
  100. </template>
  101. <!-- <template #content_action="row">
  102. <ElTooltip content="取消操作" placement="top" v-if="row.status == '1'">
  103. <ElButton
  104. :icon="useRenderIcon('refresh')"
  105. @click="handleRefresh(row)"
  106. type="danger"
  107. link
  108. />
  109. </ElTooltip>
  110. </template> -->
  111. </PageContainer>
  112. <OrderImportModal
  113. v-model:visible="state.orderImportVisible"
  114. @refresh="pageContentRef?.onSearch()"
  115. />
  116. <NotOrderImportModal
  117. v-model:visible="state.notOrderImportVisible"
  118. @refresh="pageContentRef?.onSearch()"
  119. />
  120. </PageAuth>
  121. </template>