zlExpressEditor.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * 加载表达式所需依赖
  3. * @author hjh
  4. */
  5. (function () {
  6. //依赖检查
  7. if (typeof jQuery === 'undefined') {
  8. console.error('错误:此组件需要jQuery,但是jQuery没有被加载。');
  9. }
  10. /**判断当前页面是否是HRS运行界面 */
  11. function IsRunningPage() {
  12. let win = window;
  13. do {
  14. if (win.HrsPage != null) {
  15. return true;
  16. } else {
  17. win = win.parent;
  18. }
  19. } while (win !== window.top);
  20. return false;
  21. }
  22. /**
  23. * 加载所需的依赖
  24. * */
  25. function LoadDependency(basePath) {
  26. //引入自身的依赖
  27. Import(basePath + "css/ExpressEditor.css", true);
  28. if (!IsRunningPage() || (typeof g_needLoadzlExpressEditor != 'undefined' && g_needLoadzlExpressEditor == true)) {
  29. Import(basePath + "monaco-editor/min/vs/loader.min.js");
  30. }
  31. Import(basePath + "js/EnvironmentHelper.js");
  32. Import(basePath + "js/ExpressExecutor.js");
  33. Import(basePath + "singleRowModel/SingleRowEditor.js");
  34. }
  35. /**
  36. * 导入JS
  37. * @param {any} url
  38. */
  39. function Import(url, isCss) {
  40. $.ajax({
  41. type: "GET",
  42. url: url,
  43. async: false,
  44. success: (res) => {
  45. if (isCss) {
  46. let $style = $(`<style type="text/css">${res}</style>`);
  47. $("head").append($style);
  48. }
  49. }
  50. });
  51. }
  52. //加载依赖
  53. LoadDependency("/lib/zlExpressEditor/");
  54. })();