| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- import { commonResultInfo, getRequestResultInfo } from "@/common/methods/request";
- import { QueryAccMgrLoginUser } from "@/services/go/ermcp/account";
- import { ErmcpLoginUser } from "@/services/go/ermcp/account/interface";
- import { orderContract, spotContractStatus } from "@/services/proto/spotcontract";
- import {
- GldErmcpSpotContractOperateReq,
- SpotContractOperateReq
- } from "@/services/proto/spotcontract/interface";
- import { ContractStateSign, GldContractStateSign } from "@/views/information/spot-contract/setup";
- import { message } from "ant-design-vue";
- import Long from 'long';
- import { ref, Ref } from "vue";
- import { Value } from "./check/interface";
- /**
- * 合同操作相关 针对操作类型 1: 保存草稿 2: 提交申请 3: 删除成功 4:审核通过
- * @param reqs GldErmcpSpotContractOperateReq
- * @param loading
- * @returns
- */
- export function orderContractControl(reqs: GldErmcpSpotContractOperateReq, loading: Ref<boolean>): Promise<string> {
- //处理 合同id
- if (reqs.SpotContractID) {
- reqs.SpotContractID = Long.fromString(reqs.SpotContractID)
- }
- // loading 效果
- loading.value = true
- // 获取提示信息
- const sign = getRequestResultInfo(GldContractStateSign, reqs.OperateType) // 接口请求后的返回提示 这里统一进行管理
- // 接口调用
- const result = orderContract(reqs)
- // 接口调用结果处理,提示成功或者失败信息,并关闭loading效果
- return commonResultInfo(result, sign, loading)
- }
- /**
- * 修改合同类型 针对操作类型 4:审核拒绝 6:正常完结 5:撤销
- * @param reqs
- * @param loading
- * @returns
- */
- export function orderContractOperateControl(reqs: SpotContractOperateReq, loading: Ref<boolean>): Promise<string> {
- //处理 合同id
- if (reqs.SpotContractID) {
- reqs.SpotContractID = Long.fromString(reqs.SpotContractID)
- }
- // loading 效果
- loading.value = true
- // 获取提示信息
- const sign = getRequestResultInfo(ContractStateSign, reqs.OperateType) // 接口请求后的返回提示 这里统一进行管理
- // 接口调用
- const result = spotContractStatus(reqs)
- // 接口调用结果处理,提示成功或者失败信息,并关闭loading效果
- return commonResultInfo(result, sign, loading)
- }
- /**
- * 处理 /账号列表: 交易用户 业务员 跟单员
- * @returns
- */
- export function handleAccountManager() {
- // 交易用户
- const traderList = ref<Value[]>([])
- function getRoleList() {
- QueryAccMgrLoginUser(2).then(res => {
- const set = new Set<number>([])
- traderList.value.length = 0;
- res.forEach(e => {
- const { roleid, rolename, accountstatus } = e;
- if (accountstatus === 4) { // 账户的状态 - 4 正常
- if (!set.has(roleid)) { // 去重
- set.add(roleid)
- traderList.value.push({ id: roleid, name: rolename })
- }
- }
- })
- }).catch(err => message.error(err))
- }
- // 处理 跟单员 / 业务员 列表
- function handleList(el: ErmcpLoginUser, type: string, set: Set<number>): Value | null {
- const { loginstatus, userid, accountname, logincode, roletype } = el;
- let result = null
- if (loginstatus === 1) {// 登录账户状态 - 1:正常
- if (roletype.includes(type)) { // 过滤角色类型
- if (!set.has(userid)) { // 去重
- set.add(userid)
- result = { id: userid, name: `${accountname}-${logincode}` }
- }
- }
- }
- return result
- }
- // 业务员
- const businesserList = ref<Value[]>([])
- // 跟单员
- const merchandiserList = ref<Value[]>([])
- function getBusinesserList() {
- QueryAccMgrLoginUser(1).then(res => {
- const bSet = new Set<number>([]);
- const mSet = new Set<number>([]);
- const list: ErmcpLoginUser[] = []
- res.forEach(e => {
- // eslint-disable-next-line prefer-spread
- list.push.apply(list, e.userlist)
- })
- list.forEach(el => {
- // 业务员
- const b = handleList(el, '22', bSet)
- if (b) {
- businesserList.value.push(b)
- }
- // 跟单员
- const m = handleList(el, '23', mSet)
- if (m) {
- merchandiserList.value.push(m)
- }
- })
- }).catch(err => message.error(err))
- }
- return { traderList, businesserList, merchandiserList, getRoleList, getBusinesserList }
- }
|