recording.vue 6.4 KB

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