index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <script setup lang="tsx">
  2. import { nextTick } from 'vue';
  3. import { fetchGetskuStatisticsList } from '@/service/api/finance/summary';
  4. import { fetchGetLoginUserList } from '@/service/api/common';
  5. import { useAuth } from '@/hooks/business/auth';
  6. import { commonExport } from '@/utils/common';
  7. import { useTable } from '@/components/zt/Table/hooks/useTable';
  8. const columns: NaiveUI.TableColumn<Api.finance.SkuStatisticsVo>[] = [
  9. {
  10. key: 'skuId',
  11. title: '商品ID',
  12. align: 'center',
  13. width: 120
  14. },
  15. {
  16. key: 'skuName',
  17. title: '商品名称',
  18. align: 'center',
  19. width: 200
  20. },
  21. {
  22. key: 'spec',
  23. title: '规格',
  24. align: 'center',
  25. width: 200
  26. },
  27. {
  28. key: 'price',
  29. title: '单价(元)',
  30. align: 'center',
  31. width: 120
  32. },
  33. {
  34. key: 'prodCount',
  35. title: '商品总数量',
  36. align: 'center',
  37. width: 200
  38. },
  39. {
  40. key: 'total',
  41. title: '小计(元)',
  42. align: 'center',
  43. width: 120
  44. }
  45. ];
  46. const [registerTable, { refresh, setTableLoading, setFieldsValue, getSeachForm, getTableData }] = useTable({
  47. searchFormConfig: {
  48. schemas: [
  49. {
  50. field: 'channelIds',
  51. label: '企业名称',
  52. component: 'ApiSelect',
  53. componentProps: {
  54. api: fetchGetLoginUserList,
  55. labelFeild: 'channelName',
  56. valueFeild: 'id',
  57. multiple: true,
  58. onUpdateValue: () => {
  59. nextTick(() => {
  60. handleSearch();
  61. });
  62. },
  63. getOptions: async (options: any) => {
  64. await setFieldsValue({ channelIds: [options[0].id] });
  65. handleSearch();
  66. }
  67. }
  68. },
  69. {
  70. label: '商品ID',
  71. field: 'skuId',
  72. component: 'NInput'
  73. },
  74. {
  75. label: '商品名称',
  76. field: 'skuName',
  77. component: 'NInput'
  78. },
  79. {
  80. label: '商品规格',
  81. field: 'spec',
  82. component: 'NInput'
  83. },
  84. {
  85. label: '结算周期',
  86. component: 'NDatePicker',
  87. field: 'Time',
  88. componentProps: {
  89. type: 'datetimerange'
  90. }
  91. }
  92. ],
  93. labelWidth: 120,
  94. layout: 'horizontal',
  95. size: 'small',
  96. gridProps: {
  97. cols: '1 xl:4 s:1 l:3',
  98. itemResponsive: true
  99. },
  100. collapsedRows: 1
  101. },
  102. tableConfig: {
  103. keyField: 'id',
  104. title: '对账单汇总表(商品)',
  105. showAddButton: false,
  106. defaultParamsNotReset: 'channelIds',
  107. fieldMapToTime: [['Time', ['startTime', 'endTime']]]
  108. }
  109. });
  110. function handleSearch() {
  111. refresh();
  112. }
  113. async function handleExport() {
  114. setTableLoading(true);
  115. try {
  116. await commonExport('/platform/sku/skuStatisticsExcel', getSeachForm(), '对账单列表.xlsx');
  117. setTableLoading(false);
  118. } catch {
  119. setTableLoading(false);
  120. }
  121. }
  122. </script>
  123. <template>
  124. <LayoutTable>
  125. <ZTable
  126. :columns="columns"
  127. :immediate="false"
  128. :api="fetchGetskuStatisticsList"
  129. :show-table-action="false"
  130. @register="registerTable"
  131. >
  132. <template #prefix="{ loading }">
  133. <NButton
  134. v-if="useAuth().hasAuth('finance:summary:export')"
  135. size="small"
  136. :loading="loading"
  137. :disabled="getTableData().length == 0"
  138. @click="handleExport"
  139. >
  140. 导出
  141. </NButton>
  142. </template>
  143. </ZTable>
  144. </LayoutTable>
  145. </template>
  146. <style scoped></style>