import request from '@/config/axios'

export interface TaskManagementVO {
  id?: number
  name?: string
  taskType?: number
  deviceList?: string
  projectForm?: string
  startDate?: string
  endDate?: string
  cronExpression?: string
  operableUsers?: string
  enabled?: boolean
  execFrequency?: string
  frequencyValue?: string
  time?: string
  validMinutes?: number
  creator?: string
  createTime?: string
  updateTime?: string
}

export const TaskManagementApi = {
  getTaskManagementPage: async (params: any) => {
    return await request.get({ url: `/mes/mold-task-management/page`, params })
  },

  createTaskManagementTicket: async (id: number | string) => {
    return await request.post({ url: `/mes/mold-task-management/createMoldTicket`, params: { id } })
  },

  createTaskManagement: async (data: TaskManagementVO) => {
    return await request.post({ url: `/mes/mold-task-management/create`, data })
  },

  updateTaskManagement: async (data: TaskManagementVO) => {
    return await request.put({ url: `/mes/mold-task-management/update`, data })
  },

  deleteTaskManagement: async (ids: string) => {
    return await request.delete({ url: `/mes/mold-task-management/delete?ids=` + ids })
  },

  exportTaskManagement: async (params: any) => {
    return await request.download({ url: `/mes/mold-task-management/export-excel`, params })
  }
}
