recording-history.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('Home.page_customer.item7')" />
  4. <view class="info-card">
  5. <cwg-complex-search :fields="filterFields" v-model="searchParams" @search="handleSearch"
  6. @reset="handleReset" />
  7. <cwg-tabel ref="tableRef" :columns="currentColumns" :immediate="false" :queryParams="search" :api="listApi"
  8. :show-operation="false">
  9. <!-- 状态列自定义渲染 -->
  10. <template #status="{ row }">
  11. <view v-if="getStatusText(row)" class="status-tag" :class="getStatusClass(row.status)">
  12. {{ getStatusText(row) }}
  13. </view>
  14. <view v-else></view>
  15. </template>
  16. <!-- 账户类型列自定义渲染 -->
  17. <template #accountType="{ row }">
  18. {{ getAccountTypeText(row.type || row.loginType) }}
  19. </template>
  20. <!-- 金额列格式化 -->
  21. <template #amount="{ row }">
  22. <view>-{{ formatNumber(row.withdrawAmount || row.amount) }}</view>
  23. </template>
  24. <!-- 备注列格式化 -->
  25. <template #note="{ row }">
  26. <view>{{ formatNote(row.approveDesc) }}</view>
  27. </template>
  28. </cwg-tabel>
  29. </view>
  30. </cwg-page-wrapper>
  31. </template>
  32. <script setup lang="ts">
  33. import { computed, ref, nextTick } from 'vue';
  34. import { useI18n } from 'vue-i18n';
  35. const { t, locale } = useI18n();
  36. import { customApi } from '@/service/custom';
  37. import useUserStore from "@/stores/use-user-store";
  38. const userStore = useUserStore();
  39. const userInfo = computed(() => userStore.userInfo);
  40. const search = ref({
  41. type: 1
  42. })
  43. const getInfoAgentTransfer = computed(() => userInfo.value.customInfo?.agentTransfer)
  44. const typeMap = computed(() => ([
  45. { value: 1, text: t('Custom.Recording.NewAccount') },
  46. // { value: 2, text: t('Custom.Recording.LeverageApply') },
  47. { value: 3, text: t('Custom.Recording.InternalTransfer') },
  48. // { value: 4, text: t('Custom.Recording.ActivitiesApply') },
  49. ...(getInfoAgentTransfer.value == 1 ? [{ value: 5, text: t('Home.page_ib.item9') }] : [])
  50. ]));
  51. const isZh = computed(() => ['cn', 'zh', 'zhHant'].includes(locale.value));
  52. // 账户类型映射
  53. const accountTypeMap = {
  54. 1: 'AccountType.ClassicAccount',
  55. 2: 'AccountType.SeniorAccount',
  56. 5: 'AccountType.SpeedAccount',
  57. 6: 'AccountType.SpeedAccount',
  58. 7: 'AccountType.StandardAccount',
  59. 8: 'AccountType.CentAccount'
  60. }
  61. // 拒绝原因映射(示例)
  62. const reasons = ref({})
  63. // 根据类型获取列配置
  64. const getColumnsByType = (type: number) => {
  65. switch (type) {
  66. case 1: // 开户记录
  67. return [
  68. {
  69. prop: 'platform',
  70. label: t('Custom.Recording.Platform'),
  71. align: 'left'
  72. },
  73. {
  74. prop: 'type',
  75. label: t('Custom.PaymentHistory.payType'),
  76. align: 'left',
  77. slot: 'accountType'
  78. },
  79. {
  80. prop: 'withdrawCurrency',
  81. label: t('Custom.Recording.CurrencyType'),
  82. align: 'left',
  83. formatter: ({ row }) => row.currency || '--',
  84. },
  85. {
  86. prop: 'leverage',
  87. label: t('Custom.Recording.Lever'),
  88. formatter: ({ row }) => `1: ${row.leverage}` || '--',
  89. align: 'left'
  90. },
  91. {
  92. prop: 'addTime',
  93. label: t('Custom.PaymentHistory.ApplicationDate'),
  94. type: 'date',
  95. dateFormat: 'YYYY-MM-DD HH:mm',
  96. align: 'left'
  97. },
  98. {
  99. prop: 'status',
  100. label: t('Custom.Recording.Status'),
  101. slot: 'status',
  102. align: 'left'
  103. },
  104. {
  105. prop: 'note',
  106. label: t('Custom.Recording.Note'),
  107. type: 'note',
  108. align: 'left'
  109. }
  110. ]
  111. case 2: // 杠杆修改记录
  112. return [
  113. {
  114. prop: 'login',
  115. label: t('Custom.Recording.TradingAccount'),
  116. align: 'left',
  117. formatter: ({ row }) => row.login || '--'
  118. },
  119. {
  120. prop: 'oldLeverage',
  121. label: t('Custom.Recording.OldLever'),
  122. align: 'left',
  123. formatter: ({ row }) => row.oldLeverage ? `1:${row.oldLeverage}` : '--'
  124. },
  125. {
  126. prop: 'newLeverage',
  127. label: t('Custom.Recording.NewLever'),
  128. align: 'left',
  129. formatter: ({ row }) => row.newLeverage ? `1:${row.newLeverage}` : '--'
  130. },
  131. {
  132. prop: 'addTime',
  133. label: t('Custom.PaymentHistory.ApplicationDate'),
  134. type: 'date',
  135. dateFormat: 'YYYY-MM-DD HH:mm',
  136. align: 'left'
  137. },
  138. {
  139. prop: 'status',
  140. label: t('Custom.PaymentHistory.Status'),
  141. slot: 'status',
  142. align: 'left'
  143. },
  144. {
  145. prop: 'note',
  146. label: t('Custom.Recording.Note'),
  147. type: 'note',
  148. align: 'left'
  149. }
  150. ]
  151. case 3: // 转账记录
  152. case 5: // 内部转账记录
  153. return [
  154. {
  155. prop: 'withdrawLogin',
  156. label: t('Custom.Recording.TransferAccounts'),
  157. align: 'left',
  158. formatter: ({ row }) => row.withdrawLogin || '--'
  159. },
  160. {
  161. prop: 'depositLogin',
  162. label: t('Custom.Recording.IntoAccount'),
  163. align: 'left',
  164. formatter: ({ row }) => row.depositLogin || '--',
  165. },
  166. {
  167. prop: 'withdrawCurrency',
  168. label: t('Custom.Recording.CurrencyType'),
  169. align: 'left',
  170. formatter: ({ row }) => row.withdrawCurrency || '--',
  171. },
  172. {
  173. prop: 'withdrawAmount',
  174. label: t('Custom.Recording.Amount'),
  175. align: 'left',
  176. slot: 'amount'
  177. },
  178. {
  179. prop: 'addTime',
  180. label: t('Custom.PaymentHistory.ApplicationDate'),
  181. type: 'date',
  182. dateFormat: 'YYYY-MM-DD HH:mm',
  183. align: 'left'
  184. },
  185. {
  186. prop: 'status',
  187. label: t('Custom.PaymentHistory.Status'),
  188. slot: 'status',
  189. align: 'left'
  190. },
  191. {
  192. prop: 'note',
  193. label: t('Custom.Recording.Note'),
  194. type: 'note',
  195. align: 'left'
  196. }
  197. ]
  198. case 4: // 活动申请记录
  199. return [
  200. {
  201. prop: 'login',
  202. label: t('Custom.Recording.TradingAccount'),
  203. align: 'left',
  204. formatter: ({ row }) => row.login || '--'
  205. },
  206. {
  207. prop: 'loginType',
  208. label: t('Custom.Recording.AccountType'),
  209. align: 'left',
  210. slot: 'accountType'
  211. },
  212. {
  213. prop: 'title',
  214. label: t('Custom.Recording.ActivityName'),
  215. align: 'left',
  216. formatter: ({ row }) => row.title || '--'
  217. },
  218. {
  219. prop: 'addTime',
  220. label: t('Custom.PaymentHistory.ApplicationDate'),
  221. type: 'date',
  222. dateFormat: 'YYYY-MM-DD HH:mm',
  223. align: 'left'
  224. },
  225. {
  226. prop: 'status',
  227. label: t('Custom.PaymentHistory.Status'),
  228. slot: 'status',
  229. align: 'left'
  230. },
  231. {
  232. prop: 'note',
  233. label: t('Custom.Recording.Note'),
  234. type: 'note',
  235. align: 'left'
  236. }
  237. ]
  238. }
  239. }
  240. // 动态传入筛选字段配置
  241. const filterFields = computed(() => [
  242. { key: 'type', type: 'select', label: t('Custom.PaymentHistory.payType'), placeholder: t('placeholder.choose'), options: typeMap.value, defaultValue: 1 },
  243. { key: 'date', label: t('placeholder.Start') + ' - ' + t('placeholder.End'), type: 'daterange' }
  244. ])
  245. const searchParams = ref({})
  246. const tableRef = ref(null)
  247. const handleSearch = (params) => {
  248. search.value = params
  249. nextTick(() => {
  250. tableRef.value.refreshTable()
  251. })
  252. }
  253. const handleReset = (params) => {
  254. search.value = params
  255. nextTick(() => {
  256. tableRef.value.refreshTable()
  257. })
  258. }
  259. // 当前列配置
  260. const currentColumns = computed(() => getColumnsByType(search.value.type))
  261. // 获取状态文本
  262. const getStatusText = (row: any) => {
  263. const status = row.status
  264. // 根据不同记录类型处理状态
  265. if (search.value.type === 1) {
  266. if (status === 1) return t('State.ToBeProcessed')
  267. if (status === 2 && row.accountStatus === 2) return t('State.Completed')
  268. if (status === 2 && (row.accountStatus === 1 || !row.accountStatus)) return t('State.InTheProcessing')
  269. if (status === 3) return t('State.Refused')
  270. } else if (search.value.type === 2) {
  271. if (status === 1) return t('State.ToBeProcessed')
  272. if (status === 2 && row.leverageStatus === 2) return t('State.Completed')
  273. if (status === 2 && row.leverageStatus === 1) return t('State.InTheProcessing')
  274. if (status === 3) return t('State.Refused')
  275. } else if (search.value.type === 3 || search.value.type === 5) {
  276. if (status === 1) return t('State.ToBeProcessed')
  277. if (status === 2 && row.withdrawStatus === 2 && row.depositStatus === 2) return t('State.Completed')
  278. if (status === 2 && (row.withdrawStatus === 1 || row.depositStatus === 1)) return t('State.InTheProcessing')
  279. if (status === 3 || row.withdrawStatus === 3 || row.depositStatus === 3) return t('State.Refused')
  280. } else {
  281. // 活动申请等
  282. if (status === 1) return t('State.ToBeProcessed')
  283. if (status === 2) return t('State.Completed')
  284. if (status === 3) return t('State.Refused')
  285. }
  286. return ''
  287. }
  288. // 获取状态样式类
  289. const getStatusClass = (status: number) => {
  290. const classMap: Record<number, string> = {
  291. 1: 'status-pending',
  292. 2: 'status-success',
  293. 3: 'status-processing',
  294. 4: 'status-danger'
  295. }
  296. return classMap[status] || ''
  297. }
  298. // 获取账户类型文本
  299. const getAccountTypeText = (type: number) => {
  300. const key = accountTypeMap[type as keyof typeof accountTypeMap]
  301. return key ? t(key) : '--'
  302. }
  303. // 格式化数字
  304. const formatNumber = (value: string | number) => {
  305. if (!value) return '--'
  306. const num = Number(value)
  307. return isNaN(num) ? '--' : num.toFixed(2)
  308. }
  309. // 格式化备注
  310. const formatNote = (approveDesc: string) => {
  311. if (!approveDesc) return '--'
  312. const reason = reasons.value[approveDesc as keyof typeof reasons.value]
  313. if (reason) {
  314. return isZh.value ? reason.content : reason.enContent
  315. }
  316. return approveDesc
  317. }
  318. const listApi = ref(null)
  319. listApi.value = customApi.CustomRecordAccount
  320. </script>
  321. <style scoped lang="scss">
  322. @import "@/uni.scss";
  323. .avatar {
  324. width: px2rpx(60);
  325. height: px2rpx(60);
  326. border-radius: 4px;
  327. }
  328. .content-title {
  329. display: flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. font-size: px2rpx(20);
  333. font-weight: 500;
  334. .content-title-btns {
  335. margin: px2rpx(8) 0;
  336. display: flex;
  337. align-items: center;
  338. justify-content: center;
  339. gap: px2rpx(12);
  340. .btn-primary {
  341. min-width: px2rpx(120);
  342. background-color: var(--color-error);
  343. color: white;
  344. padding: 0 px2rpx(12);
  345. border: none;
  346. font-size: px2rpx(14);
  347. text-align: center;
  348. cursor: pointer;
  349. display: flex;
  350. align-items: center;
  351. justify-content: center;
  352. gap: px2rpx(8);
  353. }
  354. .btn-primary:active {
  355. background-color: #cf1322;
  356. ;
  357. }
  358. }
  359. }
  360. .operation-btn {
  361. :deep(span) {
  362. display: flex;
  363. align-items: center;
  364. justify-content: center;
  365. gap: px2rpx(4);
  366. cursor: pointer;
  367. background-color: var(--color-slate-150);
  368. padding: px2rpx(8) 0;
  369. }
  370. }
  371. .operation-btn.disabled {
  372. cursor: not-allowed;
  373. opacity: 0.5;
  374. }
  375. .search-bar {
  376. display: flex;
  377. align-items: center;
  378. justify-content: flex-start;
  379. flex-wrap: wrap;
  380. gap: px2rpx(16);
  381. margin: px2rpx(16) 0;
  382. .cwg-combox,
  383. .uni-easyinput,
  384. .uni-date {
  385. width: px2rpx(240) !important;
  386. flex: none;
  387. }
  388. }
  389. </style>