import axios from '../../bc-libs/api.request'

/**
 * 查询指定流程的文档目录
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getCatalog = parmas => {
  return axios.request({
    url: '/api/v1/base/pdf/catalog/byLoginUser',
    params: parmas,
    method: 'get'
  })
}

/**
 * 查询当前用户在该业务有权使用的印章
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getSeal = parmas => {
  return axios.request({
    url: '/api/v1/base/seal/byLoginUser',
    params: parmas,
    method: 'get'
  })
}

/**
 * 查询文件的签章记录
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getSignRecord = parmas => {
  return axios.request({
    url: '/api/v1/base/seal/useRecord',
    params: parmas,
    method: 'get'
  })
}

/**
 * 新增
 * @param params
 * @returns {Promise<any>}
 */
export const doSign = (params) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: '/api/v1/base/sign/do/byLoginUser',
      method: 'POST',
      data: params
    }).then(response => {
      resolve(response.data)
    }).catch(err => {
      reject(err)
    })
  })
}

/**
 * 修改
 * @param params
 * @returns {Promise<any>}
 */
export const editRbacUser = (params) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: '/v1/baseSenior/merge',
      method: 'POST',
      data: params
    }).then(response => {
      resolve(response.data)
    }).catch(err => {
      reject(err)
    })
  })
}

/**
 * 删除
 * @param id
 * @returns {Promise<any>}
 */
export const deleteRbacUser = (id) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: '/v1/baseSenior/delete/' + id,
      method: 'POST'
    }).then(response => {
      resolve(response.data)
    }).catch(err => {
      reject(err)
    })
  })
}

/**
 * 关键字分页查询
 * @param parmas
 * @returns {*|void|ClientRequest|ClientHttp2Stream|never|AxiosPromise<any>}
 */
export const getRbacUserByKeyValue = parmas => {
  return axios.request({
    url: 'api/v1/baseSenior/keyValue',
    params: parmas,
    method: 'post'
  })
}

/**
 * 新增
 * @param params
 * @returns {Promise<any>}
 */
export const transferFile = (params) => {
  return new Promise((resolve, reject) => {
    axios.request({
      url: '/api/v1/base/pdf/transferFile',
      method: 'POST',
      data: params
    }).then(response => {
      resolve(response.data.result)
    }).catch(err => {
      reject(err)
    })
  })
}
