business.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <script setup lang="ts">
  2. import { ref, watch ,shallowRef} from "vue";
  3. import apis from "./config/apis";
  4. import { ElMessage } from "element-plus";
  5. import { usePermission } from "/@/hooks/core";
  6. import { frontEndExport } from "/@/utils/export";
  7. import { isBeyondTime } from "/@/views/time/_utils";
  8. import sourceSearchConfig from "./config/search.config";
  9. import sourceContentConfig from "./config/content.config";
  10. import { usePageSearch, type PageHooks } from "/@/hooks/page";
  11. import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
  12. import { PageContentInstance } from "/@/components/PageContent";
  13. import { useBusinessSearch, useBusinessContent } from "./../../_hooks";
  14. import { useUserStore } from "/@/store/modules/user";
  15. import { httpRequsetExport } from "/@/utils/export";
  16. import dayjs from "dayjs"
  17. const pageContentRef = ref<PageContentInstance | null>(null);
  18. const lockKey = "companyNo";
  19. const pageName = "receivableDetail";
  20. const { hasPermissionWithCode } = usePermission(pageName);
  21. const loading = shallowRef(false);
  22. const userStore = useUserStore();
  23. const { searchConfig } = useBusinessSearch({
  24. sourceConfig: sourceSearchConfig,
  25. queryField: "companyNo"
  26. });
  27. const searchConfigRef = ref(searchConfig);
  28. const { contentConfig } = useBusinessContent({
  29. sourceConfig: sourceContentConfig,
  30. apis: { httpList: apis.list }
  31. });
  32. const hooks: PageHooks = {
  33. pageSearchHook: () =>
  34. usePageSearch((params) => {
  35. const { date, ...rest } = 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. ...rest
  45. },
  46. deleteProps:['date']
  47. }
  48. },
  49. (params) => {
  50. const { date, companyNo ,depart_id} = params;
  51. const start = dayjs(date).format('YYYY-MM-DD');
  52. const daysInMonth = dayjs(date).daysInMonth();
  53. const end = dayjs(start).subtract(-(daysInMonth - 1), 'days').format('YYYY-MM-DD');
  54. return {
  55. result: {
  56. start: start + " 00:00:00",
  57. end: end + " 23:59:59",
  58. companyNo,
  59. plat_type: "1",
  60. depart_id
  61. },
  62. deleteProps:['date']
  63. }
  64. }, searchConfig, false, lockKey)
  65. };
  66. watch(
  67. () => userStore.level,
  68. level => {
  69. const { formItems } = searchConfigRef.value;
  70. const index = formItems.findIndex(({ field }) => field === "depart_id");
  71. const { itemid = "" } = userStore.info || {};
  72. if (Number(level) === 2) {
  73. searchConfigRef.value.formItems[index].disabled = Number(level) === 2;
  74. searchConfigRef.value.formItems[index].defaultValue = itemid;
  75. }
  76. },
  77. {
  78. immediate: true
  79. }
  80. );
  81. const callback = {
  82. onSuccess: () => (loading.value = false),
  83. onStart: () => (loading.value = true),
  84. onFail: () => (loading.value = false)
  85. };
  86. async function handleExportAllReport() {
  87. const params = pageContentRef.value.getBasicParams() || {};
  88. const { start, end } = params;
  89. if (!params[lockKey]) {
  90. ElMessage.warning("请选择业务公司");
  91. return;
  92. }
  93. const beyondTime = isBeyondTime({ start, end, len: 30 });
  94. if (beyondTime) return;
  95. await httpRequsetExport({
  96. fileType: "aplication/x-msexecl",
  97. name: "应收账款明细.xlsx",
  98. url: "/admin/report/dzListExport",
  99. ...callback,
  100. params
  101. });
  102. }
  103. </script>
  104. <template>
  105. <PageContainer
  106. :hooks="hooks"
  107. :getContentRef="ref => (pageContentRef = ref)"
  108. :content-config="contentConfig"
  109. :search-config="searchConfig"
  110. lockKey="companyNo"
  111. v-loading="loading"
  112. >
  113. <template #content_header>
  114. <el-button
  115. v-if="hasPermissionWithCode('18')"
  116. :icon="useRenderIcon('arrow-up-line')"
  117. @click="handleExportAllReport"
  118. size="small"
  119. type="primary"
  120. >导出</el-button
  121. >
  122. </template>
  123. </PageContainer>
  124. </template>