import { request } from 'umi';

export function queryMfrList(data) {
  return request('/api/supplier/v1/supplier/list', {
    method: 'POST',
    data,
  });
};

export async function queryCreaterList() {
  let res = await request('/api/supplier/v1/supplier-name/list', {
    method: 'POST',
  });
  var obj = {};
  res.data.list = res.data.list.reduce(function (item, next) {
    obj[next.created_by] ? '' : obj[next.created_by] = true && item.push(next);
    return item;
  }, []);
  console.log(res)
  res.data.list = res?.data?.list.map(item => {
    return { value: item.created_by, label: item.created_by }
  })
  return res;
};
export function editMfr(data) {
  return request('/api/supplier/v1/supplier/edit', {
    method: 'POST',
    data,
  });
};
export function deleteMfr(data) {
  return request('/api/supplier/v1/supplier/del', {
    method: 'POST',
    data,
  });
};
export function saveMfr(data) {
  return request('/api/supplier/v1/supplier/save', {
    method: 'POST',
    data,
  });
};