Log.js 86 KB

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