import {normalCallPost} from '@/assets/utils/index';

// 查询流程定义列表
export function listDefinition(query) {
  return normalCallPost('/flowable/definition/list', query)
}

// 部署流程实例
export function definitionStart(procDefId,data) {
  return normalCallPost('/flowable/definition/start', {"procDefId": procDefId,data:data})
}

// 获取流程变量
export function getProcessVariables(taskId) {
  return normalCallPost('/task/process/processVariables', {"taskId":taskId})
  // return request({
  //   url: '/flowable/task/processVariables/' + taskId,
  //   method: 'get'
  // })
}

// 激活/挂起流程
export function updateState(params) {
  return normalCallPost('/flowable/definition/updateState', params)
}

// 指定流程办理人员列表
export function userList(query) {
  return normalCallPost('/user/list', query)

}

// 指定流程办理组列表(由角色确定)
export function roleList(query) {
  return normalCallPost('/role/list', query)
  // return request({
  //   url: '/flowable/definition/roleList',
  //   method: 'get',
  //   params: query
  // })
}

// 读取xml文件
export function readXml(deployId) {
  return normalCallPost('/flowable/definition/readXml', {"deployId": deployId})
}
// 读取image文件
export function readImage(deployId) {
  return normalCallPost('/flowable/definition/readImage', {"deployId": deployId})
}

// 读取image文件
export function getFlowViewer(procInsId) {
  return normalCallPost('/task/process/flowViewer', {"procInsId": procInsId})

}

// 保存xml文件
export function saveXml(data) {
  return normalCallPost('/flowable/definition/saveXml', data)
}

// 新增流程定义
export function addDeployment(data) {
  // return request({
  //   url: '/system/deployment',
  //   method: 'post',
  //   data: data
  // })
}

// 修改流程定义
export function updateDeployment(data) {

  return new Promise((resolve, reject)=>{
    this.$post('/flowable/definition/edit', {"query.id": data.deployId}).then(({data})=>{     
      resolve(data.result);
    }).catch(reject)
  })
}

// 删除流程定义
export function delDeployment(query) {

  // /{id:[formId]}
  return normalCallPost('/flowable/definition/deleteDefinition', {deployId:[query.deployId]})
  // return request({
  //   url: '/flowable/definition/delete/',
  //   method: 'delete',
  //   params: query
  // })
}

// 导出流程定义
export function exportDeployment(query) {
  return normalCallPost('/flowable/definition/export', query)
  // return request({
  //   url: '/system/deployment/export',
  //   method: 'get',
  //   params: query
  // })
}
