import request from '@/router/axios';

export const getList = (current, size, params) => {
    return request({
        url: '/api/blade-manager/wbsTree/lazy-tree?parentId=0',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}

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

export const getAlltree = (tenantId, type = '', wbsId, params) => {
    return request({
        url: '/api/blade-manager/wbsTree/tree',
        method: 'get',
        params: {
            ...params,
            tenantId,
            type,
            wbsId
        }
    })
}

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

export const remove = (ids) => {
    return request({
        url: '/api/blade-manager/wbsTree/remove',
        method: 'post',
        params: {
            id: ids,
        }
    })
}

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

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

export const selectByNodeTable = (id, params) => {
    return request({
        url: '/api/blade-manager/wbsTree/get-node-table',
        method: 'get',
        params: {
            ...params,
            id
        }
    })
}

export const getParamElements = (params) => {
    return request({
        url: '/api/blade-manager/param/get-param-elements',
        method: 'get',
        params: {
            ...params
        }
    })
}
export const delParamElements = (params) => {
    return request({
        url: '/api/blade-manager/param/del-param-elements',
        method: 'get',
        params: {
            ...params
        }
    })
}
export const specifiedParamElements = (params) => {
    return request({
        url: '/api/blade-manager/param/specified-param-elements',
        method: 'post',
        params: {
            ...params
        }
    })
}

export const saveFormAndElement = (formElementDTO) => {
    return request({
        url: '/api/blade-manager/wbsTree/save-table-element',
        method: 'post',
        data: formElementDTO
    })
}

export const selectFormElements = (id, params) => {
    return request({
        url: '/api/blade-manager/wbsTree/get-table-elements',
        method: 'get',
        params: {
            ...params,
            id
        }
    })
}

// 项目获取元素信息
export const selectPrivateFormElements = (id, params) => {
  return request({
    url: '/api/blade-manager/wbsTree/get-private-table-elements',
    method: 'get',
    params: {
      ...params,
      id
    }
  })
}
//根据表单id查询所有元素
export const getTableElments = (id,search ,params) => {
    return request({
      url: '/api/blade-manager/wbsTree/get-table-formula-elements',
      method: 'get',
      params: {
        ...params,
        id,
        search
      }
    })
  }


export const removeTableById = (id, params) => {
    return request({
        url: '/api/blade-manager/wbsTree/remove-table',
        method: 'get',
        params: {
            ...params,
            id
        }
    })
}

export const importWbsTree = (froms) => {
    return request({
        url: '/api/blade-manager/wbsTree/import-wbsTree',
        method: 'post',
        //设置请求头
        headers: { "Content-Type": "multipart/form-data" },
        data: froms
    })
}

export const exportTemplate = () => {
    return request({
        url: '/api/blade-manager/wbsTree/export-template',
        method: 'get',
        responseType: 'arraybuffer'
    })
}


//查询当前节点的同级节点
export const findWbsTreeSameLevel = (params) => {
    return request({
        url: '/api/blade-manager/wbsTree/get-same-level',
        method: 'get',
        params
    })
}

//wbs树节点手动排序
export const wbsTreeSort = (data) => {
    return request({
        url: '/api/blade-manager/wbsTree/submit-sort',
        method: 'post',
        data
    })
}

//查询当前节点下的所有表单
export const findWbsTreeTableSameLevel = (params) => {
    return request({
        url: '/api/blade-manager/wbsFormElement/get-table-same-level',
        method: 'get',
        params
    })
}

//表单排序
export const wbsTreeTableSort = (data) => {
    return request({
        url: '/api/blade-manager/wbsFormElement/submit-table-sort',
        method: 'post',
        data
    })
}

// 私有wbs树当前节点同级节点
export const findWbsTreePrivateSameLevel = (params) => {
    return request({
        url: `/api/blade-manager/wbsPrivate/get-node-same-level`,
        method: 'get',
        params
    })
}

// wbs私有树节点手动排序
export const wbsTreePrivateSort = (data) => {
    return request({
        url: '/api/blade-manager/wbsPrivate/submit-sort',
        method: 'post',
        data
    })
}

// 节点参数列表
export const parameters = (params) => {
    return request({
        url: '/api/blade-manager/param/list',
        method: 'get',
        params
    })
}

// 保存参数
export const saveOrUpdateBatch = (data) => {
    return request({
        url: '/api/blade-manager/param/saveOrUpdateBatch',
        method: 'post',
        data
    })
}

// 参数名称接口
export const keymap = (params) => {
    return request({
        url: '/api/blade-manager/param/keymap',
        method: 'get',
        params
    })
}

// 上传元素
export const importwbsTreeFormBatch = (data) => {
    return request({
        url: '/api/blade-manager/wbsTree/import-wbsTreeFormBatch',
        method: 'post',
        data
    })
}

// 上传元素
export const exportBatchTemplate = (params) => {
    return request({
        url: '/api/blade-manager/wbsTree/export-batchTemplate',
        method: 'get',
        params
    })
}


// 公有编辑元素
export const updateBatchNodeTableInfo = (data) => {
    return request({
        url: '/api/blade-manager/wbsTree/update-batch-node-tableInfo',
        method: 'post',
        data
    })
}


// 私有元素
export const updateBatchNodeTableInfo2 = (data) => {
    return request({
        url: '/api/blade-manager/wbsPrivate/update-batch-node-tableInfo',
        method: 'post',
        data
    })
}
// 元素库编辑表单
export const updateBatchNodeTableInfoElement = (data) => {
    return request({
        url: '/api/blade-manager/tableinfo/update-batch-tableInfo',
        method: 'post',
        data
    })
}

export const updateStatus = (params) => {
    return request({
        url: '/api/blade-manager/wbsPrivate/update-status',
        method: 'get',
        params
    })
}

export const updateDefaultConceal = (params) => {
    return request({
        url: '/api/blade-manager/wbsPrivate/showTable',
        method: 'get',
        params
    })
}


export const getNodeTabAndParam = (id, params) => {
    return request({
        url: '/api/blade-manager/wbsTree/get-node-table-param',
        method: 'get',
        params: {
            ...params,
            id
        }
    })
}

export const submitFullName = (id, fullNames, params) => {
    return request({
        url: '/api/blade-manager/wbsTree/submit-full-name',
        method: 'post',
        params: {
            ...params,
            id,
            fullNames,
        }
    })
}
//刷新节点参数
export const refrehPram = (params) => {
    return request({
        url: '/api/blade-manager/param/refresh',
        method: 'get',
        params
    })
}
//同步项目下当前表的所有htmlUrl
export const syncCurrentFormInProject = (params) => {
    return request({
        url: '/api/blade-manager/wbsPrivate/syncCurrentFormInProject',
        method: 'get',
        params
    })
}
//按类型搜索树接口
export const getQueryValueByType = (params) => {
    return request({
        url: '/api/blade-manager/wbsTree/getQueryValueByType',
        method: 'get',
        params
    })
}

//过滤
export const getQueryValueByNodeType = (params) => {
    return request({
        url: '/api/blade-manager/wbsTree/getQueryValueByNodeType',
        method: 'get',
        params
    })
}
//获取表单类型树
//查询当前节点的同级节点
export const getTreeByType = (params) => {
    return request({
        url: '/api/blade-manager/wbsPrivate/tab-Type-lazy-tree-project',
        method: 'get',
        params
    })
}

//获取推荐表单
export const getRecommendTable = (params) => {
    return request({
        url: '/api/blade-manager/synchronousRecord/getRecommendTable',
        method: 'get',
        params
    })
}