pointDialog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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="24"></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: '123',
  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) {
  198. const { cId, id, comPoint1, hide1 } = val
  199. dialogForm.value = {
  200. cId, id, comPoint1, hide1,
  201. }
  202. if (val.ibId) {
  203. loadCommissionAccountTypes(val.ibId).then(
  204. () => {
  205. return setCommissionDefaultsFromLoginPoint(val.id)
  206. },
  207. )
  208. }
  209. }
  210. })
  211. const getSpreadLabelCommission = (item) => {
  212. return item.groupName || ''
  213. }
  214. const handleCommissionAccountTypeChange = (type, loginType) => {
  215. const setting = commissionAccountTypeSettings.value[type]
  216. const availableSpreads = getAvailableSpreadsCommission(loginType)
  217. if (
  218. setting.selectedIndex !== null &&
  219. setting.selectedIndex !== undefined
  220. ) {
  221. setting.selectedItem = availableSpreads[setting.selectedIndex] || null
  222. } else {
  223. setting.selectedItem = null
  224. }
  225. }
  226. const toVerified = () => {
  227. // 确认按钮点击事件
  228. emit('confirm')
  229. }
  230. const cancel = () => {
  231. // 取消按钮点击事件
  232. emit('close')
  233. }
  234. const closeDia = () => {
  235. emit('close')
  236. }
  237. const confirmDia = async () => {
  238. // 确认按钮点击事件
  239. const loginConfig = []
  240. Object.keys(commissionAccountTypeSettings.value).forEach((key) => {
  241. const setting = commissionAccountTypeSettings.value[key]
  242. if (setting.selectedItem) {
  243. loginConfig.push(setting.selectedItem)
  244. }
  245. })
  246. let res = await ibApi.customCommissionPoint({
  247. id: dialogForm.value.id,
  248. loginConfig,
  249. })
  250. if (res.code == Code.StatusOK) {
  251. uni.showToast({
  252. title: t('Msg.ModifySuccess'),
  253. })
  254. this.cancel()
  255. } else {
  256. uni.showToast({
  257. title: res.msg,
  258. icon: 'none',
  259. })
  260. }
  261. emit('confirm')
  262. }
  263. </script>
  264. <style lang="scss" scoped>
  265. @import "@/uni.scss";
  266. .dialog-account-adjust-body {
  267. padding: 20rpx;
  268. }
  269. .account-adjust-cid-row {
  270. display: flex;
  271. align-items: center;
  272. margin-bottom: 20rpx;
  273. }
  274. .account-adjust-cid-label {
  275. color: #606266;
  276. margin-right: px2rpx(5);
  277. }
  278. .account-adjust-cid-value {
  279. font-weight: bold;
  280. color: #303133;
  281. }
  282. .form-section {
  283. margin-bottom: 20rpx;
  284. }
  285. .section-title {
  286. display: flex;
  287. align-items: center;
  288. margin-bottom: px2rpx(15);
  289. font-weight: bold;
  290. font-size: px2rpx(14);
  291. }
  292. .section-title i {
  293. margin-right: 10rpx;
  294. }
  295. .account-type-grid {
  296. }
  297. .account-type-card {
  298. display: flex;
  299. flex-direction: column;
  300. margin-bottom: px2rpx(20);
  301. }
  302. .account-type-label {
  303. margin-bottom: 10rpx;
  304. font-size: 14rpx;
  305. }
  306. .account-select {
  307. width: 100%;
  308. }
  309. .dialog-account-adjust-footer {
  310. padding: 20rpx;
  311. }
  312. .account-adjust-notes-panel {
  313. margin-bottom: 20rpx;
  314. }
  315. .account-adjust-notes-section {
  316. background-color: #f5f7fa;
  317. padding: 15rpx;
  318. border-radius: 8rpx;
  319. }
  320. .account-adjust-notes-title {
  321. display: flex;
  322. align-items: center;
  323. margin-bottom: px2rpx(10);
  324. font-weight: bold;
  325. font-size: px2rpx(13);
  326. }
  327. .account-adjust-notes-title-icon {
  328. margin-right: px2rpx(10);
  329. }
  330. .account-adjust-notes-list {
  331. margin-left: px2rpx(20);
  332. color: #606266;
  333. font-size: px2rpx(13);
  334. }
  335. .account-adjust-notes-list .list {
  336. margin-bottom: px2rpx(5);
  337. margin-left: px2rpx(10);
  338. }
  339. .account-adjust-footer-buttons {
  340. display: flex;
  341. justify-content: flex-end;
  342. gap: 15rpx;
  343. }
  344. .account-adjust-footer-buttons button {
  345. min-width: 120rpx;
  346. }
  347. </style>