pointDialog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <cwg-popup :title="t('Ib.Custom.AccountAdjust')" :visible="visible" @close="closeDia" @confirm="confirmDia">
  3. <view class="dia-content dialog-account-adjust-body">
  4. <view class="account-adjust-cid-row">
  5. <text class="account-adjust-cid-label">{{ t('Label.CidAccount') }}:</text>
  6. <text class="account-adjust-cid-value">{{ dialogForm.cId || '--' }}</text>
  7. </view>
  8. <uni-forms :model="dialogForm" ref="formRef" label-width="0" class="dialogCheck_form dialog-account-adjust-form">
  9. <view class="form-section form-section-commission">
  10. <view class="section-title">
  11. <cwg-icon name="crm-option" :size="22" color="#000"></cwg-icon>
  12. {{ t('Ib.Index.Spread5') }}
  13. </view>
  14. <view class="account-type-grid">
  15. <view class="account-type-card">
  16. <view class="account-type-label">
  17. {{ t('AccountType.StandardAccount') }}
  18. </view>
  19. <cwg-combox
  20. v-model:value="commissionAccountTypeSettings.standard.selectedIndex"
  21. :options="getAvailableSpreadsCommission('7').map((item, index) => ({
  22. text: getSpreadLabelCommission(item),
  23. value: index
  24. }))"
  25. :placeholder="t('placeholder.choose')"
  26. class="account-select"
  27. @change="(value) => handleCommissionAccountTypeChange('standard', '7', value)"
  28. />
  29. </view>
  30. <view class="account-type-card">
  31. <view class="account-type-label">
  32. {{ t('AccountType.SeniorAccount') }}
  33. </view>
  34. <cwg-combox
  35. v-model:value="commissionAccountTypeSettings.ecn.selectedIndex"
  36. :options="getAvailableSpreadsCommission('2').map((item, index) => ({
  37. text: getSpreadLabelCommission(item),
  38. value: index
  39. }))"
  40. :placeholder="t('placeholder.choose')"
  41. class="account-select"
  42. @change="(value) => handleCommissionAccountTypeChange('ecn', '2', value)"
  43. />
  44. </view>
  45. <view class="account-type-card">
  46. <view class="account-type-label">
  47. {{ t('AccountType.CentAccount') }}
  48. </view>
  49. <cwg-combox
  50. v-model:value="commissionAccountTypeSettings.cent.selectedIndex"
  51. :options="getAvailableSpreadsCommission('8').map((item, index) => ({
  52. text: getSpreadLabelCommission(item),
  53. value: index
  54. }))"
  55. :placeholder="t('placeholder.choose')"
  56. class="account-select"
  57. @change="(value) => handleCommissionAccountTypeChange('cent', '8', value)"
  58. />
  59. </view>
  60. </view>
  61. </view>
  62. </uni-forms>
  63. </view>
  64. <view class="dialog-footer dialog-account-adjust-footer">
  65. <view class="account-adjust-notes-panel">
  66. <view class="account-adjust-notes-section">
  67. <view class="account-adjust-notes-title">
  68. <cwg-icon name="gy" :size="20" class="account-adjust-notes-title-icon"></cwg-icon>
  69. <span class="account-adjust-notes-title-text">{{ t('Ib.Custom.AccountAdjustNotesSection2Title') }}</span>
  70. </view>
  71. <view class="account-adjust-notes-list">
  72. <view class="list">{{ t('Ib.Custom.AccountAdjustNotesSection2Item1') }}</view>
  73. <view class="list">{{ t('Ib.Custom.AccountAdjustNotesSection2Item2') }}</view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </cwg-popup>
  79. </template>
  80. <script setup lang="ts">
  81. import { ref, reactive, computed, onMounted, onUnmounted, watch } from 'vue'
  82. import { onLoad } from '@dcloudio/uni-app'
  83. import { useI18n } from 'vue-i18n' // uni-app 中已集成,但需配置
  84. import { customApi } from '@/service/custom'
  85. import { financialApi } from '@/service/financial'
  86. import Config from '@/config/index'
  87. import PaymentMethodsList from './components/PaymentMethodsList.vue'
  88. import { ibApi } from '@/service/ib'
  89. import useUserStore from '@/stores/use-user-store'
  90. import { lang } from '@/composables/config'
  91. const props = defineProps({
  92. // 是否显示弹窗
  93. visible: {
  94. type: Boolean,
  95. default: false,
  96. },
  97. // 详情formData
  98. detail: { type: Object, default: () => ({}) },
  99. })
  100. const { Code, Host80 } = Config
  101. const { t } = useI18n()
  102. const formRef = ref(null)
  103. const dialogForm = ref({
  104. cId: '',
  105. })
  106. const commissionAccountTypeSettings = ref({
  107. ecn: { selectedIndex: null, selectedItem: null, loginType: '2' },
  108. standard: { selectedIndex: null, selectedItem: null, loginType: '7' },
  109. cent: { selectedIndex: null, selectedItem: null, loginType: '8' },
  110. })
  111. const commissionAccountTypeData = ref({
  112. ecn: [],
  113. standard: [],
  114. cent: [],
  115. })
  116. const emit = defineEmits(['close', 'confirm'])
  117. onMounted(() => {
  118. console.log(props.visible)
  119. })
  120. // 佣金调整弹框:拉取点差/价格数据(与 ConsumerShareLink getCustomLinkTypes 一致)
  121. const loadCommissionAccountTypes = async (ibId) => {
  122. const params = ibId ? { ibId } : {}
  123. let res = await ibApi.customLinkTypes(params)
  124. if (res.code == Code.StatusOK) {
  125. const data = res.data || []
  126. commissionAccountTypeData.value = {
  127. ecn: data.filter(
  128. (item) => item.loginType === 2 || item.loginType === '2',
  129. ),
  130. standard: data.filter(
  131. (item) => item.loginType === 7 || item.loginType === '7',
  132. ),
  133. cent: data.filter(
  134. (item) => item.loginType === 8 || item.loginType === '8',
  135. ),
  136. }
  137. } else {
  138. uni.showToast({
  139. title: res.msg,
  140. icon: 'none',
  141. })
  142. commissionAccountTypeData.value = { ecn: [], standard: [], cent: [] }
  143. }
  144. }
  145. const getAvailableSpreadsCommission = (loginType) => {
  146. if (loginType === '2') return commissionAccountTypeData.value.ecn || []
  147. if (loginType === '7')
  148. return commissionAccountTypeData.value.standard || []
  149. if (loginType === '8') return commissionAccountTypeData.value.cent || []
  150. return []
  151. }
  152. // 佣金调整弹框:根据佣金查看(getLoginPoint)的当前值设置账户类型下拉默认选中
  153. const setCommissionDefaultsFromLoginPoint = async (customerId) => {
  154. if (!customerId) return
  155. try {
  156. const res = await ibApi.getLoginPoint({ id: customerId })
  157. if (res.code !== Code.StatusOK || !Array.isArray(res.data)) return
  158. const list = res.data || []
  159. const norm = (v) =>
  160. v === 2 || v === '2'
  161. ? '2'
  162. : v === 7 || v === '7'
  163. ? '7'
  164. : v === 8 || v === '8'
  165. ? '8'
  166. : null
  167. const byType = { 2: [], 7: [], 8: [] }
  168. list.forEach((d) => {
  169. const t = norm(d.loginType)
  170. if (t && d.groupName) byType[t].push(d.groupName)
  171. });
  172. ['2', '7', '8'].forEach((loginType) => {
  173. const key =
  174. loginType === '2' ? 'ecn' : loginType === '7' ? 'standard' : 'cent'
  175. const currentGroupName = byType[loginType][0]
  176. const options = getAvailableSpreadsCommission(loginType)
  177. const idx =
  178. currentGroupName == null
  179. ? -1
  180. : options.findIndex(
  181. (item) => (item.groupName || '') === currentGroupName,
  182. )
  183. const setting = commissionAccountTypeSettings.value[key]
  184. if (idx >= 0) {
  185. setting.selectedIndex = idx
  186. setting.selectedItem = options[idx]
  187. } else {
  188. setting.selectedIndex = null
  189. setting.selectedItem = null
  190. }
  191. })
  192. } catch (e) {
  193. console.error('设置佣金调整默认值失败:', e)
  194. }
  195. }
  196. watch(() => props.detail, (val) => {
  197. if (val.cId) {
  198. const { cId, id, comPoint1, hide1 } = val
  199. dialogForm.value = {
  200. cId, id, comPoint1, hide1,
  201. }
  202. loadCommissionAccountTypes(val.ibId).then(
  203. () => {
  204. return setCommissionDefaultsFromLoginPoint(val.id)
  205. },
  206. )
  207. }
  208. })
  209. const getSpreadLabelCommission = (item) => {
  210. return item.groupName || ''
  211. }
  212. const handleCommissionAccountTypeChange = (type, loginType) => {
  213. const setting = commissionAccountTypeSettings.value[type]
  214. const availableSpreads = getAvailableSpreadsCommission(loginType)
  215. if (
  216. setting.selectedIndex !== null &&
  217. setting.selectedIndex !== undefined
  218. ) {
  219. setting.selectedItem = availableSpreads[setting.selectedIndex] || null
  220. } else {
  221. setting.selectedItem = null
  222. }
  223. }
  224. const toVerified = () => {
  225. // 确认按钮点击事件
  226. emit('confirm')
  227. }
  228. const closeDia = () => {
  229. dialogForm.value = {
  230. cId: '',
  231. }
  232. commissionAccountTypeSettings.value = {
  233. ecn: { selectedIndex: null, selectedItem: null, loginType: '2' },
  234. standard: { selectedIndex: null, selectedItem: null, loginType: '7' },
  235. cent: { selectedIndex: null, selectedItem: null, loginType: '8' },
  236. }
  237. emit('close')
  238. }
  239. const confirmDia = async () => {
  240. // 确认按钮点击事件
  241. const loginConfig = []
  242. Object.keys(commissionAccountTypeSettings.value).forEach((key) => {
  243. const setting = commissionAccountTypeSettings.value[key]
  244. if (setting.selectedItem) {
  245. loginConfig.push(setting.selectedItem)
  246. }
  247. })
  248. let res = await ibApi.customCommissionPoint({
  249. id: dialogForm.value.id,
  250. loginConfig,
  251. })
  252. if (res.code == Code.StatusOK) {
  253. uni.showToast({
  254. title: t('Msg.ModifySuccess'),
  255. })
  256. closeDia()
  257. } else {
  258. uni.showToast({
  259. title: res.msg,
  260. icon: 'none',
  261. })
  262. }
  263. emit('confirm')
  264. }
  265. </script>
  266. <style lang="scss" scoped>
  267. @import "@/uni.scss";
  268. .dialog-account-adjust-body {
  269. padding: 20rpx;
  270. }
  271. .account-adjust-cid-row {
  272. display: flex;
  273. align-items: center;
  274. margin-bottom: 20rpx;
  275. font-size: px2rpx(20);
  276. }
  277. .account-adjust-cid-label {
  278. color: #606266;
  279. margin-right: px2rpx(5);
  280. }
  281. .account-adjust-cid-value {
  282. font-weight: bold;
  283. color: #303133;
  284. }
  285. .form-section {
  286. margin-bottom: 20rpx;
  287. }
  288. .section-title {
  289. display: flex;
  290. align-items: center;
  291. margin-bottom: px2rpx(15);
  292. font-weight: bold;
  293. font-size: px2rpx(18);
  294. }
  295. .section-title i {
  296. margin-right: 10rpx;
  297. }
  298. .account-type-grid {
  299. }
  300. .account-type-card {
  301. display: flex;
  302. flex-direction: column;
  303. margin-bottom: px2rpx(20);
  304. }
  305. .account-type-label {
  306. margin-bottom: 10rpx;
  307. font-size: 14rpx;
  308. }
  309. .account-select {
  310. width: 100%;
  311. }
  312. .dialog-account-adjust-footer {
  313. padding: 20rpx;
  314. }
  315. .account-adjust-notes-panel {
  316. margin-bottom: 20rpx;
  317. }
  318. .account-adjust-notes-section {
  319. background-color: #f5f7fa;
  320. padding: 15rpx;
  321. border-radius: 8rpx;
  322. }
  323. .account-adjust-notes-title {
  324. display: flex;
  325. align-items: center;
  326. margin-bottom: px2rpx(10);
  327. font-weight: bold;
  328. font-size: px2rpx(13);
  329. }
  330. .account-adjust-notes-title-icon {
  331. margin-right: px2rpx(10);
  332. }
  333. .account-adjust-notes-list {
  334. margin-left: px2rpx(20);
  335. color: #606266;
  336. font-size: px2rpx(13);
  337. }
  338. .account-adjust-notes-list .list {
  339. margin-bottom: px2rpx(5);
  340. margin-left: px2rpx(10);
  341. }
  342. .account-adjust-footer-buttons {
  343. display: flex;
  344. justify-content: flex-end;
  345. gap: 15rpx;
  346. }
  347. .account-adjust-footer-buttons button {
  348. min-width: 120rpx;
  349. }
  350. </style>