subsList.vue 9.3 KB

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