import request from '@/config/axios'

export interface  sopExecutionPlanSaveReqVO{
  id:number,
  sopId:number,
  frequencyUnit:number,
  frequency:number,
  timePoint:number,
  startTime?:string,
  endType?:string,
  endValue?:string,
  duration?:string,
  nonWorkDay?:number,
  nonWorkMoveDay?:number,
}

export interface PageParam {
  pageNo: number
  pageSize: number
  sopId?: number
  status?: number
  frequencyUnit?: number
  frequency?: number,
}


//创建sop计划
export const insertSopExecutionPlan=async(data:sopExecutionPlanSaveReqVO)=>{
  return await request.post({url:'/iscs/sop-execution-plan/insertSopExecutionPlan',data})
}

//修改sop计划
export const updateSopExecutionPlan=async(data:sopExecutionPlanSaveReqVO)=>{
  return await request.put({url:'/iscs/sop-execution-plan/updateSopExecutionPlan',data})
}

//获得sop计划执行分页
export const getSopExecutionPlanPage=async(params:PageParam)=>{
  return await request.get({url:'/iscs/sop-execution-plan/getSopExecutionPlanPage',params})
}

//获得sop计划执行
// export const selectSopExecutionPlanById=async(id:number)=>{
//   return await request.get({url:'/iscs/sop-execution-plan/selectSopExecutionPlanById',params:{id:id} })
// }
export const selectSopExecutionPlanBySopId=async(sopId:number)=>{
  return await request.get({url:'/iscs/sop-execution-plan/selectSopExecutionPlanBySopId',params:{sopId:sopId} })
}

// 批量删除sop计划执行
export const deleteSopExecutionPlanList=async(ids:number)=>{
  return await request.delete({url:'/iscs/sop-execution-plan/deleteSopExecutionPlanList='+ids})
}


//根据sopId获取未执行的作业
export const getNotStartJobBySopId=async(sopId:number)=>{
  return await request.get({url:'/iscs/job-ticket/getNotStartJobBySopId?sopId='+sopId})
}
