import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 定制-上能石化-产品质检信息 */
export interface Quality {
  id: number; // 主键ID
  canLabel: string; // 罐标
  productName: string; // 产品名称
  productSpec: string; // 产品规格
  inspector: string; // 质检员
  inspectionDate: string | Dayjs; // 质检日期
  qualifiedStatus: boolean; // 合格状态
  inspectionType: number; // 质检类型(枚举)
  inspectionData: string; // 质检数据(JSON格式)
}

// 定制-上能石化-产品质检 API
export const QualityApi = {
  // 查询定制-上能石化-产品质检分页
  getQualityPage: async (params: any) => {
    return await request.get({ url: `/iot/quality/page`, params })
  },

  // 查询定制-上能石化-产品质检详情
  getQuality: async (id: number) => {
    return await request.get({ url: `/iot/quality/get?id=` + id })
  },

  // 新增定制-上能石化-产品质检
  createQuality: async (data: Quality) => {
    return await request.post({ url: `/iot/quality/create`, data })
  },

  // 修改定制-上能石化-产品质检
  updateQuality: async (data: Quality) => {
    return await request.put({ url: `/iot/quality/update`, data })
  },

  // 删除定制-上能石化-产品质检
  deleteQuality: async (id: number) => {
    return await request.delete({ url: `/iot/quality/delete?id=` + id })
  },

  /** 批量删除定制-上能石化-产品质检 */
  deleteQualityList: async (ids: number[]) => {
    return await request.delete({ url: `/iot/quality/delete-list?ids=${ids.join(',')}` })
  },

  // 导出定制-上能石化-产品质检 Excel
  exportQuality: async (params) => {
    return await request.download({ url: `/iot/quality/export-excel`, params })
  }
}
