Log.js 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. /** @class Log 流程记录组件。
  3. * @example
  4. * //可以在脚本中获取该组件
  5. * //方法1:
  6. * var log = this.form.get("name"); //获取组件
  7. * //方法2
  8. * var log = this.target; //在组件事件脚本中获取
  9. * @extends MWF.xApplication.process.Xform.$Module
  10. * @o2category FormComponents
  11. * @o2range {Process}
  12. * @hideconstructor
  13. */
  14. MWF.xApplication.process.Xform.Log = MWF.APPLog = new Class(
  15. /** @lends MWF.xApplication.process.Xform.Log# */
  16. {
  17. Extends: MWF.APP$Module,
  18. options: {
  19. /**
  20. * 加载数据后事件。
  21. * @event MWF.xApplication.process.Xform.Log#postLoadData
  22. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  23. * @example
  24. * //触发该事件的时候可以获取到流程数据workLog
  25. * var workLog = this.target.workLog;
  26. * //可以修改workLog达到定制化流程记录的效果
  27. * do something
  28. */
  29. /**
  30. * 加载每行流程信息以后触发,可以通过this.event获得下列信息:
  31. * <pre><code>
  32. {
  33. "data" : {}, //当前行流程信息
  34. "node" : logTaskNode, //当前节点
  35. "log" : object, //指向流程记录
  36. "type" : "task" //"task"表示待办,"taskCompleted"表示已办
  37. }
  38. </code></pre>
  39. * @event MWF.xApplication.process.Xform.Log#postLoadLine
  40. * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
  41. */
  42. "moduleEvents": ["load", "queryLoad", "postLoad", "postLoadData", "postLoadLine"]
  43. },
  44. _loadUserInterface: function(){
  45. this.node.empty();
  46. this.node.setStyle("-webkit-user-select", "text");
  47. if (this.form.businessData){
  48. if (this.json.logType!=="record"){
  49. if (this.form.businessData.workLogList){
  50. this.workLog = Array.clone(this.form.businessData.workLogList);
  51. this.fireEvent("postLoadData");
  52. this.loadWorkLog();
  53. }
  54. }else{
  55. if (this.form.businessData.recordList){
  56. this.workLog = Array.clone(this.form.businessData.recordList);
  57. this.fireEvent("postLoadData");
  58. this.loadRecordLog();
  59. }
  60. }
  61. }
  62. },
  63. loadRecordLog: function(){
  64. if( !this.json.category || this.json.category === "none" ){
  65. if (this.json.mode==="table"){
  66. this.loadRecordLogTable();
  67. }else if (this.json.mode==="text"){
  68. this.loadRecordLogText();
  69. }else if (this.json.mode==="media"){
  70. this.loadRecordLogMedia();
  71. }else{
  72. this.loadRecordLogDefault();
  73. }
  74. }else{
  75. this.loadCategoryList("_loadRecordCategoryList", "_loadRecordCategoryList");
  76. if( !this.categoryList.length )return;
  77. this.expandCount = 0;
  78. if( this.json.expand && this.json.expand === "enable" ){
  79. this.expandCount = parseInt( this.json.expandCount );
  80. }
  81. this.table = new Element("table", this.json.tableProperties).inject( this.node );
  82. this.categoryList.each( function( key, idx ){
  83. var list = this.categoryJson[key];
  84. if( list && list.length ){
  85. var tr = new Element("tr").inject( this.table );
  86. if( this.expandCount && (idx + 1) > this.expandCount ){
  87. tr.setStyle("display","none");
  88. }
  89. var text = key;
  90. if( this.json.category === "unit" ){
  91. text = key.split("@")[0];
  92. }
  93. new Element("td", {
  94. styles : this.json.titleTdStyles,
  95. text : text
  96. }).inject( tr );
  97. var td = new Element("td", {
  98. styles : this.json.contentTdStyles
  99. }).inject( tr );
  100. var div = new Element("div",{
  101. styles : this.json.contentDivStyles || {}
  102. }).inject( td );
  103. if( this.json.sortTypeInCategory === "completedTimeAsc" || this.json.sortTypeInCategory === "completedTimeDesc" ){
  104. list.sort(function(a, b){
  105. if( this.json.sortTypeInCategory === "completedTimeAsc" ) {
  106. return Date.parse(a.recordTime) - Date.parse(b.recordTime);
  107. }else if( this.json.sortTypeInCategory === "completedTimeDesc" ) {
  108. return Date.parse(b.recordTime) - Date.parse(a.recordTime);
  109. }
  110. }.bind(this));
  111. // sortedList = [];
  112. // list.each( function( log ){
  113. // if (log.taskCompletedList.length) {
  114. // log.taskCompletedList.each(function (t) {
  115. // var copyLog = Object.clone( log );
  116. // copyLog.readList = [];
  117. // copyLog.readCompletedList = [];
  118. // copyLog.taskList = [];
  119. // copyLog.taskCompletedList = [t];
  120. // sortedList.push( copyLog );
  121. // }.bind(this));
  122. // }
  123. // }.bind(this));
  124. // sortedList.sort(function(a, b){
  125. // if( this.json.sortTypeInCategory === "completedTimeAsc" ) {
  126. // return Date.parse(a.taskCompletedList[0].completedTime) - Date.parse(b.taskCompletedList[0].completedTime);
  127. // }else if( this.json.sortTypeInCategory === "completedTimeDesc" ) {
  128. // return Date.parse(b.taskCompletedList[0].completedTime) - Date.parse(a.taskCompletedList[0].completedTime);
  129. // }
  130. // }.bind(this));
  131. // list.each( function( log ) {
  132. // if (log.taskList.length) {
  133. // log.taskList.each(function (t) {
  134. // var copyLog = Object.clone(log);
  135. // copyLog.readList = [];
  136. // copyLog.readCompletedList = [];
  137. // copyLog.taskCompletedList = [];
  138. // copyLog.taskList = [t];
  139. // sortedList.push(copyLog);
  140. // }.bind(this));
  141. // }
  142. // })
  143. }
  144. if (this.json.mode==="table"){
  145. this.loadRecordLogTable( list, div );
  146. }else if (this.json.mode==="text"){
  147. this.loadRecordLogText( list, div );
  148. }else if (this.json.mode==="media"){
  149. this.loadRecordLogMedia( list, div );
  150. }else{
  151. this.loadRecordLogDefault( list, div );
  152. }
  153. this._loadTableStyles();
  154. }
  155. }.bind(this));
  156. if( this.categoryList.length > this.expandCount ){
  157. this.loadExpandCollapseNode();
  158. }
  159. }
  160. },
  161. _loadRecordCategoryList : function( category ){
  162. this.categoryList = [];
  163. this.categoryJson = {};
  164. if( category === "fromOpinionGroup" ){
  165. this.workLog.sort( function( a, b ){
  166. if( a.properties.fromOpinionGroup && b.properties.fromOpinionGroup ) {
  167. var array1 = a.properties.fromOpinionGroup.split("#");
  168. var array2 = b.properties.fromOpinionGroup.split("#");
  169. for (var i = 0; i < array1.length; i++) {
  170. var value1 = array1[i];
  171. var value2 = array2[i];
  172. if (this.isNumber(value1) && this.isNumber(value2)) {
  173. if (parseFloat(value1) !== parseFloat(value2)) {
  174. return parseFloat(value1) - parseFloat(value2);
  175. }
  176. } else if (!this.isNumber(value1) && !this.isNumber(value2)) {
  177. return Date.parse(a.fromTime) - Date.parse(b.fromTime);
  178. } else {
  179. return this.isNumber(value1) ? -1 : 1;
  180. }
  181. }
  182. return Date.parse(a.fromTime) - Date.parse(b.fromTime);
  183. }else if( a.properties.fromOpinionGroup || b.properties.fromOpinionGroup ){
  184. return a.properties.fromOpinionGroup ? -1 : 1;
  185. }else{
  186. return Date.parse(a.fromTime) - Date.parse(b.fromTime);
  187. }
  188. }.bind(this))
  189. }
  190. this.workLog.each( function(log, idx){
  191. var key;
  192. if( this.json.category === "activityGroup" ){
  193. if( log.properties.fromOpinionGroup ){
  194. var arr = log.properties.fromOpinionGroup.split("#");
  195. key = arr[arr.length-1]
  196. }else{
  197. key = log.fromActivityName;
  198. }
  199. }else{
  200. key = log[category];
  201. }
  202. if( key && this.checkRecordShow(log)){
  203. if( this.categoryList.indexOf( key ) === -1 ){
  204. this.categoryList.push( key );
  205. }
  206. if( !this.categoryJson[key] )this.categoryJson[key] = [];
  207. this.categoryJson[key].push( log );
  208. }
  209. }.bind(this))
  210. },
  211. loadRecordLogTable: function( list, container ){
  212. var taskTable = new Element("table", {
  213. "styles": this.form.css.logTableTask,
  214. "border": "0",
  215. "cellSpacing": "0",
  216. "cellpadding": "3px",
  217. "width": "100%"
  218. }).inject(container || this.node);
  219. var tr = taskTable.insertRow(0).setStyles(this.form.css.logTableTaskTitleLine);
  220. var td = tr.insertCell(0).setStyles(this.form.css.logTableTaskTitle);
  221. td.set("text", MWF.xApplication.process.Xform.LP.person);
  222. td = tr.insertCell(1).setStyles(this.form.css.logTableTaskTitle);
  223. td.set("text", MWF.xApplication.process.Xform.LP.activity);
  224. td = tr.insertCell(2).setStyles(this.form.css.logTableTaskTitle);
  225. td.set("text", MWF.xApplication.process.Xform.LP.department);
  226. td = tr.insertCell(3).setStyles(this.form.css.logTableTaskTitle);
  227. td.set("text", MWF.xApplication.process.Xform.LP.startTime);
  228. td = tr.insertCell(4).setStyles(this.form.css.logTableTaskTitle);
  229. td.set("text", MWF.xApplication.process.Xform.LP.completedTime);
  230. td = tr.insertCell(5).setStyles(this.form.css.logTableTaskTitle);
  231. td.set("text", MWF.xApplication.process.Xform.LP.route);
  232. td = tr.insertCell(6).setStyles(this.form.css.logTableTaskTitle);
  233. td.set("text", MWF.xApplication.process.Xform.LP.opinion);
  234. td = tr.insertCell(7).setStyles(this.form.css.logTableTaskTitle);
  235. td.set("text", MWF.xApplication.process.Xform.LP.arrivedActivitys);
  236. td = tr.insertCell(8).setStyles(this.form.css.logTableTaskTitle);
  237. td.set("text", MWF.xApplication.process.Xform.LP.arrivedUsers);
  238. if( list ){
  239. list.each(function(log, idx){
  240. this.loadRecordLogLine_table(log, idx, taskTable );
  241. }.bind(this));
  242. }else{
  243. this.workLog.each(function(log, idx){
  244. if (this.checkRecordShow(log)) this.loadRecordLogLine_table(log, idx, taskTable );
  245. }.bind(this));
  246. }
  247. },
  248. checkRecordShow: function(log){
  249. var flag = true;
  250. if (this.json.filterScript && this.json.filterScript.code){
  251. this.form.Macro.environment.log = log;
  252. this.form.Macro.environment.list = null;
  253. flag = this.form.Macro.exec(this.json.filterScript.code, this);
  254. }else{
  255. if (this.json.filterActivity && this.json.filterActivity.length){
  256. filterActivitys = this.json.filterActivity;
  257. flag = (filterActivitys.indexOf(log.fromActivityName)!==-1);
  258. }
  259. if (this.json.filterActivityAlias){
  260. if (this.json.filterActivityAlias.length){
  261. filterActivityAlias = this.json.filterActivityAlias;
  262. flag = ((log.fromActivityAlias) && filterActivityAlias.indexOf(log.fromActivityAlias)!==-1);
  263. }
  264. }
  265. if (this.json.filterPerson && this.json.filterPerson.length){
  266. flag = (this.json.filterPerson.indexOf(log.person)!==-1);
  267. if (!flag) flag = (this.json.filterPerson.indexOf(o2.name.cn(log.person))!==-1);
  268. }
  269. if (this.json.filterRoute && this.json.filterRoute.length){
  270. filterRoutes = this.json.filterRoute;
  271. flag = (filterRoutes.indexOf(log.properties.routeName)!==-1);
  272. }
  273. }
  274. return flag;
  275. },
  276. loadRecordLogLine_table: function(log, idx, taskTable){
  277. var style = ((idx % 2)===0) ? "logTableTaskLine" : "logTableTaskLine_even";
  278. if (log.type==="currentTask"){
  279. if (this.json.isTask) this.loadRecordTaskLine_table(log, taskTable, true, style);
  280. }else{
  281. this.loadRecordTaskLine_table(log, taskTable, false, style);
  282. }
  283. },
  284. loadRecordTaskLine_table: function(task, table, isTask, style){
  285. // var style = "logTableTaskLine";
  286. // "logTableTaskLine_even"
  287. css = (isTask) ? Object.merge(this.form.css["logTableTaskLine_task"], this.form.css[style] ): this.form.css[style];
  288. if (isTask) style = "logTableTaskLine_task";
  289. var tr = table.insertRow(table.rows.length);
  290. var td = tr.insertCell(0).setStyles(css);
  291. var person = (task.person) ? task.person.substring(0, task.person.indexOf("@")) : "";
  292. if (task.properties.empowerFromIdentity){
  293. var ep = o2.name.cn(task.properties.empowerFromIdentity);
  294. person = person + " "+MWF.xApplication.process.Xform.LP.replace+" " + ep;
  295. }
  296. if (task.type === "empower") task.properties.startTime = task.recordTime;
  297. td.set("text", person);
  298. td = tr.insertCell(1).setStyles(css);
  299. td.set("text", task.fromActivityName || "");
  300. td = tr.insertCell(2).setStyles(css);
  301. td.set("text", (task.unit) ? task.unit.substring(0, task.unit.indexOf("@")) : "");
  302. td = tr.insertCell(3).setStyles(css);
  303. td.set("text", task.properties.startTime || "");
  304. td = tr.insertCell(4).setStyles(css);
  305. td.set("text", task.recordTime || "");
  306. var router, opinion, arrivedActivitys, arrivedUsers;
  307. arrivedActivitys = task.properties.nextManualList.map(function(o){
  308. return o.activityName;
  309. }).join(",");
  310. arrivedUsers = (task.properties.nextManualTaskIdentityList && task.properties.nextManualTaskIdentityList.length) ? o2.name.cns(task.properties.nextManualTaskIdentityList).join(",") : "";
  311. switch (task.type) {
  312. case "empower":
  313. router = MWF.xApplication.process.Xform.LP.empower;
  314. var empowerTo = (task.properties.nextManualTaskIdentityList && task.properties.nextManualTaskIdentityList.length) ? o2.name.cns(task.properties.nextManualTaskIdentityList).join(",") : "";
  315. opinion = MWF.xApplication.process.Xform.LP.empowerTo + empowerTo;
  316. task.properties.startTime = task.recordTime;
  317. break;
  318. case "retract":
  319. router = MWF.xApplication.process.Xform.LP.retract;
  320. opinion = MWF.xApplication.process.Xform.LP.retract;
  321. break;
  322. case "reroute":
  323. router = task.properties.routeName || MWF.xApplication.process.Xform.LP.reroute;
  324. opinion = task.properties.opinion || MWF.xApplication.process.Xform.LP.rerouteTo+": "+arrivedActivitys;
  325. break;
  326. case "rollback":
  327. router = task.properties.routeName || MWF.xApplication.process.Xform.LP.rollback;
  328. opinion = task.properties.opinion || MWF.xApplication.process.Xform.LP.rollbackTo+": "+task.arrivedActivityName;
  329. break;
  330. case "reset":
  331. var resetUser = task.properties.nextManualTaskIdentityList.erase(task.identity);
  332. resetUserText = o2.name.cns(resetUser).join(",");
  333. router = MWF.xApplication.process.Xform.LP.resetTo+":"+resetUserText;
  334. opinion = task.properties.opinion || ""
  335. break;
  336. case "appendTask":
  337. case "back":
  338. case "addSplit":
  339. case "urge":
  340. case "expire":
  341. case "read":
  342. default:
  343. router = task.properties.routeName || "";
  344. opinion = task.properties.opinion || "";
  345. }
  346. td = tr.insertCell(5).setStyles(css);
  347. td.set("text",router);
  348. var opinionTd = tr.insertCell(6).setStyles(css);
  349. opinionTd.set("html", "<div style='display: inline-block; float: left'>"+opinion+"</div>");
  350. td = tr.insertCell(7).setStyles(css);
  351. td.set("text",arrivedActivitys);
  352. td = tr.insertCell(8).setStyles(css);
  353. td.set("html", arrivedUsers);
  354. if (task.properties.mediaOpinion){
  355. var mediaIds = task.properties.mediaOpinion.split(",");
  356. var atts = [];
  357. if (this.form.businessData.attachmentList){
  358. this.form.businessData.attachmentList.each(function(att){
  359. if (att.site==="$mediaOpinion"){
  360. if (mediaIds.indexOf(att.id)!==-1) atts.push(att);
  361. }
  362. }.bind(this));
  363. }
  364. if (atts.length) this.loadMediaOpinion(atts, opinionTd.getFirst(), "table");
  365. }
  366. },
  367. loadRecordLogDefault: function(list, container){
  368. var logActivityNode = new Element("div", {"styles": this.form.css.logActivityNode_record}).inject(container || this.node);
  369. if( list ){
  370. list.each(function(log, idx){
  371. this.loadRecordLogLine_default(log, idx, logActivityNode);
  372. }.bind(this));
  373. }else{
  374. this.workLog.each(function(log, idx){
  375. if (this.checkRecordShow(log)) this.loadRecordLogLine_default(log, idx, logActivityNode);
  376. }.bind(this));
  377. }
  378. },
  379. loadRecordLogLine_default: function(log, idx, container){
  380. //var style = ((idx % 2)===0) ? "logTableTaskLine_even" : "logTableTaskLine";
  381. var style = ((idx % 2)===0) ? "logActivityChildRecordNode" : "logActivityChildRecordNode_even";
  382. var childNode = new Element("div", {"styles": this.form.css[style]}).inject((container || this.node));
  383. if (log.type==="currentTask"){
  384. if (this.json.isTask) this.loadRecordTaskLine_default(log, childNode, true);
  385. }else{
  386. this.loadRecordTaskLine_default(log, childNode, false);
  387. }
  388. },
  389. loadRecordTaskLine_default: function(task, node, isTask, margin, isZebra, nodeStyle, noIconNode){
  390. var style = "logTaskNode";
  391. var textStyle = "logTaskFloatTextNode";
  392. if (nodeStyle){
  393. style = "logTaskTextNode";
  394. textStyle = "logTaskTextNode";
  395. }
  396. var logTaskNode = new Element("div", {"styles": this.form.css[style]}).inject(node);
  397. var iconNode;
  398. if( !noIconNode ){
  399. iconNode = new Element("div", {"styles": this.form.css.logTaskIconNode_record}).inject(logTaskNode);
  400. }
  401. var textNode = new Element("div", {"styles": this.form.css[textStyle]}).inject(logTaskNode);
  402. if (isZebra){
  403. logTaskNode.setStyles(this.form.css[this.lineClass]);
  404. if (this.lineClass === "logTaskNode"){
  405. this.lineClass = "logTaskNode_even";
  406. }else{
  407. this.lineClass = "logTaskNode";
  408. }
  409. }
  410. var left = 0;
  411. if( iconNode ){
  412. if (margin) iconNode.setStyle("margin-left", margin);
  413. left = iconNode.getStyle("margin-left").toInt();
  414. left = left + 28;
  415. }
  416. if( !nodeStyle ){
  417. textNode.setStyle("margin-left",left+"px");
  418. }
  419. var html;
  420. var company = "";
  421. if (!isTask){
  422. company = (task.unitList) ? task.unitList[task.unitList.length-1] : "";
  423. html = this.json.textStyle;
  424. var lp = MWF.xApplication.process.Xform.LP;
  425. if (task.type=="empower") html = "<font style='color:#ff5400;'>{person}</font>({department})"+lp.in+"【{activity}】"+lp.activity+","+lp.empowerTo +"<font style='color:#ff5400;'>{empowerTo}</font>。({time})</font>";
  426. var nextTaskText = (task.properties.nextManualTaskIdentityList && task.properties.nextManualTaskIdentityList.length) ? o2.name.cns(task.properties.nextManualTaskIdentityList).join(",") : "";
  427. if (this.json.textStyleScript && this.json.textStyleScript.code){
  428. this.form.Macro.environment.log = task;
  429. this.form.Macro.environment.list = null;
  430. html = this.form.Macro.exec(this.json.textStyleScript.code, this);
  431. }
  432. // var person = (task.person) ? task.person.substring(0, task.person.indexOf("@")) : "";
  433. // if( task.type !== "empowerTask" && task.empowerFromIdentity){
  434. // person = person+" "+lp.replace+" "+o2.name.cn(task.empowerFromIdentity||"");
  435. // }
  436. var person = (task.person) ? task.person.substring(0, task.person.indexOf("@")) : "";
  437. if (task.properties.empowerFromIdentity){
  438. var ep = o2.name.cn(task.properties.empowerFromIdentity);
  439. person = person + " "+MWF.xApplication.process.Xform.LP.replace+" " + ep;
  440. }
  441. var router, opinion, arrivedActivitys, arrivedUsers;
  442. arrivedActivitys = task.properties.nextManualList.map(function(o){
  443. return o.activityName;
  444. }).join(",");
  445. arrivedUsers = (task.properties.nextManualTaskIdentityList && task.properties.nextManualTaskIdentityList.length) ? o2.name.cns(task.properties.nextManualTaskIdentityList).join(",") : "";
  446. switch (task.type) {
  447. case "empower":
  448. router = MWF.xApplication.process.Xform.LP.empower;
  449. var empowerTo = (task.properties.nextManualTaskIdentityList && task.properties.nextManualTaskIdentityList.length) ? o2.name.cns(task.properties.nextManualTaskIdentityList).join(",") : "";
  450. opinion = MWF.xApplication.process.Xform.LP.empowerTo + empowerTo;
  451. task.properties.startTime = task.recordTime;
  452. break;
  453. case "retract":
  454. router = MWF.xApplication.process.Xform.LP.retract;
  455. opinion = MWF.xApplication.process.Xform.LP.retract;
  456. break;
  457. case "reroute":
  458. router = task.properties.routeName || MWF.xApplication.process.Xform.LP.reroute;
  459. opinion = task.properties.opinion || MWF.xApplication.process.Xform.LP.rerouteTo+": "+arrivedActivitys;
  460. break;
  461. case "rollback":
  462. router = task.properties.routeName || MWF.xApplication.process.Xform.LP.rollback;
  463. opinion = task.properties.opinion || MWF.xApplication.process.Xform.LP.rollbackTo+": "+task.arrivedActivityName;
  464. break;
  465. case "reset":
  466. var resetUser = task.properties.nextManualTaskIdentityList.erase(task.identity);
  467. resetUserText = o2.name.cns(resetUser).join(",");
  468. router = MWF.xApplication.process.Xform.LP.resetTo+":"+resetUserText;
  469. opinion = task.properties.opinion || ""
  470. break;
  471. case "appendTask":
  472. case "back":
  473. case "addSplit":
  474. case "urge":
  475. case "expire":
  476. case "read":
  477. case "task":
  478. case "empowerTask":
  479. default:
  480. router = task.properties.routeName || "";
  481. opinion = task.properties.opinion || "";
  482. }
  483. html = html.replace(/\{person\}/g, person );
  484. html = html.replace(/\{department\}/g, (task.unit) ? task.unit.substring(0, task.unit.indexOf("@")) : "");
  485. html = html.replace(/\{route\}/g, router);
  486. html = html.replace(/\{time\}/g, task.recordTime);
  487. html = html.replace(/\{date\}/g, new Date().parse(task.recordTime).format("%Y-%m-%d"));
  488. html = html.replace(/\{opinion\}/g, opinion);
  489. html = html.replace(/\{company\}/g, company.substring(0, company.indexOf("@")));
  490. html = html.replace(/\{startTime\}/g, task.properties.startTime);
  491. html = html.replace(/\{startDate\}/g, new Date().parse(task.properties.startTime).format("%Y-%m-%d"));
  492. html = html.replace(/\{activity\}/g, task.fromActivityName);
  493. html = html.replace(/\{arrivedActivity\}/g, arrivedActivitys);
  494. html = html.replace(/\{img\}/g, "<span class='mwf_log_img'></span>");
  495. html = html.replace(/\{empowerTo\}/g, arrivedUsers);
  496. html = html.replace(/\{next\}/g, nextTaskText);
  497. //var html = MWF.xApplication.process.Xform.LP.nextUser + task.person+"("+task.department+")" +", "+
  498. // MWF.xApplication.process.Xform.LP.selectRoute + ": [" + task.routeName + "], " +
  499. // MWF.xApplication.process.Xform.LP.submitAt + ": " + task.completedTime+ ", " +
  500. // MWF.xApplication.process.Xform.LP.idea + ": <font style=\"color: #00F\">" + (task.opinion || "")+"</font>";
  501. textNode.set("html", html);
  502. var imgNode = textNode.getElement(".mwf_log_img");
  503. if (task.properties.mediaOpinion){
  504. var mediaIds = task.properties.mediaOpinion.split(",");
  505. var atts = [];
  506. if (this.form.businessData.attachmentList){
  507. this.form.businessData.attachmentList.each(function(att){
  508. if (att.site==="$mediaOpinion"){
  509. if (mediaIds.indexOf(att.id)!==-1) atts.push(att);
  510. }
  511. }.bind(this));
  512. }
  513. if (atts.length){
  514. if (imgNode){
  515. this.loadMediaOpinion_show(atts, task, imgNode, true);
  516. // atts.each(function(att){
  517. // this.loadMediaOpinion_image_show(att, task, imgNode);
  518. // }.bind(this));
  519. }else{
  520. this.loadMediaOpinion(atts, textNode, "default");
  521. }
  522. }
  523. }
  524. }else{
  525. var person = (task.person) ? task.person.substring(0, task.person.indexOf("@")) : "";
  526. if (task.properties.empowerFromIdentity){
  527. var ep = o2.name.cn(task.properties.empowerFromIdentity);
  528. person = person + " "+MWF.xApplication.process.Xform.LP.replace+" " + ep;
  529. }
  530. html = person+"("+task.unit.substring(0, task.unit.indexOf("@"))+"), 【"+task.fromActivityName+"】" + MWF.xApplication.process.Xform.LP.processing+", "+
  531. MWF.xApplication.process.Xform.LP.comeTime + ": " + task.properties.startTime;
  532. textNode.set("html", html);
  533. if(iconNode)iconNode.setStyle("background-image", "url("+"../x_component_process_Xform/$Form/"+this.form.options.style+"/icon/rightRed.png)");
  534. }
  535. this.fireEvent("postLoadLine",[{
  536. "data" : task,
  537. "node" : logTaskNode,
  538. "log" : this,
  539. "type" : isTask ? "task" : "taskCompleted"
  540. }]);
  541. },
  542. loadRecordLogText: function(list, container){
  543. this.lineClass = "logTaskNode";
  544. if( list ){
  545. list.each(function(log, idx){
  546. this.loadRecordLogLine_text(log, idx, container);
  547. }.bind(this));
  548. }else{
  549. this.workLog.each(function(log, idx){
  550. if (this.checkRecordShow(log)) this.loadRecordLogLine_text(log, idx, container);
  551. }.bind(this));
  552. }
  553. },
  554. loadRecordLogLine_text: function(log, idx, container){
  555. if (log.type==="currentTask"){
  556. if (this.json.isTask) this.loadRecordTaskLine_text(log, container || this.node, true);
  557. }else{
  558. this.loadRecordTaskLine_text(log, container || this.node, false);
  559. }
  560. },
  561. loadRecordTaskLine_text: function(task, node, log, isTask){
  562. this.loadRecordTaskLine_default(task, node, isTask, "0px", false, true, true);
  563. },
  564. loadRecordLogMedia: function(list, container){
  565. if( list ){
  566. list.each(function(log, idx){
  567. this.loadRecordLogLine_media(log, idx, container);
  568. }.bind(this));
  569. }else{
  570. this.workLog.each(function(log, idx){
  571. if (this.checkRecordShow(log)) this.loadRecordLogLine_media(log, idx, container);
  572. }.bind(this));
  573. }
  574. },
  575. loadRecordLogLine_media: function(log, idx, container){
  576. this.loadRecordTaskLine_media(log, container);
  577. },
  578. loadRecordTaskLine_media: function(task, container){
  579. if (task.properties.mediaOpinion){
  580. var mediaIds = task.properties.mediaOpinion.split(",");
  581. var atts = [];
  582. if (this.form.businessData.attachmentList){
  583. this.form.businessData.attachmentList.each(function(att){
  584. if (att.site==="$mediaOpinion"){
  585. if (mediaIds.indexOf(att.id)!==-1) atts.push(att);
  586. }
  587. }.bind(this));
  588. }
  589. task.completedTime = task.recordTime;
  590. if (atts.length) this.loadMediaOpinion_show(atts, task, container);
  591. }
  592. },
  593. //worklog -----------------------------------------------------------------------------
  594. loadWorkLog: function(){
  595. if( !this.json.category || this.json.category === "none" ){
  596. if (this.json.mode==="table"){
  597. this.loadWorkLogTable();
  598. }else if (this.json.mode==="text"){
  599. this.loadWorkLogText();
  600. }else if (this.json.mode==="media"){
  601. this.loadWorkLogMedia();
  602. }else{
  603. this.loadWorkLogDefault();
  604. }
  605. }else{
  606. this.loadCategoryList();
  607. if( !this.categoryList.length )return;
  608. this.expandCount = 0;
  609. if( this.json.expand && this.json.expand === "enable" ){
  610. this.expandCount = parseInt( this.json.expandCount || 0 );
  611. }
  612. this.table = new Element("table", this.json.tableProperties).inject( this.node );
  613. this.categoryList.each( function( key, idx ){
  614. var list = this.categoryJson[key];
  615. if( list && list.length ){
  616. var tr = new Element("tr").inject( this.table );
  617. if( this.expandCount && (idx + 1) > this.expandCount ){
  618. tr.setStyle("display","none");
  619. }
  620. var text = key;
  621. if( this.json.category === "unit" ){
  622. text = key.split("@")[0];
  623. }
  624. new Element("td", {
  625. styles : this.json.titleTdStyles,
  626. text : text
  627. }).inject( tr );
  628. var td = new Element("td", {
  629. styles : this.json.contentTdStyles
  630. }).inject( tr );
  631. var div = new Element("div",{
  632. styles : this.json.contentDivStyles || {}
  633. }).inject( td );
  634. var sortedList = list;
  635. if( this.json.sortTypeInCategory === "completedTimeAsc" || this.json.sortTypeInCategory === "completedTimeDesc" ){
  636. sortedList = [];
  637. list.each( function( log ){
  638. if (log.taskCompletedList.length) {
  639. log.taskCompletedList.each(function (t) {
  640. var copyLog = Object.clone( log );
  641. copyLog.readList = [];
  642. copyLog.readCompletedList = [];
  643. copyLog.taskList = [];
  644. copyLog.taskCompletedList = [t];
  645. sortedList.push( copyLog );
  646. }.bind(this));
  647. }
  648. }.bind(this));
  649. sortedList.sort(function(a, b){
  650. if( this.json.sortTypeInCategory === "completedTimeAsc" ) {
  651. return Date.parse(a.taskCompletedList[0].completedTime) - Date.parse(b.taskCompletedList[0].completedTime);
  652. }else if( this.json.sortTypeInCategory === "completedTimeDesc" ) {
  653. return Date.parse(b.taskCompletedList[0].completedTime) - Date.parse(a.taskCompletedList[0].completedTime);
  654. }
  655. }.bind(this));
  656. list.each( function( log ) {
  657. if (log.taskList.length) {
  658. log.taskList.each(function (t) {
  659. var copyLog = Object.clone(log);
  660. copyLog.readList = [];
  661. copyLog.readCompletedList = [];
  662. copyLog.taskCompletedList = [];
  663. copyLog.taskList = [t];
  664. sortedList.push(copyLog);
  665. }.bind(this));
  666. }
  667. })
  668. }
  669. if (this.json.mode==="table"){
  670. this.loadWorkLogTable( sortedList, div );
  671. }else if (this.json.mode==="text"){
  672. this.loadWorkLogText( sortedList, div );
  673. }else if (this.json.mode==="media"){
  674. this.loadWorkLogMedia( sortedList, div );
  675. }else{
  676. this.loadWorkLogDefault( sortedList, div );
  677. }
  678. this._loadTableStyles();
  679. }
  680. }.bind(this));
  681. if( this.categoryList.length > this.expandCount ){
  682. this.loadExpandCollapseNode();
  683. }
  684. }
  685. },
  686. loadCategoryList : function(m1, m2){
  687. var category;
  688. if( this.json.category === "activity" ){
  689. category = "fromActivityName";
  690. this[m1 || "_loadCategoryList"]( category );
  691. }else if( this.json.category === "unit" ){
  692. category = "unit";
  693. this[m2 || "_loadCategoryLitBySubData"]( category );
  694. }else if( this.json.category === "activityGroup" ){
  695. category = "fromOpinionGroup";
  696. this[m1 || "_loadCategoryList"]( category );
  697. }else{
  698. category = this.json.category;
  699. this[m1 || "_loadCategoryList"]( category );
  700. }
  701. },
  702. // isNumber : function( d ){
  703. // return parseFloat(d).toString() !== "NaN"
  704. // },
  705. _loadCategoryList : function( category ){
  706. this.categoryList = [];
  707. this.categoryJson = {};
  708. if( category === "fromOpinionGroup" ){
  709. this.workLog.sort( function( a, b ){
  710. if( a.fromOpinionGroup && b.fromOpinionGroup ) {
  711. var array1 = a.fromOpinionGroup.split("#");
  712. var array2 = b.fromOpinionGroup.split("#");
  713. for (var i = 0; i < array1.length; i++) {
  714. var value1 = array1[i];
  715. var value2 = array2[i];
  716. if (this.isNumber(value1) && this.isNumber(value2)) {
  717. if (parseFloat(value1) !== parseFloat(value2)) {
  718. return parseFloat(value1) - parseFloat(value2);
  719. }
  720. } else if (!this.isNumber(value1) && !this.isNumber(value2)) {
  721. return Date.parse(a.fromTime) - Date.parse(b.fromTime);
  722. } else {
  723. return this.isNumber(value1) ? -1 : 1;
  724. }
  725. }
  726. return Date.parse(a.fromTime) - Date.parse(b.fromTime);
  727. }else if( a.fromOpinionGroup || b.fromOpinionGroup ){
  728. return a.fromOpinionGroup ? -1 : 1;
  729. }else{
  730. return Date.parse(a.fromTime) - Date.parse(b.fromTime);
  731. }
  732. }.bind(this))
  733. }
  734. this.workLog.each( function(log, idx){
  735. var key;
  736. if( this.json.category === "activityGroup" ){
  737. if( log.fromOpinionGroup ){
  738. var arr = log.fromOpinionGroup.split("#");
  739. key = arr[arr.length-1]
  740. }else{
  741. key = log.fromActivityName;
  742. }
  743. }else{
  744. key = log[category];
  745. }
  746. if( key && this.checkShow(log)){
  747. var flag = false;
  748. for( var i=0; i< log.taskCompletedList.length; i++ ){
  749. var taskCompleted = log.taskCompletedList[i];
  750. flag = this.checkListShow(log, taskCompleted);
  751. if( flag )break;
  752. }
  753. if (!flag && this.json.isTask){
  754. for( var i=0; i< this.json.isTask.length; i++ ){
  755. var task = log.taskList[i];
  756. flag = this.checkListShow(log, task);
  757. if( flag )break;
  758. }
  759. }
  760. if(flag){
  761. if( this.categoryList.indexOf( key ) === -1 ){
  762. this.categoryList.push( key );
  763. }
  764. if( !this.categoryJson[key] )this.categoryJson[key] = [];
  765. this.categoryJson[key].push( log );
  766. }
  767. }
  768. }.bind(this))
  769. },
  770. _loadCategoryLitBySubData : function( category ){
  771. this.categoryList = [];
  772. this.categoryJson = {};
  773. this.workLog.each( function(log, idx){
  774. var key = log[category];
  775. if( this.checkShow(log) ){
  776. var flag = false;
  777. for( var i=0; i< log.taskCompletedList.length; i++ ){
  778. var taskCompleted = log.taskCompletedList[i];
  779. flag = this.checkListShow(log, taskCompleted);
  780. if( flag )break;
  781. }
  782. if (!flag && this.json.isTask){
  783. for( var i=0; i< this.json.isTask.length; i++ ){
  784. var task = log.taskList[i];
  785. flag = this.checkListShow(log, task);
  786. if( flag )break;
  787. }
  788. }
  789. if(flag){
  790. var log_copy = Object.clone(log);
  791. log_copy.taskCompletedList = [];
  792. log_copy.taskList = [];
  793. log_copy.readCompletedList = [];
  794. log_copy.readList = [];
  795. var sub_categoryList = [];
  796. var sub_categoryJson = {};
  797. for( var i=0; i< log.taskCompletedList.length; i++ ){
  798. var d = log.taskCompletedList[i];
  799. var key = d[category];
  800. if( key ){
  801. if( sub_categoryList.indexOf( key ) === -1 ){
  802. sub_categoryList.push( key );
  803. }
  804. if( !sub_categoryJson[key] )sub_categoryJson[key] = Object.clone(log_copy);
  805. sub_categoryJson[key].taskCompletedList.push( d );
  806. }
  807. }
  808. for( var i=0; i< log.taskList.length; i++ ){
  809. var d = log.taskList[i];
  810. var key = d[category];
  811. if( key ){
  812. if( sub_categoryList.indexOf( key ) === -1 ){
  813. sub_categoryList.push( key );
  814. }
  815. if( !sub_categoryJson[key] )sub_categoryJson[key] = Object.clone(log_copy);
  816. sub_categoryJson[key].taskList.push( d );
  817. }
  818. }
  819. for( var i=0; i< log.readCompletedList.length; i++ ){
  820. var d = log.readCompletedList[i];
  821. var key = d[category];
  822. if( key ){
  823. if( sub_categoryList.indexOf( key ) === -1 ){
  824. sub_categoryList.push( key );
  825. }
  826. if( !sub_categoryJson[key] )sub_categoryJson[key] = Object.clone(log_copy);
  827. sub_categoryJson[key].readCompletedList.push( d );
  828. }
  829. }
  830. for( var i=0; i< log.readList.length; i++ ){
  831. var d = log.readList[i];
  832. var key = d[category];
  833. if( key ){
  834. if( sub_categoryList.indexOf( key ) === -1 ){
  835. sub_categoryList.push( key );
  836. }
  837. if( !sub_categoryJson[key] )sub_categoryJson[key] = Object.clone(log_copy);
  838. sub_categoryJson[key].readList.push( d );
  839. }
  840. }
  841. sub_categoryList.each( function(key){
  842. if( this.categoryList.indexOf( key ) === -1 ){
  843. this.categoryList.push( key );
  844. }
  845. }.bind(this));
  846. for( var key in sub_categoryJson ){
  847. if( !this.categoryJson[key] )this.categoryJson[key] = [];
  848. this.categoryJson[key].push( sub_categoryJson[key] );
  849. }
  850. }
  851. }
  852. }.bind(this))
  853. },
  854. _loadTableBorderStyle: function(){
  855. if (this.json.tableStyles && this.json.tableStyles.border){
  856. this.table.set("cellspacing", "0");
  857. this.table.setStyles({
  858. "border-top": this.json.tableStyles.border,
  859. "border-left": this.json.tableStyles.border
  860. });
  861. var ths = this.table.getElements("th");
  862. if( ths && ths.length ){
  863. ths.setStyles({
  864. "border-bottom": this.json.tableStyles.border,
  865. "border-right": this.json.tableStyles.border
  866. });
  867. }
  868. var tds = this.table.getElements("td");
  869. if( tds && tds.length ) {
  870. tds.setStyles({
  871. "border-bottom": this.json.tableStyles.border,
  872. "border-right": this.json.tableStyles.border
  873. });
  874. }
  875. }
  876. },
  877. _loadTableStyles: function(){
  878. Object.each(this.json.tableStyles || {}, function(value, key){
  879. var reg = /^border\w*/ig;
  880. if (!key.test(reg)){
  881. this.table.setStyle(key, value);
  882. }
  883. }.bind(this));
  884. this._loadTableBorderStyle();
  885. },
  886. loadExpandCollapseNode : function(){
  887. if( this.json.expand && this.json.expand === "enable" ){
  888. if( this.json.expandHTML ){
  889. this.expandNode = new Element("div",{
  890. "html" : this.json.expandHTML
  891. }).inject( this.node, "bottom" );
  892. this.expandNode.addEvent("click", function(){
  893. if( !this.json.category || this.json.category === "none" ){
  894. }else{
  895. this.table.getElements("tr").setStyle("display","");
  896. this.expandNode.setStyle("display","none");
  897. this.collapseNode.setStyle("display","");
  898. }
  899. }.bind(this))
  900. }
  901. if( this.json.collapseHTML ){
  902. this.collapseNode = new Element("div",{
  903. "html" : this.json.collapseHTML,
  904. "styles" : { "display" : "none" }
  905. }).inject( this.node, "bottom" );
  906. this.collapseNode.addEvent("click", function(){
  907. if( !this.json.category || this.json.category === "none" ){
  908. }else{
  909. var trs = this.table.getElements("tr");
  910. for( var i=0; i<trs.length; i++ ){
  911. if( i >= this.expandCount ){
  912. trs[i].setStyle("display","none");
  913. }
  914. }
  915. this.expandNode.setStyle("display","");
  916. this.collapseNode.setStyle("display","none");
  917. }
  918. }.bind(this))
  919. }
  920. }
  921. },
  922. loadWorkLogMedia: function(list, container){
  923. if( list ){
  924. list.each(function(log, idx){
  925. this.loadWorkLogLine_media(log, idx, container);
  926. }.bind(this));
  927. }else{
  928. this.workLog.each(function(log, idx){
  929. if (this.checkShow(log)) this.loadWorkLogLine_media(log, idx, container);
  930. }.bind(this));
  931. }
  932. },
  933. loadWorkLogLine_media: function(log, idx, container){
  934. if (log.taskCompletedList.length){
  935. log.taskCompletedList.each(function(taskCompleted){
  936. if (this.checkListShow(log, taskCompleted)) this.loadTaskLine_media(taskCompleted, log, container);
  937. }.bind(this));
  938. }
  939. },
  940. loadTaskLine_media: function(task, log, container){
  941. if (task.mediaOpinion){
  942. var mediaIds = task.mediaOpinion.split(",");
  943. var atts = [];
  944. if (this.form.businessData.attachmentList){
  945. this.form.businessData.attachmentList.each(function(att){
  946. if (att.site==="$mediaOpinion"){
  947. if (mediaIds.indexOf(att.id)!==-1) atts.push(att);
  948. }
  949. }.bind(this));
  950. }
  951. if (atts.length) this.loadMediaOpinion_show(atts, task, container);
  952. }
  953. },
  954. loadMediaOpinion_show: function(atts, task, container, noName){
  955. atts.each(function(att){
  956. //if (!att.contentType) att.contentType = "image";
  957. if (att.type){
  958. if (att.type.indexOf("image")!==-1){
  959. this.loadMediaOpinion_image_show(att, task, container, noName);
  960. }else if(att.type.indexOf("video")!==-1){
  961. this.loadMediaOpinion_video_show(att, task, container);
  962. }else if(att.type.indexOf("audio")!==-1){
  963. this.loadMediaOpinion_voice_show(att, task, container);
  964. }else{
  965. this.loadMediaOpinion_voice_show(att, task, container);
  966. }
  967. }
  968. }.bind(this));
  969. },
  970. loadMediaOpinion_image_show: function(att, task, container, noName){
  971. var url = this.getMediaOpinionUrl(att);
  972. var node = new Element("div", {"styles": {"overflow": "hidden"}}).inject( container || this.node);
  973. if (!noName){
  974. var textNode = new Element("div", {
  975. "styles": {
  976. "line-height": "28px",
  977. "height": "28px"
  978. },
  979. "text": task.person.substring(0, task.person.indexOf("@"))+"("+task.completedTime+")"
  980. }).inject(node);
  981. }
  982. //var img = new Element("img", {"src": url, "styles": {"background-color": "#ffffff"}}).inject(node);
  983. //
  984. //var height = 200;
  985. //var width = 300;
  986. //if (layout.mobile){
  987. // var size = img.getSize();
  988. // width = 200;
  989. // height = 200*(size.y/size.x);
  990. //}
  991. //img.setStyles({"width": ""+width+"px", "height": ""+height+"px"});
  992. var imgNode = new Element("div").inject(node);
  993. var width;
  994. if (layout.mobile){
  995. width = 200;
  996. }else{
  997. var pNode = node.getParent();
  998. var offset = imgNode.getPosition( pNode );
  999. //width = Math.min( pNode.getSize().x - offset.x - 2, 800 );
  1000. width = pNode.getSize().x - offset.x - 42;
  1001. }
  1002. var img = new Element("img", {
  1003. "src": url,
  1004. "styles" : { width : width+"px" },
  1005. "events" : {
  1006. load : function(ev){
  1007. var nh=ev.target.naturalHeight;
  1008. var nw = ev.target.naturalWidth;
  1009. if( !layout.mobile && ( this.isNumber( this.json.handwritingWidth ) || this.isNumber( this.json.handwritingHeight ) ) ){
  1010. var size = this.getImageSize( nw, nh );
  1011. img.setStyles(size);
  1012. imgNode.setStyles(size);
  1013. }else{
  1014. var x = Math.min(nw, width);
  1015. img.setStyles({"width": ""+ x +"px"});
  1016. imgNode.setStyles({"width": ""+ x +"px"});
  1017. }
  1018. }.bind(this)
  1019. }
  1020. }).inject(imgNode);
  1021. // var size = img.getSize();
  1022. // var x_y = size.x/size.y;
  1023. // if (size.y>260){
  1024. // var y = 260;
  1025. // var x = 260*x_y;
  1026. // img.setStyles({"width": ""+x+"px", "height": ""+y+"px"})
  1027. // }
  1028. },
  1029. isNumber : function( d ){
  1030. return parseFloat(d).toString() !== "NaN"
  1031. },
  1032. getImageSize : function(naturalWidth, naturalHeight ){
  1033. var ww = this.json.handwritingWidth;
  1034. var wh = this.json.handwritingHeight;
  1035. if( this.isNumber(ww) && !this.isNumber(wh) ){
  1036. return {
  1037. width : Math.min( naturalWidth, parseInt( ww ) ) + "px",
  1038. height : "auto"
  1039. }
  1040. }else if( !this.isNumber(ww) && this.isNumber(wh) ){
  1041. return {
  1042. width : "auto",
  1043. height : Math.min( naturalHeight, parseInt( wh ) ) + "px"
  1044. }
  1045. }else if( this.isNumber(ww) && this.isNumber(wh) ){
  1046. var flag = ( naturalWidth / parseInt(ww) ) > ( naturalHeight / parseInt(wh) );
  1047. if( flag ){
  1048. return {
  1049. width : Math.min( naturalWidth, parseInt( ww ) ) + "px",
  1050. height : "auto"
  1051. }
  1052. }else{
  1053. return {
  1054. width : "auto",
  1055. height : Math.min( naturalHeight, parseInt( wh ) ) + "px"
  1056. }
  1057. }
  1058. }
  1059. },
  1060. loadMediaOpinion_video_show: function(att, task, container){
  1061. },
  1062. loadMediaOpinion_voice_show: function(att, task, container){
  1063. //var node = new Element("audio").inject(this.node);
  1064. var url = this.getMediaOpinionUrl(att);
  1065. var div = new Element("div", {"styles": {"overflow": "hidden"}}).inject(container || this.node);
  1066. var textNode = new Element("div", {
  1067. "styles": {
  1068. "line-height": "28px",
  1069. "height": "28px"
  1070. },
  1071. "text": task.person.substring(0, task.person.indexOf("@"))+"("+task.completedTime+")"
  1072. }).inject(div);
  1073. var node = new Element("audio", {"loop": false, "controls": true}).inject(div);
  1074. node.set("src", url);
  1075. //this.audioNode.play();
  1076. },
  1077. loadWorkLogTable: function( list, container ){
  1078. if( list ){
  1079. list.each(function(log, idx){
  1080. this.loadWorkLogLine_table(log, idx, container );
  1081. }.bind(this));
  1082. }else{
  1083. this.workLog.each(function(log, idx){
  1084. if (this.checkShow(log)) this.loadWorkLogLine_table(log, idx, container );
  1085. }.bind(this));
  1086. }
  1087. },
  1088. loadWorkLogLine_table: function(log, idx, container){
  1089. if (!log.readList) log.readList = [];
  1090. if (!log.readCompletedList) log.readCompletedList = [];
  1091. if (log.taskCompletedList.length || log.readList.length || log.readCompletedList.length || (this.json.isTask && log.taskList.length)){
  1092. var logActivityNode = new Element("div", {"styles": this.form.css.logActivityNode}).inject( container || this.node);
  1093. var titleNode = new Element("div", {"styles": this.form.css.logActivityTitleNode}).inject(logActivityNode);
  1094. var childNode = new Element("div", {"styles": this.form.css.logActivityChildNode}).inject(logActivityNode);
  1095. var iconNode = new Element("div", {"styles": this.form.css.logActivityIconNode}).inject(titleNode);
  1096. var fromAvtivityNode = new Element("div", {"styles": this.form.css.logActivityFromNode}).inject(titleNode);
  1097. var arrowNode = new Element("div", {"styles": this.form.css.logActivityArrowNode}).inject(titleNode);
  1098. var arrivedAvtivityNode = new Element("div", {"styles": this.form.css.logActivityArrivedNode}).inject(titleNode);
  1099. var timeNode = new Element("div", {"styles": this.form.css.logActivityTimeNode}).inject(titleNode);
  1100. if (log.connected){
  1101. iconNode.setStyle("background-image", "url("+"../x_component_process_Xform/$Form/"+this.form.options.style+"/icon/ok14.png)");
  1102. }else{
  1103. iconNode.setStyle("background-image", "url("+"../x_component_process_Xform/$Form/"+this.form.options.style+"/icon/rightRed.png)");
  1104. }
  1105. fromAvtivityNode.set("html", "<b>"+log.fromActivityName+"</b>");
  1106. if (log.arrivedActivityName){
  1107. arrowNode.setStyle("background-image", "url("+"../x_component_process_Xform/$Form/"+this.form.options.style+"/icon/right.png)");
  1108. arrivedAvtivityNode.set("html", "<b>"+log.arrivedActivityName+"</b>");
  1109. timeNode.set("html", "<b>"+MWF.xApplication.process.Xform.LP.begin+": </b>"+log.fromTime+"<br/><b>"+MWF.xApplication.process.Xform.LP.end+": </b>"+log.arrivedTime)
  1110. }else{
  1111. timeNode.set("html", "<b>"+MWF.xApplication.process.Xform.LP.begin+": </b>"+log.fromTime)
  1112. }
  1113. if ((idx % 2)===0){
  1114. logActivityNode.setStyles(this.form.css.logActivityNode_even);
  1115. titleNode.setStyles(this.form.css.logActivityTitleNode_even);
  1116. }
  1117. var taskTable = new Element("table", {
  1118. "styles": this.form.css.logTableTask,
  1119. "border": "0",
  1120. "cellSpacing": "0",
  1121. "cellpadding": "3px",
  1122. "width": "100%"
  1123. }).inject(childNode);
  1124. var tr = taskTable.insertRow(0).setStyles(this.form.css.logTableTaskTitleLine);
  1125. var td = tr.insertCell(0).setStyles(this.form.css.logTableTaskTitle);
  1126. td.set("text", MWF.xApplication.process.Xform.LP.person);
  1127. td = tr.insertCell(1).setStyles(this.form.css.logTableTaskTitle);
  1128. td.set("text", MWF.xApplication.process.Xform.LP.department);
  1129. td = tr.insertCell(2).setStyles(this.form.css.logTableTaskTitle);
  1130. td.set("text", MWF.xApplication.process.Xform.LP.startTime);
  1131. td = tr.insertCell(3).setStyles(this.form.css.logTableTaskTitle);
  1132. td.set("text", MWF.xApplication.process.Xform.LP.completedTime);
  1133. td = tr.insertCell(4).setStyles(this.form.css.logTableTaskTitle);
  1134. td.set("text", MWF.xApplication.process.Xform.LP.route);
  1135. td = tr.insertCell(5).setStyles(this.form.css.logTableTaskTitle);
  1136. td.set("text", MWF.xApplication.process.Xform.LP.opinion);
  1137. log.taskCompletedList.each(function(taskCompleted){
  1138. if (this.checkListShow(log, taskCompleted)) this.loadTaskLine_table(taskCompleted, taskTable, log, false);
  1139. }.bind(this));
  1140. if (this.json.isShowRead!==false){
  1141. var readNames = [];
  1142. var readCompletedNames = [];
  1143. if (log.readList && log.readList.length){
  1144. log.readList.each(function(read){
  1145. readNames.push(MWF.name.cn(read.person));
  1146. });
  1147. }
  1148. if (log.readCompletedList && log.readCompletedList.length){
  1149. log.readCompletedList.each(function(read){
  1150. readCompletedNames.push(MWF.name.cn(read.person));
  1151. });
  1152. }
  1153. this.loadReadLine_default(readNames, readCompletedNames, childNode);
  1154. }
  1155. if (this.json.isTask){
  1156. log.taskList.each(function(task){
  1157. if (this.checkListShow(log, task)) this.loadTaskLine_table(task, taskTable, log, true);
  1158. }.bind(this));
  1159. }
  1160. }
  1161. },
  1162. loadTaskLine_table: function(task, table, log, isTask){
  1163. var style = "logTableTaskLine";
  1164. if (isTask) style = "logTableTaskLine_task";
  1165. var tr = table.insertRow(table.rows.length);
  1166. var td = tr.insertCell(0).setStyles(this.form.css[style]);
  1167. td.set("text", task.person.substring(0, task.person.indexOf("@")) || "");
  1168. td = tr.insertCell(1).setStyles(this.form.css[style]);
  1169. td.set("text", task.unit.substring(0, task.unit.indexOf("@")) || "");
  1170. td = tr.insertCell(2).setStyles(this.form.css[style]);
  1171. td.set("text", task.startTime || "");
  1172. td = tr.insertCell(3).setStyles(this.form.css[style]);
  1173. td.set("text", task.completedTime || "");
  1174. td = tr.insertCell(4).setStyles(this.form.css[style]);
  1175. td.set("text", (task.processingType=="empower") ? "授权" : task.routeName || "");
  1176. td = tr.insertCell(5).setStyles(this.form.css[style]);
  1177. opinion = (task.processingType=="empower") ? "授权给"+ o2.name.cn(task.empowerToIdentity || "") : "<div style='line-height: 28px; float:left'>" + (task.opinion || "")+"</div>";
  1178. td.set("html", opinion);
  1179. if (task.mediaOpinion){
  1180. var mediaIds = task.mediaOpinion.split(",");
  1181. var atts = [];
  1182. if (this.form.businessData.attachmentList){
  1183. this.form.businessData.attachmentList.each(function(att){
  1184. if (att.site==="$mediaOpinion"){
  1185. if (mediaIds.indexOf(att.id)!==-1) atts.push(att);
  1186. }
  1187. }.bind(this));
  1188. }
  1189. if (atts.length) this.loadMediaOpinion(atts, td.getFirst(), "table");
  1190. }
  1191. },
  1192. loadWorkLogText: function(list, container){
  1193. this.lineClass = "logTaskNode";
  1194. if( list ){
  1195. list.each(function(log, idx){
  1196. this.loadWorkLogLine_text(log, idx, container);
  1197. }.bind(this));
  1198. }else{
  1199. this.workLog.each(function(log, idx){
  1200. if (this.checkShow(log)) this.loadWorkLogLine_text(log, idx, container);
  1201. }.bind(this));
  1202. }
  1203. },
  1204. loadWorkLogLine_text: function(log, idx, container){
  1205. log.taskCompletedList.each(function(taskCompleted){
  1206. if (this.checkListShow(log, taskCompleted)) this.loadTaskLine_text(taskCompleted, container || this.node, log, false);
  1207. }.bind(this));
  1208. if (this.json.isTask){
  1209. log.taskList.each(function(task){
  1210. if (this.checkListShow(log, task)) this.loadTaskLine_text(task, container || this.node, log, true);
  1211. }.bind(this));
  1212. }
  1213. },
  1214. loadTaskLine_text: function(task, node, log, isTask){
  1215. this.loadTaskLine_default(task, node, log, isTask, "0px", false, true, true);
  1216. },
  1217. checkShow: function(log){
  1218. var flag = true;
  1219. if (this.json.filterScript && this.json.filterScript.code){
  1220. this.form.Macro.environment.log = log;
  1221. this.form.Macro.environment.list = null;
  1222. flag = this.form.Macro.exec(this.json.filterScript.code, this);
  1223. }else{
  1224. if (this.json.filterActivity && this.json.filterActivity.length){
  1225. filterActivitys = this.json.filterActivity;
  1226. flag = (filterActivitys.indexOf(log.fromActivityName)!==-1);
  1227. }
  1228. if (this.json.filterActivityAlias){
  1229. if (this.json.filterActivityAlias.length){
  1230. filterActivityAlias = this.json.filterActivityAlias;
  1231. flag = ((log.fromActivityAlias) && filterActivityAlias.indexOf(log.fromActivityAlias)!==-1);
  1232. }
  1233. }
  1234. if (this.json.filterPerson && this.json.filterPerson.length){
  1235. flag = false;
  1236. filterPersons = this.json.filterPerson;
  1237. var tmpTaskCompletedList = [];
  1238. log.taskCompletedList.each(function(taskCompleted){
  1239. if ((filterPersons.indexOf(taskCompleted.person)!==-1) || (filterPersons.indexOf(taskCompleted.identity)!==-1)){
  1240. tmpTaskCompletedList.push(taskCompleted);
  1241. }
  1242. }.bind(this));
  1243. if (tmpTaskCompletedList.length){
  1244. //log.taskCompletedList = [];
  1245. //log.taskCompletedList = tmpTaskCompletedList;
  1246. flag = true;
  1247. }
  1248. }
  1249. if (this.json.filterRoute && this.json.filterRoute.length){
  1250. filterRoutes = this.json.filterRoute;
  1251. flag = (filterRoutes.indexOf(log.routeName)!==-1);
  1252. }
  1253. }
  1254. return flag;
  1255. },
  1256. checkListShow: function(log, list){
  1257. var flag = true;
  1258. if (this.json.filterScript && this.json.filterScript.code){
  1259. this.form.Macro.environment.log = log;
  1260. this.form.Macro.environment.list = list;
  1261. flag = this.form.Macro.exec(this.json.filterScript.code, this);
  1262. }else{
  1263. if (this.json.filterPerson && this.json.filterPerson.length){
  1264. flag = ((filterPersons.indexOf(list.person)!==-1)|| (filterPersons.indexOf(list.identity)!==-1));
  1265. }
  1266. }
  1267. return flag;
  1268. },
  1269. loadWorkLogDefault: function(list, container){
  1270. //var text = this.json.textStyle;
  1271. if( list ){
  1272. list.each(function(log, idx){
  1273. this.loadWorkLogLine_default(log, idx, container);
  1274. }.bind(this));
  1275. }else{
  1276. this.workLog.each(function(log, idx){
  1277. if (this.checkShow(log)) this.loadWorkLogLine_default(log, idx, container);
  1278. }.bind(this));
  1279. }
  1280. },
  1281. loadWorkLogLine_default: function(log, idx, container){
  1282. if (!log.readList) log.readList = [];
  1283. if (!log.readCompletedList) log.readCompletedList = [];
  1284. if (log.taskCompletedList.length || log.readList.length || log.readCompletedList.length || (this.json.isTask && log.taskList.length)) {
  1285. var logActivityNode = new Element("div", {"styles": this.form.css.logActivityNode}).inject(container || this.node);
  1286. var titleNode = new Element("div", {"styles": this.form.css.logActivityTitleNode}).inject(logActivityNode);
  1287. var childNode = new Element("div", {"styles": this.form.css.logActivityChildNode}).inject(logActivityNode);
  1288. var iconNode = new Element("div", {"styles": this.form.css.logActivityIconNode}).inject(titleNode);
  1289. var fromAvtivityNode = new Element("div", {"styles": this.form.css.logActivityFromNode}).inject(titleNode);
  1290. var arrowNode = new Element("div", {"styles": this.form.css.logActivityArrowNode}).inject(titleNode);
  1291. var arrivedAvtivityNode = new Element("div", {"styles": this.form.css.logActivityArrivedNode}).inject(titleNode);
  1292. var readActionNode = new Element("div", {"styles": this.form.css.logActivityReadActionNode}).inject(titleNode);
  1293. var timeNode = new Element("div", {"styles": this.form.css.logActivityTimeNode}).inject(titleNode);
  1294. if (log.connected) {
  1295. iconNode.setStyle("background-image", "url(../x_component_process_Xform/$Form/" + this.form.options.style + "/icon/ok14.png)");
  1296. } else {
  1297. iconNode.setStyle("background-image", "url(../x_component_process_Xform/$Form/" + this.form.options.style + "/icon/rightRed.png)");
  1298. }
  1299. fromAvtivityNode.set("html", "<b>" + log.fromActivityName + "</b>");
  1300. if (log.arrivedActivityName) {
  1301. arrowNode.setStyle("background-image", "url(../x_component_process_Xform/$Form/" + this.form.options.style + "/icon/right.png)");
  1302. arrivedAvtivityNode.set("html", "<b>" + log.arrivedActivityName + "</b>");
  1303. timeNode.set("html", "<b>" + MWF.xApplication.process.Xform.LP.begin + ": </b>" + log.fromTime + "<br/><b>" + MWF.xApplication.process.Xform.LP.end + ": </b>" + log.arrivedTime)
  1304. } else {
  1305. timeNode.set("html", "<b>" + MWF.xApplication.process.Xform.LP.begin + ": </b>" + log.fromTime)
  1306. }
  1307. // if ((log.readList && log.readList.length) || (log.readCompletedList && log.readCompletedList.length)){
  1308. // readActionNode.set("text", MWF.xApplication.process.Xform.LP.worklogRead);
  1309. // }
  1310. if ((idx % 2) === 0) {
  1311. logActivityNode.setStyles(this.form.css.logActivityNode_even);
  1312. titleNode.setStyles(this.form.css.logActivityTitleNode_even);
  1313. }
  1314. log.taskCompletedList.each(function (taskCompleted) {
  1315. if (this.checkListShow(log, taskCompleted)) this.loadTaskLine_default(taskCompleted, childNode, log, false);
  1316. }.bind(this));
  1317. if (this.json.isShowRead!==false){
  1318. var readNames = [];
  1319. var readCompletedNames = [];
  1320. if (log.readList && log.readList.length){
  1321. log.readList.each(function(read){
  1322. readNames.push(MWF.name.cn(read.person));
  1323. });
  1324. }
  1325. if (log.readCompletedList && log.readCompletedList.length){
  1326. log.readCompletedList.each(function(read){
  1327. readCompletedNames.push(MWF.name.cn(read.person));
  1328. });
  1329. }
  1330. //if (readCompletedNames.length)
  1331. this.loadReadLine_default(readNames, readCompletedNames, childNode);
  1332. }
  1333. if (this.json.isTask) {
  1334. log.taskList.each(function (task) {
  1335. if (this.checkListShow(log, task)) this.loadTaskLine_default(task, childNode, log, true);
  1336. }.bind(this));
  1337. }
  1338. }
  1339. },
  1340. loadReadLine_default: function(readNames, readCompletedNames, node){
  1341. var html = "";
  1342. var logReadNode = new Element("div", {"styles": this.form.css.logReadTextNode}).inject(node);
  1343. if (readNames.length){
  1344. var readStrTitle = readNames.join(", ");
  1345. var readStr = (readNames.length>20) ? (readNames.slice(0,20).join(", ") + MWF.xApplication.process.Xform.LP.andSoForth ): readStrTitle;
  1346. html = "<span style='color: #0000ff'>"+(this.json.showReadTitle || MWF.xApplication.process.Xform.LP.showReadTitle)+": </span>"+readStr+"<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
  1347. //var logReadPersonNode = new Element("div", {"styles": this.form.css.logReadTextNode}).inject(logReadNode);
  1348. }
  1349. if (readCompletedNames.length){
  1350. var readCompletedStrTitle = readCompletedNames.join(", ");
  1351. var readCompletedStr = (readCompletedNames.length>20) ? (readCompletedNames.slice(0,20).join(", ") + MWF.xApplication.process.Xform.LP.andSoForth ): readCompletedStrTitle;
  1352. html += "<span style='color: #0000ff'>"+(this.json.showReadCompletedTitle || MWF.xApplication.process.Xform.LP.showReadCompletedTitle)+": </span>"+readCompletedStr+"<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
  1353. }
  1354. if (html) logReadNode.set("html", html);
  1355. },
  1356. loadTaskLine_default: function(task, node, log, isTask, margin, isZebra, nodeStyle, noIconNode){
  1357. var style = "logTaskNode";
  1358. var textStyle = "logTaskFloatTextNode";
  1359. if (nodeStyle){
  1360. style = "logTaskTextNode";
  1361. textStyle = "logTaskTextNode";
  1362. }
  1363. var logTaskNode = new Element("div", {"styles": this.form.css[style]}).inject(node);
  1364. var iconNode;
  1365. if( !noIconNode ){
  1366. iconNode = new Element("div", {"styles": this.form.css.logTaskIconNode}).inject(logTaskNode);
  1367. }
  1368. var textNode = new Element("div", {"styles": this.form.css[textStyle]}).inject(logTaskNode);
  1369. if (isZebra){
  1370. logTaskNode.setStyles(this.form.css[this.lineClass]);
  1371. if (this.lineClass === "logTaskNode"){
  1372. this.lineClass = "logTaskNode_even";
  1373. }else{
  1374. this.lineClass = "logTaskNode";
  1375. }
  1376. }
  1377. var left = 28;
  1378. if( iconNode ){
  1379. if (margin) iconNode.setStyle("margin-left", margin);
  1380. left = iconNode.getStyle("margin-left").toInt();
  1381. left = left + 28;
  1382. }
  1383. if( !nodeStyle ){
  1384. textNode.setStyle("margin-left",left+"px");
  1385. }
  1386. var html;
  1387. var company = "";
  1388. if (!isTask){
  1389. company = (task.unitList) ? task.unitList[task.unitList.length-1] : "";
  1390. var html = this.json.textStyle;
  1391. if (task.processingType=="empower") html = "<font style='color:#ff5400;'>{person}</font>({department})授权给<font style='color:#ff5400;'>{empowerTo}</font>处理。({time})</font>";
  1392. var nextTaskText = "";
  1393. if (task.processingType=="empower"){
  1394. var nextTaskParts = [];
  1395. if (task.nextTaskIdentityListText){
  1396. var nestIds = task.nextTaskIdentityListText.split(",");
  1397. nextTaskParts = o2.name.cns(nestIds);
  1398. }else{
  1399. // var nextTasks = o2.name.cns(log.nextTaskIdentityList).join(", ");
  1400. // var nextTaskCompleteds = o2.name.cns(log.nextTaskCompletedIdentityList).join(", ");
  1401. var nextTasks = (log.nextTaskIdentityList && log.nextTaskIdentityList.length) ? o2.name.cns(log.nextTaskIdentityList).join(", ") : "";
  1402. var nextTaskCompleteds = (log.nextTaskCompletedIdentityList && log.nextTaskCompletedIdentityList.length) ? o2.name.cns(log.nextTaskCompletedIdentityList).join(", ") : "";
  1403. if (nextTasks) nextTaskParts.push(nextTasks);
  1404. if (nextTaskCompleteds) nextTaskParts.push(nextTaskCompleteds);
  1405. }
  1406. nextTaskText = nextTaskParts.join(", ");
  1407. }else{
  1408. nextTaskText = (task.empowerToIdentity) ? o2.name.cn(task.empowerToIdentity) : "";
  1409. }
  1410. if (this.json.textStyleScript && this.json.textStyleScript.code){
  1411. this.form.Macro.environment.log = log;
  1412. this.form.Macro.environment.list = null;
  1413. html = this.form.Macro.exec(this.json.textStyleScript.code, this);
  1414. }
  1415. var person = task.person.substring(0, task.person.indexOf("@"));
  1416. if( task.processingType !== "empower" && task.empowerFromIdentity){
  1417. person = person+" 代 "+o2.name.cn(task.empowerFromIdentity||"");
  1418. }
  1419. html = html.replace(/\{person\}/g, person );
  1420. html = html.replace(/\{department\}/g, task.unit.substring(0, task.unit.indexOf("@")));
  1421. html = html.replace(/\{route\}/g, task.routeName);
  1422. html = html.replace(/\{time\}/g, task.completedTime);
  1423. html = html.replace(/\{date\}/g, new Date().parse(task.completedTime).format("%Y-%m-%d"));
  1424. html = html.replace(/\{opinion\}/g, task.opinion || "");
  1425. html = html.replace(/\{company\}/g, company.substring(0, company.indexOf("@")));
  1426. html = html.replace(/\{startTime\}/g, task.startTime);
  1427. html = html.replace(/\{startDate\}/g, new Date().parse(task.startTime).format("%Y-%m-%d"));
  1428. html = html.replace(/\{activity\}/g, log.fromActivityName);
  1429. html = html.replace(/\{arrivedActivity\}/g, log.arrivedActivityName);
  1430. html = html.replace(/\{img\}/g, "<span class='mwf_log_img'></span>");
  1431. html = html.replace(/\{empowerTo\}/g, ((task.empowerToIdentity) ? o2.name.cn(task.empowerToIdentity) : ""));
  1432. html = html.replace(/\{nextTask\}/g, nextTasks);
  1433. html = html.replace(/\{nextTaskCompleted\}/g, nextTaskCompleteds);
  1434. html = html.replace(/\{next\}/g, nextTaskText);
  1435. //var html = MWF.xApplication.process.Xform.LP.nextUser + task.person+"("+task.department+")" +", "+
  1436. // MWF.xApplication.process.Xform.LP.selectRoute + ": [" + task.routeName + "], " +
  1437. // MWF.xApplication.process.Xform.LP.submitAt + ": " + task.completedTime+ ", " +
  1438. // MWF.xApplication.process.Xform.LP.idea + ": <font style=\"color: #00F\">" + (task.opinion || "")+"</font>";
  1439. textNode.set("html", html);
  1440. var imgNode = textNode.getElement(".mwf_log_img");
  1441. if (task.mediaOpinion){
  1442. var mediaIds = task.mediaOpinion.split(",");
  1443. var atts = [];
  1444. if (this.form.businessData.attachmentList){
  1445. this.form.businessData.attachmentList.each(function(att){
  1446. if (att.site==="$mediaOpinion"){
  1447. if (mediaIds.indexOf(att.id)!==-1) atts.push(att);
  1448. }
  1449. }.bind(this));
  1450. }
  1451. if (atts.length){
  1452. if (imgNode){
  1453. this.loadMediaOpinion_show(atts, task, imgNode, true);
  1454. // atts.each(function(att){
  1455. // this.loadMediaOpinion_image_show(att, task, imgNode);
  1456. // }.bind(this));
  1457. }else{
  1458. this.loadMediaOpinion(atts, textNode, "default");
  1459. }
  1460. }
  1461. }
  1462. }else{
  1463. //company = task.unitList[task.unitList.length-1];
  1464. html = task.person.substring(0, task.person.indexOf("@"))+"("+task.unit.substring(0, task.unit.indexOf("@"))+")" + MWF.xApplication.process.Xform.LP.processing+", "+
  1465. MWF.xApplication.process.Xform.LP.comeTime + ": " + task.startTime;
  1466. textNode.set("html", html);
  1467. if(iconNode)iconNode.setStyle("background-image", "url("+"../x_component_process_Xform/$Form/"+this.form.options.style+"/icon/rightRed.png)");
  1468. }
  1469. this.fireEvent("postLoadLine",[{
  1470. "data" : task,
  1471. "node" : logTaskNode,
  1472. "log" : this,
  1473. "type" : isTask ? "task" : "taskCompleted"
  1474. }]);
  1475. },
  1476. loadMediaOpinion: function(atts, node, type){
  1477. atts.each(function(att){
  1478. if (!att.type) att.type = "image";
  1479. if (att.type.indexOf("image")!==-1){
  1480. if( this.json.handwritingExpanded ){
  1481. this.loadMediaOpinion_image_show(att, null, node, true)
  1482. }else if( type === "table" && !layout.mobile ){
  1483. this.loadMediaOpinion_image_tooltip(att, node);
  1484. }else{
  1485. this.loadMediaOpinion_image(att, node);
  1486. }
  1487. }else if(att.type.indexOf("video")!==-1){
  1488. this.loadMediaOpinion_video(att, node);
  1489. }else if(att.type.indexOf("audio")!==-1){
  1490. this.loadMediaOpinion_voice(att, node);
  1491. }else {
  1492. if (this.json.handwritingExpanded){
  1493. this.loadMediaOpinion_image_show(att, null, node, true)
  1494. }else if( type === "table" && !layout.mobile ){
  1495. this.loadMediaOpinion_image_tooltip(att, node);
  1496. }else{
  1497. this.loadMediaOpinion_image(att, node);
  1498. }
  1499. }
  1500. }.bind(this));
  1501. },
  1502. getMediaOpinionUrl: function(att){
  1503. var action = MWF.Actions.get("x_processplatform_assemble_surface");
  1504. var url = action.action.actions["getAttachmentStream"].uri;
  1505. if (this.form.businessData.workCompleted){
  1506. url = action.action.actions["getWorkcompletedAttachmentStream"].uri;
  1507. url = url.replace("{id}", att.id);
  1508. url = url.replace("{workCompletedId}", this.form.businessData.workCompleted.id);
  1509. }else{
  1510. url = url.replace("{id}", att.id);
  1511. url = url.replace("{workid}", this.form.businessData.work.id);
  1512. }
  1513. url = action.action.address+url;
  1514. return o2.filterUrl(url);
  1515. },
  1516. loadMediaOpinion_image_tooltip : function(att, node){
  1517. var iconNode = new Element("div", {"styles": this.form.css.logMediaIcon}).inject(node.getParent());
  1518. iconNode.setStyle("background-image", "url('"+this.form.path+this.form.options.style+"/icon/image.png')");
  1519. iconNode.set("title", MWF.xApplication.process.Xform.LP.mediaOpinion_image);
  1520. if( !this.MTooltipsLoaded )o2.xDesktop.requireApp("Template", "MTooltips", null, false);
  1521. this.MTooltipsLoaded = true;
  1522. var tooltip = new MTooltips(this.form.app.content, iconNode, this.form.app, null, {
  1523. axis : "y", "delay" : 350,
  1524. nodeStyles : {
  1525. "max-width" : "800px"
  1526. }
  1527. });
  1528. tooltip.contentNode = new Element("div",{
  1529. styles : { width : "100%" , height : "100%" }
  1530. });
  1531. var img = new Element("img", {
  1532. "src": this.getMediaOpinionUrl(att),
  1533. "events" : {
  1534. load : function(ev){
  1535. var nh = ev.target.naturalHeight;
  1536. var nw = ev.target.naturalWidth;
  1537. if( this.isNumber( this.json.handwritingWidth ) || this.isNumber( this.json.handwritingHeight ) ){
  1538. var size = this.getImageSize( nw, nh );
  1539. ev.target.setStyles(size);
  1540. }else{
  1541. var x = Math.min(nw, 800);
  1542. ev.target.setStyles({"width": ""+ x +"px"});
  1543. }
  1544. }.bind(this)
  1545. }
  1546. }).inject(tooltip.contentNode);
  1547. },
  1548. loadMediaOpinion_image: function(att, node){
  1549. var iconNode = new Element("div", {"styles": this.form.css.logMediaIcon}).inject(node.getParent());
  1550. iconNode.setStyle("background-image", "url('"+this.form.path+this.form.options.style+"/icon/image.png')");
  1551. iconNode.set("title", MWF.xApplication.process.Xform.LP.mediaOpinion_image);
  1552. iconNode.addEvents({
  1553. "click": function(e){
  1554. if (e.target.mediaOpinionContentNode) return "";
  1555. var url = this.getMediaOpinionUrl(att);
  1556. // if (this.mediaOpinionContentNode){
  1557. // this.mediaOpinionContentNode.destroy();
  1558. // this.mediaOpinionContentNode = null;
  1559. // }
  1560. var imgNode = new Element("div", {"styles": this.form.css.logMediaOpinionContent}).inject(node.getParent(),"after");
  1561. if (!layout.mobile) imgNode.setStyle("margin-left", "40px");
  1562. //this.mediaOpinionContentNode = imgNode;
  1563. e.target.mediaOpinionContentNode = imgNode;
  1564. var imgCloseNode = new Element("div", {"styles": this.form.css.logMediaOpinionContentClose}).inject(imgNode);
  1565. imgCloseNode.addEvent("click", function(){ imgNode.destroy(); e.target.mediaOpinionContentNode = "";});
  1566. var imgAreaNode = new Element("div", {"styles": this.form.css.logMediaOpinionContentArea}).inject(imgNode);
  1567. // var height = 260;
  1568. // var width = 390;
  1569. var width;
  1570. //var height;
  1571. if (layout.mobile){
  1572. width = node.getParent().getParent().getSize().x-2;
  1573. //height = width*2/3;
  1574. }else{
  1575. var pNode = node.getParent().getParent();
  1576. var offset = imgNode.getPosition( pNode );
  1577. width = Math.min( pNode.getSize().x - offset.x - 42, 800 );
  1578. }
  1579. var img = new Element("img", {
  1580. "src": url,
  1581. "styles" : { width : width+"px" },
  1582. "events" : {
  1583. load : function(ev){
  1584. var nh = ev.target.naturalHeight;
  1585. var nw = ev.target.naturalWidth;
  1586. if( !layout.mobile && ( this.isNumber( this.json.handwritingWidth ) || this.isNumber( this.json.handwritingHeight ) ) ){
  1587. var size = this.getImageSize( nw, nh );
  1588. img.setStyles(size);
  1589. imgNode.setStyles(size);
  1590. }else{
  1591. var x = Math.min(nw, width);
  1592. img.setStyles({"width": ""+ x +"px"});
  1593. imgNode.setStyles({"width": ""+ x +"px"});
  1594. }
  1595. }.bind(this)
  1596. }
  1597. }).inject(imgAreaNode);
  1598. //img.setStyles({"width": ""+width+"px"});
  1599. //imgNode.setStyles({"width": ""+width+"px"});
  1600. //img.setStyles({"width": ""+width+"px", "height": ""+height+"px"});
  1601. //imgNode.setStyles({"width": ""+width+"px", "height": ""+height+"px"});
  1602. // var size = img.getSize();
  1603. // var x_y = size.x/size.y;
  1604. //if (size.y>260){
  1605. //}
  1606. // var p = iconNode.getPosition(this.form.app.content);
  1607. // var s = iconNode.getSize();
  1608. // var size = (layout.mobile) ? {"x": width, "y": height}: imgNode.getSize();
  1609. // var contentSize = this.form.app.content.getSize();
  1610. // var contentScroll = (layout.mobile) ? document.body.getFirst().getScroll() : {"x": 0, "y": 0};
  1611. // var y = p.y-size.y;
  1612. // var x = p.x+s.x/2-size.x/2;
  1613. //
  1614. // if (x<10) x = 10;
  1615. // if (x+size.x>contentSize.x-10) x = contentSize.x-size.x-20;
  1616. // if (y+size.y>contentSize.y-10) y = contentSize.y-size.y-20;
  1617. // if (y<10) y = 10;
  1618. // y=y+contentScroll.y;
  1619. //
  1620. // if (layout.mobile){
  1621. // x = 0;
  1622. // }
  1623. // imgNode.setStyles({
  1624. // "top": ""+y+"px",
  1625. // "left": ""+x+"px"
  1626. // });
  1627. // this.hideMediaOpinionNodeFun = this.hideMediaOpinionNode.bind(this);
  1628. // this.form.node.addEvent("mousedown", this.hideMediaOpinionNodeFun);
  1629. e.stopPropagation();
  1630. }.bind(this)
  1631. });
  1632. },
  1633. hideMediaOpinionNode: function(){
  1634. if (this.mediaOpinionContentNode){
  1635. this.mediaOpinionContentNode.destroy();
  1636. this.mediaOpinionContentNode = null;
  1637. }
  1638. // if (this.hideMediaOpinionNodeFun) this.form.node.removeEvent("click", this.hideMediaOpinionNodeFun);
  1639. },
  1640. loadMediaOpinion_video: function(att, node){
  1641. var iconNode = new Element("div", {"styles": this.form.css.logMediaIcon}).inject(node.getParent());
  1642. iconNode.setStyle("background-image", "url('"+this.form.path+this.form.options.style+"/icon/video.png')");
  1643. iconNode.set("title", MWF.xApplication.process.Xform.LP.mediaOpinion_video);
  1644. },
  1645. loadMediaOpinion_voice: function(att, node){
  1646. // this.form.css.logMediaIcon.width = "60px";
  1647. // var iconNode = new Element("audio", {
  1648. // "styles": this.form.css.logMediaIcon,
  1649. // "controls": true,
  1650. // "html": "<source src='"+url+"' type='audio/wav'></source>"
  1651. // }).inject(node.getParent());
  1652. var iconNode = new Element("div", {"styles": this.form.css.logMediaIcon}).inject(node.getParent());
  1653. iconNode.setStyle("background-image", "url('"+this.form.path+this.form.options.style+"/icon/voice.png')");
  1654. iconNode.set("title", MWF.xApplication.process.Xform.LP.mediaOpinion_voice);
  1655. iconNode.addEvents({
  1656. "click": function(e){
  1657. var url = this.getMediaOpinionUrl(att);
  1658. this.audioNode = new Element("audio", {"loop": false});
  1659. this.audioNode.set("src", url);
  1660. this.audioNode.play();
  1661. e.stopPropagation();
  1662. }.bind(this)
  1663. });
  1664. }
  1665. });