recording.vue 7.0 KB

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