index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <script setup lang="ts">
  2. import { ref, shallowRef } from "vue";
  3. import contentConfig from "./config/content.config";
  4. import searchConfig from "./config/search.config";
  5. import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
  6. import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
  7. import PostModal from "./components/post-modal.vue";
  8. import { useUserInfo } from "/@/hooks/core/useUser";
  9. import { useRouter } from "vue-router";
  10. import { httpSetPost, httpStatus } from "/@/api/InvoiceSales/invoiceApply";
  11. import { useAsync } from "/@/hooks/core/useAsync";
  12. import ExeclUpload from "./components/execl-files-upload/index.vue";
  13. import { httpRequsetExport } from "/@/utils/export";
  14. import { template } from "./config/xls-template";
  15. import { usePermission } from "/@/hooks/core/usePermission";
  16. import ApprovalModal from "./components/approval-modal.vue";
  17. import BackModal from "./components/back-modal.vue";
  18. import { ElMessage } from "element-plus";
  19. import { writeFile, utils } from "xlsx";
  20. import InvoiceModal from "./invoice-modal.vue"
  21. const PageName = "invoiceApply";
  22. // { code: "040", name: "批量审核" },
  23. // { code: "026", name: "导出发票申请信息" },
  24. // { code: "027", name: "下载发票信息导入模板" },
  25. // { code: "028", name: "批量导入财务开票结果(发票申请)" },
  26. const { hasPermissionWithCode } = usePermission(PageName);
  27. const loading = ref(false);
  28. const baseUrl = "/InvoiceSales/invoiceApplyDetail";
  29. const postModalRef = ref<InstanceType<typeof PostModal> | null>(null);
  30. const invModalRef = ref<InstanceType<typeof InvoiceModal> | null>(null);
  31. const execlUploadRef = ref<InstanceType<typeof ExeclUpload> | null>(null);
  32. const approvalModalRef = ref<InstanceType<typeof ApprovalModal> | null>(null);
  33. const backModalRef = ref<InstanceType<typeof BackModal> | null>(null);
  34. const { isSuperUser } = useUserInfo();
  35. const instance = ref(null);
  36. const { run } = useAsync({ success: () => instance.value.onSearch() });
  37. const { run: approval } = useAsync({ success: () => instance.value.onSearch() });
  38. const handleApproval = ({ invNo }) => approval(httpStatus({ invNo, status: "7" }));
  39. const { push } = useRouter();
  40. const selected = ref<any[]>([]);
  41. const hooks: PageHooks = {
  42. pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig)
  43. };
  44. function handleSetPost(data) {
  45. run(httpSetPost(data));
  46. }
  47. const events: PageEvents = {
  48. content: {
  49. preview: ({ invNo }) => push(`${baseUrl}?id=${invNo}`),
  50. create: () => push(baseUrl)
  51. }
  52. };
  53. //导出模板
  54. async function onDownloadOpenInv() {
  55. await httpRequsetExport({
  56. url: "/ipe",
  57. name: "开票信息",
  58. onStart: () => (loading.value = true),
  59. onSuccess: () => (loading.value = false),
  60. onFail: () => (loading.value = false),
  61. params: { ...instance.value.getBasicParams() }
  62. });
  63. }
  64. function handleBatchApproval() {
  65. if (selected.value.length === 0) {
  66. ElMessage.warning('请选择至少一条"待财务审核"的发票申请');
  67. return;
  68. }
  69. if (!selected.value.every(({ status }) => String(status) === "1")) {
  70. ElMessage.warning('请选择状态为"待财务审核"的发票申请');
  71. return;
  72. }
  73. approvalModalRef.value.onDisplay(selected.value);
  74. }
  75. function onDownloadTemplate() {
  76. //创建数据表
  77. const workBook = utils.book_new();
  78. const workSheet = utils.json_to_sheet([template]);
  79. utils.book_append_sheet(workBook, workSheet, "sheet");
  80. //导出模板
  81. writeFile(workBook, "开票模板.xlsx", {
  82. bookType: "xlsx"
  83. });
  84. }
  85. </script>
  86. <template>
  87. <PageAuth :pageName="PageName">
  88. <PageContainer
  89. :hooks="hooks"
  90. :events="events"
  91. :contentConfig="contentConfig"
  92. :search-config="searchConfig"
  93. :get-content-ref="ref => (instance = ref)"
  94. @content-select-change="val => (selected = val)"
  95. >
  96. <template #content_header>
  97. <ElButton
  98. v-if="hasPermissionWithCode('040') && !isSuperUser"
  99. size="small"
  100. @click="handleBatchApproval"
  101. >
  102. 财务批量审核(勾选)
  103. </ElButton>
  104. <ElButton
  105. v-if="hasPermissionWithCode('026')"
  106. :icon="useRenderIcon('arrow-up-line')"
  107. size="small"
  108. :loading="loading"
  109. @click="() => onDownloadOpenInv()"
  110. >开票信息导出</ElButton
  111. >
  112. <ElButton
  113. v-if="hasPermissionWithCode('027')"
  114. :icon="useRenderIcon('arrow-down-line')"
  115. size="small"
  116. @click="() => onDownloadTemplate()"
  117. >下载发票信息导入模板</ElButton
  118. >
  119. <!-- v-if="!isSuperUser && hasPermissionWithCode('028')" -->
  120. <ElButton
  121. @click="() => execlUploadRef.onDisplay()"
  122. size="small"
  123. >批量导入财务开票结果(发票申请)</ElButton
  124. >
  125. </template>
  126. <template #content_action="{ status, post_code, invNo, inv_type, inv_number }">
  127. <ElTooltip
  128. content="填写物流"
  129. placement="top"
  130. v-if="!isSuperUser && String(status) === '3' && !post_code"
  131. >
  132. <ElButton
  133. text
  134. type="primary"
  135. style="margin-left: 0px"
  136. :icon="useRenderIcon('promotion')"
  137. @click="() => postModalRef.onDisplay(invNo)"
  138. />
  139. </ElTooltip>
  140. <ElPopconfirm
  141. v-if="
  142. (String(status) === '1' || String(status) === '5') &&
  143. hasPermissionWithCode('010') &&
  144. !isSuperUser
  145. "
  146. placement="top"
  147. title="是否确认撤销开票申请?"
  148. @confirm="() => handleApproval({ invNo })"
  149. >
  150. <template #reference>
  151. <ElButton
  152. text
  153. type="primary"
  154. style="margin-left: 0px"
  155. :icon="useRenderIcon('refresh-right')"
  156. />
  157. </template>
  158. </ElPopconfirm>
  159. <ElTooltip content="修改发票信息" placement="top">
  160. <ElButton
  161. v-if="
  162. String(status) === '5' &&
  163. hasPermissionWithCode('005') &&
  164. !isSuperUser
  165. "
  166. text
  167. style="margin-left: 0px"
  168. :icon="useRenderIcon('edit')"
  169. type="primary"
  170. @click="() => backModalRef.onDisplay(inv_type, invNo)"
  171. />
  172. </ElTooltip>
  173. <ElButton
  174. v-if="String(status) === '4' || String(status) === '6'"
  175. link
  176. type="primary"
  177. :icon="useRenderIcon('scaletooriginal')"
  178. @click="() => invModalRef.open(inv_number)"
  179. />
  180. </template>
  181. </PageContainer>
  182. <PostModal ref="postModalRef" @post-save="handleSetPost" />
  183. <ApprovalModal
  184. ref="approvalModalRef"
  185. @onBatchApprovalComplete="() => instance.onSearch()"
  186. />
  187. <ExeclUpload ref="execlUploadRef" @on-success="() => instance.onSearch()" />
  188. <back-modal ref="backModalRef" @refresh="() => instance.onSearch()" />
  189. <InvoiceModal ref="invModalRef" />
  190. </PageAuth>
  191. </template>