import request from "@/router/axios";

export const getLazytree = (wbsId, parentId, tenantId, projectId, params) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/lazy-tree",
    method: "get",
    params: {
      ...params,
      wbsId,
      parentId,
      tenantId,
      projectId,
    },
  });
};

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

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

export const findNodeTableByCondition = (
  parentId,
  projectId,
  wbsId,
  params
) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/get-node-tables",
    method: "get",
    params: {
      ...params,
      parentId,
      projectId,
      wbsId,
    },
  });
};

export const removeTableByCondition = (
  id,
  projectId,
  wbsId,
  pKeyId,
  params
) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/remove-table",
    method: "get",
    params: {
      ...params,
      id,
      projectId,
      wbsId,
      pKeyId,
    },
  });
};

export const removePrivateTreeNode = (pKeyId) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/remove",
    method: "post",
    params: {
      pKeyId,
    },
  });
};

export const wbsTreePrivateTableSort = (data) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/submit-table-sort",
    method: "post",
    data: data,
  });
};

export const getNodeTabAndParam = (parentId, projectId, wbsId, params) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/get-node-table-param",
    method: "get",
    params: {
      ...params,
      parentId,
      projectId,
      wbsId,
    },
  });
};

export const privateSubmitFullName = (pKeyId, fullNames) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/submit-full-name",
    method: "post",
    params: {
      pKeyId,
      fullNames,
    },
  });
};

export const syncNodeParam = (projectId, pKeyId) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/sync-node-param",
    method: "post",
    params: {
      projectId,
      pKeyId,
    },
  });
};
//同步电签默认信息
export const syncProjecteVisa = (projectId, pKeyId) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/sync-project-eVisa",
    method: "post",
    params: {
      projectId,
      pKeyId,
    },
  });
};
export const syncNodeTable = (primaryKeyId) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/sync-node-table",
    method: "post",
    params: {
      primaryKeyId,
    },
  });
};
//同步项目基础信息到合同段接口sync-node-info
export const syncNodeinfo = (pKeyId) => {
  return request({
    // url: '/api/blade-manager/projectInfo/sync-node-info',
    url: "/api/blade-manager/wbsPrivate/sync-node-info",
    method: "post",
    params: {
      pKeyId,
    },
  });
};
//同步元素表单排序到合同段
export const syncContractTabSort = (projectId, pKeyId) => {
  return request({
    url: "api/blade-manager/wbsTreeContract/syncContractTabSort",
    method: "get",
    params: {
      projectId,
      pKeyId,
    },
  });
};

//清表树
export const tabTypeLazyTree = (params) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/tab-Type-lazy-tree",
    method: "get",
    params,
  });
};

export const tabTypeLazyTreeAll = (params) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/tab-Type-lazy-tree-all",
    method: "get",
    params,
  });
};
//后管-添加元素到项目
// export const projecttabInfo = (data) => {
//   return request({
//     url: '/api/blade-manager/wbsPrivate/add-projecttab-info',
//     method: 'post',
//     data:data
//   })
// }
export const projecttabInfo = (primaryKeyIds, projectId) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/add-projecttab-info",
    method: "post",
    params: {
      primaryKeyIds,
      projectId,
    },
  });
};
//后管-删除元素表
export const delTabInfoAll = (pKeyId) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/del-tab-info-all",
    method: "post",
    params: {
      pKeyId,
    },
  });
};
//后管-删除项目表单
export const delAprojectTab = (primaryKeyIds, projectId) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/del-aprojecttab-info",
    method: "post",
    params: {
      primaryKeyIds,
      projectId,
    },
  });
};
//新增元素业务时间表
export const saveTabusstime = (colId, colKey, tableId) => {
  return request({
    url: "/api/blade-manager/tabbusstimeinfo/save-tabusstime-info",
    method: "post",
    data: {
      colId,
      colKey,
      tableId,
    },
  });
};
//删除元素业务时间表
export const removeTabusstime = (ids) => {
  return request({
    url: "/api/blade-manager/tabbusstimeinfo/remove",
    method: "post",
    params: {
      ids,
    },
  });
};
//后管独立表单库表单同步到合同段所有选择的节点下
export const syncFormToContractNode = (params) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/syncFormToContractNode",
    method: "get",
    params,
  });
};

//节点关联
export const linkNodeTree = (nodeids, pkeyid) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/link-node-tree",
    method: "POST",
    params: {
      nodeids,
      pkeyid,
    },
  });
};

//node节点回显示
export const getLinekNodeTreelist = (pkeyid) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/getlinek-node-treelist",
    method: "POST",
    params: {
      pkeyid,
    },
  });
};
//获取文件题名规则
export const getNameRule = (params) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/getNameRule",
    method: "get",
    params,
  });
};
//获取获取文件题名范围
export const getTitleRange = (params) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/getTitleRange",
    method: "get",
    params,
  });
};

//新增或修改文件题名规则
export const saveOrUpdateNameRule = (row) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/saveOrUpdateNameRule",
    method: "post",
    data: row,
  });
};

//删除文件题名规则
export const deletedNameRule = (params) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/deletedNameRule",
    method: "get",
    params,
  });
};

//查询当前节点下所有元素表并分类
export const getGroupNodeTables = (params) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/get-group-node-tables",
    method: "get",
    params,
  });
};

//根据pkeyid检验html是否存在错误
export const getHtmlErrorByPKeyId = (pKeyId) => {
  return request({
    url: "/api/blade-manager/wbsPrivate/getHtmlErrorByPKeyId",
    method: "get",
    params: { pKeyId: pKeyId },
  });
};
