import request from '@/config/axios'

export interface DashboardProductVO {
	taskItems: ItemVO[]
	planItems: ItemVO[]
}

export interface ItemVO {
	key: string
	label: string
	value: number
}

export interface DeviceStatusVO {
	key: string
	label: string
	value: number
	level: string
}

export interface TaskStatisticsData {
	deviceInspection: number
	deviceInspectionProportion: string
	moldInspection: number
	moldInspectionProportion: string
	deviceMaintenance: number
	deviceMaintenanceProportion: string
	moldMaintenance: number
	moldMaintenanceProportion: string
	deviceRepair: number
	deviceRepairProportion: string
	moldRepair: number
	moldRepairProportion: string
}

export interface TaskStatisticsResponse {
	code: number
	status: number
	data: TaskStatisticsData
	msg: string
}

export interface DashboardTaskItem {
	code: string
	name: string
	type: string
	finishStatus: string
	resultStatus: number
}

export interface DashboardTaskListResponse {
	code: number
	status: number
	data: DashboardTaskItem[]
	msg: string
}

// 编码生成记录 API
export const DashboardApi = {
  // 查询编码生成记录分页
  getProduction: async (params: any) => {
    return await request.get({ url: `/mes/dashboard/getProduction`, params })
  },
getPlan: async () => {
    return await request.get({ url: `/mes/dashboard/getPlan` })
  },
  getDevice: async () => {
    return await request.get({ url: `/mes/dashboard/getDevice` })
  },
  getMold: async () => {
    return await request.get({ url: `/mes/dashboard/getMold` })
  },
  getTodoList: async () => {
    return await request.get({ url: `/mes/dashboard/getTodoList` })
  },
  getDeviceOperationalStatus: async (params?: any) => {
    return await request.get({ url: `/iot/device/getDeviceOperationalStatus`, params })
  },
  getDeviceRepairLineOptions: async () => {
    return await request.get({ url: `/mes/dashboard/getDeviceRepairLineOptions` })
  },
getDeviceTypePieOptions: async () => {
    return await request.get({ url: `/mes/dashboard/getDeviceTypePieOptions` })
  },
  getMoldTypeBarOptions: async () => {
    return await request.get({ url: `/mes/dashboard/getMoldTypeBarOptions` })
  },
  getTaskStatistics: async (params?: any) => {
    return await request.get<TaskStatisticsResponse>({ url: `/mes/dashboard/getTaskStatistics`, params })
  },
  getAllTaskList: async (params?: any) => {
    return await request.get<DashboardTaskListResponse>({ url: `/mes/dashboard/getAllTaskList`, params })
  }
}

