import request from '@/assets/js/workutils/workrequest'

export const modelList = (current, size, params) => {
  return request({
    url: '/bidprocurement/common-workclow/model/list',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  })
}

export const managerList = (current, size, params) => {
  return request({
    url: '/bidprocurement/common-workclow/manager/list',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  })
}

export const followList = (current, size, params) => {
  return request({
    url: '/bidprocurement/common-workclow/follow/list',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  })
}

export const removeModel = (ids) => {
  return request({
    url: '/bidprocurement/common-workclow/model/remove',
    method: 'post',
    params: {
      ids
    }
  })
}

export const deployModel = (params) => {
  return request({
    url: '/bidprocurement/common-workclow/model/deploy',
    method: 'post',
    params
  })
}

export const changeState = (params) => {
  return request({
    url: '/bidprocurement/common-workclow/manager/change-state',
    method: 'post',
    params
  })
}

export const deployUpload = (category, files) => {
  const formData = new FormData()
  formData.append('category', category)
  files.forEach(file => {
    formData.append('files', file)
  })
  return request({
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    url: '/bidprocurement/common-workclow/manager/deploy-upload',
    method: 'post',
    data: formData
  })
}
export const deployUploadUrl = '/bidprocurement/common-workclow/manager/deploy-upload'

export const deleteDeployment = (deploymentIds) => {
  return request({
    url: '/bidprocurement/common-workclow/manager/delete-deployment',
    method: 'post',
    params: {
      deploymentIds
    }
  })
}

export const deleteProcessInstance = (params) => {
  return request({
    url: '/bidprocurement/common-workclow/follow/delete-process-instance',
    method: 'post',
    params
  })
}
