subsList.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('Ib.Custom.Manage2')" />
  4. <view class="account-content">
  5. <!-- 移动端:按钮在筛选上方 -->
  6. <cwg-match-media :max-width="991">
  7. <view class="search-content mobile-search-content">
  8. <view class="search-bar mobile-add-btn-wrap">
  9. <button type="primary" class="search-button" @click="addSub">
  10. <cwg-icon name="icon_add" :size="18" color="#fff"></cwg-icon>
  11. {{ t('Ib.Report.Title5') }}
  12. </button>
  13. </view>
  14. <view class="search-bar">
  15. <cwg-complex-search :fields="filterFields" v-model="searchParams" @search="handleSearch"
  16. @reset="handleReset" />
  17. </view>
  18. </view>
  19. </cwg-match-media>
  20. <!-- PC端:按钮和筛选在同一行 -->
  21. <cwg-match-media :min-width="991">
  22. <view class="search-content pc-search-content">
  23. <view class="search-bar">
  24. <cwg-complex-search :fields="filterFields" v-model="searchParams" @search="handleSearch"
  25. @reset="handleReset" />
  26. </view>
  27. <view class="search-bar">
  28. <button type="primary" class="search-button" @click="addSub">
  29. <cwg-icon name="icon_add" :size="18" color="#fff"></cwg-icon>
  30. {{ t('Ib.Report.Title5') }}
  31. </button>
  32. </view>
  33. </view>
  34. </cwg-match-media>
  35. <cwg-tabel
  36. ref="tableRef"
  37. :columns="columns"
  38. :mobilePrimaryFields="mobilePrimaryFields"
  39. :queryParams="search"
  40. :api="listApi"
  41. :show-operation="true"
  42. :showPagination="true"
  43. >
  44. </cwg-tabel>
  45. </view>
  46. <ApplyIbDialog ref="applyIbDialogRef" :visible="applyVisible" @close="closeApplyIb" @confirm="confirmApply"
  47. :title="formDia?'Ib.Report.Title5':'Ib.Custom.Commit3'" :isFormApplyIb="formDia"
  48. :paramsType="applyType" :detail="applyDetail" />
  49. <cwg-popup
  50. :visible="exclusiveVisible"
  51. :title="t('Ib.Custom.Commit5')"
  52. :cancelText="t('Btn.Cancel')"
  53. :confirmText="t('Btn.Confirm')"
  54. @close="cancelExclusiveCommission"
  55. @confirm="confirmExclusiveCommission"
  56. >
  57. <view class="dia-content">
  58. <uni-forms ref="exclusiveCommissionFormRef" labelWidth="240">
  59. <uni-forms-item :label="t('Ib.Custom.Commit5')" prop="selectedPoint">
  60. <cwg-combox
  61. v-model:value="exclusiveCommissionForm.selectedPoint"
  62. :options="exclusiveCommissionForm.pointOptions"
  63. :placeholder="t('placeholder.choose')"
  64. />
  65. </uni-forms-item>
  66. </uni-forms>
  67. </view>
  68. </cwg-popup>
  69. </cwg-page-wrapper>
  70. </template>
  71. <script setup lang="ts">
  72. // 代理管理
  73. import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
  74. import { onLoad } from '@dcloudio/uni-app'
  75. import { useI18n } from 'vue-i18n' // uni-app 中已集成,但需配置
  76. import { customApi } from '@/service/custom'
  77. import { financialApi } from '@/service/financial'
  78. import Config from '@/config/index'
  79. import { ibApi } from '@/service/ib'
  80. import { useFilters } from '@/composables/useFilters'
  81. import ApplyIbDialog from '@/pages/ib/components/applyIbDialog.vue'
  82. import { nextTick } from 'vue'
  83. const { numberFormat, numberDecimal } = useFilters()
  84. const { t, locale } = useI18n()
  85. const { Code } = Config
  86. const searchParams = ref({})
  87. const search = ref({
  88. ibNo: '',
  89. name: '',
  90. cId: '',
  91. data: '',
  92. startDate: '',
  93. endDate: '',
  94. })
  95. const filterFields = [
  96. { key: 'ibNo', type: 'input', label: t('Label.IbAccount'), placeholder: t('Label.IbAccount'), defaultValue: '' },
  97. {
  98. key: 'name',
  99. type: 'input',
  100. label: t('Ib.Custom.NameLabel'),
  101. placeholder: t('Ib.Custom.NameLabel'),
  102. defaultValue: '',
  103. },
  104. { key: 'cId', type: 'input', label: 'CID', placeholder: 'CID', defaultValue: '' },
  105. { key: 'date', label: t('placeholder.Start') + ' - ' + t('placeholder.End'), type: 'daterange' },
  106. ]
  107. const tableRef = ref(null)
  108. const applyIbDialogRef = ref(null)
  109. const applyVisible = ref(false)
  110. const applyType = ref('')
  111. const applyDetail = ref()
  112. const formDia = ref(false)
  113. const exclusiveVisible = ref(false)
  114. const exclusiveCommissionFormRef = ref(null)
  115. const exclusiveCommissionForm = ref({
  116. agentId: '',
  117. selectedPoint: '',
  118. pointOptions: [],
  119. })
  120. const exclusiveRow = ref<any>(null)
  121. // 表格列配置
  122. const columns = computed(() => [
  123. {
  124. prop: 'cId',
  125. label: t('Label.CidAccount'),
  126. align: 'center',
  127. },
  128. {
  129. prop: 'ibNo',
  130. label: t('Label.IbAccount'),
  131. align: 'center',
  132. },
  133. {
  134. prop: 'name',
  135. label: t('Ib.Custom.NameLabel'),
  136. align: 'center',
  137. },
  138. {
  139. prop: 'agentNum',
  140. label: t('Ib.Custom.AgentNum'),
  141. align: 'center',
  142. },
  143. {
  144. prop: 'customNum',
  145. label: t('Ib.Custom.CustomerNum'),
  146. align: 'center',
  147. },
  148. {
  149. prop: 'addTime',
  150. label: t('Label.ApplyTime'),
  151. align: 'center',
  152. },
  153. {
  154. prop: 'lastTime',
  155. label: t('Ib.Custom.LastActiveTime'),
  156. align: 'center',
  157. },
  158. {
  159. prop: 'action',
  160. label: t('Label.Action'),
  161. type: 'action',
  162. align: 'center',
  163. menuList: [
  164. {
  165. label: t('Ib.Custom.Commit3'),
  166. type: 'vietnamDistribution',
  167. btnClick: (row) => handleMenuClick({ type: 'vietnamDistribution', row }),
  168. show: true,
  169. },
  170. {
  171. label: t('Ib.Custom.Commit5'),
  172. type: 'exclusiveCommission',
  173. btnClick: (row) => handleMenuClick({ type: 'exclusiveCommission', row }),
  174. show: (row) => row.exclusiveCommissionOptions?.length > 0,
  175. },
  176. ],
  177. },
  178. ])
  179. const mobilePrimaryFields = computed(() => [
  180. {
  181. prop: 'cId',
  182. label: t('Label.CidAccount'),
  183. align: 'center',
  184. },
  185. {
  186. prop: 'ibNo',
  187. label: t('Label.IbAccount'),
  188. align: 'center',
  189. },
  190. {
  191. prop: 'name',
  192. label: t('Ib.Custom.NameLabel'),
  193. align: 'center',
  194. },
  195. {
  196. prop: 'more',
  197. type: 'more',
  198. width: 20,
  199. align: 'right',
  200. },
  201. ])
  202. const listApi = ref(ibApi.IbSubs)
  203. const handleSearch = (params: any) => {
  204. // 拦截处理 daterange,将 date 拆分为 startDate 和 endDate
  205. const payload = { ...params }
  206. search.value = payload
  207. nextTick(() => {
  208. tableRef.value.refreshTable()
  209. })
  210. }
  211. const handleReset = (params: any) => {
  212. search.value = {
  213. ...params,
  214. }
  215. nextTick(() => {
  216. tableRef.value.refreshTable()
  217. })
  218. }
  219. onMounted(() => {
  220. // applyVisible.value = true
  221. })
  222. const handleMenuClick = (item) => {
  223. if (item.type == 'vietnamDistribution') {
  224. const { agentId, id } = item.row
  225. applyDetail.value = {
  226. id: id || agentId,
  227. }
  228. formDia.value = false
  229. applyType.value = 'vietnam'
  230. applyVisible.value = true
  231. } else if (item.type == 'exclusiveCommission') {
  232. openExclusiveCommission(item.row)
  233. }
  234. }
  235. const addSub = () => {
  236. formDia.value = true
  237. applyVisible.value = true
  238. }
  239. const closeApplyIb = () => {
  240. applyDetail.value = {}
  241. applyVisible.value = false
  242. }
  243. const confirmApply = (data) => {
  244. tableRef.value.refreshTable()
  245. }
  246. const normalizePointOptions = (options: any[]) => {
  247. if (!Array.isArray(options)) return []
  248. return options.map((o: any) => ({
  249. text: o.label ?? o.text ?? o.name ?? String(o.value ?? ''),
  250. value: o.value,
  251. }))
  252. }
  253. const openExclusiveCommission = async (row: any) => {
  254. exclusiveCommissionForm.value.agentId = row.id
  255. exclusiveCommissionForm.value.selectedPoint = ''
  256. exclusiveCommissionForm.value.pointOptions = normalizePointOptions(row?.exclusiveCommissionOptions || [])
  257. exclusiveVisible.value = true
  258. }
  259. const cancelExclusiveCommission = () => {
  260. exclusiveVisible.value = false
  261. exclusiveCommissionForm.value.selectedPoint = ''
  262. exclusiveCommissionForm.value.pointOptions = []
  263. }
  264. const confirmExclusiveCommission = async () => {
  265. try {
  266. const res = await ibApi.agentHiddenPointAdd({
  267. agentId: exclusiveCommissionForm.value.agentId,
  268. point: [{ value: exclusiveCommissionForm.value.selectedPoint }],
  269. })
  270. if (res.code == Code.StatusOK) {
  271. cancelExclusiveCommission()
  272. tableRef.value?.refreshTable?.()
  273. }
  274. } catch (e) {
  275. }
  276. }
  277. </script>
  278. <style lang="scss" scoped>
  279. @import "@/uni.scss";
  280. .search-content {
  281. display: flex;
  282. }
  283. /* PC 端对齐方式 */
  284. .pc-search-content {
  285. justify-content: space-between;
  286. align-items: flex-start;
  287. margin-bottom: px2rpx(10);
  288. }
  289. /* 移动端排版方式 */
  290. .mobile-search-content {
  291. flex-direction: column;
  292. margin-bottom: px2rpx(10);
  293. .mobile-add-btn-wrap {
  294. display: flex;
  295. justify-content: flex-end;
  296. width: 100%;
  297. margin-bottom: px2rpx(10);
  298. .search-button {
  299. background-color: var(--color-error);
  300. margin: 0 0 0 auto; /* 强制按钮靠右且消除其它 margin */
  301. }
  302. }
  303. }
  304. .search-button {
  305. display: flex;
  306. align-items: center;
  307. background-color: var(--color-error);
  308. line-height: px2rpx(36);
  309. min-width: px2rpx(120);
  310. }
  311. </style>