index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import { useRouter } from "vue-router";
  4. import { ElMessage } from "element-plus";
  5. import contentConfig from "./config/content.config";
  6. import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
  7. import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
  8. import { usePermission } from "/@/hooks/core/usePermission";
  9. import { httpStatus } from "/@/api/purchase/orderRecord";
  10. import { httpRequsetExport } from "/@/utils/export";
  11. import { useAsync } from "/@/hooks/core/useAsync";
  12. import searchConfig from "./config/search.config";
  13. const PageName = "orderRecord";
  14. const baseUrl = "/purchase/orderRecordDetail";
  15. const selectlist = ref<any[]>([]);
  16. const loading = ref(false);
  17. const { push } = useRouter();
  18. const contentRef = ref<any>(null);
  19. const { run: revoke } = useAsync({
  20. success: () => contentRef.value.onSearch()
  21. });
  22. const { hasPermissionWithCode } = usePermission("orderRecord");
  23. const hooks: PageHooks = {
  24. pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig)
  25. };
  26. const handleRevoke = payNo => {
  27. revoke(
  28. httpStatus({
  29. payNo,
  30. status: "4"
  31. })
  32. );
  33. };
  34. const events: PageEvents = {
  35. content: {
  36. create: () => push(baseUrl),
  37. preview: ({ payNo }) => push(`${baseUrl}?id=${payNo}`)
  38. }
  39. };
  40. async function onDownloadPayInfo() {
  41. if (selectlist.value.length === 0) {
  42. ElMessage.warning("请选择一条对账单");
  43. return;
  44. }
  45. if (selectlist.value.length > 1) {
  46. ElMessage.warning("只能选择一条对账单");
  47. return;
  48. }
  49. await httpRequsetExport({
  50. url: "paycgdexport",
  51. name: "对账单明细表",
  52. onStart: () => (loading.value = true),
  53. onSuccess: () => (loading.value = false),
  54. onFail: () => (loading.value = false),
  55. params: {
  56. payNo: selectlist.value[0].payNo
  57. }
  58. });
  59. }
  60. </script>
  61. <template>
  62. <PageAuth :pageName="PageName">
  63. <PageContainer
  64. :hooks="hooks"
  65. :events="events"
  66. :contentConfig="contentConfig"
  67. :search-config="searchConfig"
  68. :get-content-ref="ref => (contentRef = ref)"
  69. @content-select-change="items => (selectlist = items)"
  70. >
  71. <template #content_header>
  72. <ElButton
  73. size="small"
  74. v-if="hasPermissionWithCode('038')"
  75. :loading="loading"
  76. @click="() => onDownloadPayInfo()"
  77. >
  78. 对账单明细导出
  79. </ElButton>
  80. </template>
  81. <template #content_action="row">
  82. <ElTooltip placement="top" content="撤销对账申请">
  83. <ElButton
  84. v-if="String(row.status) === '2'"
  85. type="primary"
  86. link
  87. text
  88. :icon="useRenderIcon('refresh-right')"
  89. @click="() => handleRevoke(row.payNo)"
  90. />
  91. </ElTooltip>
  92. </template>
  93. </PageContainer>
  94. </PageAuth>
  95. </template>