Log.js 87 KB

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