export-excel-service.js 835 Bytes
'use strict';

const _ = require('lodash');
const Context = require('../framework/context');
const Api = require('../common/api');
const config = global.yoho.config;
class ExportExcelService extends Context {
  constructor() {
    super();
    this.api = this.instance(Api);
  }
  //获取要导出的数据
  getExportData(apiUrl, params) {
    const apiArr = _.split(apiUrl, '/');
    const platform = apiArr[1];
    const method = apiArr[2];
    return this.api
      .post(config.apiDomain[platform][method], params)
      .then(res => {
        if (res.code !== 200) {
          return Promise.reject({ code: 500, message: res.message });
        }
        return res.data;
      })
      .catch(error => {
        return Promise.reject({ code: 400, message: error.message });
      });
  }
}
module.exports = ExportExcelService;