import request from '@/config/axios'

// 物资检查计划查询参数
export interface PlanQuery {
  current: number
  size: number
  planName?: string
  planStatus?: number
  startTime?: Date
  endTime?: Date
}

// 物资检查计划表单对象
export interface PlanVO {
  planId?: number
  planName: string
  planStatus: number
  startTime: Date
  endTime: Date
  checkCycle: number
  checkCycleUnit: string
  remark?: string
  createTime?: Date
}

// 自动配置参数
export interface AutoConfigVO {
  configCode: string
  configValue: string
  configName: string
  configType: number
  status: number
}

// 查询物资检查计划列表
export const listPlan = async (params: PlanQuery) => {
  return await request.get({ url: '/iscs/materials-check-plan/getMaterialsCheckPlanPage', params })
}

// 查询物资检查计划详情
export const getPlanInfo = async (id: number) => {
  return await request.get({
    url: '/iscs/materials-check-plan/selectMaterialsCheckPlanById',
    params: { id: id }
  })
}

// 新增物资检查计划
export const addPlan = async (data: PlanVO) => {
  return await request.post({ url: '/iscs/materials-check-plan/insertMaterialsCheckPlan', data })
}

// 修改物资检查计划
export const updatePlan = async (data: PlanVO) => {
  return await request.put({ url: '/iscs/materials-check-plan/updateMaterialsCheckPlan', data })
}

// 删除物资检查计划
export const deletePlan = async (ids: number) => {
  return await request.delete({
    url: '/iscs/materials-check-plan/deleteMaterialsCheckPlanList?ids='+ids,
  })
}

// 查询检查计划物资柜列表
export const getCheckPlanCabinetList = async (params: PlanQuery) => {
  return await request.get({ url: '/iscs/materials-plan-cabinet/getMaterialsPlanCabinetPage', params })
}

// 更新自动创建检查计划配置(接口在邮件提醒周期配置里)
export const updateAutomaticConfig = async (data: AutoConfigVO) => {
  return await request.post({ url: '/iscs/mail-notify-config/updateAutomaticConfig', data })
}

// 查询自动创建检查计划配置
export const selectIsMailNotifyConfigByCode = async (params: { configCode: string }) => {
  return await request.get({
    url: '/iscs/mail-notify-config/selectMailNotifyConfigByCode',
    params
  })
}
