index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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: 'createTime',
  88. componentProps: {
  89. type: 'datetimerange'
  90. }
  91. },
  92. {
  93. field: 'userAttrType',
  94. label: '人员属性',
  95. component: 'dictSelect',
  96. componentProps: {
  97. dictCode: 'user_attr_type',
  98. immediate: true
  99. },
  100. show: useAuth().hasAuth('user:attr:type')
  101. }
  102. ],
  103. labelWidth: 120,
  104. layout: 'horizontal',
  105. size: 'small',
  106. gridProps: {
  107. cols: '1 xl:4 s:1 l:3',
  108. itemResponsive: true
  109. },
  110. collapsedRows: 1
  111. },
  112. tableConfig: {
  113. keyField: 'id',
  114. title: '对账单汇总表(商品)',
  115. showAddButton: false,
  116. defaultParamsNotReset: 'channelIds',
  117. fieldMapToTime: [['Time', ['startTime', 'endTime']]]
  118. }
  119. });
  120. function handleSearch() {
  121. refresh();
  122. }
  123. async function handleExport() {
  124. setTableLoading(true);
  125. try {
  126. await commonExport('/platform/sku/skuStatisticsExcel', getSeachForm(), '对账单列表.xlsx');
  127. } finally {
  128. setTableLoading(false);
  129. }
  130. }
  131. </script>
  132. <template>
  133. <LayoutTable>
  134. <ZTable
  135. :columns="columns"
  136. :immediate="false"
  137. :api="fetchGetskuStatisticsList"
  138. :show-table-action="false"
  139. @register="registerTable"
  140. >
  141. <template #prefix="{ loading }">
  142. <NButton
  143. v-if="useAuth().hasAuth('finance:summary:export')"
  144. size="small"
  145. :loading="loading"
  146. :disabled="getTableData().length == 0"
  147. @click="handleExport"
  148. >
  149. 导出
  150. </NButton>
  151. </template>
  152. </ZTable>
  153. </LayoutTable>
  154. </template>
  155. <style scoped></style>