import { TenantForm, TenantQuery, TenantVO } from './types';

import { AxiosPromise } from 'axios';
import request from '@/utils/request';

// 查询租户列表
export function listDivide(query: TenantQuery): AxiosPromise<TenantVO[]> {
  return request({
    url: '/system/commission-template/list',
    method: 'post',
    data: query
  });
}

// 查询租户详细
export function getTenant(id: string | number): AxiosPromise<TenantVO> {
  return request({
    url: '/system/tenant/' + id,
    method: 'get'
  });
}

// 新增模板
export function addTenant(data: TenantForm) {
  return request({
    url: '/system/commission-template',
    method: 'post',
    headers: {
      // isEncrypt: true // 加密传输
      validateRepeat: true // 校验重复提交
    },
    data: data
  });
}
// 查看比例详情
export function getsections(data: any) {
  return request({
    url: '/system/commission-template/sections',
    method: 'post',

    data: data
  });
}
// 删除比例
export function deletesection(ids: any) {
  return request({
    url: `/system/commission-section/${ids}`,
    method: 'delete'
  });
}

// 修改比例
export function putsections(data: any) {
  return request({
    url: '/system/commission-section/edit',
    method: 'post',
    data: data
  });
}
// 添加比例
export function addsection(data: any) {
  return request({
    url: '/system/commission-section/batch',
    method: 'post',
    headers: {
      // isEncrypt: true // 加密传输
      validateRepeat: true // 校验重复提交
    },
    data: data
  });
}

// 修改租户
export function updateTenant(data: TenantForm) {
  return request({
    url: '/system/commission-template/edit',
    method: 'post',
    data: data
  });
}

// 租户状态修改
export function changeTenantStatus(id: string | number, tenantId: string | number, status: string) {
  const data = {
    id,
    tenantId,
    status
  };
  return request({
    url: '/system/tenant/changeStatus',
    method: 'put',
    data: data
  });
}

// 删除模板
export function delTenant(id: string | number | Array<string | number>) {
  return request({
    url: `/system/commission-template/${id}`,
    method: 'delete'
  });
}
