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/updateBatchElements?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
  })
}
