subsList.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. <view class="search-content">
  6. <view class="search-bar">
  7. <uni-easyinput v-model="search.ibNo" :placeholder="t('Label.IbAccount')" />
  8. <uni-easyinput v-model="search.name" :placeholder="t('Ib.Custom.NameLabel')" />
  9. <uni-easyinput v-model="search.cId" placeholder="CID" />
  10. <uni-datetime-picker type="daterange" v-model="search.date"
  11. :placeholder="t('placeholder.Start') + ' - ' + t('placeholder.End')" @change="handleDateChange"/>
  12. </view>
  13. <view class="search-bar">
  14. <button type="primary" class="search-button" @click="addSub">
  15. <cwg-icon name="icon_add" :size="18" color="#fff"></cwg-icon>
  16. {{t('Ib.Report.Title5')}}
  17. </button>
  18. </view>
  19. </view>
  20. <cwg-tabel
  21. ref="tableRef"
  22. :columns="columns"
  23. :mobilePrimaryFields="mobilePrimaryFields"
  24. :queryParams="search"
  25. :api="listApi"
  26. :show-operation="true"
  27. :showPagination="true"
  28. >
  29. <template #action="{ row }">
  30. <cwg-dropdown :menu-list="menuList(row)" @menuClick="handleMenuClick">
  31. <view class="pc-header-btn">
  32. <cwg-icon name="crm-ellipsis" :size="24" />
  33. </view>
  34. </cwg-dropdown>
  35. </template>
  36. </cwg-tabel>
  37. </view>
  38. <ApplyIbDialog ref="applyIbDialogRef" :visible="applyVisible" @close="closeApplyIb" @confirm="confirmApply" :title="formDia?'Ib.Custom.Commit3':'Ib.Report.Title5'" :isFormApplyIb="formDia" :paramsType="applyType" :detail="applyDetail"/>
  39. <cwg-popup
  40. :visible="exclusiveVisible"
  41. :title="t('Ib.Custom.Commit5')"
  42. :cancelText="t('Btn.Cancel')"
  43. :confirmText="t('Btn.Confirm')"
  44. @close="cancelExclusiveCommission"
  45. @confirm="confirmExclusiveCommission"
  46. >
  47. <view class="dia-content">
  48. <uni-forms ref="exclusiveCommissionFormRef" labelWidth="240">
  49. <uni-forms-item :label="t('Ib.Custom.Commit5')" prop="selectedPoint">
  50. <cwg-combox
  51. v-model:value="exclusiveCommissionForm.selectedPoint"
  52. :options="exclusiveCommissionForm.pointOptions"
  53. :placeholder="t('placeholder.choose')"
  54. />
  55. </uni-forms-item>
  56. </uni-forms>
  57. </view>
  58. </cwg-popup>
  59. </cwg-page-wrapper>
  60. </template>
  61. <script setup lang="ts">
  62. // 代理管理
  63. import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
  64. import { onLoad } from '@dcloudio/uni-app'
  65. import { useI18n } from 'vue-i18n' // uni-app 中已集成,但需配置
  66. import { customApi } from '@/service/custom'
  67. import { financialApi } from '@/service/financial'
  68. import Config from '@/config/index'
  69. import { lang } from '@/composables/config'
  70. import { ibApi } from '@/service/ib'
  71. import { useFilters } from '@/composables/useFilters'
  72. import ApplyIbDialog from '@/pages/ib/components/applyIbDialog.vue'
  73. const { numberFormat, numberDecimal } = useFilters()
  74. const search = ref({
  75. ibNo: '',
  76. name: '',
  77. date: '',
  78. cId: '',
  79. startDate: '',
  80. endDate: '',
  81. })
  82. const tableRef = ref(null)
  83. const applyIbDialogRef = ref(null)
  84. const applyVisible = ref(false)
  85. const applyType = ref('')
  86. const applyDetail = ref()
  87. const formDia = ref(false)
  88. const exclusiveVisible = ref(false)
  89. const exclusiveCommissionFormRef = ref(null)
  90. const exclusiveCommissionForm = ref({
  91. agentId: "",
  92. selectedPoint: '',
  93. pointOptions: [],
  94. })
  95. const exclusiveRow = ref<any>(null)
  96. const { t, locale } = useI18n()
  97. const { Code } = Config
  98. // 表格列配置
  99. const columns = ref([
  100. {
  101. prop: 'cId',
  102. label: t('Label.CidAccount'),
  103. align: 'center',
  104. },
  105. {
  106. prop: 'ibNo',
  107. label: t('Label.IbAccount'),
  108. align: 'center',
  109. },
  110. {
  111. prop: 'name',
  112. label: t('Ib.Custom.NameLabel'),
  113. align: 'center',
  114. },
  115. {
  116. prop: 'agentNum',
  117. label: t('Ib.Custom.AgentNum'),
  118. align: 'center',
  119. },
  120. {
  121. prop: 'customNum',
  122. label: t('Ib.Custom.CustomerNum'),
  123. align: 'center',
  124. },
  125. {
  126. prop: 'addTime',
  127. label: t('Label.ApplyTime'),
  128. align: 'center',
  129. },
  130. {
  131. prop: 'lastTime',
  132. label: t('Ib.Custom.LastActiveTime'),
  133. align: 'center',
  134. },
  135. {
  136. prop: 'action',
  137. label: t('Label.Action'),
  138. align: 'center',
  139. slot: 'action',
  140. },
  141. ])
  142. const mobilePrimaryFields = ref([
  143. {
  144. prop: 'cId',
  145. label: t('Label.CidAccount'),
  146. align: 'center',
  147. },
  148. {
  149. prop: 'ibNo',
  150. label: t('Label.IbAccount'),
  151. align: 'center',
  152. },
  153. {
  154. prop: 'name',
  155. label: t('Ib.Custom.NameLabel'),
  156. align: 'center',
  157. },
  158. {
  159. prop: 'more',
  160. type: 'more',
  161. width: 20,
  162. align: 'right',
  163. },
  164. ])
  165. const listApi = ref(ibApi.IbSubs)
  166. const handleDateChange = (val) => {
  167. search.value.startDate = val[0]
  168. search.value.endDate = val[1]
  169. }
  170. onMounted(()=>{
  171. applyVisible.value = true
  172. })
  173. // 下拉菜单配置
  174. const menuList = (row) => {
  175. return [
  176. {
  177. label: t('Ib.Custom.Commit3'),
  178. type: 'vietnamDistribution',
  179. row,
  180. show: true,
  181. },
  182. {
  183. label: t('Ib.Custom.Commit5'),
  184. type: 'exclusiveCommission',
  185. row,
  186. show: row.exclusiveCommissionOptions?.length > 0,
  187. },
  188. ].filter((item) => item.show)
  189. }
  190. const handleMenuClick = (item) => {
  191. if (item.type == 'vietnamDistribution') {
  192. const { agentId, id } = item.row
  193. applyDetail.value = {
  194. id: id|| agentId
  195. }
  196. formDia.value = true
  197. applyType.value = 'vietnam'
  198. applyVisible.value = true
  199. } else if (item.type == 'exclusiveCommission') {
  200. openExclusiveCommission(item.row)
  201. }
  202. }
  203. const addSub = () => {
  204. formDia.value = false
  205. applyVisible.value = true
  206. }
  207. const closeApplyIb = () => {
  208. applyVisible.value = false
  209. }
  210. const confirmApply = (data) => {
  211. tableRef.value.refreshTable()
  212. }
  213. const normalizePointOptions = (options: any[]) => {
  214. if (!Array.isArray(options)) return []
  215. return options.map((o: any) => ({
  216. text: o.label ?? o.text ?? o.name ?? String(o.value ?? ''),
  217. value: o.value,
  218. }))
  219. }
  220. const openExclusiveCommission = async (row: any) => {
  221. exclusiveCommissionForm.value.agentId = row.id
  222. exclusiveCommissionForm.value.selectedPoint = ''
  223. exclusiveCommissionForm.value.pointOptions = normalizePointOptions(row?.exclusiveCommissionOptions || [])
  224. exclusiveVisible.value = true
  225. }
  226. const cancelExclusiveCommission = () => {
  227. exclusiveVisible.value = false
  228. exclusiveCommissionForm.value.selectedPoint = ''
  229. exclusiveCommissionForm.value.pointOptions = []
  230. }
  231. const confirmExclusiveCommission = async () => {
  232. try {
  233. const res = await ibApi.agentHiddenPointAdd({
  234. agentId: exclusiveCommissionForm.value.agentId,
  235. point: [{ value: exclusiveCommissionForm.value.selectedPoint }],
  236. })
  237. if (res.code == Code.StatusOK) {
  238. cancelExclusiveCommission()
  239. tableRef.value?.refreshTable?.()
  240. }
  241. } catch (e) {
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. @import "@/uni.scss";
  247. .search-content {
  248. display: flex;
  249. justify-content: space-between;
  250. }
  251. .search-button{
  252. display: flex;
  253. align-items: center;
  254. line-height: px2rpx(36);
  255. min-width: px2rpx(120);
  256. }
  257. </style>