import request from '@/axios';

export const getParentList = (current, size, params) => {
  return request({
    url: '/system/autocode/rule/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    },
  });
};

export const getChildList = (current, size, ruleId, params) => {
  return request({
    url: '/system/autocode/part/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      ruleId: ruleId,
    },
  })
};

export const remove = ids => {
  return request({
    url: '/system/autocode/rule/' + ids,
    method: 'delete'
  })
};

export const add = row => {
  return request({
    url: '/system/autocode/rule',
    method: 'post',
    data: row
  })
};

export const update = row => {
  return request({
    url: '/system/autocode/rule',
    method: 'put',
    data: row
  })
};
export function getRule(ruleId) {
  return request({
    url: '/system/autocode/rule/' + ruleId,
    method: 'get'
  })
};
export const getDictTree = () => {
  return request({
    url: '/blade-system/dict-biz/tree?code=DICT',
    method: 'get',
  });
};

export const getDictionary = params => {
  return request({
    url: '/blade-system/dict-biz/dictionary',
    method: 'get',
    params,
  });
};

export const removePart = ids => {
  return request({
    url: '/system/autocode/part/' + ids,
    method: 'delete'
  })
};

export const addPart = row => {
  return request({
    url: '/system/autocode/part',
    method: 'post',
    data: row
  })
};

export const updatePart = row => {
  return request({
    url: '/system/autocode/part',
    method: 'put',
    data: row
  })
};
export function getPart(partId) {
  return request({
    url: '/system/autocode/part/' + partId,
    method: 'get'
  })
};