printWork.js 7.7 KB

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