import request from '@/config/axios'

export interface notifyConfigSaveReqVO {
  id: number
  sopId: number
  rule: string
  type: number
  notifyTimeType: number
  notifyTime: number
  workstationId: number
  status: number
  notifyConfigDetailSaveReqVOS: [
    id: number,
    roleId: number,
    configId: number,
    status: number,
    isClient: number,
    notifyTemplateId: number
  ]
}

export interface PageParam {
  pageNo: number
  pageSize: number
  id?: number
  sopId?: number
}

export interface notifyConfigDetailDOs {
  id: number
  roleId: number
  configId: number
  status: number
  isClient: number
  notifyTemplateId: number
}

//创建通知规则
export const insertNotifyConfig = async (data: notifyConfigSaveReqVO) => {
  return await request.post({ url: '/iscs/notify-config/insertNotifyConfig', data })
}

//修改通知规则
export const updateNotifyConfig = async (data: notifyConfigSaveReqVO) => {
  return await request.put({ url: '/iscs/notify-config/updateNotifyConfig', data })
}

//获得通知规则分页
export const getNotifyConfigPage = async (params: PageParam) => {
  return await request.get({ url: '/iscs/notify-config/getNotifyConfigPage', params })
}

//批量删除通知规则
export const deleteNotifyConfigList = async (ids: number) => {
  return await request.delete({ url: '/iscs/notify-config/deleteNotifyConfigList?ids=' + ids })
}

//获得通知规则
export const selectNotifyConfigById = async (id: number) => {
  return await request.get({ url: '/iscs/notify-config/selectNotifyConfigById',  params: { id: id } })
}

//获得工作流程list
export const getSopWorkflowStepList = async (sopId: number) => {
  return await request.get({ url: '/iscs/sop-workflow-step/getSopWorkflowStepList?sopId=' + sopId })
}

//获得通知规则角色和模板设置关联分页
export const getNotifyConfigDetailPage = async (params: PageParam) => {
  return await request.get({ url: '/iscs/notify-config-detail/getNotifyConfigDetailPage', params })
}

//创建或修改通知规则角色和模板设置关联
export const insertOrUpdateList = async (data: notifyConfigDetailDOs) => {
  return await request.post({ url: '/iscs/notify-config-detail/insertOrUpdateList', data })
}
