index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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 #nickName="{ row }">
  73. <el-button type="primary" link @click="handleDetail(row)">
  74. {{ row.nickName }}
  75. </el-button>
  76. </template>
  77. <template #action="{ row }">
  78. <div>
  79. <el-button
  80. type="primary"
  81. link
  82. v-permission="'finance:withdrawal:detail'"
  83. @click="handleUpdate(row)"
  84. >
  85. [详情]
  86. </el-button>
  87. <el-button
  88. type="primary"
  89. link
  90. v-if="row.status == 1"
  91. v-permission="'finance:withdrawal:audit'"
  92. @click="handleChangeStatus(row)"
  93. >
  94. [审核]
  95. </el-button>
  96. </div>
  97. </template>
  98. </common-table>
  99. <!-- 审核弹窗 -->
  100. <audit-dialog ref="auditDialogRef" @success="reload" />
  101. <!-- 详情弹窗 -->
  102. <detail-dialog ref="detailDialogRef" />
  103. <customer-detail ref="detailRef"></customer-detail>
  104. </ele-page>
  105. </template>
  106. <script setup>
  107. import { ref, reactive, onMounted } from 'vue';
  108. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  109. import pageSearch from './components/page-search.vue';
  110. import { useDictData } from '@/utils/use-dict-data';
  111. import request from '@/utils/request';
  112. import auditDialog from './components/audit-dialog.vue';
  113. import detailDialog from './components/detail-dialog.vue';
  114. import customerDetail from '@/views/customer/list/components/customer-detail.vue';
  115. defineOptions({ name: 'withdrawal' });
  116. // 添加统计数据的响应式对象
  117. const statistics = reactive({
  118. totalWithdrawMoney: 0,
  119. unWithdrawMoney: 0,
  120. auditWithdrawMoney: 0,
  121. withdrawSuccessMoney: 0,
  122. averageWithdrawDuration: 0,
  123. noWithdrawMoney: 0
  124. });
  125. // 获取统计数据
  126. async function fetchStatistics() {
  127. try {
  128. const res = await request.get('/sys/finance/withdrawSum');
  129. if (res.data.code === 200) {
  130. Object.assign(statistics, res.data.data);
  131. }
  132. } catch (error) {
  133. console.error('获取统计数据失败:', error);
  134. }
  135. }
  136. onMounted(() => {
  137. fetchStatistics();
  138. });
  139. const [statusDicts] = useDictData(['withdrawal_status']);
  140. const useStatus = ref('');
  141. function handleStatusChange(value) {
  142. if (value === '6') {
  143. pageConfig.pageUrl = '/sys/finance/noWithdrawList';
  144. pageConfig.params.status = value;
  145. pageRef.value?.reload();
  146. } else {
  147. pageConfig.pageUrl = '/sys/finance/withdrawList';
  148. pageConfig.params.status = value;
  149. pageRef.value?.reload();
  150. }
  151. }
  152. //提现类型 string
  153. const withdrawTypeDicts = ref([
  154. { label: '微信', value: 1 },
  155. { label: '支付宝', value: 2 }
  156. ]);
  157. /** 表格列配置 */
  158. const columns = ref([
  159. {
  160. type: 'selection',
  161. columnKey: 'selection',
  162. width: 50,
  163. align: 'center',
  164. fixed: 'left'
  165. },
  166. { label: '提现时间', prop: 'createTime', align: 'center', width: 180 },
  167. {
  168. label: '用户名',
  169. prop: 'nickName',
  170. align: 'center',
  171. minWidth: 140,
  172. slot: 'nickName'
  173. },
  174. {
  175. label: '支付单号/流水号',
  176. prop: 'transferNo',
  177. align: 'center',
  178. minWidth: 160
  179. },
  180. {
  181. label: '对方账户',
  182. prop: 'withdrawType',
  183. align: 'center',
  184. formatter: (row) =>
  185. withdrawTypeDicts.value.find((d) => d.value == row.withdrawType)?.label
  186. },
  187. { label: '金额', prop: 'withdrawMoney', align: 'center' },
  188. {
  189. label: '交易状态',
  190. prop: 'status',
  191. align: 'center',
  192. formatter: (row) =>
  193. statusDicts.value.find((d) => d.dictValue == row.status)?.dictLabel
  194. },
  195. {
  196. label: '交易类型',
  197. prop: 'withdrawType',
  198. align: 'center',
  199. formatter: (row) => '提现'
  200. },
  201. {
  202. columnKey: 'action',
  203. label: '操作',
  204. width: 140,
  205. align: 'center',
  206. slot: 'action',
  207. fixed: 'right'
  208. }
  209. ]);
  210. /** 页面组件实例 */
  211. const pageRef = ref(null);
  212. const auditDialogRef = ref(null);
  213. const detailDialogRef = ref(null);
  214. const pageConfig = reactive({
  215. pageUrl: '/sys/finance/withdrawList',
  216. fileName: '提现管理',
  217. cacheKey: 'withdrawalTable',
  218. params: {
  219. status: ''
  220. }
  221. });
  222. //详情页面
  223. const detailRef = ref(null);
  224. function handleDetail(row, type) {
  225. row.id = row.userId;
  226. detailRef.value?.handleOpen(row, type);
  227. }
  228. //刷新表格
  229. function reload(where) {
  230. pageRef.value?.reload(where);
  231. }
  232. //审核
  233. function handleChangeStatus(row) {
  234. auditDialogRef.value?.handleOpen(row.id);
  235. }
  236. //详情
  237. function handleUpdate(row) {
  238. detailDialogRef.value?.handleOpen(row);
  239. }
  240. //一键审核
  241. function handleStepAudit() {
  242. const selections = pageRef.value?.getSelections();
  243. if (!selections?.length) {
  244. ElMessage.warning('请至少选择一条数据');
  245. return;
  246. }
  247. auditDialogRef.value?.handleOpen(selections.map((item) => item.id));
  248. }
  249. </script>