factory.js 1.0 KB

123456789101112131415161718192021222324252627
  1. starter.factory('Comp', function ($resource, $q, $filter, cfg, formatFilter, global) {
  2. global.erp_api = "http://192.168.1.36:13210/api/";
  3. return {
  4. sn: $resource(formatFilter('{0}erp/comp/', cfg.api)),
  5. comp: function (actionname) {
  6. return $resource(formatFilter('{0}ext_erp/Comp/{1}', cfg.api, actionname == undefined ? "" : actionname))
  7. },
  8. dept: function (actionname) {
  9. return $resource(formatFilter('{0}ext_erp/Dept/{1}', cfg.api, actionname == undefined ? "" : actionname))
  10. }
  11. };
  12. })
  13. .config(function ($httpProvider) {
  14. $httpProvider.interceptors.push(function ($q, cfg, global) {
  15. return {
  16. 'request': function (config) {
  17. if (config.url.indexOf("ext_erp") != -1) {
  18. config.headers['cid'] = JSON.stringify({"linkid": global.user.compno, "langid": "TW", "phone": global.user.cellphone});
  19. config.headers['sn'] = global.sn;
  20. }
  21. return config;
  22. }
  23. };
  24. });
  25. })