recording.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. startDate: defaultDateRange[0],
  107. endDate: defaultDateRange[1],
  108. })
  109. const search = reactive({
  110. types: 1,
  111. startDate: defaultDateRange[0],
  112. endDate: defaultDateRange[1],
  113. })
  114. const filterFields = computed(() => [
  115. {
  116. key: 'types',
  117. type: 'select',
  118. label: t('placeholder.choose'),
  119. placeholder: t('placeholder.choose'),
  120. options: typeList.value,
  121. defaultValue: 1,
  122. isSelect: true,
  123. clearable: false,
  124. },
  125. {
  126. key: 'date',
  127. label: t('placeholder.Start') + ' - ' + t('placeholder.End'),
  128. type: 'daterange',
  129. defaultValue: defaultDateRange,
  130. },
  131. ])
  132. const tableRef = ref<any>(null)
  133. const handleSearch = (params: any) => {
  134. const payload = { ...params }
  135. Object.assign(search, payload)
  136. nextTick(() => {
  137. tableRef.value?.refreshTable?.()
  138. })
  139. }
  140. const handleReset = (params) => {
  141. searchParams.value = {
  142. ...params,
  143. types: 1,
  144. }
  145. Object.assign(search, params,{ types: 1,})
  146. nextTick(() => {
  147. tableRef.value?.refreshTable?.()
  148. })
  149. }
  150. const isZh = computed(() => {
  151. return ['cn', 'zhHant'].indexOf(locale.value) != -1
  152. })
  153. // 表格列配置 根据types 切换
  154. const columns = computed(() => {
  155. return columnList.value[search.types]
  156. })
  157. const mobilePrimaryFields = computed(() => {
  158. return [
  159. ...mobileList.value[search.types],
  160. {
  161. prop: 'more',
  162. type: 'more',
  163. width: 20,
  164. align: 'right',
  165. },
  166. ]
  167. })
  168. // 接口 根据types 切换
  169. const listApi = computed(() => {
  170. let other = {}
  171. switch (search.types) {
  172. case 1:
  173. other = {
  174. mamType: 0,
  175. }
  176. break
  177. case 4:
  178. other = {
  179. type: 4,
  180. }
  181. break
  182. case 11:
  183. case 12:
  184. other = {
  185. mamType: 3,
  186. }
  187. break
  188. }
  189. return (params) => ibApi[apiList.value[search.types]]({ ...params, ...other })
  190. })
  191. const cancel = async (id) => {
  192. tableRef.value.setDetailVisible(false)
  193. try {
  194. await confirm({
  195. title: t('Msg.SystemPrompt'),
  196. content: t('Msg.Cancle'),
  197. confirmText: t('Btn.item6'),
  198. cancelText: t('Btn.item7'),
  199. })
  200. let res = await ibApi.withdrawCancel({ id })
  201. if (res.code == Code.StatusOK) {
  202. uni.showToast({
  203. title: t('Msg.Success'),
  204. icon: 'success',
  205. })
  206. nextTick(() => {
  207. tableRef.value?.refreshTable?.()
  208. })
  209. } else {
  210. uni.showToast({
  211. title: res.msg,
  212. icon: 'none',
  213. })
  214. }
  215. } catch (err) {
  216. uni.showToast({
  217. title: err.msg,
  218. icon: 'none',
  219. })
  220. }
  221. }
  222. onMounted(() => {
  223. })
  224. </script>
  225. <style lang="scss" scoped>
  226. @import "@/uni.scss";
  227. .search-content {
  228. display: flex;
  229. justify-content: space-between;
  230. .uni-date {
  231. width: px2rpx(250) !important;
  232. flex: none;
  233. }
  234. }
  235. .cancel-btn{
  236. display: block;
  237. width: px2rpx(50);
  238. line-height: px2rpx(14) !important;
  239. }
  240. </style>