recording.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('Home.page_ib.item7')" />
  4. <view class="account-content">
  5. <view class="search-content">
  6. <view class="search-bar">
  7. <cwg-complex-search :fields="filterFields" v-model="searchParams" @search="handleSearch"
  8. @reset="handleReset" />
  9. </view>
  10. <view />
  11. </view>
  12. <cwg-tabel
  13. ref="tableRef"
  14. :columns="columns"
  15. :mobilePrimaryFields="mobilePrimaryFields"
  16. :queryParams="search"
  17. :api="listApi"
  18. :show-operation="true"
  19. :showPagination="true"
  20. >
  21. <template #remitChannelName="{row}">
  22. <text>
  23. {{
  24. isZh ? row.remitChannelName || '--' : row.remitChannelEnName || '--'
  25. }}
  26. </text>
  27. </template>
  28. <template #status="{row}">
  29. <text v-if="row.status == 1">
  30. {{ t('State.ToBeProcessed') }}
  31. </text>
  32. <text v-if="row.status == 2&&row.submitStatus == 2">
  33. {{ t('State.Completed') }}
  34. </text>
  35. <text v-if="row.status == 2&&row.submitStatus != 2">
  36. {{ t('State.InTheProcessing') }}
  37. </text>
  38. <text v-if="row.status == 3 || row.callbackStatus == 2">
  39. {{ t('State.Refused') }}
  40. </text>
  41. <text v-if="row.status == 5">
  42. {{ t('State.Cancelled') }}
  43. </text>
  44. <button class="cancel-btn" v-if="row.status == 1" @click.stop="cancel(row.id)">
  45. {{ t('Btn.Cancel') }}
  46. </button>
  47. </template>
  48. </cwg-tabel>
  49. </view>
  50. <cwg-confirm-popup />
  51. </cwg-page-wrapper>
  52. </template>
  53. <script setup lang="ts">
  54. // 申请历史
  55. import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
  56. import { onLoad } from '@dcloudio/uni-app'
  57. import { useI18n } from 'vue-i18n' // uni-app 中已集成,但需配置
  58. import { customApi } from '@/service/custom'
  59. import { financialApi } from '@/service/financial'
  60. import Config from '@/config/index'
  61. import { ibApi } from '@/service/ib'
  62. import { useRecordingConst } from '@/pages/ib/const/recording'
  63. import { useFilters } from '@/composables/useFilters'
  64. import { useConfirm } from '@/hooks/useConfirm'
  65. import { nextTick } from 'vue'
  66. const confirm = useConfirm()
  67. const { numberFormat, numberDecimal } = useFilters()
  68. const { t, locale } = useI18n()
  69. const { columnList, mobileList, apiList } = useRecordingConst()
  70. let { Code } = Config
  71. const typeList = computed(() => [
  72. { text: t('Ib.Recording.NewAccount'), value: 1 },
  73. { text: t('Ib.Recording.LeverageApply'), value: 2 },
  74. { text: t('Ib.Recording.InternalTransfer'), value: 3 },
  75. { text: t('Ib.Recording.ActivitiesApply'), value: 4 },
  76. { text: t('Ib.Recording.MaidAdjust'), value: 5 },
  77. { text: t('Ib.Recording.BelongingAdjust'), value: 6 },
  78. { text: t('Ib.Recording.CommissionAllocation'), value: 7 },
  79. { text: t('Custom.Withdraw.Title'), value: 8 },
  80. { text: t('Ib.Recording.MamHangUndo'), value: 9 },
  81. { text: t('Home.page_ib.item9'), value: 10 },
  82. { text: t('Ib.PammManager.title2'), value: 11 },
  83. { text: t('Ib.PammManager.title3'), value: 12 },
  84. { text: t('Ib.Transfer.IbAccountTransfer'), value: 13 },
  85. ])
  86. const getCurrentMonthRange = () => {
  87. const now = new Date()
  88. const year = now.getFullYear()
  89. const month = now.getMonth()
  90. // 第一天
  91. const firstDay = new Date(year, month, 1)
  92. // 最后一天
  93. const lastDay = new Date(year, month + 1, 0)
  94. const format = (date) => {
  95. const y = date.getFullYear()
  96. const m = String(date.getMonth() + 1).padStart(2, '0')
  97. const d = String(date.getDate()).padStart(2, '0')
  98. return `${y}-${m}-${d}`
  99. }
  100. return [format(firstDay), format(lastDay)]
  101. }
  102. const defaultDateRange = getCurrentMonthRange()
  103. const searchParams = ref({
  104. types: 1,
  105. date: defaultDateRange,
  106. })
  107. const search = ref({
  108. types: 1,
  109. startDate: defaultDateRange[0],
  110. endDate: defaultDateRange[1],
  111. })
  112. const filterFields = computed(() => [
  113. {
  114. key: 'types',
  115. type: 'select',
  116. label: t('placeholder.choose'),
  117. placeholder: t('placeholder.choose'),
  118. options: typeList.value,
  119. defaultValue: 1,
  120. isSelect: true,
  121. clearable: false,
  122. },
  123. {
  124. key: 'date',
  125. label: t('placeholder.Start') + ' - ' + t('placeholder.End'),
  126. type: 'daterange',
  127. defaultValue: defaultDateRange,
  128. },
  129. ])
  130. const tableRef = ref<any>(null)
  131. const handleSearch = (params: any) => {
  132. const payload = { ...params }
  133. search.value = payload
  134. nextTick(() => {
  135. tableRef.value?.refreshTable?.()
  136. })
  137. }
  138. const handleReset = (params) => {
  139. searchParams.value = {
  140. ...params,
  141. types: 1,
  142. }
  143. search.value = {
  144. ...params,
  145. types: 1,
  146. }
  147. nextTick(() => {
  148. tableRef.value?.refreshTable?.()
  149. })
  150. }
  151. const isZh = computed(() => {
  152. return ['cn', 'zhHant'].indexOf(locale.value) != -1
  153. })
  154. // 表格列配置 根据types 切换
  155. const columns = computed(() => {
  156. return columnList.value[search.value.types]
  157. })
  158. const mobilePrimaryFields = computed(() => {
  159. return [
  160. ...mobileList.value[search.value.types],
  161. {
  162. prop: 'more',
  163. type: 'more',
  164. width: 20,
  165. align: 'right',
  166. },
  167. ]
  168. })
  169. // 接口 根据types 切换
  170. const listApi = computed(() => {
  171. let other = {}
  172. switch (search.value.types) {
  173. case 1:
  174. other = {
  175. mamType: 0,
  176. }
  177. break
  178. case 4:
  179. other = {
  180. type: 4,
  181. }
  182. break
  183. case 11:
  184. case 12:
  185. other = {
  186. mamType: 3,
  187. }
  188. break
  189. }
  190. return (params) => ibApi[apiList.value[search.value.types]]({ ...params, ...other })
  191. })
  192. const cancel = async (id) => {
  193. tableRef.value.setDetailVisible(false)
  194. try {
  195. await confirm({
  196. title: t('Msg.SystemPrompt'),
  197. content: t('Msg.Cancle'),
  198. confirmText: t('Btn.item6'),
  199. cancelText: t('Btn.item7'),
  200. })
  201. let res = await ibApi.withdrawCancel({ id })
  202. if (res.code == Code.StatusOK) {
  203. uni.showToast({
  204. title: t('Msg.Success'),
  205. icon: 'success',
  206. })
  207. } else {
  208. uni.showToast({
  209. title: res.msg,
  210. icon: 'none',
  211. })
  212. }
  213. } catch (err) {
  214. }
  215. }
  216. onMounted(() => {
  217. })
  218. </script>
  219. <style lang="scss" scoped>
  220. @import "@/uni.scss";
  221. .search-content {
  222. display: flex;
  223. justify-content: space-between;
  224. .uni-date {
  225. width: px2rpx(250) !important;
  226. flex: none;
  227. }
  228. }
  229. .cancel-btn{
  230. display: block;
  231. width: px2rpx(50);
  232. line-height: px2rpx(10) !important;
  233. }
  234. </style>