Log_bak.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.xApplication.process.Xform.Log_bak = MWF.APPLog = new Class({
  3. Extends: MWF.APP$Module,
  4. _loadUserInterface: function(){
  5. this.node.empty();
  6. this.node.setStyle("-webkit-user-select", "text");
  7. if (this.form.businessData){
  8. if (this.form.businessData.workLogList){
  9. this.workLog = this.form.businessData.workLogList;
  10. this.loadWorkLog();
  11. }
  12. }
  13. },
  14. loadWorkLog: function(){
  15. if (this.json.mode=="table"){
  16. this.loadWorkLogTable();
  17. }else if (this.json.mode=="text"){
  18. this.loadWorkLogText();
  19. }else{
  20. this.loadWorkLogDefault();
  21. }
  22. },
  23. loadWorkLogTable: function(){
  24. this.table = new Element("table", {
  25. "styles": this.form.css.logTable,
  26. "border": "0",
  27. "cellSpacing": "0",
  28. "cellpadding": "3px",
  29. "width": "100%"
  30. }).inject(this.node);
  31. this.workLog.each(function(log, idx){
  32. this.loadWorkLogLine_table(log, idx);
  33. }.bind(this));
  34. },
  35. loadWorkLogLine_table: function(log, idx){
  36. var tr = this.table.insertRow((this.table.rows) ? this.table.rows.length : 0).setStyles(this.form.css.logTableTr);
  37. var iconTd = tr.insertCell(0).setStyles(this.form.css.logTableIconTd);
  38. var activityTd = tr.insertCell(1).setStyles(this.form.css.logTableActivityTd);
  39. var taskTd = tr.insertCell(2).setStyles(this.form.css.logTableTaskTd);
  40. if (log.connected){
  41. iconTd.setStyle("background-image", "url("+"/x_component_process_Xform/$Form/"+this.form.options.style+"/icon/ok14.png)");
  42. }else{
  43. iconTd.setStyle("background-image", "url("+"/x_component_process_Xform/$Form/"+this.form.options.style+"/icon/rightRed.png)");
  44. }
  45. var avtivityNode = new Element("div", {"styles": this.form.css.logTableActivityNode}).inject(activityTd);
  46. //var fromAvtivityNode = new Element("div", {"styles": this.form.css.logTableActivityFromNode}).inject(tmpDiv);
  47. //var arrowNode = new Element("div", {"styles": this.form.css.logTableActivityArrowNode}).inject(tmpDiv);
  48. //var arrivedAvtivityNode = new Element("div", {"styles": this.form.css.logTableActivityArrivedNode}).inject(tmpDiv);
  49. var timeNode = new Element("div", {"styles": this.form.css.logTableActivityTimeNode}).inject(activityTd);
  50. if (log.arrivedActivityName){
  51. var html = "<b>"+log.fromActivityName+"</b> -> <b>"+log.arrivedActivityName+"</b>";
  52. avtivityNode.set("html", html);
  53. timeNode.set("html", "<b>"+MWF.xApplication.process.Xform.LP.begin+": </b>"+log.fromTime+"<br/><b>"+MWF.xApplication.process.Xform.LP.end+": </b>"+log.arrivedTime)
  54. }else{
  55. var html = "<b>"+log.fromActivityName+"</b>";
  56. avtivityNode.set("html", html);
  57. timeNode.set("html", "<b>"+MWF.xApplication.process.Xform.LP.begin+": </b>"+log.fromTime)
  58. }
  59. if (log.taskCompletedList.length || (this.json.isTask!="false" && log.taskList.length)){
  60. var taskTable = new Element("table", {
  61. "styles": this.form.css.logTableTask,
  62. "border": "0",
  63. "cellSpacing": "0",
  64. "cellpadding": "3px",
  65. "width": "100%"
  66. }).inject(taskTd);
  67. var tr = taskTable.insertRow(0).setStyles(this.form.css.logTableTaskTitleLine);
  68. var td = tr.insertCell(0).setStyles(this.form.css.logTableTaskTitle);
  69. td.set("text", MWF.xApplication.process.Xform.LP.person);
  70. td = tr.insertCell(1).setStyles(this.form.css.logTableTaskTitle);
  71. td.set("text", MWF.xApplication.process.Xform.LP.department);
  72. td = tr.insertCell(2).setStyles(this.form.css.logTableTaskTitle);
  73. td.set("text", MWF.xApplication.process.Xform.LP.startTime);
  74. td = tr.insertCell(3).setStyles(this.form.css.logTableTaskTitle);
  75. td.set("text", MWF.xApplication.process.Xform.LP.completedTime);
  76. td = tr.insertCell(4).setStyles(this.form.css.logTableTaskTitle);
  77. td.set("text", MWF.xApplication.process.Xform.LP.route);
  78. td = tr.insertCell(5).setStyles(this.form.css.logTableTaskTitle);
  79. td.set("text", MWF.xApplication.process.Xform.LP.opinion);
  80. log.taskCompletedList.each(function(taskCompleted){
  81. this.loadTaskLine_table(taskCompleted, taskTable, log, false);
  82. }.bind(this));
  83. if (this.json.isTask!="false"){
  84. log.taskList.each(function(task){
  85. this.loadTaskLine_table(task, taskTable, log, true);
  86. }.bind(this));
  87. }
  88. }
  89. },
  90. loadTaskLine_table: function(task, table, log, isTask){
  91. var style = "logTableTaskLine";
  92. if (isTask) style = "logTableTaskLine_task";
  93. var tr = table.insertRow(table.rows.length);
  94. var td = tr.insertCell(0).setStyles(this.form.css[style]);
  95. td.set("text", task.person || "");
  96. td = tr.insertCell(1).setStyles(this.form.css[style]);
  97. td.set("text", task.department || "");
  98. td = tr.insertCell(2).setStyles(this.form.css[style]);
  99. td.set("text", task.startTime || "");
  100. td = tr.insertCell(3).setStyles(this.form.css[style]);
  101. td.set("text", task.completedTime || "");
  102. td = tr.insertCell(4).setStyles(this.form.css[style]);
  103. td.set("text", task.routeName || "");
  104. td = tr.insertCell(5).setStyles(this.form.css[style]);
  105. td.set("text", task.opinion || "");
  106. },
  107. loadWorkLogText: function(){
  108. this.lineClass = "logTaskNode";
  109. this.workLog.each(function(log, idx){
  110. this.loadWorkLogLine_text(log, idx);
  111. }.bind(this));
  112. },
  113. loadWorkLogLine_text: function(log, idx){
  114. log.taskCompletedList.each(function(taskCompleted){
  115. this.loadTaskLine_text(taskCompleted, this.node, log, false);
  116. }.bind(this));
  117. if (this.json.isTask!="false"){
  118. log.taskList.each(function(task){
  119. this.loadTaskLine_text(task, this.node, log, true);
  120. }.bind(this));
  121. }
  122. },
  123. loadTaskLine_text: function(task, node, log, isTask){
  124. this.loadTaskLine_default(task, node, log, isTask, "0px", true);
  125. },
  126. loadWorkLogDefault: function(){
  127. //var text = this.json.textStyle;
  128. this.workLog.each(function(log, idx){
  129. this.loadWorkLogLine_default(log, idx);
  130. }.bind(this));
  131. },
  132. loadWorkLogLine_default: function(log, idx){
  133. var logActivityNode = new Element("div", {"styles": this.form.css.logActivityNode}).inject(this.node);
  134. var titleNode = new Element("div", {"styles": this.form.css.logActivityTitleNode}).inject(logActivityNode);
  135. var childNode = new Element("div", {"styles": this.form.css.logActivityChildNode}).inject(logActivityNode);
  136. var iconNode = new Element("div", {"styles": this.form.css.logActivityIconNode}).inject(titleNode);
  137. var fromAvtivityNode = new Element("div", {"styles": this.form.css.logActivityFromNode}).inject(titleNode);
  138. var arrowNode = new Element("div", {"styles": this.form.css.logActivityArrowNode}).inject(titleNode);
  139. var arrivedAvtivityNode = new Element("div", {"styles": this.form.css.logActivityArrivedNode}).inject(titleNode);
  140. var timeNode = new Element("div", {"styles": this.form.css.logActivityTimeNode}).inject(titleNode);
  141. if (log.connected){
  142. iconNode.setStyle("background-image", "url("+"/x_component_process_Xform/$Form/"+this.form.options.style+"/icon/ok14.png)");
  143. }else{
  144. iconNode.setStyle("background-image", "url("+"/x_component_process_Xform/$Form/"+this.form.options.style+"/icon/rightRed.png)");
  145. }
  146. fromAvtivityNode.set("html", "<b>"+log.fromActivityName+"</b>");
  147. if (log.arrivedActivityName){
  148. arrowNode.setStyle("background-image", "url("+"/x_component_process_Xform/$Form/"+this.form.options.style+"/icon/right.png)");
  149. arrivedAvtivityNode.set("html", "<b>"+log.arrivedActivityName+"</b>");
  150. timeNode.set("html", "<b>"+MWF.xApplication.process.Xform.LP.begin+": </b>"+log.fromTime+"<br/><b>"+MWF.xApplication.process.Xform.LP.end+": </b>"+log.arrivedTime)
  151. }else{
  152. timeNode.set("html", "<b>"+MWF.xApplication.process.Xform.LP.begin+": </b>"+log.fromTime)
  153. }
  154. if ((idx % 2)==0){
  155. logActivityNode.setStyles(this.form.css.logActivityNode_even);
  156. titleNode.setStyles(this.form.css.logActivityTitleNode_even);
  157. }
  158. log.taskCompletedList.each(function(taskCompleted){
  159. this.loadTaskLine_default(taskCompleted, childNode, log, false);
  160. }.bind(this));
  161. if (this.json.isTask!="false"){
  162. log.taskList.each(function(task){
  163. this.loadTaskLine_default(task, childNode, log, true);
  164. }.bind(this));
  165. }
  166. },
  167. loadTaskLine_default: function(task, node, log, isTask, margin, isZebra){
  168. var logTaskNode = new Element("div", {"styles": this.form.css.logTaskNode}).inject(node);
  169. var iconNode = new Element("div", {"styles": this.form.css.logTaskIconNode}).inject(logTaskNode);
  170. var textNode = new Element("div", {"styles": this.form.css.logTaskTextNode}).inject(logTaskNode);
  171. if (isZebra){
  172. logTaskNode.setStyles(this.form.css[this.lineClass]);
  173. if (this.lineClass == "logTaskNode"){
  174. this.lineClass = "logTaskNode_even";
  175. }else{
  176. this.lineClass = "logTaskNode";
  177. }
  178. }
  179. if (margin) iconNode.setStyle("margin-left", margin);
  180. var left = iconNode.getStyle("margin-left").toInt();
  181. left = left + 28;
  182. textNode.setStyle("margin-left", ""+left+"px");
  183. //this.textStyle
  184. if (!isTask){
  185. var html = this.json.textStyle;
  186. html = html.replace(/\{person\}/g, task.person);
  187. html = html.replace(/\{department\}/g, task.department);
  188. html = html.replace(/\{route\}/g, task.routeName);
  189. html = html.replace(/\{time\}/g, task.completedTime);
  190. html = html.replace(/\{opinion\}/g, task.opinion);
  191. html = html.replace(/\{company\}/g, task.company);
  192. html = html.replace(/\{startTime\}/g, task.startTime);
  193. html = html.replace(/\{activity\}/g, log.fromActivityName);
  194. html = html.replace(/\{arrivedActivity\}/g, task.arrivedActivityName);
  195. //var html = MWF.xApplication.process.Xform.LP.nextUser + task.person+"("+task.department+")" +", "+
  196. // MWF.xApplication.process.Xform.LP.selectRoute + ": [" + task.routeName + "], " +
  197. // MWF.xApplication.process.Xform.LP.submitAt + ": " + task.completedTime+ ", " +
  198. // MWF.xApplication.process.Xform.LP.idea + ": <font style=\"color: #00F\">" + (task.opinion || "")+"</font>";
  199. textNode.set("html", html);
  200. }else{
  201. var html = task.person+"("+task.department+")" + MWF.xApplication.process.Xform.LP.processing+", "+
  202. MWF.xApplication.process.Xform.LP.comeTime + ": " + task.startTime;
  203. textNode.set("html", html);
  204. iconNode.setStyle("background-image", "url("+"/x_component_process_Xform/$Form/"+this.form.options.style+"/icon/rightRed.png)");
  205. }
  206. }
  207. });