all.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <script setup lang="ts">
  2. import { ref, shallowRef, watch } from "vue";
  3. import searchConfig from "./config/search.config";
  4. import contentConfig from "./config/content.config";
  5. import { PageContentInstance } from "/@/components/PageContent";
  6. import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
  7. import { usePageSearch, type PageHooks } from "/@/hooks/page";
  8. import { isBeyondTime } from "/@/views/time/_utils";
  9. import { httpRequsetExport } from "/@/utils/export";
  10. import { usePermission } from "/@/hooks/core";
  11. import { useUserStore } from "/@/store/modules/user";
  12. import dayjs from "dayjs"
  13. const pageName = "receivableDetail";
  14. const { hasPermissionWithCode } = usePermission(pageName);
  15. const pageContentRef = ref<PageContentInstance | null>(null);
  16. const userStore = useUserStore();
  17. const loading = shallowRef(false);
  18. const hooks: PageHooks = {
  19. pageSearchHook: () => usePageSearch((params) => {
  20. const { date, ...rest } = params;
  21. const start = dayjs(date).format('YYYY-MM-DD');
  22. const daysInMonth = dayjs(date).daysInMonth();
  23. const end = dayjs(start).subtract(-(daysInMonth - 1), 'days').format('YYYY-MM-DD');
  24. return {
  25. result: {
  26. start: start + " 00:00:00",
  27. end: end + " 23:59:59",
  28. plat_type:"1",
  29. ...rest
  30. },
  31. deleteProps:['date']
  32. }
  33. },
  34. (params) => {
  35. const { date , depart_id} = params;
  36. const start = dayjs(date).format('YYYY-MM-DD');
  37. const daysInMonth = dayjs(date).daysInMonth();
  38. const end = dayjs(start).subtract(-(daysInMonth - 1), 'days').format('YYYY-MM-DD');
  39. return {
  40. result: {
  41. start: start + " 00:00:00",
  42. end: end + " 23:59:59",
  43. plat_type: "1",
  44. depart_id
  45. },
  46. deleteProps:['date']
  47. }
  48. }, searchConfig)
  49. };
  50. const searchConfigRef = ref(searchConfig)
  51. watch(
  52. () => userStore.level,
  53. level => {
  54. const { formItems } = searchConfigRef.value;
  55. const index = formItems.findIndex(({ field }) => field === "depart_id");
  56. const { itemid = "" } = userStore.info || {};
  57. if (Number(level) === 2) {
  58. searchConfigRef.value.formItems[index].disabled = Number(level) === 2;
  59. searchConfigRef.value.formItems[index].defaultValue = itemid;
  60. }
  61. },
  62. {
  63. immediate: true
  64. }
  65. );
  66. const callback = {
  67. onSuccess: () => (loading.value = false),
  68. onStart: () => (loading.value = true),
  69. onFail: () => (loading.value = false)
  70. };
  71. async function handleExportAllReport() {
  72. const params = pageContentRef.value.getBasicParams() || {};
  73. const { start, end } = params;
  74. const beyondTime = isBeyondTime({ start, end, len: 30 });
  75. console.log(params)
  76. if (beyondTime) return;
  77. await httpRequsetExport({
  78. fileType: "aplication/x-msexecl",
  79. name: "应收账款明细.xlsx",
  80. url: "/admin/report/dzListExport",
  81. ...callback,
  82. params
  83. });
  84. }
  85. </script>
  86. <template>
  87. <page-auth :page-name="pageName" v-loading="loading">
  88. <page-container
  89. :hooks="hooks"
  90. :page-name="pageName"
  91. :get-content-ref="ref => (pageContentRef = ref)"
  92. :content-config="contentConfig"
  93. :search-config="searchConfig"
  94. >
  95. <template #content_header>
  96. <el-button
  97. v-if="hasPermissionWithCode('9')"
  98. @click="handleExportAllReport"
  99. size="small"
  100. :icon="useRenderIcon('arrow-up-line')"
  101. type="primary"
  102. >导出</el-button
  103. >
  104. </template>
  105. </page-container>
  106. </page-auth>
  107. </template>