Log.js 98 KB

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