index.vue 6.8 KB

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