setup.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import { commonResultInfo, getRequestResultInfo } from "@/common/methods/request";
  2. import { QueryAccMgrLoginUser } from "@/services/go/ermcp/account";
  3. import { ErmcpLoginUser } from "@/services/go/ermcp/account/interface";
  4. import { orderContract, spotContractStatus } from "@/services/proto/spotcontract";
  5. import {
  6. GldErmcpSpotContractOperateReq,
  7. SpotContractOperateReq
  8. } from "@/services/proto/spotcontract/interface";
  9. import { ContractStateSign, GldContractStateSign } from "@/views/information/spot-contract/setup";
  10. import { message } from "ant-design-vue";
  11. import Long from 'long';
  12. import { ref, Ref } from "vue";
  13. import { Value } from "./check/interface";
  14. /**
  15. * 合同操作相关 针对操作类型 1: 保存草稿 2: 提交申请 3: 删除成功 4:审核通过
  16. * @param reqs GldErmcpSpotContractOperateReq
  17. * @param loading
  18. * @returns
  19. */
  20. export function orderContractControl(reqs: GldErmcpSpotContractOperateReq, loading: Ref<boolean>): Promise<string> {
  21. //处理 合同id
  22. if (reqs.SpotContractID) {
  23. reqs.SpotContractID = Long.fromString(reqs.SpotContractID)
  24. }
  25. // loading 效果
  26. loading.value = true
  27. // 获取提示信息
  28. const sign = getRequestResultInfo(GldContractStateSign, reqs.OperateType) // 接口请求后的返回提示 这里统一进行管理
  29. // 接口调用
  30. const result = orderContract(reqs)
  31. // 接口调用结果处理,提示成功或者失败信息,并关闭loading效果
  32. return commonResultInfo(result, sign, loading)
  33. }
  34. /**
  35. * 修改合同类型 针对操作类型 4:审核拒绝 6:正常完结 5:撤销
  36. * @param reqs
  37. * @param loading
  38. * @returns
  39. */
  40. export function orderContractOperateControl(reqs: SpotContractOperateReq, loading: Ref<boolean>): Promise<string> {
  41. //处理 合同id
  42. if (reqs.SpotContractID) {
  43. reqs.SpotContractID = Long.fromString(reqs.SpotContractID)
  44. }
  45. // loading 效果
  46. loading.value = true
  47. // 获取提示信息
  48. const sign = getRequestResultInfo(ContractStateSign, reqs.OperateType) // 接口请求后的返回提示 这里统一进行管理
  49. // 接口调用
  50. const result = spotContractStatus(reqs)
  51. // 接口调用结果处理,提示成功或者失败信息,并关闭loading效果
  52. return commonResultInfo(result, sign, loading)
  53. }
  54. /**
  55. * 处理 /账号列表: 交易用户 业务员 跟单员
  56. * @returns
  57. */
  58. export function handleAccountManager() {
  59. // 交易用户
  60. const traderList = ref<Value[]>([])
  61. function getRoleList() {
  62. QueryAccMgrLoginUser(2).then(res => {
  63. const set = new Set<number>([])
  64. traderList.value.length = 0;
  65. res.forEach(e => {
  66. const { roleid, rolename, accountstatus } = e;
  67. if (accountstatus === 4) { // 账户的状态 - 4 正常
  68. if (!set.has(roleid)) { // 去重
  69. set.add(roleid)
  70. traderList.value.push({ id: roleid, name: rolename })
  71. }
  72. }
  73. })
  74. }).catch(err => message.error(err))
  75. }
  76. // 处理 跟单员 / 业务员 列表
  77. function handleList(el: ErmcpLoginUser, type: string, set: Set<number>): Value | null {
  78. const { loginstatus, userid, accountname, logincode, roletype } = el;
  79. let result = null
  80. if (loginstatus === 1) {// 登录账户状态 - 1:正常
  81. if (roletype.includes(type)) { // 过滤角色类型
  82. if (!set.has(userid)) { // 去重
  83. set.add(userid)
  84. result = { id: userid, name: `${accountname}-${logincode}` }
  85. }
  86. }
  87. }
  88. return result
  89. }
  90. // 业务员
  91. const businesserList = ref<Value[]>([])
  92. // 跟单员
  93. const merchandiserList = ref<Value[]>([])
  94. function getBusinesserList() {
  95. QueryAccMgrLoginUser(1).then(res => {
  96. const bSet = new Set<number>([]);
  97. const mSet = new Set<number>([]);
  98. const list: ErmcpLoginUser[] = []
  99. res.forEach(e => {
  100. // eslint-disable-next-line prefer-spread
  101. list.push.apply(list, e.userlist)
  102. })
  103. list.forEach(el => {
  104. // 业务员
  105. const b = handleList(el, '22', bSet)
  106. if (b) {
  107. businesserList.value.push(b)
  108. }
  109. // 跟单员
  110. const m = handleList(el, '23', mSet)
  111. if (m) {
  112. merchandiserList.value.push(m)
  113. }
  114. })
  115. }).catch(err => message.error(err))
  116. }
  117. return { traderList, businesserList, merchandiserList, getRoleList, getBusinesserList }
  118. }