detail.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="table-box">
  3. <el-card style="margin-bottom: 15px">
  4. <el-row :gutter="10">
  5. <el-col :xs="4" :sm="4" :md="4" :lg="4" :xl="4">
  6. <div class="form-box borderRight">
  7. <div class="form-title">
  8. 总交易金额
  9. <el-tooltip class="box-item" effect="dark" content="总成交金额" placement="top">
  10. <el-icon><QuestionFilled /></el-icon>
  11. </el-tooltip>
  12. </div>
  13. <div class="form-num">
  14. {{ formatAmount(form.allOrderAmount) }}
  15. </div>
  16. </div>
  17. </el-col>
  18. <el-col :xs="4" :sm="4" :md="4" :lg="4" :xl="4">
  19. <div class="form-box borderRight">
  20. <div class="form-title">
  21. 交易笔数
  22. <el-tooltip class="box-item" effect="dark" content="成交订单总数" placement="top">
  23. <el-icon><QuestionFilled /></el-icon>
  24. </el-tooltip>
  25. </div>
  26. <div class="form-num">
  27. {{ formatAmount2(form.orderTransactionNumber) }}
  28. </div>
  29. </div>
  30. </el-col>
  31. <el-col :xs="4" :sm="4" :md="4" :lg="4" :xl="4">
  32. <div class="form-box borderRight">
  33. <div class="form-title">
  34. 核销金额
  35. <el-tooltip class="box-item" effect="dark" content="已完成核销的金额" placement="top">
  36. <el-icon><QuestionFilled /></el-icon>
  37. </el-tooltip>
  38. </div>
  39. <div class="form-num">
  40. {{ formatAmount(form.verificationAmount) }}
  41. </div>
  42. </div>
  43. </el-col>
  44. <el-col :xs="4" :sm="4" :md="4" :lg="4" :xl="4">
  45. <div class="form-box borderRight">
  46. <div class="form-title">
  47. 已提现金额
  48. <el-tooltip class="box-item" effect="dark" content="用户已成功提现的金额" placement="top">
  49. <el-icon><QuestionFilled /></el-icon>
  50. </el-tooltip>
  51. </div>
  52. <div class="form-num">
  53. {{ formatAmount(form.totalWithdrawalAmount) }}
  54. </div>
  55. </div>
  56. </el-col>
  57. <el-col :xs="4" :sm="4" :md="4" :lg="4" :xl="4">
  58. <div class="form-box borderRight">
  59. <div class="form-title">
  60. 冻结金额
  61. <el-tooltip class="box-item" effect="dark" content="当前冻结中的金额(未可提现)" placement="top">
  62. <el-icon><QuestionFilled /></el-icon>
  63. </el-tooltip>
  64. </div>
  65. <div class="form-num">
  66. {{ formatAmount(form.freezeAmounts) }}
  67. </div>
  68. </div>
  69. </el-col>
  70. <el-col :xs="4" :sm="4" :md="4" :lg="4" :xl="4">
  71. <div class="form-box">
  72. <div class="form-title">
  73. 冻结待提现金额
  74. <el-tooltip class="box-item" effect="dark" content="已申请提现但仍在冻结中的金额" placement="top">
  75. <el-icon><QuestionFilled /></el-icon>
  76. </el-tooltip>
  77. </div>
  78. <div class="form-num">
  79. {{ formatAmount(form.unwithdrawnAmountsFrozen) }}
  80. </div>
  81. </div>
  82. </el-col>
  83. </el-row>
  84. </el-card>
  85. <ProTable ref="proTable" :columns="columns" :request-api="getTableList" :init-param="initParam" :data-callback="dataCallback">
  86. <template #buyAmount="scope">
  87. {{ formatAmount(scope.row.buyAmount) }}
  88. </template>
  89. </ProTable>
  90. </div>
  91. </template>
  92. <script setup lang="tsx" name="useProTable">
  93. import { ref, reactive, onMounted, onActivated } from "vue";
  94. import { useRoute } from "vue-router";
  95. import { Reconciliation } from "@/api/interface";
  96. import { ElMessage } from "element-plus";
  97. import ProTable from "@/components/ProTable/index.vue";
  98. import { ProTableInstance, ColumnProps } from "@/components/ProTable/interface";
  99. import { getDetails, getDetailStatis } from "@/api/modules/Reconciliation";
  100. import { QuestionFilled } from "@element-plus/icons-vue";
  101. const route = useRoute();
  102. const form = ref({ allOrderAmount: 0, orderTransactionNumber: 0, userCount: 0, verificationAmount: 0 });
  103. // ProTable 实例
  104. const proTable = ref<ProTableInstance>();
  105. const id = ref((route.query.id as string) || "");
  106. const initParam = reactive({ storeId: id.value });
  107. // 页面加载时触发查询
  108. onMounted(() => {
  109. proTable.value?.getTableList();
  110. getStatis();
  111. });
  112. // 从其他页面返回时触发查询
  113. onActivated(() => {
  114. proTable.value?.getTableList();
  115. getStatis();
  116. });
  117. // 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
  118. const dataCallback = (data: any) => {
  119. return {
  120. list: data.records,
  121. total: data.total
  122. };
  123. };
  124. // 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
  125. // 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
  126. const getTableList = (params: any) => {
  127. let newParams = JSON.parse(JSON.stringify(params));
  128. newParams.page = newParams.pageNum;
  129. newParams.size = newParams.pageSize;
  130. delete newParams.pageNum;
  131. delete newParams.pageSize;
  132. return getDetails(newParams);
  133. };
  134. const status = ref<any[]>([
  135. { value: 0, label: "待支付" },
  136. { value: 1, label: "已支付(待使用)" },
  137. { value: 2, label: "已核销" },
  138. { value: 3, label: "已过期" },
  139. { value: 4, label: "已取消" },
  140. { value: 5, label: "已退款" },
  141. { value: 6, label: "退款失败" },
  142. { value: 7, label: "已完成" }
  143. ]);
  144. const couponType = ref<any[]>([
  145. { value: "1", label: "代金券" },
  146. { value: "2", label: "套餐" }
  147. ]);
  148. // 表格配置项
  149. const columns = reactive<ColumnProps<Reconciliation.ResDetailList>[]>([
  150. { prop: "userId", label: "用户ID", search: { el: "input", tooltip: "用户ID" } },
  151. { prop: "userName", label: "用户名", search: { el: "input", tooltip: "用户名" } },
  152. { prop: "orderNo", label: "订单编号", search: { el: "input", tooltip: "订单编号" } },
  153. { prop: "couponType", label: "订单类型", enum: couponType },
  154. { prop: "buyAmount", label: "订单金额" },
  155. { prop: "buyTime", label: "购买时间" },
  156. { prop: "status", label: "状态", enum: status }
  157. ]);
  158. const getStatis = async () => {
  159. try {
  160. if (id.value) {
  161. const res = await getDetailStatis({ storeId: id.value });
  162. if (res.code == 200) {
  163. form.value = res.data;
  164. }
  165. }
  166. } catch (error) {
  167. // ElMessage.error("获取详情失败");
  168. }
  169. };
  170. // 交易金额格式化
  171. const formatAmount2 = (amount: number | string) => {
  172. const num = Number(amount);
  173. if (isNaN(num)) return "0";
  174. if (Math.abs(num) >= 1000) {
  175. return `${num / 10000}万笔`;
  176. } else if (num === 0) {
  177. return "0";
  178. } else {
  179. return `${num}`;
  180. }
  181. };
  182. // 添加金额格式化函数
  183. const formatAmount = (amount: number | string) => {
  184. const num = Number(amount);
  185. if (isNaN(num)) return "0";
  186. if (Math.abs(num) >= 1000) {
  187. return `${(num / 10000).toFixed(2)}万元`;
  188. } else if (num === 0) {
  189. return "0";
  190. } else {
  191. return `${num.toFixed(2)}元`;
  192. }
  193. };
  194. </script>
  195. <style lang="scss" scoped>
  196. .form-box {
  197. display: flex;
  198. flex-direction: column;
  199. align-items: center;
  200. margin-bottom: 20px;
  201. .form-title {
  202. font-size: 14px;
  203. }
  204. .form-num {
  205. margin-top: 20px;
  206. font-size: 18px;
  207. font-weight: 500;
  208. }
  209. }
  210. .borderRight {
  211. border-right: 1px solid #e6e6e6;
  212. }
  213. </style>