api.ts 2.56 KB
import { http } from "@/typing/http";
import request from "@/utils/request";
import qs from 'qs';
import { CONTRACT_HOST, HOST } from "@/utils/host";
import { Any } from "currency.js";

type PrResArr<T> = http.PromiseResp<T[]>;

export interface Item {
    id?:number, //授权ID
    typeName?:string, //合同类型名称
    createTime?:number, //创建时间
    updateTime?:number, //更新时间
    enabled?:boolean, //是否启用
    roles?:Roles[],//授权角色
}
export interface Roles {
    roleCode?:string, //角色编码
    roleName?:string, //角色名称
}
export interface TypesItem {
    id?: number; // id
    name?: string;
    fixedAmount?: boolean;
    contractableTradeCompCategories?: number[];
    feeType?: string;
    feeTypeValue?: string;
    bizType?: string;
    bizTypeValue?: number;
    subjectType?: string;
    subjectTypeValue?: string;
    servicePlaceTypes?: number[];
}

export interface PageParams {
    current?: number;
    pageSize?: number;
    contractTypeName?:string //合同类型名称
}
export interface SaveParams {
    contractAuthId?: number;
    typeId: number;//合同类型id
    typeName:string //合同类型名称
    roles?:Roles[],//授权角色
}
interface DelParams {
    contractAuthId?: number; //合同授权id
}

export interface DisableParams {
    contractAuthId?: number;//合同授权id
    enabled?: boolean;//是否启用
}

/**
 * 查询所有角色列表
 */
export function getAllRoleCodeApi(params: CommonApi.RoleParams): PrResArr<CommonApi.RoleCodeVO> {
    return request.get(`${HOST}/role/listAll`, { params });
}
/**
 * 查询合同类型列表
 */
export function getContractTypes(params: PageParams): http.PromisePageResp<TypesItem> {
    return request.get(`${CONTRACT_HOST}/erp/contract/type/page`, { params });
}

/**
 * 分页查询合同授权
 */
export function getContractAuthPage(params?: PageParams): http.PromisePageResp<Item> {
    return request.get(`${CONTRACT_HOST}/erp/contractAuth/page`, {params});
}

/**
 * 新增合同授权/编辑合同授权
 */
export function addContractAuth(params?: SaveParams): http.PromisePageResp<Any> {
    return request.post(`${CONTRACT_HOST}/erp/contractAuth/save`, {...params});
}

/**
 * 删除合同授权
 */
 export function delContractAuth(params?: DelParams): http.PromisePageResp<Any> {
    return request.post(`${CONTRACT_HOST}/erp/contractAuth/delete`, {...params});
}

/**
 * 启用或禁用
 */
 export function disableContractAuth(params?: DisableParams): http.PromisePageResp<Any> {
    return request.post(`${CONTRACT_HOST}/erp/contractAuth/enableOrDisable`, {...params});
}