import request from "@/utils/request";

// 获取流程列表
export const getList = data => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/getList`,
    method: "POST",
    data: data
  });
};


// 获取ITSM流程列表
export const findProcessList = data => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/findProcessList?name=${data.name}&currentPage=${data.currentPage}&pageSize=${data.pageSize}`,
    method: "POST",
    data: null
  });
};

// 检查新版本
export const processNewVersion = data => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/processNewVersion`,
    method: "POST",
    data: data
  });
};


// 同步流程
export const synchronizedProcessByName = data => {
  console.log(data)
  return request({
    url: `/api/itsm/CloudOperationMaintenance/synchronizedProcessByName`,
    method: "POST",
    data: data
  });
};



// 获取流程列表
export const findVersionByItsmProKey = (data, itsmProKey) => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/findVersionByItsmProKey?itsmProKey=${itsmProKey}`,
    method: "POST",
    data: data
  });
};

// 根据版本id获取流程详情
export const getDetail = (id) => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/detail/${id}`,
    method: "GET",
    data: null
  });
};


// 获取编辑流程详情
export const getFormDetail = (id) => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/${id}`,
    method: "GET",
    data: null
  });
};

// 保存编辑流程详情
export const putDetail = (data, id) => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/${id}`,
    method: "PUT",
    data: data
  });
};


// 保存编辑流程详情
export const putSelectVersion = (data) => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/selectVersion?itsmProKey=${data.itsmProKey}&version=${data.version}`,
    method: "PUT",
    data: null
  });
};


// 获取用于展示的字段列表
export const getFiledList = (data) => {
  return request({
    url: `/api/itsm/ProcessForm/getList`,
    method: "POST",
    data: data
  });
};

// 获取用户编辑的字段列表
export const getFormJson = (data) => {
  return request({
    url: `/api/itsm/ProcessForm/formJson`,
    method: "POST",
    data: data
  });
};

// 保存编辑的字段列表
export const saveFormJson = (data) => {
  return request({
    url: `/api/itsm/ProcessForm/saveFormJson`,
    method: "POST",
    data: data
  });
};

// 复制表单详情
export const copyFormDetail = (data) => {
  return request({
    url: `/api/itsm/ProcessForm/copyFormDetail`,
    method: "POST",
    data: data
  });
};


// 删除流程版本
export const deleteProcessByKey = (data) => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/deleteProcessByKey?key=${data.key}&version=${data.version}`,
    method: "DElETE",
    data: null
  });
};

// 获取ITSM规则数据
export const getProcessAdvanced = (data) => {
  return request({
    url: `/api/itsm/ProcessForm/getProcessAdvanced`,
    method: "POST",
    data: data
  });
};

// 保存规则数据
export const saveProcessAdvanced = (data) => {
  return request({
    url: `/api/itsm/ProcessForm/saveProcessAdvanced`,
    method: "POST",
    data: data
  });
};

// 获取我方保存的规则数据
export const getRuleByProcessDefKey = (data) => {
  return request({
    url: `/api/itsm/CloudOperationMaintenance/getRuleByProcessDefKey`,
    method: "GET",
    data: data
  });
};