import request from '@/config/axios'

// 质量通知单 VO
export interface QualityNoticeVO {
  id: number // 主键ID
  inspectionNo: string // 送检单号
  batchNo: string // 批次号
  materialCode: string // 物料编码
  inspectionQuantity: number // 检验批数量
  unqualifiedReason: string // 不合格原因
  materialUseDepartment: string // 物料使用部门
  attachmentInfo: string // 附件信息
  unqualifiedDescription: string // 不合格描述
  purchaseOrderNo: string // 采购订单号
  supplierName: string // 供应商名称
  supplierCode: string // 供应商编码
  unqualifiedQuantity: number // 不合格数量
  problemSourceType: string // 问题来源类型
  limitProcessingTime: Date // 限制处理时间
  isSupplierObjectionAccepted: number // 供方异议是否接收:0-未接收;1-已接收
  supplierObjectionRemark: string // 供方异议备注
  measures: any
}

// 质量通知单 API
export const QualityNoticeApi = {
  // 查询质量通知单分页
  getQualityNoticePage: async (params: any) => {
    return await request.get({ url: `/contract/quality-notice/page`, params })
  },

  // 查询质量通知单详情
  getQualityNotice: async (id: number) => {
    return await request.get({ url: `/contract/quality-notice/get?id=` + id })
  },

  // 新增质量通知单
  createQualityNotice: async (data: QualityNoticeVO) => {
    return await request.post({ url: `/contract/quality-notice/create`, data })
  },

  // 修改质量通知单
  updateQualityNotice: async (data: QualityNoticeVO) => {
    return await request.put({ url: `/contract/quality-notice/update`, data })
  },

  // 删除质量通知单
  deleteQualityNotice: async (id: number) => {
    return await request.delete({ url: `/contract/quality-notice/delete?id=` + id })
  },
  // 删除质量通知单
  deleteQualityNoticeList: async (ids: number[]) => {
    return await request.delete({ url: `/contract/quality-notice/delete-list?id=`, params: { ids: ids.join(',') } })
  },

  // 导出质量通知单 Excel
  exportQualityNotice: async (params) => {
    return await request.download({ url: `/contract/quality-notice/export-excel`, params })
  }
}
