index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <script setup lang="tsx">
  2. import { nextTick } from 'vue';
  3. import { fetchGetfreightStatisticsList } from '@/service/api/finance/commodity-freight';
  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.FreightStatisticsVo>[] = [
  9. {
  10. key: 'date',
  11. title: '日期',
  12. align: 'center',
  13. width: 120
  14. },
  15. {
  16. key: 'sendSize',
  17. title: '寄方',
  18. align: 'center',
  19. width: 200
  20. },
  21. {
  22. key: 'receiver',
  23. title: '收方',
  24. align: 'center',
  25. width: 200
  26. },
  27. {
  28. key: 'delivery',
  29. title: '运输公司',
  30. align: 'center',
  31. width: 120
  32. },
  33. {
  34. key: 'deliveryNo',
  35. title: '运单号码',
  36. align: 'center',
  37. width: 200
  38. },
  39. {
  40. key: 'sendArea',
  41. title: '寄件地区',
  42. align: 'center',
  43. width: 200
  44. },
  45. {
  46. key: 'toAddress',
  47. title: '到件地区',
  48. align: 'center',
  49. width: 200
  50. },
  51. {
  52. key: 'money',
  53. title: '费用(元)',
  54. align: 'center',
  55. width: 120
  56. },
  57. {
  58. key: 'orderNo',
  59. title: '订/退单号',
  60. align: 'center',
  61. width: 200
  62. }
  63. ];
  64. const [registerTable, { refresh, setTableLoading, setFieldsValue, getSeachForm, getTableData }] = useTable({
  65. searchFormConfig: {
  66. schemas: [
  67. {
  68. field: 'channelIds',
  69. label: '企业名称',
  70. component: 'ApiSelect',
  71. componentProps: {
  72. api: fetchGetLoginUserList,
  73. labelFeild: 'channelName',
  74. valueFeild: 'id',
  75. multiple: true,
  76. onUpdateValue: () => {
  77. nextTick(() => {
  78. handleSearch();
  79. });
  80. },
  81. getOptions: async (options: any) => {
  82. await setFieldsValue({ channelIds: [options[0].id] });
  83. handleSearch();
  84. }
  85. }
  86. },
  87. {
  88. label: '收货人姓名',
  89. field: 'receiver',
  90. component: 'NInput'
  91. },
  92. {
  93. label: '收货人手机号',
  94. field: 'mobile',
  95. component: 'NInput'
  96. },
  97. {
  98. label: '运输公司',
  99. field: 'delivery',
  100. component: 'NSelect',
  101. componentProps: {
  102. options: [
  103. {
  104. label: '全部',
  105. value: ''
  106. },
  107. {
  108. label: '邮政',
  109. value: '1'
  110. },
  111. {
  112. label: '麦芽田-闪送',
  113. value: '3'
  114. }
  115. ]
  116. }
  117. },
  118. {
  119. label: '运单单号',
  120. field: 'deliveryNo',
  121. component: 'NInput'
  122. },
  123. {
  124. label: '到件地址',
  125. field: 'toAddress',
  126. component: 'NInput'
  127. },
  128. {
  129. label: '订/退单号',
  130. field: 'orderNo',
  131. component: 'NInput'
  132. },
  133. {
  134. label: '结算周期',
  135. component: 'NDatePicker',
  136. field: 'createTime',
  137. componentProps: {
  138. type: 'datetimerange'
  139. }
  140. }
  141. ],
  142. labelWidth: 120,
  143. layout: 'horizontal',
  144. size: 'small',
  145. gridProps: {
  146. cols: '1 xl:4 s:1 l:3',
  147. itemResponsive: true
  148. },
  149. collapsedRows: 1
  150. },
  151. tableConfig: {
  152. keyField: 'id',
  153. title: '商品运费明细表',
  154. showAddButton: false,
  155. defaultParamsNotReset: 'channelIds',
  156. fieldMapToTime: [['Time', ['startTime', 'endTime']]]
  157. }
  158. });
  159. function handleSearch() {
  160. refresh();
  161. }
  162. async function handleExport() {
  163. setTableLoading(true);
  164. try {
  165. await commonExport('/platform/sku/freightStatisticsExcel', getSeachForm(), '运费明细列表.xlsx');
  166. setTableLoading(false);
  167. } catch {
  168. setTableLoading(false);
  169. }
  170. }
  171. </script>
  172. <template>
  173. <LayoutTable>
  174. <ZTable
  175. :columns="columns"
  176. :immediate="false"
  177. :api="fetchGetfreightStatisticsList"
  178. :show-table-action="false"
  179. @register="registerTable"
  180. >
  181. <template #prefix="{ loading }">
  182. <NButton
  183. v-if="useAuth().hasAuth('finance:commodity-freight:export')"
  184. size="small"
  185. :loading="loading"
  186. :disabled="getTableData().length == 0"
  187. @click="handleExport"
  188. >
  189. 导出
  190. </NButton>
  191. </template>
  192. </ZTable>
  193. </LayoutTable>
  194. </template>
  195. <style scoped></style>