import { request } from '@/api/_service'
import qs from 'qs'

const BASE = 'planning_production/wip/wip_management/'

function apiParams (method, data = {}) {
  return {
    method,
    platform: 'background',
    ...data
  }
}

function stringifyListParams (data = {}) {
  return qs.stringify(apiParams('planning_production_wip_wip_management_list', data), {
    arrayFormat: 'brackets',
    allowDots: true,
    encode: false
  })
}

export function getWipDataList (data) {
  return request({
    url: BASE + 'list?' + stringifyListParams(data),
    method: 'get',
    params: {}
  })
}

export function createWipData (data) {
  return request({
    url: BASE + 'create',
    method: 'post',
    data: apiParams('planning_production_wip_wip_management_create', data)
  })
}
