index.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { queryResultLoadingAndInfo } from "@/common/methods/request/resultInfo";
  2. import { QueryAccMgrLoginUser } from "@/services/go/ermcp/account";
  3. import { ErmcpLoginUser, ErmcpLoginUserEx } from "@/services/go/ermcp/account/interface";
  4. import { Ref, ref } from "vue";
  5. /**
  6. * 获取(业务账户, 交易账户, 管理账户)
  7. * 因没有数据更新推送,为了防止新增的时候,导致数据不能及时更新,故每次进入页面都请求一次数据
  8. * @param loading
  9. * @param type 查询类型 1-业务账户 2-交易账户 3-管理账户
  10. * @param isFilter 是否过滤.false,不过滤,true: 过滤正常账号数据,
  11. * @returns
  12. */
  13. export function handlerManagerList(loading: Ref<boolean>, type: 1 | 2 | 3, isFilter = false) {
  14. const tableList = ref<ErmcpLoginUserEx[]>([]);
  15. function queryTable(): Promise<ErmcpLoginUserEx[]> {
  16. return queryResultLoadingAndInfo(QueryAccMgrLoginUser, loading, type)
  17. .then(res => {
  18. const result = isFilter ? res.filter((e: ErmcpLoginUserEx) => e.accountstatus === 4) : res
  19. tableList.value = result
  20. return result
  21. })
  22. }
  23. /**
  24. * 根据code 查找业务员、跟单员对应的名字
  25. * @param code
  26. * @returns
  27. */
  28. function findManagerName(id: number, arr?: ErmcpLoginUserEx[]) {
  29. let result = '--'
  30. const temp = arr ? arr : tableList.value
  31. temp.forEach(el => {
  32. el.userlist.forEach(e => {
  33. const { accountname, logincode, userid } = e
  34. if (userid === id) {
  35. result = `${accountname}-${logincode}`
  36. }
  37. })
  38. })
  39. return result
  40. }
  41. /**
  42. * 获取业务员、跟单员
  43. * @param roletype '22':业务员 '23':跟单员
  44. * @returns
  45. */
  46. function getBusinesserOrMerchandiser(roletype: '22' | '23', isFilter = false): ErmcpLoginUser[] {
  47. const result: ErmcpLoginUser[] = []
  48. tableList.value.forEach(el => {
  49. if (el.roleid === Number(roletype)) {
  50. el.userlist.forEach(e => {
  51. if (isFilter) {
  52. if (e.loginstatus === 1) { // 过滤正常数据
  53. result.push(e)
  54. }
  55. } else {// 不进行数据过滤
  56. result.push(e)
  57. }
  58. })
  59. }
  60. })
  61. return result
  62. }
  63. return { tableList, queryTable, findManagerName, getBusinesserOrMerchandiser }
  64. }