work.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. layout.addReady(function(){
  2. (function(layout){
  3. var uri = new URI(window.location.href);
  4. var options = uri.get("data");
  5. var appNames = "process.Work";
  6. var statusObj = null;
  7. var _load = function(){
  8. // layout.message = new MWF.xDesktop.MessageMobile();
  9. // layout.message.load();
  10. layout.apps = [];
  11. //layout.node = $("layout");
  12. layout.node = $("layout") || $("appContent") || document.body;
  13. var appName=appNames, m_status=statusObj, option=options;
  14. var topWindow = window.opener;
  15. if (topWindow){
  16. try{
  17. if (!appName) appName = topWindow.layout.desktop.openBrowserApp;
  18. if (!m_status) m_status = topWindow.layout.desktop.openBrowserStatus;
  19. if (!option) option = topWindow.layout.desktop.openBrowserOption;
  20. }catch(e){}
  21. }
  22. if (options.job && !options.workid && !options.draftid && !options.draft){
  23. var workData = null;
  24. o2.Actions.get("x_processplatform_assemble_surface").listWorkByJob(options.job, function(json){
  25. if (json.data) workData = json.data;
  26. }.bind(this), null, false);
  27. if (workData){
  28. var len = workData.workList.length + workData.workCompletedList.length;
  29. if (len){
  30. if (len>1 && options.choice){
  31. layout.node.empty();
  32. layout.node.setStyle("background", "#f1f1f1");
  33. var node = new Element("div", {
  34. "styles": {"font-size": "18px", "text-align": "center", "font-weight": "bold", "margin": "auto", "height": "30px", "width": "90%", "max-width": "600px", "padding": "40px 0px 20px 20px"},
  35. "text": o2.LP.widget.choiceWork
  36. }).inject(layout.node);
  37. var node = new Element("div", {"styles": {"margin": "auto", "padding": "0px 20px", "width": "90%", "max-width": "600px"}}).inject(layout.node);
  38. workData.workList.each(function(work){
  39. var workNode = new Element("div", {
  40. "styles": {
  41. "background": "#ffffff",
  42. "border-radius": "10px",
  43. "clear": "both",
  44. "margin-bottom": "10px",
  45. "height": "40px",
  46. "padding": "10px 10px"
  47. }
  48. }).inject(node);
  49. var html = "<div style='height: 40px; width: 40px; float: left; background: url(../x_component_process_Xform/$Form/default/icon/work.png) no-repeat center center'></div>" +
  50. "<div style='height: 40px; width: 40px; float: right'><div class='MWFAction' style='height: 20px; width: 40px; margin-top: 10px; border: 1px solid #999999; border-radius: 5px;text-align: center; cursor: pointer'>"+o2.LP.widget.open+"</div></div>"+
  51. "<div style='height: 20px; line-height: 20px; margin: 0px 40px; overflow: hidden'>"+work.title+"</div>" +
  52. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>"+work.activityName+"</div>" +
  53. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.activityArrivedTime+"</div>" +
  54. "<div style='color:#999999; float: left; margin-right: 10px'>"+(work.manualTaskIdentityText || "")+"</div></div>";
  55. workNode.set("html", html);
  56. var action = workNode.getElement(".MWFAction");
  57. action.store("work", work);
  58. action.addEvent("click", function(e){
  59. var work = e.target.retrieve("work");
  60. options.workId = work.id;
  61. layout.node.empty();
  62. layout.openApplication(null, appName, option||{}, m_status);
  63. //if (work) this.openWork(work.id, null, work.title, options);
  64. }.bind(this));
  65. }.bind(this));
  66. workData.workCompletedList.each(function(work){
  67. var workNode = new Element("div", {
  68. "styles": {
  69. "background": "#ffffff",
  70. "border-radius": "10px",
  71. "clear": "both",
  72. "margin-bottom": "10px",
  73. "height": "40px",
  74. "padding": "10px 10px"
  75. }
  76. }).inject(node);
  77. var html = "<div style='height: 40px; width: 40px; float: left; background: url(../x_component_process_Xform/$Form/default/icon/work.png) no-repeat center center'></div>" +
  78. "<div style='height: 40px; width: 40px; float: right'><div class='MWFAction' style='height: 20px; width: 40px; margin-top: 10px; border: 1px solid #999999; border-radius: 5px;text-align: center; cursor: pointer'>"+o2.LP.widget.open+"</div></div>"+
  79. "<div style='height: 20px; line-height: 20px; margin: 0px 40px'>"+work.title+"</div>" +
  80. "<div style='margin: 0px 40px'><div style='color:#999999; float: left; margin-right: 10px'>+o2.LP.widget.workcompleted+</div>" +
  81. "<div style='color:#999999; float: left; margin-right: 10px'>"+work.completedTime+"</div>";
  82. workNode.set("html", html);
  83. var action = workNode.getElement(".MWFAction");
  84. action.store("work", work);
  85. action.addEvent("click", function(e){
  86. var work = e.target.retrieve("work");
  87. options.workCompletedId = work.id;
  88. layout.node.empty();
  89. layout.openApplication(null, appName, option||{}, m_status);
  90. }.bind(this));
  91. }.bind(this));
  92. }else{
  93. if (workData.workList.length){
  94. options.workId = workData.workList[0].id;
  95. }else{
  96. options.workCompletedId = workData.workCompletedList[0].id;
  97. }
  98. layout.openApplication(null, appName, option||{}, m_status);
  99. }
  100. }else{
  101. if (options.draft) options.draft = JSON.parse(options.draft);
  102. layout.openApplication(null, appName, option||{}, m_status);
  103. }
  104. }
  105. }else{
  106. if (options.draft) options.draft = JSON.parse(options.draft);
  107. layout.openApplication(null, appName, option||{}, m_status);
  108. }
  109. if (layout.session.user.name === "anonymous"){
  110. o2.loadCss("../o2_core/o2/xDesktop/$Default/blue/style-skin.css");
  111. }else{
  112. o2.xDesktop.getUserLayout(function(){
  113. var style = layout.userLayout.flatStyle;
  114. o2.loadCss("../o2_core/o2/xDesktop/$Default/"+style+"/style-skin.css");
  115. });
  116. }
  117. };
  118. if (layout.session && layout.session.user){
  119. _load();
  120. }else{
  121. if (layout.sessionPromise){
  122. layout.sessionPromise.then(function(){
  123. _load();
  124. },function(){});
  125. }
  126. }
  127. // _load();
  128. })(layout);
  129. });