import { axios } from '@/utils/request'
import { stringify } from 'qs'

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getTaskPage(parameter) {
  return axios({
    url: '/act/my-task/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getTaskPageClaim(parameter) {
  return axios({
    url: '/act/my-task/claim/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getTaskPageFinish(parameter) {
  return axios({
    url: '/act/my-task/finish/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function getLocalTaskPageFinish (parameter) {
  return axios({
    url: '/audit/audits/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getTaskPageStart(parameter) {
  return axios({
    url: '/act/my-task/start/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 审批 func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function audit(parameter) {
  return axios({
    url: '/act/audit',
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getAuditRecord(processInstanceId) {
  return axios({
    url: '/act/audit/history/' + processInstanceId,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * getShineProImage func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getShineProDefImage(processInstanceId) {
  return axios({
    url: '/act/shine-procDef-image/' + processInstanceId,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * getShineProImage func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getShineProDefXml(parameter) {
  return axios({
    url: '/act/shine-procDef-xml/' + parameter.id,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    responseType: 'blob'
  })
}

/**
 * getShineProImage func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getShineProImage(processInstanceId) {
  return axios({
    url: '/act/shine-proc-image/' + processInstanceId,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
