subsList.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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 search = ref({
  87. ibNo: '',
  88. name: '',
  89. cId: '',
  90. data: '',
  91. startDate: '',
  92. endDate: '',
  93. })
  94. const filterFields = [
  95. { key: 'ibNo', type: 'input', label: t('Label.IbAccount'), placeholder: t('Label.IbAccount'), defaultValue: '' },
  96. {
  97. key: 'name',
  98. type: 'input',
  99. label: t('Ib.Custom.NameLabel'),
  100. placeholder: t('Ib.Custom.NameLabel'),
  101. defaultValue: '',
  102. },
  103. { key: 'cId', type: 'input', label: 'CID', placeholder: 'CID', defaultValue: '' },
  104. { key: 'date', label: t('placeholder.Start') + ' - ' + t('placeholder.End'), type: 'daterange' },
  105. ]
  106. const tableRef = ref(null)
  107. const applyIbDialogRef = ref(null)
  108. const applyVisible = ref(false)
  109. const applyType = ref('')
  110. const applyDetail = ref()
  111. const formDia = ref(false)
  112. const exclusiveVisible = ref(false)
  113. const exclusiveCommissionFormRef = ref(null)
  114. const exclusiveCommissionForm = ref({
  115. agentId: '',
  116. selectedPoint: '',
  117. pointOptions: [],
  118. })
  119. const exclusiveRow = ref<any>(null)
  120. // 表格列配置
  121. const columns = computed(() => [
  122. {
  123. prop: 'cId',
  124. label: t('Label.CidAccount'),
  125. align: 'center',
  126. },
  127. {
  128. prop: 'ibNo',
  129. label: t('Label.IbAccount'),
  130. align: 'center',
  131. },
  132. {
  133. prop: 'name',
  134. label: t('Ib.Custom.NameLabel'),
  135. align: 'center',
  136. },
  137. {
  138. prop: 'agentNum',
  139. label: t('Ib.Custom.AgentNum'),
  140. align: 'center',
  141. },
  142. {
  143. prop: 'customNum',
  144. label: t('Ib.Custom.CustomerNum'),
  145. align: 'center',
  146. },
  147. {
  148. prop: 'addTime',
  149. label: t('Label.ApplyTime'),
  150. align: 'center',
  151. },
  152. {
  153. prop: 'lastTime',
  154. label: t('Ib.Custom.LastActiveTime'),
  155. align: 'center',
  156. },
  157. {
  158. prop: 'action',
  159. label: t('Label.Action'),
  160. type: 'action',
  161. align: 'center',
  162. menuList: [
  163. {
  164. label: t('Ib.Custom.Commit3'),
  165. type: 'vietnamDistribution',
  166. btnClick: (row) => handleMenuClick({ type: 'vietnamDistribution', row }),
  167. show: true,
  168. },
  169. {
  170. label: t('Ib.Custom.Commit5'),
  171. type: 'exclusiveCommission',
  172. btnClick: (row) => handleMenuClick({ type: 'exclusiveCommission', row }),
  173. show: (row) => row.exclusiveCommissionOptions?.length > 0,
  174. },
  175. ]
  176. },
  177. ])
  178. const mobilePrimaryFields = computed(() => [
  179. {
  180. prop: 'cId',
  181. label: t('Label.CidAccount'),
  182. align: 'center',
  183. },
  184. {
  185. prop: 'ibNo',
  186. label: t('Label.IbAccount'),
  187. align: 'center',
  188. },
  189. {
  190. prop: 'name',
  191. label: t('Ib.Custom.NameLabel'),
  192. align: 'center',
  193. },
  194. {
  195. prop: 'more',
  196. type: 'more',
  197. width: 20,
  198. align: 'right',
  199. },
  200. ])
  201. const listApi = ref(ibApi.IbSubs)
  202. const handleSearch = (params: any) => {
  203. // 拦截处理 daterange,将 date 拆分为 startDate 和 endDate
  204. const payload = { ...params }
  205. search.value = payload
  206. nextTick(() => {
  207. tableRef.value.refreshTable()
  208. })
  209. }
  210. const handleReset = () => {
  211. search.value = {
  212. ibNo: '',
  213. name: '',
  214. cId: '',
  215. startDate: '',
  216. endDate: '',
  217. }
  218. nextTick(() => {
  219. tableRef.value.refreshTable()
  220. })
  221. }
  222. onMounted(() => {
  223. // applyVisible.value = true
  224. })
  225. const handleMenuClick = (item) => {
  226. if (item.type == 'vietnamDistribution') {
  227. const { agentId, id } = item.row
  228. applyDetail.value = {
  229. id: id || agentId,
  230. }
  231. formDia.value = false
  232. applyType.value = 'vietnam'
  233. applyVisible.value = true
  234. } else if (item.type == 'exclusiveCommission') {
  235. openExclusiveCommission(item.row)
  236. }
  237. }
  238. const addSub = () => {
  239. formDia.value = true
  240. applyVisible.value = true
  241. }
  242. const closeApplyIb = () => {
  243. applyVisible.value = false
  244. }
  245. const confirmApply = (data) => {
  246. tableRef.value.refreshTable()
  247. }
  248. const normalizePointOptions = (options: any[]) => {
  249. if (!Array.isArray(options)) return []
  250. return options.map((o: any) => ({
  251. text: o.label ?? o.text ?? o.name ?? String(o.value ?? ''),
  252. value: o.value,
  253. }))
  254. }
  255. const openExclusiveCommission = async (row: any) => {
  256. exclusiveCommissionForm.value.agentId = row.id
  257. exclusiveCommissionForm.value.selectedPoint = ''
  258. exclusiveCommissionForm.value.pointOptions = normalizePointOptions(row?.exclusiveCommissionOptions || [])
  259. exclusiveVisible.value = true
  260. }
  261. const cancelExclusiveCommission = () => {
  262. exclusiveVisible.value = false
  263. exclusiveCommissionForm.value.selectedPoint = ''
  264. exclusiveCommissionForm.value.pointOptions = []
  265. }
  266. const confirmExclusiveCommission = async () => {
  267. try {
  268. const res = await ibApi.agentHiddenPointAdd({
  269. agentId: exclusiveCommissionForm.value.agentId,
  270. point: [{ value: exclusiveCommissionForm.value.selectedPoint }],
  271. })
  272. if (res.code == Code.StatusOK) {
  273. cancelExclusiveCommission()
  274. tableRef.value?.refreshTable?.()
  275. }
  276. } catch (e) {
  277. }
  278. }
  279. </script>
  280. <style lang="scss" scoped>
  281. @import "@/uni.scss";
  282. .search-content {
  283. display: flex;
  284. }
  285. /* PC 端对齐方式 */
  286. .pc-search-content {
  287. justify-content: space-between;
  288. align-items: flex-start;
  289. margin-bottom: px2rpx(10);
  290. }
  291. /* 移动端排版方式 */
  292. .mobile-search-content {
  293. flex-direction: column;
  294. margin-bottom: px2rpx(10);
  295. .mobile-add-btn-wrap {
  296. display: flex;
  297. justify-content: flex-end;
  298. width: 100%;
  299. margin-bottom: px2rpx(10);
  300. .search-button {
  301. background-color: var(--color-error);
  302. margin: 0 0 0 auto; /* 强制按钮靠右且消除其它 margin */
  303. }
  304. }
  305. }
  306. .search-button {
  307. display: flex;
  308. align-items: center;
  309. background-color: var(--color-error);
  310. line-height: px2rpx(36);
  311. min-width: px2rpx(120);
  312. }
  313. </style>