compilation_config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Zhong
  6. * @date 2019/8/14
  7. * @version
  8. */
  9. /*
  10. * 不同运行环境下(CommonJS、浏览器)的费用定额功能模块配置
  11. * 如果运行环境使用了CommonJS,通过module.exports工厂函数返回内容
  12. * 否则将工厂函数返回内容挂载在浏览器宿主对象
  13. * @param {Object}root 浏览器宿主对象
  14. * {String}overWriteUrl 费用定额重写路径(eg:/web/over_write/js/chongqing_2018.js)
  15. * {Function}factory 工厂函数
  16. * @return {Object}
  17. * */
  18. (function (root, overWriteUrl, factory) {
  19. if (typeof module !== 'undefined') {
  20. module.exports = factory(overWriteUrl);
  21. } else {
  22. root._compilationConfig = factory(overWriteUrl);
  23. }
  24. }(window, overWriteUrl, function (url) {
  25. if (!url) {
  26. return {};
  27. }
  28. const COMPILATION_MAP = {
  29. chongqing_2018: 1,
  30. neimenggu_2017: 2,
  31. jiangxi_2017: 3,
  32. guangdong_2018: 4,
  33. gansu_2013: 5
  34. };
  35. // 费用定额定制需求配置
  36. let config = {
  37. // 定额工作内容列可下拉选择(0关闭、1开启)(广东)
  38. dynamicRationWorkContent: 0
  39. };
  40. // 提取重写路径中的关键信息 eg: chongqing_2018
  41. let compilation = url.split('/').pop().slice(0, -3),
  42. compilationNum = COMPILATION_MAP[compilation];
  43. if (!compilationNum) {
  44. return {};
  45. }
  46. // 广东18
  47. if (compilationNum === COMPILATION_MAP.guangdong_2018) {
  48. config.dynamicRationWorkContent = 1;
  49. }
  50. return config;
  51. }));