Log.js 85 KB

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