processOld.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399
  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. $.ajax({
  268. url:basePath + 'common/getProcessInstanceId.action',
  269. type: 'POST',
  270. data: {jp_nodeId: id, _noc: 1},
  271. success: function(result){
  272. instance = result.processInstanceId;
  273. callback && callback.call(null, instance);
  274. },
  275. error: function(xhr){
  276. if(xhr.responseText) {
  277. var response =$.evalJSON(xhr.responseText);
  278. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  279. dialog.show('获取信息失败', '请先登录!');
  280. } else {
  281. dialog.show('错误', response.exceptionInfo);
  282. }
  283. }
  284. }
  285. });
  286. };
  287. // get process
  288. var getProcess = function(id) {
  289. setLoading(true);
  290. // $.post(basePath + 'common/getCurrentNode.action', {
  291. // jp_nodeId: id,
  292. // _noc: 1
  293. // }, function(result, text) {
  294. // setLoading(false);
  295. // var e = result.exceptionInfo;
  296. // if(e) {
  297. // if(e == 'ERR_NETWORK_SESSIONOUT') {
  298. // dialog.show('错误', '请先登录!');
  299. // } else {
  300. // dialog.show('出现异常', '请稍后再试...');
  301. // }
  302. // } else {
  303. // instance = result.info.InstanceId;
  304. // parseNode(result.info.currentnode);
  305. // // result.info.button 额外的按钮,以供修改单据(例如客户拜访),在这里不考虑
  306. // }
  307. // });
  308. $.ajax({
  309. url:basePath + 'common/getCurrentNode.action',
  310. type: 'POST',
  311. data: {jp_nodeId: id, _noc: 1},
  312. success: function(result){
  313. setLoading(false);
  314. instance = result.info.InstanceId;
  315. parseNode(result.info.currentnode);
  316. },
  317. error: function(xhr,a,b,c){
  318. setLoading(false);
  319. if(xhr.responseText) {
  320. var response =$.evalJSON(xhr.responseText);
  321. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  322. dialog.show('获取信息失败', '请先登录!');
  323. } else {
  324. dialog.show('错误', response.exceptionInfo,-1);
  325. }
  326. }
  327. }
  328. });
  329. };
  330. // get main point
  331. var getMainPoint = function(id) {
  332. // $.post(basePath + 'common/getCustomSetupOfTask.action', {
  333. // nodeId: id,
  334. // _noc: 1
  335. // }, function(result, text) {
  336. // if(result.cs) {
  337. // var points = [], data = result.data ? result.data.split(';') : [];
  338. // $.each(result.cs, function(i, c){
  339. // var m = c.indexOf('^'), n = c.indexOf('$'), q = c.indexOf('@');
  340. // points.push({
  341. // type: c.substring(m + 1, n),
  342. // text: c.substring(0, m),
  343. // required: c.substr(n + 1, 1) === 'Y',
  344. // value: data[i] ? data[i].substring(data[i].lastIndexOf("(") + 1, data[i].lastIndexOf(")")) : null,
  345. // logic: q > 0 ? c.substring(q + 1) : null
  346. // });
  347. // });
  348. // if(points.length > 0)
  349. // parseMainPoint(points);
  350. // }
  351. // });
  352. $.ajax({
  353. url:basePath + 'common/getCustomSetupOfTask.action',
  354. type: 'POST',
  355. data: {nodeId: id, _noc: 1},
  356. success: function(result){
  357. if(result.cs) {
  358. var points = [], data = result.data ? result.data.split(';') : [];
  359. $.each(result.cs, function(i, c){
  360. var m = c.indexOf('^'), n = c.indexOf('$'), q = c.indexOf('@');
  361. points.push({
  362. type: c.substring(m + 1, n),
  363. text: c.substring(0, m),
  364. required: c.substr(n + 1, 1) === 'Y',
  365. value: data[i] ? data[i].substring(data[i].lastIndexOf("(") + 1, data[i].lastIndexOf(")")) : null,
  366. logic: q > 0 ? c.substring(q + 1) : null
  367. });
  368. });
  369. if(points.length > 0)
  370. parseMainPoint(points);
  371. }
  372. },
  373. error: function(xhr){
  374. if(xhr.responseText) {
  375. var response =$.evalJSON(xhr.responseText);
  376. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  377. dialog.show('获取信息失败', '请先登录!');
  378. } else {
  379. dialog.show('错误', response.exceptionInfo);
  380. }
  381. }
  382. }
  383. });
  384. };
  385. // get history
  386. var getHistory = function(instanceId, callback) {
  387. setLoading(true);
  388. // $.post(basePath + 'common/getAllHistoryNodes.action', {
  389. // processInstanceId: instanceId,
  390. // _noc: 1
  391. // }, function(result, text) {
  392. // setLoading(false);
  393. // var e = result.exceptionInfo;
  394. // if(e) {
  395. // if(e == 'ERR_NETWORK_SESSIONOUT') {
  396. // dialog.show('错误', '请先登录!');
  397. // } else {
  398. // dialog.show('出现异常', '请稍后再试...');
  399. // }
  400. // } else {
  401. // if(callback)
  402. // callback.call(null, result.nodes);
  403. // if(result.nodes && result.nodes.length > 0) {
  404. // parseHistory(result.nodes);
  405. // }
  406. // }
  407. // });
  408. $.ajax({
  409. url:basePath + 'common/getAllHistoryNodes.action',
  410. type: 'POST',
  411. data: {processInstanceId: instanceId, _noc: 1},
  412. success: function(result){
  413. setLoading(false);
  414. if(callback)
  415. callback.call(null, result.nodes);
  416. if(result.nodes && result.nodes.length > 0) {
  417. parseHistory(result.nodes);
  418. }
  419. },
  420. error: function(xhr){
  421. setLoading(false);
  422. if(xhr.responseText) {
  423. var response =$.evalJSON(xhr.responseText);
  424. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  425. dialog.show('获取用户信息失败', '请先登录!');
  426. } else {
  427. dialog.show('错误', response.exceptionInfo);
  428. }
  429. }
  430. }
  431. });
  432. };
  433. // get bill main
  434. var getBillMain = function(caller, url, cond, billId) {
  435. // $.post(basePath + 'common/rsForm.action', {
  436. // caller: caller,
  437. // condition: cond,
  438. // url: url,
  439. // _noc: 1
  440. // }, function(result, text) {
  441. // var e = result.exceptionInfo;
  442. // if(e) {
  443. // if(e == 'ERR_NETWORK_SESSIONOUT') {
  444. // dialog.show('错误', '请先登录!');
  445. // } else {
  446. // dialog.show('出现异常', '请稍后再试...');
  447. // }
  448. // } else {
  449. // if(result.data) {
  450. // parseBillMain(result);
  451. // if(caller == 'VisitRecord' || caller == 'VisitRecord!Vender') {
  452. // initVisitRecord(result, billId);
  453. // }
  454. // }
  455. // }
  456. // });
  457. $.ajax({
  458. url:basePath + 'common/rsForm.action',
  459. type: 'POST',
  460. data: {caller: caller, condition: cond, url: url, _noc: 1},
  461. success: function(result){
  462. if(result.data) {
  463. parseBillMain(result);
  464. if(caller == 'VisitRecord' || caller == 'VisitRecord!Vender') {
  465. initVisitRecord(result, billId);
  466. }
  467. }
  468. },
  469. error: function(xhr){
  470. if(xhr.responseText) {
  471. var response =$.evalJSON(xhr.responseText);
  472. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  473. dialog.show('获取用户信息失败', '请先登录!');
  474. } else {
  475. dialog.show('错误', response.exceptionInfo);
  476. }
  477. }
  478. }
  479. });
  480. };
  481. //init extra element when VisitRecord
  482. var initVisitRecord = function(main, billId) {
  483. $('#ex').css('display', 'block');
  484. var data = main.data['评价'], title = data ? (data['评分'] || '良') : '良',
  485. msg = data ? data['评语'] : '';
  486. if(title) {
  487. $('#ex-rating button[title="' + title + '"]').addClass('active');
  488. }
  489. $('#ex-msg').val(msg);
  490. $('#ex-rating button').click(function(){
  491. $('#ex-rating button').each(function(){
  492. $(this).removeClass('active');
  493. });
  494. $(this).addClass('active');
  495. });
  496. $('#ex-confirm').click(function(){
  497. msg = $('#ex-msg').val() || '-';
  498. title = '';
  499. $('#ex-rating button').each(function(){
  500. if($(this).hasClass('active'))
  501. title = $(this).attr('title');
  502. });
  503. setLoading(true);
  504. // $.post(basePath + 'crm/customermgr/updateVisitRecordPingjia.action', {
  505. // id: billId,
  506. // vr_newtitle: title,
  507. // vr_purpose: msg,
  508. // _noc: 1
  509. // }, function(result, text) {
  510. // setLoading(false);
  511. // var e = result.exceptionInfo;
  512. // if(e) {
  513. // if(e == 'ERR_NETWORK_SESSIONOUT') {
  514. // dialog.show('错误', '请先登录!');
  515. // } else {
  516. // dialog.show('出现异常', '请稍后再试...');
  517. // }
  518. // } else {
  519. // dialog.show('提示', '评价成功', -1);
  520. // }
  521. // });
  522. $.ajax({
  523. url:basePath + 'crm/customermgr/updateVisitRecordPingjia.action',
  524. type: 'POST',
  525. data: {id: billId, vr_newtitle: title, vr_purpose: msg, _noc: 1},
  526. success: function(result){
  527. setLoading(false);
  528. dialog.show('提示', '评价成功', -1);
  529. },
  530. error: function(xhr){
  531. setLoading(false);
  532. if(xhr.responseText) {
  533. var response =$.evalJSON(xhr.responseText);
  534. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  535. dialog.show('获取信息失败', '请先登录!');
  536. } else {
  537. dialog.show('错误', response.exceptionInfo);
  538. }
  539. }
  540. }
  541. });
  542. });
  543. };
  544. // get bill detail
  545. var getBillDetail = function(caller, url, cond){
  546. setLoading(true);
  547. // $.post(basePath + 'common/rsGrid.action', {
  548. // caller: caller,
  549. // condition: cond,
  550. // url: url,
  551. // start: 0,
  552. // end: 100,
  553. // _noc: 1
  554. // }, function(result, text) {
  555. // setLoading(false);
  556. // var e = result.exceptionInfo;
  557. // if(e) {
  558. // if(e == 'ERR_NETWORK_SESSIONOUT') {
  559. // dialog.show('错误', '请先登录!');
  560. // } else {
  561. // dialog.show('出现异常', '请稍后再试...');
  562. // }
  563. // } else {
  564. // if(result.data)
  565. // parseBillDetail(result.data, $('#bill-detail'));
  566. // }
  567. // });
  568. $.ajax({
  569. url:basePath + 'common/rsGrid.action',
  570. type: 'POST',
  571. data: {caller: caller, condition: cond, url: url, start: 0, end: 100, _noc: 1},
  572. success: function(result){
  573. setLoading(false);
  574. if(result.data)
  575. parseBillDetail(result.data, $('#bill-detail'));
  576. },
  577. error: function(xhr){
  578. setLoading(false);
  579. if(xhr.responseText) {
  580. var response =$.evalJSON(xhr.responseText);
  581. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  582. dialog.show('获取信息失败', '请先登录!');
  583. } else {
  584. dialog.show('错误', response.exceptionInfo);
  585. }
  586. }
  587. }
  588. });
  589. };
  590. // parse current node
  591. var parseNode = function(node) {
  592. current = node;
  593. $('#jp_name').text(node.jp_name);
  594. $('#jp_name').css('margin-left', "-" + node.jp_name.replace(/[^\x00-\xff]/g, 'xx').length * 7 + "px");
  595. $('#jp_nodeName').text(node.jp_nodeName);
  596. $('#jp_launcherName').text(node.jp_launcherName);
  597. $('#jp_launchTime').text(parseDate(new Date(node.jp_launchTime)));
  598. $('#jp_codevalue').text(node.jp_codevalue);
  599. // get bill main data
  600. if(node.jp_keyName && node.jp_keyValue) {
  601. getBillMain(node.jp_caller, node.jp_url, node.jp_keyName + '=\'' + node.jp_keyValue + '\'', node.jp_keyValue);
  602. }
  603. // has detail
  604. if(node.jp_formDetailKey) {
  605. $('#detail-header').bind('boxready', function(){
  606. getBillDetail(node.jp_caller, node.jp_url, node.jp_formDetailKey + '=\'' + node.jp_keyValue + '\'');
  607. });
  608. } else {
  609. $('#detail-header').css('display', 'none');
  610. }
  611. // main point
  612. getMainPoint(node.jp_nodeId);
  613. // deal relative
  614. if(true){
  615. dealRelative(node.jp_caller);
  616. }
  617. };
  618. // parse main point
  619. var parseMainPoint = function(points) {
  620. var html = '<ul class="list-group">';
  621. html += '<li class="list-group-item disabled"><strong>问题要点</strong></li>';
  622. $.each(points, function(i, p){
  623. html += '<li class="list-group-item">';
  624. html += '<span>' + p.text + '</span>';
  625. if(p.type === 'B') {
  626. 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>';
  627. } else if(p.type === 'S' || p.type === 'N') {
  628. 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>';
  629. } else if(p.type === 'D') {
  630. 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>';
  631. }
  632. html += '</li>';
  633. });
  634. html += '</ul>';
  635. $('#points').html(html);
  636. // toggle switch
  637. $('#points .has-switch').click(function(){
  638. var e = $(this), box = e.find('input'), checked = box.is(':checked');
  639. if(checked)
  640. box.removeAttr('checked');
  641. else
  642. box.attr('checked','checked');
  643. e.find('>div').removeClass(checked ? 'switch-on' : 'switch-off');
  644. e.find('>div').addClass(checked ? 'switch-off' : 'switch-on');
  645. });
  646. };
  647. // parse bill main
  648. var parseBillMain = function(main) {
  649. var bill = main.data, html = '<table class="table table-condensed table-bordered table-striped">', g = null;
  650. if(main.group) {
  651. for(k in bill) {
  652. g = bill[k];
  653. html += '<tr><td colspan="2" class="text-center text-success"><strong>' + k + '</strong>&nbsp;<span class="glyphicon glyphicon-chevron-down"></span></td></tr>';
  654. for(b in g) {
  655. html += '<tr>';
  656. html += '<td class="text-right special"><strong>' + b + '</strong></td>';
  657. html += '<td class="text-center">' + g[b] + '</td>';
  658. html += '</tr>';
  659. };
  660. }
  661. } else {
  662. for(b in bill) {
  663. html += '<tr>';
  664. html += '<td class="text-right special"><strong>' + b + '</strong></td>';
  665. html += '<td class="text-center">' + bill[b] + '</td>';
  666. html += '</tr>';
  667. };
  668. }
  669. html += '</table>';
  670. $('#bill-main').html(html);
  671. };
  672. // parse bill detail
  673. var parseBillDetail = function(detail, content){
  674. var html = '<table id="bill-detail-table" class="table table-condensed table-bordered table-striped">';
  675. for(c in detail) {
  676. html += '<tr>';
  677. html += '<td class="text-right special"><strong>' + c + '</strong></td>';
  678. if(detail[c] && detail[c].length > 0) {
  679. $.each(detail[c], function(i, p){
  680. html += '<td class="text-center">' + p + '</td>';
  681. });
  682. } else {
  683. html += '<td class="text-center text-muted">(无)</td>';
  684. }
  685. html += '</tr>';
  686. }
  687. html += '</table>';
  688. content.html(html);
  689. var table = $('table', content);
  690. freezeTable(table, 0, 1, pageWidth());
  691. var flag = false;
  692. $(window).resize(function() {
  693. if (flag)
  694. return ;
  695. setTimeout(function() {
  696. adjustTableSize(table.attr('id'), pageWidth());
  697. flag = false;
  698. }, 100);
  699. flag = true;
  700. });
  701. };
  702. // parse history
  703. var parseHistory = function(hist) {
  704. var html = '<ul class="list-unstyled list-inline">';
  705. $.each(hist, function(i, h){
  706. var res = h.jn_dealResult == '同意' ? 'success' : (h.jn_dealResult == '不同意' ? 'error' : 'warning');
  707. html += '<li>';
  708. html += '<div class="text-top">';
  709. html += '<span>' + h.jn_name + '</span>';
  710. html += '</div>';
  711. html += '<blockquote>';
  712. html += '<strong>' + h.jn_dealManName + '</strong>';
  713. html += '<div class="text-trans ' + res + '">';
  714. html += '<span>' + h.jn_dealResult + '</span>';
  715. html += '</div>';
  716. html += '<footer>' + h.jn_dealTime + '</footer>';
  717. html += '</blockquote>';
  718. if(h.jn_operatedDescription || h.jn_nodeDescription || h.jn_infoReceiver) {
  719. html += '<div class="highlight">';
  720. if(h.jn_nodeDescription)
  721. html += '<div>' + h.jn_nodeDescription + '</div>';
  722. if(h.jn_infoReceiver)
  723. html += '<p class="text-muted"><i>' + h.jn_infoReceiver + '</i></p>';
  724. if(h.jn_operatedDescription) {
  725. if(h.jn_operatedDescription.indexOf('(是)') > 0 ||
  726. h.jn_operatedDescription.indexOf('(否)') > 0) {
  727. html += '<ul class="list-group">';
  728. var descs = h.jn_operatedDescription.split(';');
  729. $.each(descs, function(j, d){
  730. res = d.substr(d.length - 3) == '(是)' ? 'glyphicon glyphicon-ok text-success' :
  731. 'glyphicon glyphicon-remove text-warning';
  732. html += '<li class="list-group-item"><span class="pull-right ' + res + '"></span>' + d.substr(0, d.length-3) + '</li>';
  733. });
  734. html += '</ul>';
  735. } else {
  736. html += '<div>' + h.jn_operatedDescription + '</div>';
  737. }
  738. }
  739. html += '</div>';
  740. }
  741. html += '</li>';
  742. });
  743. html += '</ul>';
  744. $('#history').html(html);
  745. };
  746. // get process by node id
  747. var nodeId = getUrlParam('nodeId');
  748. if (nodeId) {
  749. getProcess(nodeId);
  750. // get history by instance id
  751. $('#history-header').bind('boxready', function(){
  752. if(instance) {
  753. getHistory(instance);
  754. } else {
  755. getInstance(nodeId, function(instanceId){
  756. getHistory(instanceId);
  757. });
  758. }
  759. });
  760. }
  761. // get radio,checkbox value
  762. var getBoxValue = function(selector) {
  763. var value = null;
  764. $(selector).each(function(){
  765. var t = $(this);
  766. if(t.is(":checked")) {
  767. value = t.val();
  768. }
  769. });
  770. return value;
  771. };
  772. // node next step
  773. var nextStep = function(callback) {
  774. $.post(basePath + 'common/dealNextStepOfPInstance.action', {
  775. processInstanceId: instance,
  776. _noc: 1
  777. }, function(result, text) {
  778. if(result.hasNext) {
  779. if (result.actorUsers.length > 0 && result.actorUsers[0].JP_CANDIDATES.length>0) {
  780. var html = '<p>';
  781. html += "下一步审批节点有多位处理人,请指定一位:";
  782. html += '</p>';
  783. html += '<form>';
  784. html += '<div class="form-group" style="max-height:150px;overflow-y:auto;">';
  785. $.each(result.actorUsers[0].JP_CANDIDATES, function(i, u){
  786. html += '<label class="radio-inline" style="margin-bottom:10px;margin-right:20px;">';
  787. html += '<input type="radio" name="user" value="' + u + '"' +
  788. (i == 0 ? ' checked="checked"' : '') + ' style="position:static;"> ' + u;
  789. html += '</label>';
  790. });
  791. html += '</div>';
  792. html += '<div class="btn-group btn-group-xs btn-group-justified">';
  793. html += '<div class="btn-group"><button type="button" class="btn btn-primary" id="confirm">指定</button></div>';
  794. html += '<div class="btn-group"><button type="button" class="btn btn-default" id="cancel">暂不指定</button></div>';
  795. html += '</div>';
  796. html += '</form>';
  797. dialog.show('下一步', html);
  798. // choose one to handle next node
  799. $('#confirm').click(function(){
  800. appointNext(result.actorUsers[0].JP_NODEID, getBoxValue('form input[type="radio"]'), callback);
  801. });
  802. // notice evenyone to receive next node
  803. $('#cancel').click(function(){
  804. noticeNext(result.actorUsers[0].JP_NODEID, result.actorUsers[0].JP_CANDIDATES, callback);
  805. });
  806. } else {
  807. callback && callback.call();
  808. }
  809. }
  810. });
  811. };
  812. // appoint one to deal next
  813. var appointNext = function(nodeId, user, callback) {
  814. // $.post(basePath + 'common/takeOverTask.action', {
  815. // em_code: user.substring(user.lastIndexOf('(') + 1, user.length - 1),
  816. // nodeId: nodeId,
  817. // _noc: 1
  818. // }, function(result, text) {
  819. // if(result.success)
  820. // callback && callback.call();
  821. // else
  822. // dialog.show('错误', '指派失败,请稍后再试!');
  823. // });
  824. $.ajax({
  825. url:basePath + 'common/takeOverTask.action',
  826. type: 'POST',
  827. data: {em_code: user.substring(user.lastIndexOf('(') + 1, user.length - 1), nodeId: nodeId, _noc: 1},
  828. success: function(result){
  829. if(result.success)
  830. callback && callback.call();
  831. },
  832. error: function(xhr){
  833. if(xhr.responseText) {
  834. var response =$.evalJSON(xhr.responseText);
  835. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  836. dialog.show('获取信息失败', '请先登录!');
  837. } else {
  838. dialog.show('指派失败', response.exceptionInfo);
  839. }
  840. }
  841. }
  842. });
  843. };
  844. // notice next users
  845. var noticeNext = function(nodeId, users, callback) {
  846. // $.post(basePath + 'common/processpaging.action', {
  847. // persons: unescape(users.join(',')),
  848. // nodeId: nodeId,
  849. // _noc: 1
  850. // }, function(result, text) {
  851. // if(result.success)
  852. // callback && callback.call();
  853. // });
  854. $.ajax({
  855. url:basePath + 'common/processpaging.action',
  856. type: 'POST',
  857. data: {persons: unescape(users.join(',')), nodeId: nodeId, _noc: 1},
  858. success: function(result){
  859. if(result.success)
  860. callback && callback.call();
  861. },
  862. error: function(xhr){
  863. if(xhr.responseText) {
  864. var response =$.evalJSON(xhr.responseText);
  865. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  866. dialog.show('获取信息失败', '请先登录!');
  867. } else {
  868. dialog.show('错误', response.exceptionInfo);
  869. }
  870. }
  871. }
  872. });
  873. };
  874. // load next process
  875. var processNext = function(id) {
  876. if(id != '-1') {
  877. var url = window.location.href;
  878. window.location.href = url.substr(0, url.indexOf('?') + 1) + 'nodeId=' + id;
  879. } else {
  880. dialog.show('提示', '暂时没有新的审批任务了!');
  881. }
  882. };
  883. // is valid
  884. var isValid = function() {
  885. var deals = $('#points input');
  886. if(deals.length > 0) {
  887. $.each(deals, function(i, d){
  888. var e = $(d), type = e.attr('type'), val = e.val();
  889. if((type === 'text' || type === 'date') && !val)
  890. return false;
  891. });
  892. }
  893. return true;
  894. };
  895. // get your points
  896. var getDealPoints = function() {
  897. var deals = $('#points input');
  898. if(deals.length > 0) {
  899. var points = [];
  900. $.each(deals, function(i, d){
  901. var e = $(d), text = e.attr('title'), type = e.attr('type'), val = e.val(),
  902. lg = e.attr('logic');
  903. val = type == 'checkbox' ? (e.is(':checked') ? '是' : '否') : val;
  904. points.push(text + '(' + val + ')' + (lg ? '@' + lg + '@' : ''));
  905. });
  906. return points.join(';');
  907. }
  908. return null;
  909. };
  910. // agree
  911. var agree = function() {
  912. if(!isValid()) {
  913. dialog.show(' 警告', '您还有审批要点问题没处理!', -1);
  914. return;
  915. }
  916. setLoading(true);
  917. // $.post(basePath + 'common/review.action', {
  918. // taskId: nodeId,
  919. // nodeName: current.jp_nodeName,
  920. // nodeLog: $('#deal-msg').val(),
  921. // holdtime: ((new Date() - readyTime) / 1000).toFixed(0),
  922. // customDes: getDealPoints(),
  923. // result: true,
  924. // _noc: 1
  925. // }, function(result, text) {
  926. // setLoading(false);
  927. // if(result.success) {
  928. // if (result.nextnode == '0') {
  929. // dialog.show('审批成功', '您暂时没有其它的审批任务了。');
  930. // } else {
  931. // if(result.after) {
  932. // if (result.after.trim().substr(0, 12) == 'AFTERSUCCESS') {
  933. // dialog.show('审批出现提示:' + result.after.replace('AFTERSUCCESS', ''),
  934. // '自动为您跳转到下一条...', 5, function(){
  935. // nextStep(function(){
  936. // processNext(result.nextnode);
  937. // });
  938. // });
  939. // } else {
  940. // dialog.show('审批出现异常', result.after);
  941. // }
  942. // } else {
  943. // dialog.show('审批成功', '自动为您跳转到下一条...', 1, function(){
  944. // nextStep(function(){
  945. // processNext(result.nextnode);
  946. // });
  947. // });
  948. // }
  949. // }
  950. // } else if (result.exceptionInfo){
  951. // dialog.show('无法审批', result.exceptionInfo);
  952. // } else {
  953. // dialog.show('处理结果', "该任务已处理,不能重复操作!");
  954. // }
  955. // });
  956. $.ajax({
  957. url:basePath + 'common/review.action',
  958. type: 'POST',
  959. data: {taskId: nodeId, nodeName: current.jp_nodeName, nodeLog: $('#deal-msg').val(),
  960. holdtime: ((new Date() - readyTime) / 1000).toFixed(0),customDes: getDealPoints(),result: true,_noc: 1},
  961. success: function(result){
  962. setLoading(false);
  963. if(result.success) {
  964. if (result.nextnode == '0') {
  965. dialog.show('审批成功', '您暂时没有其它的审批任务了。');
  966. } else {
  967. if(result.after) {
  968. if (result.after.trim().substr(0, 12) == 'AFTERSUCCESS') {
  969. dialog.show('审批出现提示:' + result.after.replace('AFTERSUCCESS', ''),
  970. '自动为您跳转到下一条...', 5, function(){
  971. nextStep(function(){
  972. processNext(result.nextnode);
  973. });
  974. });
  975. } else {
  976. dialog.show('审批出现异常', result.after);
  977. }
  978. } else {
  979. dialog.show('审批成功', '自动为您跳转到下一条...', 1, function(){
  980. nextStep(function(){
  981. processNext(result.nextnode);
  982. });
  983. });
  984. }
  985. }
  986. }
  987. },
  988. error: function(xhr){
  989. setLoading(false);
  990. if(xhr.responseText) {
  991. var response =$.evalJSON(xhr.responseText);
  992. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  993. dialog.show('获取用户信息失败', '请先登录!');
  994. } else {
  995. dialog.show('无法审批', response.exceptionInfo);
  996. }
  997. }
  998. }
  999. });
  1000. };
  1001. $('#agree').click(function(){
  1002. agree();
  1003. });
  1004. // disagree -> return back
  1005. var disagree = function(backNode, msg){
  1006. setLoading(true);
  1007. // $.post(basePath + 'common/review.action', {
  1008. // taskId: nodeId,
  1009. // nodeName: current.jp_nodeName,
  1010. // backTaskName: backNode,
  1011. // nodeLog: msg,
  1012. // holdtime: ((new Date() - readyTime) / 1000).toFixed(0),
  1013. // result: false,
  1014. // _noc: 1
  1015. // }, function(result, text) {
  1016. // setLoading(false);
  1017. // if(result.success) {
  1018. // if(result.after) {
  1019. // dialog.show('回退过程出现提示:' + result.after);
  1020. // } else {
  1021. // dialog.show('回退成功', '自动为您跳转到下一条...', 1, function(){
  1022. // nextStep(function(){
  1023. // processNext(result.nextnode);
  1024. // });
  1025. // });
  1026. // }
  1027. // } else {
  1028. // dialog.show('处理结果', "该任务已处理,不能重复操作!");
  1029. // }
  1030. // });
  1031. $.ajax({
  1032. url:basePath + 'common/review.action',
  1033. type: 'POST',
  1034. data: {taskId: nodeId, nodeName: current.jp_nodeName, backTaskName: backNode, nodeLog: msg,
  1035. holdtime: ((new Date() - readyTime) / 1000).toFixed(0), result: false, _noc: 1},
  1036. success: function(result){
  1037. setLoading(false);
  1038. if(result.success) {
  1039. if(result.after) {
  1040. dialog.show('回退过程出现提示:' + result.after);
  1041. } else {
  1042. dialog.show('回退成功', '自动为您跳转到下一条...', 1, function(){
  1043. nextStep(function(){
  1044. processNext(result.nextnode);
  1045. });
  1046. });
  1047. }
  1048. } else {
  1049. dialog.show('处理结果', "该任务已处理,不能重复操作!");
  1050. }
  1051. },
  1052. error: function(xhr){
  1053. setLoading(false);
  1054. if(xhr.responseText) {
  1055. var response =$.evalJSON(xhr.responseText);
  1056. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1057. dialog.show('获取用户信息失败', '请先登录!');
  1058. } else {
  1059. dialog.show('错误', response.exceptionInfo);
  1060. }
  1061. }
  1062. }
  1063. });
  1064. };
  1065. $('#disagree').click(function(){
  1066. getHistory(instance, function(nodes){
  1067. var html = '<form>';
  1068. html += '<div class="form-group">';
  1069. html += '<label class="radio-inline">';
  1070. html += '<input type="radio" name="node" value="RECORDER" checked="checked"> 制单人';
  1071. html += '</label>';
  1072. $.each(nodes, function(i, n){
  1073. html += '<label class="radio-inline">';
  1074. html += '<input type="radio" name="node" value="' + n.jn_name + '"> ' + n.jn_name;
  1075. html += '</label>';
  1076. });
  1077. html += '</div>';
  1078. html += '<div class="form-group"><textarea id="back-msg" rows="2" placeholder="填写您不同意的原因..." class="form-control">' + $('#deal-msg').val() + '</textarea><span class="help-block text-lg text-error" id="back_err"></span></div>';
  1079. html += '<div class="btn-group btn-group-xs btn-group-justified">';
  1080. html += '<div class="btn-group"><button type="button" class="btn btn-primary" id="back">回退</button></div>';
  1081. html += '<div class="btn-group"><button type="button" class="btn btn-default" id="cancel2">取消</button></div>';
  1082. html += '</div>';
  1083. html += '</form>';
  1084. dialog.show('回退到节点', html);
  1085. // choose one to back
  1086. $('#back').click(function(){
  1087. var msg = $('#back-msg').val();
  1088. if (!msg) {
  1089. $('#back_err').text('请填写您不同意的原因!');
  1090. $('#back-msg').focus();
  1091. } else {
  1092. disagree(getBoxValue('form input[type="radio"]'), msg);
  1093. }
  1094. });
  1095. // cancel
  1096. $('#cancel2').click(function(){
  1097. dialog.hide();
  1098. });
  1099. });
  1100. });
  1101. // end
  1102. var end = function(){
  1103. setLoading(true);
  1104. // $.post(basePath + 'common/endProcessInstance.action', {
  1105. // processInstanceId: instance,
  1106. // holdtime: ((new Date() - readyTime) / 1000).toFixed(0),
  1107. // nodeId: nodeId,
  1108. // _noc: 1
  1109. // }, function(result, text) {
  1110. // setLoading(false);
  1111. // if(result.success) {
  1112. // dialog.show('流程已结束', '自动为您跳转到下一条...', 1, function(){
  1113. // nextStep(function(){
  1114. // processNext(result.nextnode);
  1115. // });
  1116. // });
  1117. // } else {
  1118. // dialog.show('警告', "流程实例不存在!");
  1119. // }
  1120. // });
  1121. $.ajax({
  1122. url:basePath + 'common/endProcessInstance.action',
  1123. type: 'POST',
  1124. data: {processInstanceId: instance, holdtime: ((new Date() - readyTime) / 1000).toFixed(0),
  1125. nodeId: nodeId, _noc: 1},
  1126. success: function(result){
  1127. setLoading(false);
  1128. if(result.success) {
  1129. dialog.show('流程已结束', '自动为您跳转到下一条...', 1, function(){
  1130. nextStep(function(){
  1131. processNext(result.nextnode);
  1132. });
  1133. });
  1134. } else {
  1135. dialog.show('警告', "流程实例不存在!");
  1136. }
  1137. },
  1138. error: function(xhr){
  1139. setLoading(false);
  1140. if(xhr.responseText) {
  1141. var response =$.evalJSON(xhr.responseText);
  1142. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1143. dialog.show('获取用户信息失败', '请先登录!');
  1144. } else {
  1145. dialog.show('错误', response.exceptionInfo);
  1146. }
  1147. }
  1148. }
  1149. });
  1150. };
  1151. $('#end').click(function(){
  1152. end();
  1153. });
  1154. // change
  1155. var change = function(user, msg){
  1156. if(!user) {
  1157. $('#change_err').text('您还没选择变更人!');
  1158. return;
  1159. }
  1160. if(!isValid()) {
  1161. $('#change_err').text('您还有审批要点问题没处理!');
  1162. return;
  1163. }
  1164. setLoading(true);
  1165. // $.post(basePath + 'common/setAssignee.action', {
  1166. // taskId: nodeId,
  1167. // assigneeId: user,
  1168. // processInstanceId: instance,
  1169. // customDes: getDealPoints(),
  1170. // description: msg,
  1171. // _noc: 1
  1172. // }, function(result, text) {
  1173. // setLoading(false);
  1174. // if(result.result) {
  1175. // dialog.show('处理结果', '节点已成功变更');
  1176. // } else {
  1177. // dialog.show('处理结果', "任务不存在,无法变更!");
  1178. // }
  1179. // });
  1180. $.ajax({
  1181. url:basePath + 'common/setAssignee.action',
  1182. type: 'POST',
  1183. data: {taskId: nodeId, assigneeId: user, processInstanceId: instance,
  1184. ncustomDes: getDealPoints(), description: msg, _noc: 1},
  1185. success: function(result){
  1186. setLoading(false);
  1187. if(result.result) {
  1188. dialog.show('处理结果', '节点已成功变更');
  1189. } else {
  1190. dialog.show('处理结果', "任务不存在,无法变更!");
  1191. }
  1192. },
  1193. error: function(xhr){
  1194. setLoading(false);
  1195. if(xhr.responseText) {
  1196. var response =$.evalJSON(xhr.responseText);
  1197. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1198. dialog.show('获取用户信息失败', '请先登录!');
  1199. } else {
  1200. dialog.show('错误', response.exceptionInfo);
  1201. }
  1202. }
  1203. }
  1204. });
  1205. };
  1206. $('#change').click(function(){
  1207. var html = '<form>';
  1208. html += '<div class="form-group has-feedback dropdown"><input id="em_new" name="em_new" class="form-control dropdown-toggle" type="text" placeholder="新的处理人,点击搜索"/><span id="change_search_icon" class="glyphicon glyphicon-search form-control-feedback"></span><div class="dropdown-menu"><div id="em_search" class="list-group"></div></div>' +
  1209. '<span class="help-block text-lg">' +
  1210. '<span id="change_name"></span>' +
  1211. '<span id="em_code"></span>' +
  1212. '</span></div>';
  1213. html += '<div class="form-group"><textarea id="change-msg" rows="2" placeholder="填写您要变更的原因..." class="form-control">' + $('#deal-msg').val() + '</textarea><span class="help-block text-lg text-error" id="change_err"></span></div>';
  1214. html += '<div class="btn-group btn-group-xs btn-group-justified">';
  1215. html += '<div class="btn-group"><button type="button" class="btn btn-primary" id="change3">变更</button></div>';
  1216. html += '<div class="btn-group"><button type="button" class="btn btn-default" id="cancel3">取消</button></div>';
  1217. html += '</div>';
  1218. html += '</form>';
  1219. dialog.show('变更办理人', html);
  1220. // search deal man
  1221. $('#em_new').bind('focus', function(){
  1222. if($(this).val()) {
  1223. $(this).parent().children('.dropdown-menu').css('display', 'block');
  1224. }
  1225. });
  1226. $('#em_new').bind('change', function(){// 点击获取变更的候选人
  1227. var v = $(this).val();
  1228. var view = $(this).parent().children('.dropdown-menu');
  1229. if(v) {
  1230. view.css('display', 'block');
  1231. getSearchResult(v);
  1232. } else {
  1233. view.css('display', 'none');
  1234. }
  1235. });
  1236. $('#em_new').bind('keyup', function(event){// 回车获取变更的候选人
  1237. if(event.keyCode == 13) {
  1238. event.preventDefault();
  1239. var v = $(this).val();
  1240. var view = $(this).parent().children('.dropdown-menu');
  1241. if(v) {
  1242. view.css('display', 'block');
  1243. getSearchResult(v);
  1244. } else {
  1245. view.css('display', 'none');
  1246. }
  1247. }
  1248. });
  1249. $('#change_search_icon').bind('click', function(event){// 变更查询放大镜图标点击获取变更的候选人
  1250. var v = $('#em_new').val();
  1251. var view = $('#em_new').parent().parent().children('.dropdown-menu');
  1252. if(v) {
  1253. view.css('display', 'block');
  1254. getSearchResult(v);
  1255. } else {
  1256. view.css('display', 'none');
  1257. }
  1258. });
  1259. // change
  1260. $('#change3').click(function(){
  1261. var msg = $('#change-msg').val();
  1262. change($('#em_code').text(), msg);
  1263. });
  1264. // cancel
  1265. $('#cancel3').click(function(){
  1266. dialog.hide();
  1267. });
  1268. });
  1269. // get search result
  1270. var getSearchResult = function(input) {
  1271. setLoading(true);
  1272. $.post(basePath + 'hr/emplmana/search.action', {
  1273. keyword: input
  1274. }, function(result, text){
  1275. setLoading(false);
  1276. if(result.length > 0) {
  1277. parseSearchResult(result);
  1278. }
  1279. });
  1280. };
  1281. // parse search result
  1282. var parseSearchResult = function(datas){
  1283. var html = '';
  1284. $.each(datas, function(i, d){
  1285. var e = d.split('\n');
  1286. html += '<a href="javascript:onItemClick(\'' + e[1] + '\',\'' + e[2] + '\');" class="list-group-item">';
  1287. html += '<span class="left">' + (e[0] || '(空)') + '</span>';
  1288. html += '<span class="right">' + e[2] + '(' + e[1] + ')</span>';
  1289. html += '</a>';
  1290. });
  1291. $('#em_search').html(html);
  1292. };
  1293. //关联查询
  1294. var dealRelative = function(caller) {
  1295. $('#expand').html('展开&nbsp;<span '+
  1296. 'class="glyphicon glyphicon-share-alt"></span>');
  1297. $('#expand').click(function(){
  1298. $('#expand').addClass('hidden');
  1299. $('#re-content').removeClass('hidden');
  1300. $('#shrink').removeClass('hidden');
  1301. });
  1302. $('#expand').bind('boxready', function(){
  1303. setLoading(true);
  1304. // $.post(basePath + 'common/form/relativeSearchMobile.action', {
  1305. // caller: caller
  1306. // }, function(result){
  1307. // setLoading(false);
  1308. // if(result.exceptionInfo) {
  1309. // dialog.show('错误', '数据加载错误,请重试', 1, function(){dialog.hide();})
  1310. // } else {
  1311. // $('#relative .title .text').css('width', (138+result.data[0].form.title.length*18)+'px');
  1312. // $('#relative .title .text').append('-'+result.data[0].form.title);
  1313. // var html = '';
  1314. // html += '<div class="control-group">'+
  1315. // '<label class="control-lable" for="'+result.data[0].form.items[0].name+'">'+
  1316. // result.data[0].form.items[0].fieldLabel+':</label>'+
  1317. // '<select type="text" id="'+result.data[0].form.items[0].name+'" name="'+
  1318. // result.data[0].form.items[0].name+'" class="form-control"></select>'+
  1319. // '<button id="re-search" type="button" class="btn btn-success">筛选</button>'+
  1320. // '</div>';
  1321. // $('#re-filtrate').html(html);
  1322. // }
  1323. // });
  1324. $.ajax({
  1325. url:basePath + 'common/form/relativeSearchMobile.action',
  1326. type: 'POST',
  1327. data: {caller: caller},
  1328. success: function(result){
  1329. setLoading(false);
  1330. $('#relative .title .text').css('width', (138+result.data[0].form.title.length*18)+'px');
  1331. $('#relative .title .text').append('-'+result.data[0].form.title);
  1332. var html = '';
  1333. html += '<div class="control-group">'+
  1334. '<label class="control-lable" for="'+result.data[0].form.items[0].name+'">'+
  1335. result.data[0].form.items[0].fieldLabel+':</label>'+
  1336. '<select type="text" id="'+result.data[0].form.items[0].name+'" name="'+
  1337. result.data[0].form.items[0].name+'" class="form-control"></select>'+
  1338. '<button id="re-search" type="button" class="btn btn-success">筛选</button>'+
  1339. '</div>';
  1340. $('#re-filtrate').html(html);
  1341. },
  1342. error: function(xhr){
  1343. setLoading(false);
  1344. if(xhr.responseText) {
  1345. var response =$.evalJSON(xhr.responseText);
  1346. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1347. dialog.show('获取信息失败', '请先登录!', 1, function(){dialog.hide();})
  1348. } else {
  1349. dialog.show('错误', response.exceptionInfo,1, function(){dialog.hide();});
  1350. }
  1351. }
  1352. }
  1353. });
  1354. });
  1355. $('#shrink').click(function(){
  1356. $('#expand').removeClass('hidden');
  1357. $('#re-content').addClass('hidden');
  1358. $('#shrink').addClass('hidden');
  1359. });
  1360. };
  1361. // touch on mobile need jquery-mobile.js & event 'tap'
  1362. window.onItemClick = function(code, name) {
  1363. $('#em_search').parent().css('display', 'none');
  1364. $('#change_name').text(name + ' - ')
  1365. $('#em_code').text(code);
  1366. };
  1367. });