jprocand.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. function getUrlParam(name){
  2. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  3. var r = window.location.search.substr(1).match(reg);
  4. if (r != null)
  5. return decodeURI(r[2]);
  6. return null;
  7. }
  8. function parseDate(date){
  9. var y = date.getFullYear(), m = date.getMonth() + 1, d = date.getDate(),
  10. h = date.getHours(), i = date.getMinutes();
  11. var now = new Date(), _y = now.getFullYear(), _m = now.getMonth() + 1, _d = now.getDate();
  12. if(_y != y) {
  13. return y + '-' + m + '-' + d + ' ' + h + ':' + i;
  14. } else {
  15. if(_m != m) {
  16. return m + '月' + d + '号' + h + '点' + i + '分';
  17. } else {
  18. if(_d != d) {
  19. return d + '号' + h + '点' + i + '分';
  20. } else {
  21. return (h < 12 ? '上午' : '下午' ) + h + '点' + i + '分';
  22. }
  23. }
  24. }
  25. }
  26. /*
  27. * 锁定表头和列
  28. *
  29. * 参数定义
  30. * table - 要锁定的表格元素或者表格ID
  31. * freezeRowNum - 要锁定的前几行行数,如果行不锁定,则设置为0
  32. * freezeColumnNum - 要锁定的前几列列数,如果列不锁定,则设置为0
  33. * width - 表格的滚动区域宽度
  34. */
  35. function freezeTable(table, freezeRowNum, freezeColumnNum, width) {
  36. if (typeof(freezeRowNum) == 'string')
  37. freezeRowNum = parseInt(freezeRowNum);
  38. if (typeof(freezeColumnNum) == 'string')
  39. freezeColumnNum = parseInt(freezeColumnNum);
  40. var tableId;
  41. if (typeof(table) == 'string') {
  42. tableId = table;
  43. table = $('#' + tableId);
  44. } else
  45. tableId = table.attr('id');
  46. if(table.width() <= width) return;
  47. height = table.height() + 10;
  48. var divTableLayout = $("#" + tableId + "_tableLayout");
  49. if (divTableLayout.length != 0) {
  50. divTableLayout.before(table);
  51. divTableLayout.empty();
  52. } else {
  53. table.after("<div id='" + tableId + "_tableLayout' style='overflow:hidden;height:" + height + "px; width:" + width + "px;'></div>");
  54. divTableLayout = $("#" + tableId + "_tableLayout");
  55. }
  56. var html = '';
  57. if (freezeRowNum > 0 && freezeColumnNum > 0)
  58. html += '<div id="' + tableId + '_tableFix" style="padding: 0px;"></div>';
  59. if (freezeRowNum > 0)
  60. html += '<div id="' + tableId + '_tableHead" style="padding: 0px;"></div>';
  61. if (freezeColumnNum > 0)
  62. html += '<div id="' + tableId + '_tableColumn" style="padding: 0px;"></div>';
  63. html += '<div id="' + tableId + '_tableData" style="padding: 0px;"></div>';
  64. $(html).appendTo("#" + tableId + "_tableLayout");
  65. var divTableFix = freezeRowNum > 0 && freezeColumnNum > 0 ? $("#" + tableId + "_tableFix") : null;
  66. var divTableHead = freezeRowNum > 0 ? $("#" + tableId + "_tableHead") : null;
  67. var divTableColumn = freezeColumnNum > 0 ? $("#" + tableId + "_tableColumn") : null;
  68. var divTableData = $("#" + tableId + "_tableData");
  69. divTableData.append(table);
  70. if (divTableFix != null) {
  71. var tableFixClone = table.clone(true);
  72. tableFixClone.attr("id", tableId + "_tableFixClone");
  73. divTableFix.append(tableFixClone);
  74. }
  75. if (divTableHead != null) {
  76. var tableHeadClone = table.clone(true);
  77. tableHeadClone.attr("id", tableId + "_tableHeadClone");
  78. divTableHead.append(tableHeadClone);
  79. }
  80. if (divTableColumn != null) {
  81. var tableColumnClone = table.clone(true);
  82. tableColumnClone.attr("id", tableId + "_tableColumnClone");
  83. divTableColumn.append(tableColumnClone);
  84. }
  85. $("#" + tableId + "_tableLayout table").css("margin", "0");
  86. if (freezeRowNum > 0) {
  87. var HeadHeight = 0;
  88. var ignoreRowNum = 0;
  89. $("#" + tableId + "_tableHead tr:lt(" + freezeRowNum + ")").each(function () {
  90. if (ignoreRowNum > 0)
  91. ignoreRowNum--;
  92. else {
  93. var td = $(this).find('td:first, th:first');
  94. HeadHeight += td.outerHeight(true);
  95. ignoreRowNum = td.attr('rowSpan');
  96. if (typeof(ignoreRowNum) == 'undefined')
  97. ignoreRowNum = 0;
  98. else
  99. ignoreRowNum = parseInt(ignoreRowNum) - 1;
  100. }
  101. });
  102. HeadHeight += 2;
  103. divTableHead.css("height", HeadHeight);
  104. divTableFix != null && divTableFix.css("height", HeadHeight);
  105. }
  106. if (freezeColumnNum > 0) {
  107. var ColumnsWidth = 0;
  108. var ColumnsNumber = 0;
  109. $("#" + tableId + "_tableColumn tr:eq(" + freezeRowNum + ")").find("td:lt(" + freezeColumnNum + "), th:lt(" + freezeColumnNum + ")").each(function () {
  110. if (ColumnsNumber >= freezeColumnNum)
  111. return;
  112. ColumnsWidth += $(this).outerWidth(true);
  113. ColumnsNumber += $(this).attr('colSpan') ? parseInt($(this).attr('colSpan')) : 1;
  114. });
  115. ColumnsWidth += 2;
  116. divTableColumn.css("width", ColumnsWidth);
  117. divTableFix != null && divTableFix.css("width", ColumnsWidth);
  118. }
  119. divTableData.scroll(function () {
  120. divTableHead != null && divTableHead.scrollLeft(divTableData.scrollLeft());
  121. divTableColumn != null && divTableColumn.scrollTop(divTableData.scrollTop());
  122. });
  123. divTableFix != null && divTableFix.css({ "overflow": "hidden", "position": "absolute", "z-index": "50" });
  124. divTableHead != null && divTableHead.css({ "overflow": "hidden", "width": width, "position": "absolute", "z-index": "45" });// - 17
  125. divTableColumn != null && divTableColumn.css({ "overflow": "hidden", "height": height, "position": "absolute", "z-index": "40" });// - 17
  126. divTableData.css({ "overflow": "scroll", "width": width, "height": height, "position": "absolute" });
  127. divTableFix != null && divTableFix.offset(divTableLayout.offset());
  128. divTableHead != null && divTableHead.offset(divTableLayout.offset());
  129. divTableColumn != null && divTableColumn.offset(divTableLayout.offset());
  130. divTableData.offset(divTableLayout.offset());
  131. }
  132. /*
  133. * 调整锁定表的宽度和高度,这个函数在resize事件中调用
  134. *
  135. * 参数定义
  136. * table - 要锁定的表格元素或者表格ID
  137. * width - 表格的滚动区域宽度
  138. */
  139. function adjustTableSize(table, width) {
  140. var tableId;
  141. if (typeof(table) == 'string')
  142. tableId = table;
  143. else
  144. tableId = table.attr('id');
  145. height = $("#" + tableId).height() + 10;
  146. $("#" + tableId + "_tableLayout").width(width).height(height);
  147. $("#" + tableId + "_tableHead").width(width);// - 17
  148. $("#" + tableId + "_tableColumn").height(height);// - 17
  149. $("#" + tableId + "_tableData").width(width).height(height);
  150. }
  151. //返回当前页面宽度
  152. function pageWidth() {
  153. if ($.browser.msie) {
  154. return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
  155. } else {
  156. // - padding
  157. return self.innerWidth - 30;
  158. }
  159. };
  160. // close page
  161. function closePage() {
  162. top.window.opener = top;
  163. top.window.open('','_self','');
  164. top.window.close();
  165. }
  166. $(document).ready(function() {
  167. //init custom event(trigger when tabpane active for the first time)
  168. $.event.special.boxready = {
  169. /**
  170. * 初始化事件处理器 - this指向元素
  171. * @param 附加的数据
  172. * @param 事件类型命名空间
  173. * @param 回调函数
  174. */
  175. setup: function(data, namespaces, eventHandle) {
  176. var elem = this;
  177. $.event.add(elem, 'click', function (event) {
  178. if ($.data(elem, '@loaded') !== true) {
  179. $.event.trigger('boxready', null, elem);
  180. $.data(elem, '@loaded', true);
  181. }
  182. });
  183. },
  184. /**
  185. * 卸载事件处理器 - this指向元素
  186. * @param 事件类型命名空间
  187. */
  188. teardown: function(namespaces) {
  189. var elem = this;
  190. $.event.remove(elem, 'click');
  191. $.removeData(elem, '@loaded');
  192. }
  193. };
  194. var cls = 'active', instance = null, current = null, readyTime = new Date();
  195. // toggle tabs
  196. $('.nav-tabs>li>a').click(function(){
  197. if(!$(this).hasClass(cls)) {
  198. var nav = $(this).parent().parent(), bd = nav.next(),
  199. old = nav.children('.' + cls).index(),
  200. index = $(this).parent().index();
  201. $('.tab-pane:eq(' + old + ')', bd).removeClass(cls);
  202. $('.tab-pane:eq(' + index + ')', bd).addClass(cls);
  203. nav.children('.' + cls).removeClass(cls);
  204. $(this).parent().addClass(cls);
  205. }
  206. });
  207. // modal dialog
  208. var dialog = {
  209. show: function(title, content, timeout, callback){
  210. var back = $('.modal-backdrop'), modal = $('.modal'),
  211. tt = $('.modal-title', modal), tb = $('.modal-body', modal);
  212. back.css('display', 'block');
  213. modal.css('display', 'block');
  214. tt.text(title);
  215. if(timeout && timeout > 0) {
  216. content = '<div><strong class="text-success text-xl" id="timeout">' + timeout + '</strong>&nbsp;秒后,' + content + '</div>';
  217. }
  218. tb.html(content);
  219. if(timeout) {
  220. var pre = 1000;
  221. if(timeout <=0 ) {// auto close
  222. pre = 1500;
  223. if(!callback)
  224. callback = dialog.hide;
  225. }
  226. var timer = function(t) {
  227. setTimeout(function(){
  228. if(t > -1) {
  229. $('#timeout').text(t--);
  230. timer(t);
  231. } else {
  232. callback && callback.call();
  233. }
  234. }, pre);
  235. };
  236. timer(timeout);
  237. }
  238. },
  239. hide: function() {
  240. var back = $('.modal-backdrop'), modal = $('.modal');
  241. back.css('display', 'none');
  242. modal.css('display', 'none');
  243. }
  244. };
  245. // loading
  246. var setLoading = function(isLoading) {
  247. $('.loading-container').css('display', isLoading ? 'block' : 'none');
  248. };
  249. // get instance
  250. var getInstance = function(id, callback) {
  251. $.post(basePath + 'common/getProcessInstanceId.action', {
  252. jp_nodeId: id,
  253. _noc: 1
  254. }, function(result, text) {
  255. var e = result.exceptionInfo;
  256. if(e) {
  257. if(e == 'ERR_NETWORK_SESSIONOUT') {
  258. dialog.show('错误', '请先登录!');
  259. } else {
  260. dialog.show('出现异常', '请稍后再试...');
  261. }
  262. } else {
  263. instance = result.processInstanceId;
  264. callback && callback.call(null, instance);
  265. }
  266. });
  267. };
  268. // get process
  269. var getProcess = function(id) {
  270. setLoading(true);
  271. $.post(basePath + 'common/getCurrentNode.action', {
  272. jp_nodeId: id,
  273. _noc: 1
  274. }, function(result, text) {
  275. setLoading(false);
  276. var e = result.exceptionInfo;
  277. if(e) {
  278. if(e == 'ERR_NETWORK_SESSIONOUT') {
  279. dialog.show('错误', '请先登录!');
  280. } else {
  281. dialog.show('出现异常', '请稍后再试...');
  282. }
  283. } else {
  284. instance = result.info.InstanceId;
  285. parseNode(result.info.currentnode);
  286. // result.info.button 额外的按钮,以供修改单据(例如客户拜访),在这里不考虑
  287. }
  288. });
  289. };
  290. // get main point
  291. var getMainPoint = function(id) {
  292. $.post(basePath + 'common/getCustomSetupOfTask.action', {
  293. nodeId: id,
  294. _noc: 1
  295. }, function(result, text) {
  296. if(result.cs) {
  297. var points = [], data = result.data ? result.data.split(';') : [];
  298. $.each(result.cs, function(i, c){
  299. var m = c.indexOf('^'), n = c.indexOf('$'), q = c.indexOf('@');
  300. points.push({
  301. type: c.substring(m + 1, n),
  302. text: c.substring(0, m),
  303. required: c.substr(n + 1, 1) === 'Y',
  304. value: data[i] ? data[i].substring(data[i].lastIndexOf("(") + 1, data[i].lastIndexOf(")")) : null,
  305. logic: q > 0 ? c.substring(q + 1) : null
  306. });
  307. });
  308. if(points.length > 0)
  309. parseMainPoint(points);
  310. }
  311. });
  312. };
  313. // get history
  314. var getHistory = function(instanceId, callback) {
  315. setLoading(true);
  316. $.post(basePath + 'common/getAllHistoryNodes.action', {
  317. processInstanceId: instanceId,
  318. _noc: 1
  319. }, function(result, text) {
  320. setLoading(false);
  321. var e = result.exceptionInfo;
  322. if(e) {
  323. if(e == 'ERR_NETWORK_SESSIONOUT') {
  324. dialog.show('错误', '请先登录!');
  325. } else {
  326. dialog.show('出现异常', '请稍后再试...');
  327. }
  328. } else {
  329. if(callback)
  330. callback.call(null, result.nodes);
  331. if(result.nodes && result.nodes.length > 0) {
  332. parseHistory(result.nodes);
  333. }
  334. }
  335. });
  336. };
  337. // get bill main
  338. var getBillMain = function(caller, url, cond, billId) {
  339. $.post(basePath + 'common/rsForm.action', {
  340. caller: caller,
  341. condition: cond,
  342. url: url,
  343. _noc: 1
  344. }, function(result, text) {
  345. var e = result.exceptionInfo;
  346. if(e) {
  347. if(e == 'ERR_NETWORK_SESSIONOUT') {
  348. dialog.show('错误', '请先登录!');
  349. } else {
  350. dialog.show('出现异常', '请稍后再试...');
  351. }
  352. } else {
  353. if(result.data) {
  354. parseBillMain(result);
  355. if(caller == 'VisitRecord') {
  356. initVisitRecord(result, billId);
  357. }
  358. }
  359. }
  360. });
  361. };
  362. // get bill detail
  363. var getBillDetail = function(caller, url, cond){
  364. setLoading(true);
  365. $.post(basePath + 'common/rsGrid.action', {
  366. caller: caller,
  367. condition: cond,
  368. url: url,
  369. start: 0,
  370. end: 100,
  371. _noc: 1
  372. }, function(result, text) {
  373. setLoading(false);
  374. var e = result.exceptionInfo;
  375. if(e) {
  376. if(e == 'ERR_NETWORK_SESSIONOUT') {
  377. dialog.show('错误', '请先登录!');
  378. } else {
  379. dialog.show('出现异常', '请稍后再试...');
  380. }
  381. } else {
  382. if(result.data)
  383. parseBillDetail(result.data);
  384. }
  385. });
  386. };
  387. // parse current node
  388. var parseNode = function(node) {
  389. current = node;
  390. $('#jp_name').html('[接管] ' + node.jp_name);
  391. $('#jp_name').css('margin-left', "-" + node.jp_name.replace(/[^\x00-\xff]/g, 'xx').length * 7 + "px");
  392. $('#jp_nodeName').text( node.jp_nodeName);
  393. $('#jp_launcherName').text(node.jp_launcherName);
  394. $('#jp_launchTime').text(parseDate(new Date(node.jp_launchTime)));
  395. $('#jp_codevalue').text(node.jp_codevalue);
  396. // get bill main data
  397. if(node.jp_keyName && node.jp_keyValue) {
  398. getBillMain(node.jp_caller, node.jp_url, node.jp_keyName + '=\'' + node.jp_keyValue + '\'', node.jp_keyValue);
  399. }
  400. // has detail
  401. if(node.jp_formDetailKey) {
  402. $('#detail-header').bind('boxready', function(){
  403. getBillDetail(node.jp_caller, node.jp_url, node.jp_formDetailKey + '=\'' + node.jp_keyValue + '\'');
  404. });
  405. } else {
  406. $('#detail-header').css('display', 'none');
  407. }
  408. // main point
  409. getMainPoint(node.jp_nodeId);
  410. };
  411. // parse main point
  412. var parseMainPoint = function(points) {
  413. var html = '<ul class="list-group">';
  414. html += '<li class="list-group-item disabled"><strong>问题要点</strong></li>';
  415. $.each(points, function(i, p){
  416. html += '<li class="list-group-item">';
  417. html += '<span>' + p.text + '</span>';
  418. if(p.type === 'B') {
  419. html += '<div class="pull-right"><div class="has-switch switch-small"><div class="' + (p.value && p.value != '是' ? 'switch-off' : 'switch-on') + ' switch-animate"><input type="checkbox" ' + (p.value && p.value != '是' ? '' : 'checked') + ' title="' + p.text + '" ' + (p.logic ? 'logic="' + p.logic + '"' : '') + '> <span class="switch-left switch-success switch-small">是</span> <label class="switch-small">&nbsp;</label> <span class="switch-right switch-warning switch-small">否</span></div></div></div>';
  420. } else if(p.type === 'S' || p.type === 'N') {
  421. html += '<div class="pull-right"><input class="form-control input-xs" type="text" placeholder="..." value="' + (p.value || '') + '" ' + (p.logic ? 'logic="' + p.logic + '"' : '') + ' title="' + p.text + '" ' + (p.required ? 'required' : '') + '></div>';
  422. } else if(p.type === 'D') {
  423. html += '<div class="pull-right"><input class="form-control input-xs" type="date" placeholder="..." value="' + (p.value || '') + '" ' + (p.logic ? 'logic="' + p.logic + '"' : '') + ' title="' + p.text + '" ' + (p.required ? 'required' : '') + '></div>';
  424. }
  425. html += '</li>';
  426. });
  427. html += '</ul>';
  428. $('#points').html(html);
  429. // toggle switch
  430. $('#points .has-switch').click(function(){
  431. var e = $(this), box = e.find('input'), checked = box.is(':checked');
  432. if(checked)
  433. box.removeAttr('checked');
  434. else
  435. box.attr('checked','checked');
  436. e.find('>div').removeClass(checked ? 'switch-on' : 'switch-off');
  437. e.find('>div').addClass(checked ? 'switch-off' : 'switch-on');
  438. });
  439. };
  440. // parse bill main
  441. var parseBillMain = function(main) {
  442. var bill = main.data, html = '<table class="table table-condensed table-bordered table-striped">', g = null;
  443. if(main.group) {
  444. for(k in bill) {
  445. g = bill[k];
  446. html += '<tr><td colspan="2" class="text-center text-success"><strong>' + k + '</strong>&nbsp;<span class="glyphicon glyphicon-chevron-down"></span></td></tr>';
  447. for(b in g) {
  448. html += '<tr>';
  449. html += '<td class="text-right special"><strong>' + b + '</strong></td>';
  450. html += '<td class="text-center">' + g[b] + '</td>';
  451. html += '</tr>';
  452. };
  453. }
  454. } else {
  455. for(b in bill) {
  456. html += '<tr>';
  457. html += '<td class="text-right special"><strong>' + b + '</strong></td>';
  458. html += '<td class="text-center">' + bill[b] + '</td>';
  459. html += '</tr>';
  460. };
  461. }
  462. html += '</table>';
  463. $('#bill-main').html(html);
  464. };
  465. // parse bill detail
  466. var parseBillDetail = function(detail){
  467. var html = '<table id="bill-detail-table" class="table table-condensed table-bordered table-striped">';
  468. for(c in detail) {
  469. html += '<tr>';
  470. html += '<td class="text-right special"><strong>' + c + '</strong></td>';
  471. if(detail[c] && detail[c].length > 0) {
  472. $.each(detail[c], function(i, p){
  473. html += '<td class="text-center">' + p + '</td>';
  474. });
  475. } else {
  476. html += '<td class="text-center text-muted">(无)</td>';
  477. }
  478. html += '</tr>';
  479. }
  480. html += '</table>';
  481. $('#bill-detail').html(html);
  482. var table = $('#bill-detail table');
  483. freezeTable(table, 0, 1, pageWidth());
  484. var flag = false;
  485. $(window).resize(function() {
  486. if (flag)
  487. return ;
  488. setTimeout(function() {
  489. adjustTableSize(table.attr('id'), pageWidth());
  490. flag = false;
  491. }, 100);
  492. flag = true;
  493. });
  494. };
  495. // parse history
  496. var parseHistory = function(hist) {
  497. var html = '<ul class="list-unstyled list-inline">';
  498. $.each(hist, function(i, h){
  499. var res = h.jn_dealResult == '同意' ? 'success' : (h.jn_dealResult == '不同意' ? 'error' : 'warning');
  500. html += '<li>';
  501. html += '<div class="text-top">';
  502. html += '<span>' + h.jn_name + '</span>';
  503. html += '</div>';
  504. html += '<blockquote>';
  505. html += '<strong>' + h.jn_dealManName + '</strong>';
  506. html += '<div class="text-trans ' + res + '">';
  507. html += '<span>' + h.jn_dealResult + '</span>';
  508. html += '</div>';
  509. html += '<footer>' + h.jn_dealTime + '</footer>';
  510. html += '</blockquote>';
  511. if(h.jn_operatedDescription || h.jn_nodeDescription || h.jn_infoReceiver) {
  512. html += '<div class="highlight">';
  513. if(h.jn_nodeDescription)
  514. html += '<div>' + h.jn_nodeDescription + '</div>';
  515. if(h.jn_infoReceiver)
  516. html += '<p class="text-muted"><i>' + h.jn_infoReceiver + '</i></p>';
  517. if(h.jn_operatedDescription) {
  518. if(h.jn_operatedDescription.indexOf('(是)') > 0 ||
  519. h.jn_operatedDescription.indexOf('(否)') > 0) {
  520. html += '<ul class="list-group">';
  521. var descs = h.jn_operatedDescription.split(';');
  522. $.each(descs, function(j, d){
  523. res = d.substr(d.length - 3) == '(是)' ? 'glyphicon glyphicon-ok text-success' :
  524. 'glyphicon glyphicon-remove text-warning';
  525. html += '<li class="list-group-item"><span class="pull-right ' + res + '"></span>' + d.substr(0, d.length-3) + '</li>';
  526. });
  527. html += '</ul>';
  528. } else {
  529. html += '<div>' + h.jn_operatedDescription + '</div>';
  530. }
  531. }
  532. html += '</div>';
  533. }
  534. html += '</li>';
  535. });
  536. html += '</ul>';
  537. $('#history').html(html);
  538. };
  539. // get process by node id
  540. var nodeId = getUrlParam('nodeId');
  541. if (nodeId) {
  542. getProcess(nodeId);
  543. // get history by instance id
  544. $('#history-header').bind('boxready', function(){
  545. if(instance) {
  546. getHistory(instance);
  547. } else {
  548. getInstance(nodeId, function(instanceId){
  549. getHistory(instanceId);
  550. });
  551. }
  552. });
  553. }
  554. // get radio,checkbox value
  555. var getBoxValue = function(selector) {
  556. var value = null;
  557. $(selector).each(function(){
  558. var t = $(this);
  559. if(t.is(":checked")) {
  560. value = t.val();
  561. }
  562. });
  563. return value;
  564. };
  565. // accept接管按钮
  566. var accept = function() {
  567. setLoading(true);
  568. $.post(basePath + 'common/takeOverTask.action', {
  569. nodeId: nodeId,
  570. em_code: em_code,
  571. needreturn: true,
  572. _noc: 1
  573. }, function(result, text) {
  574. setLoading(false);
  575. if(result.success) {
  576. $('.modal .modal-header').css('color', '#27ad60');
  577. dialog.show('接管成功', '正在为您跳转至单据操作界面...', 1, function(){
  578. window.location.href = basePath + 'jsps/mobile/process.jsp?nodeId=' + nodeId;
  579. });
  580. } else if (result.exceptionInfo){
  581. $('.modal .modal-header').css('color', '#f50');
  582. dialog.show('接管失败', result.exceptionInfo + '<br>请返回应用界面');
  583. } else {
  584. $('.modal .modal-header').css('color', '#f50');
  585. dialog.show('处理结果', "出现错误,请联系管理员。");
  586. }
  587. });
  588. };
  589. $('#accept').click(function(){
  590. accept();
  591. });
  592. // close 跳转至首页
  593. $('#close').click(function(){
  594. window.location.href = basePath;
  595. });
  596. // get search result
  597. var getSearchResult = function(input) {
  598. setLoading(true);
  599. $.post(basePath + 'hr/emplmana/search.action', {
  600. keyword: input
  601. }, function(result, text){
  602. setLoading(false);
  603. if(result.length > 0) {
  604. parseSearchResult(result);
  605. }
  606. });
  607. };
  608. // parse search result
  609. var parseSearchResult = function(datas){
  610. var html = '';
  611. $.each(datas, function(i, d){
  612. var e = d.split('\n');
  613. html += '<a href="javascript:onItemClick(\'' + e[1] + '\',\'' + e[2] + '\');" class="list-group-item">';
  614. html += '<span>' + e[0] + '</span>';
  615. html += '<span class="right">' + e[1] + '(' + e[2] + ')</span>';
  616. html += '</a>';
  617. });
  618. $('#em_search').html(html);
  619. };
  620. // touch on mobile need jquery-mobile.js & event 'tap'
  621. window.onItemClick = function(code, name) {
  622. $('#em_search').parent().css('display', 'none');
  623. $('#em_code').text(code);
  624. };
  625. });