// 流程审批
import request, { tenantRequest } from '@/utils/request'
import {
  addScope, addUser, submit, reject
} from './base'
//  审核管理分页列表
export function getPublishWorkflows (query) {
  const { pageNum: pageIndex, pageSize, self, ...params } = query
  return tenantRequest({
    url: '/workflow/calendarRelease/page',
    method: 'GET',
    params: self
      ? addUser({
        pageIndex,
        pageSize,
        ...params
      })
      : addScope({
        pageIndex,
        pageSize,
        ...params
      })
  })
}
// 审核详情资源
export function getPublishWorkflowDetail (workflowId) {
  return request({
    url: `/workflow/${workflowId}/list`,
    method: 'GET'
  })
}
// 审批通过

// 审核驳回
export function calendarPublishReject (workflowId, data, name) {
  return reject(
    {
      url: `/workflow/calendarRelease/${workflowId}/reject`,
      method: 'POST',
      data
    },
    name
  )
}
// 流程重提交
export function calendarPublishRestart (workflowId, name) {
  return submit({
    url: `/workflow/${workflowId}/restart `,
    method: 'POST'
  }, name)
}
// 流程终止
export function calendarPublishStop (workflowId) {
  return request({
    url: `/workflow/${workflowId}/stop`,
    method: 'POST'
  })
}
