import request from '/@/utils/request';
import type { ClientGroupListParams, ClientGroupType, AdminRoleUserType } from './types'
import { AxiosPromise } from 'axios';


/**
 * 获取集团客户对照列表
 * @param params 
 * @returns 
 */
export const getClientGroupListApi = (params: ClientGroupListParams): AxiosPromise<{ [key: string]: any;list: ClientGroupType[]}> => {
    return request({
        url: '/client/group/info/list',
        method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params
    })
}


/**
 * 删除指定id的集团客户对照
 * @param id 
 * @returns 
 */
export const delClientGroupApi = (id: number): AxiosPromise<void> => {
    return request({
        url: '/client/group/info/delete',
        method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params: { id }
    })
}


/**
 * 保存集团对照数据
 * @param params 
 * @returns 
 */
export const saveClientGroupApi = (params: Partial<ClientGroupType>): AxiosPromise<void> => {
    return request({
        url: '/client/group/info/save',
        method: 'post',
        data: params
    })
}


/**
 * 请求所有集团管理权限的用户
 * @returns 
 */
export const getAdminRoleUserApi = (): AxiosPromise<AdminRoleUserType[]> => {
    return request({
        url: '/client/group/info/listManagers',
        method: 'post'
    })
}

/**
 * 根据code获取集团对照详情
 * @param code 
 * @returns 
 */
export const getClientGroupDetailByCodeApi = (code: string) :AxiosPromise<ClientGroupType> => {
    return request({
        url: '/client/group/info/detail2',
        method: 'post',
        params: { code }
    })
}