index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <ele-page flex-table>
  3. <page-search @search="reload" :status="useStatus"></page-search>
  4. <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns">
  5. <template #toolbar>
  6. <div class="flex items-center mb-4">
  7. <el-statistic
  8. :value="statistics.totalWithdrawMoney"
  9. title="提现累计金额"
  10. value-style="font-size:30px"
  11. class="mr-10"
  12. ></el-statistic>
  13. <el-statistic
  14. :value="statistics.unWithdrawMoney"
  15. title="待提现金额"
  16. value-style="font-size:30px"
  17. class="mr-10"
  18. ></el-statistic>
  19. <el-statistic
  20. :value="statistics.auditWithdrawMoney"
  21. title="提现中金额"
  22. value-style="font-size:30px"
  23. class="mr-10"
  24. ></el-statistic>
  25. <el-statistic
  26. :value="statistics.withdrawSuccessMoney"
  27. title="已提现金额"
  28. value-style="font-size:30px"
  29. class="mr-10"
  30. ></el-statistic>
  31. <el-statistic
  32. :value="statistics.averageWithdrawDuration"
  33. title="平均提现时长"
  34. value-style="font-size:30px"
  35. class="mr-10"
  36. ></el-statistic>
  37. <el-statistic
  38. :value="statistics.noWithdrawMoney"
  39. title="长期不提现金额"
  40. value-style="font-size:30px"
  41. class="mr-10"
  42. ></el-statistic>
  43. </div>
  44. <div class="flex items-center mb-6">
  45. <div class="common-title mr-10">交易记录</div>
  46. <el-button
  47. type="primary"
  48. v-permission="'finance:withdrawal:batchAudit'"
  49. @click="handleStepAudit()"
  50. >
  51. 一键审核
  52. </el-button>
  53. </div>
  54. <el-radio-group @change="handleStatusChange" v-model="useStatus">
  55. <el-radio-button label="全部" value="" />
  56. <el-radio-button label="提现中" value="2" />
  57. <el-radio-button label="提现完成" value="4" />
  58. <el-radio-button label="提现失败" value="5" />
  59. <el-radio-button label="长期不提现用户" value="6" />
  60. </el-radio-group>
  61. </template>
  62. <template #status="{ row }">
  63. {{ statusDicts.find((d) => d.value == row.status)?.label }}
  64. </template>
  65. <template #action="{ row }">
  66. <div>
  67. <el-button
  68. type="primary"
  69. link
  70. v-permission="'finance:withdrawal:detail'"
  71. @click="handleUpdate(row)"
  72. >
  73. [详情]
  74. </el-button>
  75. <el-button
  76. type="primary"
  77. link
  78. v-if="row.status == 1"
  79. v-permission="'finance:withdrawal:audit'"
  80. @click="handleChangeStatus(row)"
  81. >
  82. [审核]
  83. </el-button>
  84. </div>
  85. </template>
  86. </common-table>
  87. <!-- 审核弹窗 -->
  88. <audit-dialog ref="auditDialogRef" @success="reload" />
  89. </ele-page>
  90. </template>
  91. <script setup>
  92. import { ref, reactive, onMounted } from 'vue';
  93. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  94. import pageSearch from './components/page-search.vue';
  95. import { useDictData } from '@/utils/use-dict-data';
  96. import request from '@/utils/request';
  97. import auditDialog from './components/audit-dialog.vue';
  98. defineOptions({ name: 'withdrawal' });
  99. // 添加统计数据的响应式对象
  100. const statistics = reactive({
  101. totalWithdrawMoney: 0,
  102. unWithdrawMoney: 0,
  103. auditWithdrawMoney: 0,
  104. withdrawSuccessMoney: 0,
  105. averageWithdrawDuration: 0,
  106. noWithdrawMoney: 0
  107. });
  108. // 获取统计数据
  109. async function fetchStatistics() {
  110. try {
  111. const res = await request.get('/sys/finance/withdrawSum');
  112. if (res.data.code === 200) {
  113. Object.assign(statistics, res.data.data);
  114. }
  115. } catch (error) {
  116. console.error('获取统计数据失败:', error);
  117. }
  118. }
  119. onMounted(() => {
  120. fetchStatistics();
  121. });
  122. const [statusDicts] = useDictData(['withdrawal_status']);
  123. const useStatus = ref('');
  124. function handleStatusChange(value) {
  125. if (value === '6') {
  126. pageConfig.pageUrl = '/sys/finance/noWithdrawList';
  127. pageRef.value?.reload();
  128. } else {
  129. pageConfig.pageUrl = '/sys/finance/withdrawList';
  130. pageRef.value.reload({ status: value });
  131. }
  132. }
  133. //提现类型 string
  134. const withdrawTypeDicts = ref([
  135. { label: '微信', value: 1 },
  136. { label: '支付宝', value: 2 }
  137. ]);
  138. /** 表格列配置 */
  139. const columns = ref([
  140. {
  141. type: 'selection',
  142. columnKey: 'selection',
  143. width: 50,
  144. align: 'center',
  145. fixed: 'left'
  146. },
  147. { label: '提现时间', prop: 'createTime', align: 'center', width: 180 },
  148. { label: '用户名', prop: 'nickName', align: 'center', minWidth: 140 },
  149. {
  150. label: '支付单号/流水号',
  151. prop: 'transferNo',
  152. align: 'center',
  153. minWidth: 160
  154. },
  155. {
  156. label: '对方账户',
  157. prop: 'withdrawType',
  158. align: 'center',
  159. formatter: (row) =>
  160. withdrawTypeDicts.value.find((d) => d.value == row.withdrawType)
  161. ?.label
  162. },
  163. { label: '金额', prop: 'withdrawMoney', align: 'center' },
  164. {
  165. label: '交易状态',
  166. prop: 'status',
  167. align: 'center',
  168. formatter: (row) =>
  169. statusDicts.value.find((d) => d.dictValue == row.status)?.dictLabel
  170. },
  171. {
  172. label: '交易类型',
  173. prop: 'withdrawType',
  174. align: 'center',
  175. formatter: (row) => '提现'
  176. },
  177. {
  178. columnKey: 'action',
  179. label: '操作',
  180. width: 140,
  181. align: 'center',
  182. slot: 'action',
  183. fixed: 'right'
  184. }
  185. ]);
  186. /** 页面组件实例 */
  187. const pageRef = ref(null);
  188. const auditDialogRef = ref(null);
  189. const pageConfig = reactive({
  190. pageUrl: '/sys/finance/withdrawList',
  191. fileName: '提现管理',
  192. cacheKey: 'withdrawalTable'
  193. });
  194. //刷新表格
  195. function reload(where) {
  196. pageRef.value?.reload(where);
  197. }
  198. //审核
  199. function handleChangeStatus(row) {
  200. auditDialogRef.value?.handleOpen(row.id);
  201. }
  202. //一键审核
  203. function handleStepAudit() {
  204. const selections = pageRef.value?.getSelections();
  205. if (!selections?.length) {
  206. ElMessage.warning('请至少选择一条数据');
  207. return;
  208. }
  209. auditDialogRef.value?.handleOpen(selections.map(item => item.id));
  210. }
  211. </script>