import request from "@/router/axios";

export const getList = (current, size, params) => {
  return request({
    url: "/api/blade-manager/wbsFormElement/list",
    method: "get",
    params: {
      ...params,
      current,
      size,
    },
  });
};

export const getDetail = (id) => {
  return request({
    url: "/api/blade-manager/wbsFormElement/detail",
    method: "get",
    params: {
      id,
    },
  });
};

export const remove = (ids, initTableName, eKey) => {
  return request({
    url: "/api/blade-manager/wbsFormElement/remove",
    method: "post",
    params: {
      ids,
      initTableName,
      eKey,
    },
  });
};

export const add = (row) => {
  return request({
    url: "/api/blade-manager/wbsFormElement/submit",
    method: "post",
    data: row,
  });
};

export const update = (row) => {
  return request({
    url: "/api/blade-manager/wbsFormElement/submit",
    method: "post",
    data: row,
  });
};
export const saveElement = (row) => {
  return request({
    url: "/api/blade-manager/wbsFormElement/save",
    method: "post",
    data: row,
  });
};

export const updateBatchElements = (list, initTableName) => {
  return request({
    url:
      "/api/blade-manager/wbsTree/update-batch-elements?initTableName=" +
      initTableName,
    method: "post",
    data: list,
  });
};

export const getTemplate = () => {
  return request({
    url: "/api/blade-manager/wbsFormElement/export-template",
    method: "get",
    responseType: "arraybuffer",
  });
};

export const importWbsElement = (formData) => {
  return request({
    url: "/api/blade-manager/wbsFormElement/import-wbsElement",
    method: "post",
    data: formData,
  });
};
//同步查询功能
export const querySyncRecord = (data) => {
  return request({
    url: "/api/blade-manager/synchronousRecord/querySyncRecord",
    method: "get",
    params: data,
  });
};

//复制节点
export const copyNode = (formData) => {
  return request({
    url: "/api/blade-manager/wbsTree/copyNode",
    method: "post",
    data: formData,
  });
};
//删除同步记录
export const deleteRecord = (data) => {
  return request({
    url: "/api/blade-manager/synchronousRecord/delete",
    method: "get",
    params: data,
  });
};
//刷新同步记录状态
export const reFlush = (data) => {
  return request({
    url: "/api/blade-manager/synchronousRecord/reFlush",
    method: "get",
    params: data,
  });
};

//获取元素实体表详情
export const getElementDetail = (data) => {
  return request({
    url: "/api/blade-manager/wbsFormElement/elementDetail",
    method: "get",
    params: data,
  });
};

//获取元素实体表详情 对应的清表列表
export const getElementDetailPage = (data) => {
  return request({
    url: "/api/blade-manager/wbsFormElement/elementDetailPage",
    method: "get",
    params: data,
  });
};
