withdrawaRecord.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div class="table-box">
  3. <ProTable
  4. ref="proTable"
  5. :columns="columns"
  6. :request-api="getTableList"
  7. :init-param="initParam"
  8. :data-callback="dataCallback"
  9. :pagination="true"
  10. >
  11. <!-- 表格操作 -->
  12. <template #operation="scope">
  13. <el-button type="primary" link @click="toDetail(scope.row)"> 查看详情 </el-button>
  14. </template>
  15. </ProTable>
  16. <el-dialog v-model="dialogVisible" title="提现详情" width="500px">
  17. <div class="withdrawal-detail">
  18. <!-- 提现进度 -->
  19. <div class="progress-section">
  20. <h4 class="section-title">提现进度</h4>
  21. <el-steps :active="currentStep" direction="vertical" :process-status="processStatus" :finish-status="finishStatus">
  22. <el-step>
  23. <template #title>
  24. <div class="step-title">发起提现</div>
  25. </template>
  26. <template #description>
  27. <div class="step-time">
  28. {{ withdrawalDetail.createdTime || "2025/10/1 12:00:00" }}
  29. </div>
  30. </template>
  31. </el-step>
  32. <el-step>
  33. <template #title>
  34. <div class="step-title">等待审核</div>
  35. </template>
  36. </el-step>
  37. <el-step>
  38. <template #title>
  39. <div class="step-title">
  40. {{ paymentName(withdrawalDetail.paymentStatus) }}
  41. </div>
  42. </template>
  43. </el-step>
  44. </el-steps>
  45. </div>
  46. <!-- 提现详情 -->
  47. <div class="detail-section">
  48. <div class="detail-list">
  49. <div class="detail-item">
  50. <span class="detail-label">收款账户</span>
  51. <span class="detail-value">{{ withdrawalDetail.settlementAccount || "支付宝账户 (130****1234)" }}</span>
  52. </div>
  53. <div class="detail-item">
  54. <span class="detail-label">提现金额</span>
  55. <span class="detail-value amount">¥{{ withdrawalDetail.money || "6146.6" }}</span>
  56. </div>
  57. <div class="detail-item">
  58. <span class="detail-label">发起提现时间</span>
  59. <span class="detail-value">{{ withdrawalDetail.createdTime || "2025/10/1 12:00:00" }}</span>
  60. </div>
  61. <div class="detail-item">
  62. <span class="detail-label">结算账户</span>
  63. <span class="detail-value">{{ withdrawalDetail.settlementAccount || "重庆老火锅_钱包" }}</span>
  64. </div>
  65. <div class="detail-item">
  66. <span class="detail-label">提现状态</span>
  67. <span class="detail-value status">{{ paymentName(withdrawalDetail.paymentStatus) }}</span>
  68. </div>
  69. <div class="detail-item" v-if="withdrawalDetail.approveFailReason">
  70. <span class="detail-label">拒绝原因</span>
  71. <span class="detail-value">{{ withdrawalDetail.approveFailReason }}</span>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </el-dialog>
  77. </div>
  78. </template>
  79. <script setup lang="tsx" name="voucherManagement">
  80. import { computed, onActivated, onMounted, reactive, ref, watch } from "vue";
  81. import { useRouter } from "vue-router";
  82. import type { FormInstance, FormRules } from "element-plus";
  83. import { ElMessage } from "element-plus";
  84. import ProTable from "@/components/ProTable/index.vue";
  85. import { ColumnProps, ProTableInstance } from "@/components/ProTable/interface";
  86. import { getCashOutRecordList } from "@/api/modules/homeEntry";
  87. import { ElMessageBox } from "element-plus/es";
  88. import { localGet } from "@/utils";
  89. const dialogVisible = ref(false);
  90. const withdrawalDetail = ref<any>({});
  91. // ProTable 实例(需要在使用它的地方之前定义)
  92. const proTable = ref<ProTableInstance>();
  93. // 提现状态枚举
  94. const paymentStatusEnum = [
  95. { label: "提现中", value: 0 },
  96. { label: "提现成功", value: 1 },
  97. { label: "提现失败", value: 2 },
  98. { label: "提现待审核", value: 3 },
  99. { label: "提现拒绝", value: 4 },
  100. { label: "提现待审核通过", value: 5 }
  101. ];
  102. // 表格配置项
  103. const columns = reactive<ColumnProps<any>[]>([
  104. {
  105. prop: "settlementAccount",
  106. label: "收款账号",
  107. render: (scope: any) => {
  108. return "支付宝账号" + "(" + scope.row.settlementAccount + ")";
  109. }
  110. },
  111. {
  112. prop: "money",
  113. label: "提现金额",
  114. render: (scope: any) => {
  115. return scope.row.money ? `¥${scope.row.money}` : "--";
  116. }
  117. },
  118. {
  119. prop: "cashOutType",
  120. label: "提现方式",
  121. render: scope => {
  122. return scope.row.cashOutType ? "自动提现" : "手动提现";
  123. }
  124. },
  125. {
  126. prop: "createdTime",
  127. label: "发起提现时间",
  128. search: {
  129. el: "date-picker",
  130. props: {
  131. type: "daterange",
  132. "range-separator": " - ",
  133. "start-placeholder": "开始日期",
  134. "end-placeholder": "结束日期"
  135. }
  136. }
  137. },
  138. {
  139. prop: "paymentStatus",
  140. label: "提现状态",
  141. render: scope => {
  142. return scope.row.paymentStatus === 0
  143. ? "提现中"
  144. : scope.row.paymentStatus === 1
  145. ? "提现成功"
  146. : scope.row.paymentStatus === 2
  147. ? "提现失败"
  148. : scope.row.paymentStatus === 3
  149. ? "提现待审核"
  150. : scope.row.paymentStatus === 4
  151. ? "提现拒绝"
  152. : "提现待审核通过";
  153. },
  154. search: {
  155. el: "select",
  156. props: { placeholder: "请选择", clearable: true }
  157. },
  158. enum: paymentStatusEnum,
  159. fieldNames: { label: "label", value: "value" }
  160. },
  161. { prop: "operation", label: "操作", fixed: "right", width: 330 }
  162. ]);
  163. // 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
  164. const initParam = reactive({
  165. storeId: localGet("createdId"),
  166. cashOutEndTime: null,
  167. cashOutStartTime: null
  168. });
  169. // 页面加载时触发查询
  170. onMounted(async () => {
  171. proTable.value?.getTableList();
  172. });
  173. // 从其他页面返回时触发查询
  174. onActivated(() => {
  175. proTable.value?.getTableList();
  176. });
  177. // dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total 这些字段,可以在这里进行处理成这些字段
  178. // 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
  179. const dataCallback = (data: any) => {
  180. return {
  181. list: data.cashOutRecordList || data.list || [],
  182. total: data.total || 0
  183. };
  184. };
  185. // 格式化日期为 yyyy-mm-dd
  186. const formatDate = (date: string | Date) => {
  187. const d = new Date(date);
  188. const year = d.getFullYear();
  189. const month = String(d.getMonth() + 1).padStart(2, "0");
  190. const day = String(d.getDate()).padStart(2, "0");
  191. return `${year}-${month}-${day}`;
  192. };
  193. // 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
  194. // 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
  195. const getTableList = (params: any) => {
  196. let newParams = JSON.parse(JSON.stringify(params));
  197. // 处理 createdTime 参数,转换为 cashOutStartTime 和 cashOutEndTime
  198. if (newParams.createdTime && Array.isArray(newParams.createdTime) && newParams.createdTime.length === 2) {
  199. newParams.cashOutStartTime = formatDate(newParams.createdTime[0]);
  200. newParams.cashOutEndTime = formatDate(newParams.createdTime[1]);
  201. delete newParams.createdTime;
  202. } else {
  203. // 如果没有选择日期范围,清空 cashOutStartTime 和 cashOutEndTime
  204. newParams.cashOutStartTime = null;
  205. newParams.cashOutEndTime = null;
  206. }
  207. return getCashOutRecordList(newParams);
  208. };
  209. // 查看详情
  210. const toDetail = (row: any) => {
  211. withdrawalDetail.value = row;
  212. dialogVisible.value = true;
  213. };
  214. const paymentName = computed(() => {
  215. return status => {
  216. switch (status) {
  217. case 0:
  218. return "提现中";
  219. case 1:
  220. return "提现成功";
  221. case 2:
  222. return "提现失败";
  223. case 3:
  224. return "提现待审核";
  225. case 4:
  226. return "提现拒绝";
  227. case 5:
  228. return "提现待审核通过";
  229. default:
  230. return "";
  231. }
  232. };
  233. });
  234. // 计算当前步骤
  235. // active 表示当前激活的步骤索引(从0开始)
  236. // 步骤0: 发起提现(总是已完成)
  237. // 步骤1: 等待审核(根据状态判断)
  238. // 步骤2: 提现成功/拒绝(根据状态判断)
  239. const currentStep = computed(() => {
  240. const status = withdrawalDetail.value.paymentStatus;
  241. // 0: 提现中 -> 步骤1(发起提现已完成,等待审核进行中)
  242. // 1: 提现成功 -> 步骤2(所有步骤都已完成)
  243. // 2: 提现失败 -> 步骤1(等待审核失败)
  244. // 3: 提现待审核 -> 步骤1(等待审核进行中)
  245. // 4: 提现拒绝 -> 步骤2(审核已完成,在第三步显示拒绝状态)
  246. // 5: 提现待审核通过 -> 步骤2(所有步骤都已完成)
  247. if (status === 1 || status === 5) {
  248. return 2; // 提现成功,所有步骤都完成
  249. } else if (status === 4) {
  250. return 2; // 提现拒绝,在第三步显示错误状态
  251. } else if (status === 0 || status === 3) {
  252. return 1; // 等待审核进行中
  253. } else if (status === 2) {
  254. return 1; // 提现失败,在等待审核阶段失败
  255. }
  256. return 0; // 默认在第一步
  257. });
  258. // 处理状态(用于失败情况)
  259. const processStatus = computed<"error" | "process" | "finish" | "wait">(() => {
  260. const status = withdrawalDetail.value.paymentStatus;
  261. if (status === 4) {
  262. return "error" as const; // 提现拒绝,在第三步显示错误状态
  263. } else if (status === 2) {
  264. return "error" as const; // 提现失败,在等待审核阶段显示错误状态
  265. }
  266. return "process" as const; // 进行中
  267. });
  268. // 完成状态
  269. const finishStatus = computed<"finish">(() => {
  270. return "finish" as const; // 完成状态
  271. });
  272. // 获取状态文本
  273. const getStatusText = (status: string) => {
  274. const statusMap: Record<string, string> = {
  275. processing: "提现中",
  276. pending: "等待审核",
  277. success: "提现成功",
  278. failed: "提现失败",
  279. rejected: "审核拒绝"
  280. };
  281. return statusMap[status] || "提现中";
  282. };
  283. </script>
  284. <style lang="scss" scoped>
  285. // 在组件样式中添加
  286. .date-range {
  287. display: block; // 确保换行生效
  288. padding: 0 8px; // 可选:增加内边距
  289. word-wrap: break-word; // 长单词内换行
  290. white-space: normal; // 允许自然换行
  291. }
  292. .table-header-btn {
  293. .button {
  294. margin-bottom: 10px;
  295. }
  296. .tabs {
  297. :deep(.el-tabs__nav-wrap::after) {
  298. height: 0;
  299. }
  300. }
  301. }
  302. .reject-reason-content {
  303. padding: 20px 0;
  304. .reject-reason-item {
  305. display: flex;
  306. margin-bottom: 20px;
  307. &:last-child {
  308. margin-bottom: 0;
  309. }
  310. .reject-reason-label {
  311. flex-shrink: 0;
  312. min-width: 100px;
  313. font-size: 14px;
  314. font-weight: 500;
  315. color: #606266;
  316. }
  317. .reject-reason-value {
  318. flex: 1;
  319. font-size: 14px;
  320. color: #303133;
  321. word-break: break-word;
  322. &.reject-reason-text {
  323. min-height: 80px;
  324. padding: 12px;
  325. line-height: 1.6;
  326. white-space: pre-wrap;
  327. background-color: #f5f7fa;
  328. border-radius: 4px;
  329. }
  330. }
  331. }
  332. }
  333. .withdrawal-detail {
  334. .section-title {
  335. margin: 0 0 20px;
  336. font-size: 16px;
  337. font-weight: 600;
  338. color: #303133;
  339. }
  340. .progress-section {
  341. margin-bottom: 30px;
  342. :deep(.el-steps) {
  343. .el-step {
  344. margin-bottom: 24px;
  345. &:last-child {
  346. margin-bottom: 0;
  347. }
  348. }
  349. .el-step__head {
  350. .el-step__icon {
  351. width: 20px;
  352. height: 20px;
  353. font-size: 14px;
  354. }
  355. }
  356. .el-step__main {
  357. padding-bottom: 8px;
  358. .el-step__title {
  359. margin-bottom: 8px;
  360. font-size: 14px;
  361. line-height: 1.5;
  362. .step-title {
  363. font-size: 14px;
  364. font-weight: 500;
  365. color: #303133;
  366. }
  367. }
  368. .el-step__description {
  369. .step-time {
  370. margin-top: 4px;
  371. font-size: 12px;
  372. color: #909399;
  373. }
  374. }
  375. }
  376. .el-step__line {
  377. top: 20px;
  378. bottom: -24px;
  379. left: 9px;
  380. height: calc(100% + 4px);
  381. border-left: 2px dashed #dcdfe6;
  382. }
  383. .el-step__line-inner {
  384. height: 100%;
  385. border: none;
  386. }
  387. .el-step:last-child .el-step__line {
  388. display: none;
  389. }
  390. }
  391. }
  392. .detail-section {
  393. .detail-list {
  394. .detail-item {
  395. display: flex;
  396. align-items: flex-start;
  397. margin-bottom: 16px;
  398. &:last-child {
  399. margin-bottom: 0;
  400. }
  401. .detail-label {
  402. flex-shrink: 0;
  403. width: 100px;
  404. font-size: 14px;
  405. color: #606266;
  406. }
  407. .detail-value {
  408. flex: 1;
  409. font-size: 14px;
  410. color: #303133;
  411. word-break: break-word;
  412. &.amount {
  413. font-size: 16px;
  414. font-weight: 600;
  415. color: #303133;
  416. }
  417. &.status {
  418. color: #409eff;
  419. }
  420. }
  421. }
  422. }
  423. }
  424. }
  425. </style>