import request from '@/utils/request'

/** 金蝶生产单据整合（BOM 主轴，需令号） */
export function queryMaterialDocHub(sclh) {
  return request({
    url: '/system/kingdee/materialDocHub/query',
    method: 'get',
    params: { sclh },
    timeout: 300000
  })
}

/** 工序计划看板分页（令号可选） */
export function queryMaterialDocHubBoardPage(params) {
  return request({
    url: '/system/kingdee/materialDocHub/board/page',
    method: 'get',
    params,
    timeout: 120000
  })
}

/** 展开工单：仅工序计划 */
export function queryMaterialDocHubBoardDetail(moBillNo, materialNumber) {
  return request({
    url: '/system/kingdee/materialDocHub/board/detail',
    method: 'get',
    params: { moBillNo, materialNumber },
    timeout: 60000
  })
}

/** 按需：工序汇报 */
export function queryMaterialDocHubReports(moBillNo, materialNumber, operNumber) {
  const params = { moBillNo }
  if (materialNumber) params.materialNumber = materialNumber
  if (operNumber != null && operNumber !== '') params.operNumber = operNumber
  return request({
    url: '/system/kingdee/materialDocHub/board/reports',
    method: 'get',
    params,
    timeout: 120000
  })
}

/** 按需：入库点质检与入库 */
export function queryMaterialDocHubInstockQc(moBillNo, materialNumber, operNumber) {
  const params = { moBillNo }
  if (materialNumber) params.materialNumber = materialNumber
  if (operNumber != null && operNumber !== '') params.operNumber = operNumber
  return request({
    url: '/system/kingdee/materialDocHub/board/instockQc',
    method: 'get',
    params,
    timeout: 120000
  })
}

/** 按需：委外 C/G */
export function queryMaterialDocHubSubcontract(moBillNo) {
  return request({
    url: '/system/kingdee/materialDocHub/board/subcontract',
    method: 'get',
    params: { moBillNo },
    timeout: 60000
  })
}
