import { creatRequest } from '../../utils/request.js';

const requestList = {
  // 新增受访对象
  addInvestigationUser: {
    method: 'POST',
    url: 'checkTask/saveInvestigationUser'
  },
  // 编辑受访对象
  editInvestigationUser: {
    method: 'POST',
    url: 'checkTask/editInvestigationUsers'
  },
  // 删除受访对象
  delInvestigationUser: {
    method: 'POST',
    url: 'checkTask/delInvestigationUsers'
  },
  // 获取模板对象
  getTemplateData: {
    method: 'GET',
    url: 'situation/getPageTemplateContent'
  }
};

export const commServer = (key, data) => {
  let obj = requestList[key];
  if(key == 'delInvestigationUser'){
	  const {checkId,investigationId} = data;
	  return creatRequest({
		  ...obj,
		  url: `checkTask/delInvestigationUsers?checkId=${checkId}&investigationId=${investigationId}`
	  });
  }
  
  if(key == 'getTemplateData'){
  	  const {pageTemplateId} = data;
  	  return creatRequest({
  		  ...obj,
  		  url: `situation/getPageTemplateContent?pageTemplateId=${pageTemplateId}`
  	  });
  }
  
  return creatRequest(obj, data);
}