customer.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('Home.page_ib.item2')" />
  4. <view class="info-card">
  5. <!-- 移动端:分类标签在搜索组件下 -->
  6. <cwg-match-media :max-width="991">
  7. <view class="search-content mobile-search-content">
  8. <view class="search-bar">
  9. <cwg-complex-search :fields="filterFields" v-model="search" @search="handleSearch"
  10. @reset="handleReset" />
  11. </view>
  12. <view class="search-tabs">
  13. <view class="crm-cursor tab-item" :class="{ active: search.belongsType == 1 }"
  14. @click="chooseBelongsType(1)">
  15. {{ t('Ib.Custom.Unverified') }}
  16. <view v-if="statistics.unverifiedNum !== undefined" class="count-badge">({{ statistics.unverifiedNum }})
  17. </view>
  18. </view>
  19. <view class="crm-cursor tab-item" :class="{ active: search.belongsType == 2 }"
  20. @click="chooseBelongsType(2)">
  21. {{ t('Ib.Custom.UnDeposit') }}
  22. <view v-if="statistics.unDepositNum !== undefined" class="count-badge">({{ statistics.unDepositNum }})
  23. </view>
  24. </view>
  25. <view class="crm-cursor tab-item" :class="{ active: search.belongsType == 3 }"
  26. @click="chooseBelongsType(3)">
  27. {{ t('Ib.Custom.Deposited') }}
  28. <view v-if="statistics.depositNum !== undefined" class="count-badge">({{ statistics.depositNum }})</view>
  29. </view>
  30. </view>
  31. </view>
  32. </cwg-match-media>
  33. <!-- PC端:分类标签和搜索组件在同一行 (搜索在左,标签在右) -->
  34. <cwg-match-media :min-width="992">
  35. <view class="search-content pc-search-content">
  36. <view class="search-bar">
  37. <cwg-complex-search :fields="filterFields" v-model="search" @search="handleSearch"
  38. @reset="handleReset" />
  39. </view>
  40. <view class="search-tabs">
  41. <view class="crm-cursor tab-item" :class="{ active: search.belongsType == 1 }"
  42. @click="chooseBelongsType(1)">
  43. {{ t('Ib.Custom.Unverified') }}
  44. <view v-if="statistics.unverifiedNum !== undefined" class="count-badge">({{ statistics.unverifiedNum }})
  45. </view>
  46. </view>
  47. <view class="crm-cursor tab-item" :class="{ active: search.belongsType == 2 }"
  48. @click="chooseBelongsType(2)">
  49. {{ t('Ib.Custom.UnDeposit') }}
  50. <view v-if="statistics.unDepositNum !== undefined" class="count-badge">({{ statistics.unDepositNum }})
  51. </view>
  52. </view>
  53. <view class="crm-cursor tab-item" :class="{ active: search.belongsType == 3 }"
  54. @click="chooseBelongsType(3)">
  55. {{ t('Ib.Custom.Deposited') }}
  56. <view v-if="statistics.depositNum !== undefined" class="count-badge">({{ statistics.depositNum }})</view>
  57. </view>
  58. </view>
  59. </view>
  60. </cwg-match-media>
  61. <cwg-tabel
  62. ref="tableRef"
  63. :columns="columns"
  64. :mobilePrimaryFields="mobilePrimaryFields"
  65. :queryParams="search"
  66. :api="listApi"
  67. :show-operation="true"
  68. :showPagination="true"
  69. >
  70. </cwg-tabel>
  71. <!-- 跟单全局设置 -->
  72. <DocumentaryDialog :visible="docVisible" :detail="formInfoRow" @close="closeDoc" @confirm="confirmDoc" />
  73. <!-- 开户调整 -->
  74. <PointDialog :visible="pointVisible" :detail="pointForm" @close="closePoint" @confirm="confirmPoint" />
  75. <!-- 申请成为代理 -->
  76. <ApplyIbDialog :visible="applyVisible" :detail="applyForm" @close="closeApply" @confirm="confirmApply" />
  77. </view>
  78. </cwg-page-wrapper>
  79. </template>
  80. <script setup lang="ts">
  81. import { computed, ref, onMounted, nextTick } from 'vue'
  82. import { useI18n } from 'vue-i18n'
  83. import Config from '@/config/index'
  84. const { t, locale } = useI18n()
  85. import { customApi } from '@/service/custom'
  86. import { ibApi } from '@/service/ib'
  87. import DocumentaryDialog from '@/pages/ib/components/documentaryDialog.vue'
  88. import PointDialog from '@/pages/ib/components/pointDialog.vue'
  89. import ApplyIbDialog from '@/pages/ib/components/applyIbDialog.vue'
  90. const { Code } = Config
  91. const statistics = ref({
  92. unverifiedNum: 0,
  93. unDepositNum: 0,
  94. depositNum: 0,
  95. })
  96. const search = ref({
  97. 'name': '',
  98. 'email': '',
  99. 'cId': '',
  100. // 1:未实名 2:未入金 3:已入金
  101. belongsType: null,
  102. })
  103. const filterFields = [
  104. { key: 'cId', type: 'input', label: 'CID', placeholder: 'CID', defaultValue: '' },
  105. {
  106. key: 'name',
  107. type: 'input',
  108. label: t('Ib.Custom.NameLabel'),
  109. placeholder: t('Ib.Custom.NameLabel'),
  110. defaultValue: '',
  111. },
  112. { key: 'email', type: 'input', label: t('Label.Email'), placeholder: t('Label.Email'), defaultValue: '' },
  113. ]
  114. const formInfoRow = ref({})
  115. const pointForm = ref({})
  116. const applyForm = ref({})
  117. const applyTable = ref([])
  118. const docVisible = ref(false)
  119. const pointVisible = ref(false)
  120. const applyVisible = ref(false)
  121. const tableRef = ref(null)
  122. // 表格列配置
  123. const columns = ref([
  124. {
  125. prop: 'cId',
  126. label: t('Label.CidAccount'),
  127. align: 'center',
  128. },
  129. {
  130. prop: 'name',
  131. label: t('Ib.Custom.NameLabel'),
  132. align: 'center',
  133. },
  134. {
  135. prop: 'email',
  136. label: t('Label.Email'),
  137. align: 'center',
  138. },
  139. {
  140. prop: 'countryEnName',
  141. label: t('Label.Nationality'),
  142. align: 'center',
  143. width: locale.value == 'en' ? 110 : 0,
  144. },
  145. {
  146. prop: 'addTime',
  147. label: t('Label.RegistrationTime'),
  148. align: 'center',
  149. width: locale.value == 'en' ? 110 : 0,
  150. },
  151. {
  152. prop: 'belongsType',
  153. label: t('Ib.Custom.CustomerStatus'),
  154. align: 'center',
  155. formatter: ({ row }) => row.belongsType == 1 ? t('Ib.Custom.Unverified') :
  156. row.belongsType == 2 ? t('Ib.Custom.UnDeposit') :
  157. row.belongsType == 3 ? t('Ib.Custom.Deposited') : '--',
  158. },
  159. {
  160. prop: 'ibStatus',
  161. label: t('Ib.Custom.ApplyAgent'),
  162. align: 'center',
  163. formatter: ({ row }) => row.ibStatus == 2 ? t('Ib.Custom.Yes') : t('Ib.Custom.No'),
  164. },
  165. {
  166. prop: 'action',
  167. label: t('Label.Action'),
  168. type: 'action',
  169. align: 'center',
  170. menuList: [
  171. {
  172. label: t('Documentary.AgentBackground.item1'),
  173. type: 'documentary',
  174. btnClick: (row) => handleMenuClick({ type: 'documentary', row }),
  175. show: true,
  176. },
  177. {
  178. label: t('Home.msg.ibTitle'),
  179. type: 'applyIb',
  180. btnClick: (row) => handleMenuClick({ type: 'applyIb', row }),
  181. show: (row) => row.ibStatus == 1 && row.belongsType != 1,
  182. },
  183. {
  184. label: t('Ib.Custom.AccountAdjust'),
  185. type: 'Point',
  186. btnClick: (row) => handleMenuClick({ type: 'Point', row }),
  187. show: (row) => row.belongsType != 1,
  188. },
  189. ],
  190. },
  191. ])
  192. const mobilePrimaryFields = ref([
  193. {
  194. prop: 'cId',
  195. label: t('Label.CidAccount'),
  196. align: 'center',
  197. },
  198. {
  199. prop: 'name',
  200. label: t('Ib.Custom.NameLabel'),
  201. align: 'center',
  202. },
  203. {
  204. prop: 'email',
  205. label: t('Label.Email'),
  206. align: 'center',
  207. },
  208. {
  209. prop: 'more',
  210. type: 'more',
  211. width: 20,
  212. align: 'right',
  213. },
  214. ])
  215. const listApi = ref(null)
  216. listApi.value = ibApi.customerSubs
  217. const handleSearch = (params: any) => {
  218. console.log(params)
  219. // 合并表单的过滤参数,同时保留当前的 belongsType 标签选中状态
  220. search.value = {
  221. ...params,
  222. belongsType: search.value.belongsType,
  223. }
  224. nextTick(() => {
  225. tableRef.value.refreshTable()
  226. })
  227. }
  228. const handleReset = (params: any) => {
  229. search.value = {
  230. ...params,
  231. belongsType: search.value.belongsType, // 保持当前的分类标签选中
  232. }
  233. nextTick(() => {
  234. tableRef.value.refreshTable()
  235. })
  236. }
  237. //选择belongsType(点击已选中的 tab 可反选取消)
  238. const chooseBelongsType = (belongsType) => {
  239. if (search.value.belongsType == belongsType) {
  240. search.value.belongsType = null // 反选:取消选中
  241. } else {
  242. search.value.belongsType = belongsType
  243. }
  244. // 切换 tab 时自动重新请求列表
  245. nextTick(() => {
  246. tableRef.value.refreshTable()
  247. })
  248. }
  249. // 下拉菜单配置
  250. const menuList = (row) => {
  251. return [
  252. {
  253. label: t('Documentary.AgentBackground.item1'),
  254. type: 'documentary',
  255. row,
  256. show: true,
  257. },
  258. {
  259. label: t('Home.msg.ibTitle'),
  260. type: 'applyIb',
  261. row,
  262. show: row.ibStatus == 1 && row.belongsType != 1,
  263. },
  264. {
  265. label: t('Ib.Custom.AccountAdjust'),
  266. type: 'Point',
  267. row,
  268. show: row.belongsType != 1,
  269. },
  270. ].filter((item) => item.show)
  271. }
  272. const handleMenuClick = (item) => {
  273. if (item.type == 'documentary') {
  274. const { cId, id, permissionDisplay } = item.row
  275. formInfoRow.value = {
  276. cId, id, permissionDisplay,
  277. }
  278. docVisible.value = true
  279. } else if (item.type == 'applyIb') {
  280. applyForm.value = item.row
  281. applyVisible.value = true
  282. } else if (item.type == 'Point') {
  283. pointForm.value = item.row
  284. nextTick(() => {
  285. pointVisible.value = true
  286. })
  287. }
  288. }
  289. //获取统计数
  290. const getStatistics = async () => {
  291. try {
  292. let res = await ibApi.customerSubsStatistics({})
  293. if (res.code == Code.StatusOK && res.data) {
  294. statistics.value = {
  295. unverifiedNum: res.data.unverifiedNum || 0,
  296. unDepositNum: res.data.unDepositNum || 0,
  297. depositNum: res.data.depositNum || 0,
  298. }
  299. }
  300. } catch (error) {
  301. }
  302. }
  303. onMounted(() => {
  304. getStatistics()
  305. })
  306. const closeDoc = () => {
  307. docVisible.value = false
  308. }
  309. const closeApply = () => {
  310. applyVisible.value = false
  311. }
  312. const closePoint = () => {
  313. pointForm.value = {}
  314. pointVisible.value = false
  315. }
  316. const confirmDoc = () => {
  317. docVisible.value = false
  318. tableRef.value.refreshTable()
  319. }
  320. const confirmPoint = () => {
  321. pointVisible.value = false
  322. tableRef.value.refreshTable()
  323. }
  324. const confirmApply = () => {
  325. applyVisible.value = false
  326. tableRef.value.refreshTable()
  327. }
  328. </script>
  329. <style scoped lang="scss">
  330. @import "@/uni.scss";
  331. .search-content {
  332. display: flex;
  333. justify-content: space-between;
  334. align-items: flex-start;
  335. }
  336. .mobile-search-content {
  337. flex-direction: column;
  338. align-items: flex-start;
  339. gap: px2rpx(10);
  340. .search-tabs {
  341. padding: 0;
  342. margin: 0;
  343. }
  344. }
  345. .pc-search-content {
  346. flex-direction: row;
  347. align-items: flex-start;
  348. }
  349. .search-bar {
  350. display: flex;
  351. align-items: center;
  352. justify-content: flex-start;
  353. flex-wrap: wrap;
  354. gap: px2rpx(10);
  355. margin: px2rpx(16) 0;
  356. .cwg-combox,
  357. .uni-easyinput,
  358. .uni-date {
  359. width: px2rpx(180) !important;
  360. flex: none;
  361. }
  362. }
  363. .search-tabs {
  364. display: flex;
  365. align-items: center;
  366. flex-wrap: wrap;
  367. gap: px2rpx(10);
  368. margin: px2rpx(16) 0;
  369. .tab-item {
  370. display: flex;
  371. min-width: px2rpx(100);
  372. border: 1px solid #F0F0F0;
  373. border-radius: px2rpx(4);
  374. margin-right: px2rpx(5);
  375. height: px2rpx(33);
  376. line-height: px2rpx(33);
  377. justify-content: center;
  378. &.active {
  379. color: var(--color-white);
  380. background-color: var(--color-error);
  381. border-color: var(--color-error);
  382. }
  383. }
  384. }
  385. .action-btn {
  386. display: flex;
  387. //align-items: center;
  388. justify-content: center;
  389. }
  390. </style>