import request from '@/utils/request';

export async function getProcessDefinitionBpmnXML(id) {
  const res = await request({
    url: '/bpm/process-definition/get-bpmn-xml?id=' + id,
    method: 'get'
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function getTaskAssignRuleList(query) {
  const res = await request({
    url: '/bpm/task-assign-rule/list',
    method: 'get',
    params: query
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function processInstanceCreateAPI(data) {
  const res = await request(
    {
      url: '/bpm/process-instance/create',
      method: 'post',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function getModelPage(query) {
  const res = await request({
    url: '/bpm/model/page',
    method: 'get',
    params: query
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function getProcessDefinitionInfo(params) {
  const res = await request({
    url: `/bpm/process-definition/get`,
    method: 'get',
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function listAllUserBind() {
  const res = await request.get('/main/user/listAllUserBind');
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 获取用户组精简信息列表
export async function listSimpleUserGroups() {
  const res = await request({
    url: '/bpm/user-group/list-all-simple',
    method: 'get'
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


//商机
export async function businessOpportunityUpdateStatusAPI(data) {
  const res = await request(
    {
      url: '/eom/businessopportunity/updateApprovalStatus',
      method: 'put',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//报价
export async function quoteUpdateStatusAPI(data) {
  const res = await request(
    {
      url: '/eom/quote/updateApprovalStatus',
      method: 'put',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//需求管理
export async function purchaserequirementStatusAPI(data) {
  const res = await request(
    {
      url: '/eom/purchaserequirement/updateApprovalStatus',
      method: 'put',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//计划管理
export async function purchaseplanStatusAPI(data) {
  const res = await request(
    {
      url: '/eom/purchaseplan/updateApprovalStatus',
      method: 'put',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//核价管理
export async function purchaseinquiryStatusAPI(data) {
  const res = await request(
    {
      url: '/eom/purchaseinquiry/updateApprovalStatus',
      method: 'put',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//合同
export async function contractStatusAPI(data) {
  const res = await request(
    {
      url: '/eom/contract/updateApprovalStatus',
      method: 'put',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//费用
export async function finfeeapplyStatusAPI(data) {
  const res = await request(
    {
      url: '/eom/finfeeapply/updateApprovalStatus',
      method: 'put',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//发票
export async function fininvoiceapplyStatusAPI(data) {
  const res = await request(
    {
      url: '/eom/fininvoiceapply/updateApprovalStatus',
      method: 'put',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//运输-计划
export async function logistictrakplanStatusAPI(data) {
  const res = await request(
    {
      url: '/eom/logistictrakplan/updateApprovalStatus',
      method: 'put',
      data
    },
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
