import request from '@/utils/request';
export default {
  //列表
  list: async function (params) {
    const res = await request.post('/strip/manage/list', params);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  getByCode: async function (code) {
    const res = await request.get(`/system/dict/getByCode/${code}`, {});
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //详情
  info: async function (params) {
    const res = await request.get('/strip/manage/info', params);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //选择条码类型获取条码信息列表
  getDictionary: async function (params) {
    const res = await request.get('/pub/dictionary/getItems', params);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  getBarModeList: async function (dictBarCode) {
    const res = await request.get('/bar/manage/getBarModeList/' + dictBarCode);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //保存old -- 废弃
  save: async function (params) {
    const res = await request.post('/strip/manage/save', params);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //删除
  delete: async function (params) {
    const res = await request.get('/strip/manage/delete', params);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },

  //列表new
  getPageList: async function (params) {
    const res = await request.post('/bar/manage/getPage', params);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //保存new
  saveBarcode: async function (params) {
    const res = await request.post('/bar/manage/saveOrEdit', params);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //删除new
  deleteApi: async function (barId) {
    const res = await request.get('/bar/manage/delete/' + barId);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //详情new
  infoApi: async function (barId) {
    const res = await request.get('/bar/manage/detail/' + barId);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 批量打印
  batchBarPrint: async function (params) {
    const res = await request.post('/main/print/batchBarPrint', params);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
};
