task.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. //读取链接参数
  2. function getUrlParam(name, link){
  3. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  4. var search;
  5. if (link) {search = link.substr(link.indexOf("?"),link.length);}
  6. else { search = window.location.search;}
  7. var r = search.substr(1).match(reg);
  8. if (r != null)
  9. return decodeURI(r[2]);
  10. return null;
  11. }
  12. //处理日期
  13. function parseDate(date){
  14. var y = date.getFullYear(), m = date.getMonth() + 1, d = date.getDate(),
  15. h = date.getHours(), i = date.getMinutes();
  16. var now = new Date(), _y = now.getFullYear(), _m = now.getMonth() + 1, _d = now.getDate();
  17. if(_y != y) {
  18. return y + '-' + m + '-' + d + ' ' + h + ':' + i;
  19. } else {
  20. if(_m != m) {
  21. return m + '月' + d + '号' + h + '点' + i + '分';
  22. } else {
  23. if(_d != d) {
  24. return d + '号' + h + '点' + i + '分';
  25. } else {
  26. return (h < 12 ? '上午' : '下午' ) + h + '点' + i + '分';
  27. }
  28. }
  29. }
  30. }
  31. /**
  32. * 锁定表头和列
  33. *
  34. * 参数定义
  35. * table - 要锁定的表格元素或者表格ID
  36. * freezeRowNum - 要锁定的前几行行数,如果行不锁定,则设置为0
  37. * freezeColumnNum - 要锁定的前几列列数,如果列不锁定,则设置为0
  38. * width - 表格的滚动区域宽度
  39. */
  40. function freezeTable(table, freezeRowNum, freezeColumnNum, width) {
  41. if (typeof(freezeRowNum) == 'string')
  42. freezeRowNum = parseInt(freezeRowNum);
  43. if (typeof(freezeColumnNum) == 'string')
  44. freezeColumnNum = parseInt(freezeColumnNum);
  45. var tableId;
  46. if (typeof(table) == 'string') {
  47. tableId = table;
  48. table = $('#' + tableId);
  49. } else
  50. tableId = table.attr('id');
  51. if(table.width() <= width) return;
  52. height = table.height() + 10;
  53. var divTableLayout = $("#" + tableId + "_tableLayout");
  54. if (divTableLayout.length != 0) {
  55. divTableLayout.before(table);
  56. divTableLayout.empty();
  57. } else {
  58. table.after("<div id='" + tableId + "_tableLayout' style='overflow:hidden;height:" + height + "px; width:" + width + "px;'></div>");
  59. divTableLayout = $("#" + tableId + "_tableLayout");
  60. }
  61. var html = '';
  62. if (freezeRowNum > 0 && freezeColumnNum > 0)
  63. html += '<div id="' + tableId + '_tableFix" style="padding: 0px;"></div>';
  64. if (freezeRowNum > 0)
  65. html += '<div id="' + tableId + '_tableHead" style="padding: 0px;"></div>';
  66. if (freezeColumnNum > 0)
  67. html += '<div id="' + tableId + '_tableColumn" style="padding: 0px;"></div>';
  68. html += '<div id="' + tableId + '_tableData" style="padding: 0px;"></div>';
  69. $(html).appendTo("#" + tableId + "_tableLayout");
  70. var divTableFix = freezeRowNum > 0 && freezeColumnNum > 0 ? $("#" + tableId + "_tableFix") : null;
  71. var divTableHead = freezeRowNum > 0 ? $("#" + tableId + "_tableHead") : null;
  72. var divTableColumn = freezeColumnNum > 0 ? $("#" + tableId + "_tableColumn") : null;
  73. var divTableData = $("#" + tableId + "_tableData");
  74. divTableData.append(table);
  75. if (divTableFix != null) {
  76. var tableFixClone = table.clone(true);
  77. tableFixClone.attr("id", tableId + "_tableFixClone");
  78. divTableFix.append(tableFixClone);
  79. }
  80. if (divTableHead != null) {
  81. var tableHeadClone = table.clone(true);
  82. tableHeadClone.attr("id", tableId + "_tableHeadClone");
  83. divTableHead.append(tableHeadClone);
  84. }
  85. if (divTableColumn != null) {
  86. var tableColumnClone = table.clone(true);
  87. tableColumnClone.attr("id", tableId + "_tableColumnClone");
  88. divTableColumn.append(tableColumnClone);
  89. }
  90. $("#" + tableId + "_tableLayout table").css("margin", "0");
  91. if (freezeRowNum > 0) {
  92. var HeadHeight = 0;
  93. var ignoreRowNum = 0;
  94. $("#" + tableId + "_tableHead tr:lt(" + freezeRowNum + ")").each(function () {
  95. if (ignoreRowNum > 0)
  96. ignoreRowNum--;
  97. else {
  98. var td = $(this).find('td:first, th:first');
  99. HeadHeight += td.outerHeight(true);
  100. ignoreRowNum = td.attr('rowSpan');
  101. if (typeof(ignoreRowNum) == 'undefined')
  102. ignoreRowNum = 0;
  103. else
  104. ignoreRowNum = parseInt(ignoreRowNum) - 1;
  105. }
  106. });
  107. HeadHeight += 2;
  108. divTableHead.css("height", HeadHeight);
  109. divTableFix != null && divTableFix.css("height", HeadHeight);
  110. }
  111. if (freezeColumnNum > 0) {
  112. var ColumnsWidth = 0;
  113. var ColumnsNumber = 0;
  114. $("#" + tableId + "_tableColumn tr:eq(" + freezeRowNum + ")").find("td:lt(" + freezeColumnNum + "), th:lt(" + freezeColumnNum + ")").each(function () {
  115. if (ColumnsNumber >= freezeColumnNum)
  116. return;
  117. ColumnsWidth += $(this).outerWidth(true);
  118. ColumnsNumber += $(this).attr('colSpan') ? parseInt($(this).attr('colSpan')) : 1;
  119. });
  120. ColumnsWidth += 2;
  121. divTableColumn.css("width", ColumnsWidth);
  122. divTableFix != null && divTableFix.css("width", ColumnsWidth);
  123. }
  124. divTableData.scroll(function () {
  125. divTableHead != null && divTableHead.scrollLeft(divTableData.scrollLeft());
  126. divTableColumn != null && divTableColumn.scrollTop(divTableData.scrollTop());
  127. });
  128. divTableFix != null && divTableFix.css({ "overflow": "hidden", "position": "absolute", "z-index": "50" });
  129. divTableHead != null && divTableHead.css({ "overflow": "hidden", "width": width, "position": "absolute", "z-index": "45" });// - 17
  130. divTableColumn != null && divTableColumn.css({ "overflow": "hidden", "height": height, "position": "absolute", "z-index": "40" });// - 17
  131. divTableData.css({ "overflow": "scroll", "width": width, "height": height, "position": "absolute" });
  132. divTableFix != null && divTableFix.offset(divTableLayout.offset());
  133. divTableHead != null && divTableHead.offset(divTableLayout.offset());
  134. divTableColumn != null && divTableColumn.offset(divTableLayout.offset());
  135. divTableData.offset(divTableLayout.offset());
  136. }
  137. /**
  138. * 调整锁定表的宽度和高度,这个函数在resize事件中调用
  139. *
  140. * 参数定义
  141. * table - 要锁定的表格元素或者表格ID
  142. * width - 表格的滚动区域宽度
  143. */
  144. function adjustTableSize(table, width) {
  145. var tableId;
  146. if (typeof(table) == 'string')
  147. tableId = table;
  148. else
  149. tableId = table.attr('id');
  150. height = $("#" + tableId).height() + 10;
  151. $("#" + tableId + "_tableLayout").width(width).height(height);
  152. $("#" + tableId + "_tableHead").width(width);// - 17
  153. $("#" + tableId + "_tableColumn").height(height);// - 17
  154. $("#" + tableId + "_tableData").width(width).height(height);
  155. }
  156. //返回当前页面宽度
  157. function pageWidth() {
  158. if ($.browser.msie) {
  159. return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
  160. } else {
  161. // - padding
  162. return self.innerWidth - 30;
  163. }
  164. };
  165. $(document).ready(function() {
  166. //自定义事件类型 boxready(当第一次点击时触发,当Tab页面第一次打开时触发)
  167. $.event.special.boxready = {
  168. /**
  169. * 初始化事件处理器 - this指向元素
  170. * @param 附加的数据
  171. * @param 事件类型命名空间
  172. * @param 回调函数
  173. */
  174. setup: function(data, namespaces, eventHandle) {
  175. var elem = this;
  176. $.event.add(elem, 'click', function (event) {
  177. if ($.data(elem, '@loaded') !== true) {
  178. $.event.trigger('boxready', null, elem);
  179. $.data(elem, '@loaded', true);
  180. }
  181. });
  182. },
  183. /**
  184. * 卸载事件处理器 - this指向元素
  185. * @param 事件类型命名空间
  186. */
  187. teardown: function(namespaces) {
  188. var elem = this;
  189. $.event.remove(elem, 'click');
  190. $.removeData(elem, '@loaded');
  191. }
  192. };
  193. var cls = 'active', instance = null, current = null, readyTime = new Date();
  194. // Tab切换开关增加点击事件
  195. $('.nav-tabs>li>a').click(function(){
  196. if(!$(this).hasClass(cls)) {
  197. var nav = $(this).parent().parent(), bd = nav.parent().next(),
  198. old = nav.children('.' + cls).index(),
  199. index = $(this).parent().index();
  200. $('.tab-pane:eq(' + old + ')', bd).removeClass(cls);
  201. $('.tab-pane:eq(' + index + ')', bd).addClass(cls);
  202. nav.children('.' + cls).removeClass(cls);
  203. $(this).parent().addClass(cls);
  204. }
  205. });
  206. // 模态对话框
  207. var dialog = {
  208. show: function(title, content, timeout, callback){
  209. var back = $('.modal-backdrop'), modal = $('.modal'),
  210. tt = $('.modal-title', modal), tb = $('.modal-body', modal);
  211. back.css('display', 'block');
  212. modal.css('display', 'block');
  213. tt.text(title);
  214. if(timeout && timeout > 0) {
  215. content = '<div><strong class="text-success text-xl" id="timeout">' + timeout + '</strong>&nbsp;秒后,' + content + '</div>';
  216. }
  217. tb.html(content);
  218. if(timeout) {
  219. var pre = 1000;
  220. if(timeout <=0 ) {// auto close
  221. pre = 1500;
  222. if(!callback)
  223. callback = dialog.hide;
  224. }
  225. var timer = function(t) {
  226. setTimeout(function(){
  227. if(t > -1) {
  228. $('#timeout').text(t--);
  229. timer(t);
  230. } else {
  231. callback && callback.call();
  232. }
  233. }, pre);
  234. };
  235. timer(timeout);
  236. }
  237. },
  238. hide: function() {
  239. var back = $('.modal-backdrop'), modal = $('.modal');
  240. back.css('display', 'none');
  241. modal.css('display', 'none');
  242. }
  243. };
  244. // 加载框
  245. var setLoading = function(isLoading) {
  246. $('.loading-container').css('display', isLoading ? 'block' : 'none');
  247. };
  248. //处理singleFormItems.action结果请求,返回parseBillMain处理的格式
  249. var dealForm = function(result) {
  250. var taskInfo = {data:{}, group:false};
  251. var data = eval('(' + result.data + ')');
  252. for(i in result.items) {
  253. var item = result.items[i];
  254. if(item.group == 0) {
  255. taskInfo.data[$(item.html).text()] = {};
  256. taskInfo.group = true;
  257. } else {
  258. if(item.groupName) {
  259. if(item.xtype!='hidden'){
  260. if(data[item.dataIndex]!='')
  261. taskInfo.data[item.groupName][item.fieldLabel] =
  262. (data[item.dataIndex]||data[item.dataIndex]==0)?data[item.dataIndex]:
  263. ((item.value||item.value==0)?item.value:'无');
  264. }
  265. } else {
  266. if (item.xtype!='hidden') {
  267. if(data[item.dataIndex]!='')
  268. taskInfo.data[item.fieldLabel]=
  269. (data[item.dataIndex]||data[item.dataIndex]==0)?data[item.dataIndex]:
  270. ((item.value||item.value==0)?item.value:'无');
  271. };
  272. }
  273. }
  274. }
  275. return taskInfo;
  276. };
  277. //处理singleGridPanel.action的结果,返回parseBillDetail处理的格式
  278. var dealGrid = function(result) {
  279. var resultData = {};
  280. var data = eval('(' + result.data + ')');
  281. for(i in result.columns) {
  282. var column = result.columns[i];
  283. if(!column.hidden){
  284. resultData[column.header] = [];
  285. for (d in data) {
  286. resultData[column.header].push(data[d][column.dataIndex])
  287. };
  288. }
  289. }
  290. return resultData;
  291. };
  292. //获取相关单据的明细
  293. var getRelationDetail = function(caller, gridCondition, container){
  294. setLoading(true);
  295. $.post(basePath + 'common/singleGridPanel.action', {
  296. caller: caller,
  297. condition: gridCondition,
  298. _m: 0
  299. }, function(result, text) {
  300. setLoading(false);
  301. var e = result.exceptionInfo;
  302. if(e) {
  303. if(e == 'ERR_NETWORK_SESSIONOUT') {
  304. dialog.show('获取用户信息失败', '请先登录!');
  305. } else {
  306. dialog.show('出现异常', '请稍后再试...');
  307. }
  308. } else {
  309. parseBillDetail(dealGrid(result), container);
  310. }
  311. });
  312. };
  313. //收缩监听事件
  314. $('#shrink').click(function(){
  315. setLoading(true);
  316. $('#relative #relation').addClass('hidden');
  317. $('#relative #expand').removeClass('hidden');
  318. setLoading(false);
  319. });
  320. //获取相关单据
  321. var getRelation = function(billLink) {
  322. $('#relation').removeClass('hidden');
  323. var c = getUrlParam('whoami', billLink);
  324. var fc = getUrlParam('formCondition', billLink).replace('IS', '=');
  325. var gc = getUrlParam('gridCondition', billLink).replace('IS', '=');
  326. setLoading(true);
  327. $.post(basePath + 'common/singleFormItems.action', {
  328. caller: c,
  329. condition: fc,
  330. _noc: 1
  331. }, function(result, text) {
  332. setLoading(false);
  333. var e = result.exceptionInfo;
  334. if(e) {
  335. if(e == 'ERR_NETWORK_SESSIONOUT') {
  336. dialog.show('获取用户信息失败', '请先登录!');
  337. } else {
  338. dialog.show('出现异常', '请稍后再试...');
  339. }
  340. } else {
  341. parseBillMain(dealForm(result), $('#relation-main'));
  342. $('#relation-detail-header').bind('boxready', function(){
  343. getRelationDetail(c, gc, $('#relation-detail'));
  344. });
  345. }
  346. });
  347. };
  348. //get record 获取任务的操作记录
  349. var getRecord = function(id) {
  350. $.post(basePath+'common/getFieldsDatas.action', {
  351. caller: 'WorkRecord',
  352. fields: 'wr_recorder,wr_recorddate,wr_redcord',
  353. condition: 'wr_raid='+ id + ' order by wr_recorddate'
  354. }, function(result){
  355. var e = result.exceptionInfo;
  356. if(e) {
  357. if(e == 'ERR_NETWORK_SESSIONOUT') {
  358. dialog.show('获取用户信息失败', '请先登录!');
  359. } else {
  360. dialog.show('出现异常', '请稍后再试...');
  361. }
  362. } else {
  363. parseRecord(result);
  364. }
  365. });
  366. };
  367. //parseRecord 显示任务记录的信息
  368. var parseRecord = function(result){
  369. var data = eval('(' + result.data + ')');
  370. var html = '';
  371. for(d in data) {
  372. html += '<div class="record">' +
  373. '<div><span class="recorder">' + data[d].WR_RECORDER + '</span>&nbsp;&nbsp;' +
  374. '<span class="recorddate">' + parseDate(new Date(data[d].WR_RECORDDATE)) + '<span></div>' +
  375. '<div class="record-content">' + data[d].WR_REDCORD + '</div>' +
  376. '</div>'
  377. };
  378. $('#record').html(html);
  379. };
  380. //get task 获取task
  381. var getTask = function(caller, id) {
  382. setLoading(true);
  383. var url = basePath + 'common/singleFormItems.action';
  384. if(caller == 'WorkRecord') url = basePath + 'plm/RecordFormItemsAndData.action';
  385. $.post(url, {
  386. caller: caller,
  387. condition: 'ra_id=' + id,
  388. _noc:1
  389. }, function(result, text){
  390. setLoading(false);
  391. var e = result.exceptionInfo;
  392. if(e) {
  393. if(e == 'ERR_NETWORK_SESSIONOUT') {
  394. dialog.show('获取用户信息失败', '请先登录!');
  395. } else {
  396. dialog.show('出现异常', e + ',请稍后再试...');
  397. }
  398. } else {
  399. parseTask(result);
  400. }
  401. });
  402. };
  403. // 增加被指定任务处理人回复任务的按钮
  404. var addReplyButton = function() {
  405. $('#deal .form').append('<textarea id="deal-msg" rows="2" placeholder="回复您的任务完成情况..."' +
  406. 'class="form-control"></textarea>');
  407. $('#buttons').append('<div class="btn-group">' +
  408. '<button id="reply" type="button" class="btn btn-default line">' +
  409. '<span class="glyphicon glyphicon-edit"></span>&nbsp;回复' +
  410. '</button>' +
  411. '</div>');
  412. $('#reply').click(function(){
  413. replyTask($('#deal-msg').val());
  414. });
  415. }
  416. // 被指定任务处理人回复任务处理情况
  417. var replyTask = function(record) {
  418. if(record) {
  419. setLoading(true);
  420. $.ajax({
  421. url: basePath + 'plm/record/endBillTask.action',
  422. type: 'POST',
  423. dataType: 'json',
  424. data: {caller:'ResourceAssignment!Bill', ra_id: id, record: record, _noc: 1},
  425. success: function(data){
  426. setLoading(false);
  427. var e = data.exceptionInfo;
  428. if(e) {
  429. if(e == 'ERR_NETWORK_SESSIONOUT') {
  430. dialog.show('获取用户信息失败', '请先登录!');
  431. } else {
  432. dialog.show('出现异常', e + ',请联系管理员或关闭页面');
  433. }
  434. } else if(data.success) {
  435. dialog.show('任务回复成功', '回复内容已提交任务发起人确认,请关闭页面');
  436. }
  437. },
  438. error: function(response) {
  439. consoe.log(response);
  440. }
  441. });
  442. } else {
  443. dialog('提示', '回复前请先填写任务完成情况', 1);
  444. }
  445. };
  446. // 增加任务发起人确认和驳回任务的按钮
  447. var addConfirmButton = function() {
  448. $('#deal .form').append('<textarea id="deal-msg" rows="2" placeholder="请说说您对任务完成情况的意见..."' +
  449. 'class="form-control"></textarea>');
  450. $('#buttons').append('<div class="btn-group">' +
  451. '<button id="confirm" type="button" class="btn btn-default line">' +
  452. '<span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;确认' +
  453. '</button>' +
  454. '</div>' +
  455. '<div class="btn-group">' +
  456. '<button id="noConfirm" type="button" class="btn btn-default line">' +
  457. '<span class="glyphicon glyphicon-thumbs-down"></span>&nbsp;驳回' +
  458. '</button>' +
  459. '</div>');
  460. $('#confirm').click(function(){
  461. confirmTask($('#deal-msg').val());
  462. });
  463. $('#noConfirm').click(function(){
  464. noConfirmTask($('#deal-msg').val());
  465. });
  466. }
  467. // 任务发起人确认任务
  468. var confirmTask = function(record) {
  469. if(record) {
  470. setLoading(true);
  471. $.ajax({
  472. url: basePath + 'plm/record/confirmBillTask.action',
  473. type: 'POST',
  474. dataType: 'json',
  475. data: {caller:'ResourceAssignment!Bill', ra_id: id, record: record, _noc: 1},
  476. success: function(data){
  477. setLoading(false);
  478. var e = data.exceptionInfo;
  479. if(e) {
  480. if(e == 'ERR_NETWORK_SESSIONOUT') {
  481. dialog.show('获取用户信息失败', '请先登录!');
  482. } else {
  483. dialog.show('出现异常', e + ',请联系管理员或关闭页面');
  484. }
  485. } else if(data.success) {
  486. dialog.show('任务确认成功', '任务已成功结束,正在刷新...', 1, function(){
  487. location.reload();
  488. });
  489. }
  490. },
  491. error: function(response) {
  492. consoe.log(response);
  493. }
  494. });
  495. } else {
  496. dialog('提示', '确认前请先填写你的意见', 1);
  497. }
  498. };
  499. // 任务发起人驳回任务
  500. var noConfirmTask = function(record) {
  501. if(record) {
  502. setLoading(true);
  503. $.ajax({
  504. url: basePath + 'plm/record/noConfirmBillTask.action',
  505. type: 'POST',
  506. dataType: 'json',
  507. data: {caller:'ResourceAssignment!Bill', ra_id: id, record: record, _noc: 1},
  508. success: function(data){
  509. setLoading(false);
  510. var e = data.exceptionInfo;
  511. if(e) {
  512. if(e == 'ERR_NETWORK_SESSIONOUT') {
  513. dialog.show('获取用户信息失败', '请先登录!');
  514. } else {
  515. dialog.show('出现异常', e + ',请联系管理员或关闭页面');
  516. }
  517. } else if(data.success) {
  518. dialog.show('任务驳回成功', '任务处理人将接收到您的意见,并重新处理任务,请关闭页面');
  519. }
  520. },
  521. error: function(response) {
  522. consoe.log(response);
  523. }
  524. });
  525. } else {
  526. dialog('提示', '驳回前请先填写你的意见', 1);
  527. }
  528. };
  529. // 展现任务数据
  530. var parseTask = function(task) {
  531. if(task.title && task.title!='') {
  532. $('#jp_name').text(task.title);
  533. } else {
  534. $('#jp_name').text('任务处理');
  535. }
  536. $('#jp_name').css('margin-left', "-" + $('#jp_name').text().replace(/[^\x00-\xff]/g, 'xx').length * 7 + "px");
  537. var taskInfo = dealForm(task);
  538. var data = eval('(' + task.data + ')');
  539. var buttons = task.buttons;
  540. parseBillMain(taskInfo, $('#bill-main'));
  541. if(data.sourcelink) {
  542. var caller = getUrlParam('whoami', data.sourcelink);
  543. if(!caller || caller=='') {
  544. $('#relative #expand').text('无法显示任务相关单据');
  545. }else {
  546. $('#relative #expand').click(function(){
  547. $('#relative #expand').addClass('hidden');
  548. getRelation(data.sourcelink);
  549. });
  550. };
  551. } else {
  552. $('#relative #expand').text('本任务无相关单据');
  553. }
  554. if(data.ra_statuscode == 'START') {// 进行中的任务,被指定的处理人可以回复任务
  555. addReplyButton();
  556. } else if(data.ra_statuscode == 'UNCONFIRMED') {// 待确认的任务,发起人可以确认或驳回
  557. addConfirmButton();
  558. } else {// 已结束的任务,不能做处理
  559. console.log('已结束');
  560. }
  561. // if(buttons.indexOf('erpOverButton') != -1) {//添加结束处理
  562. // addEndButoon();
  563. // }
  564. // 不加关闭按钮,2015年9月28日15:32:37
  565. }
  566. // parse bill main 把相关单据主表信息展现到页面中
  567. var parseBillMain = function(main, container) {
  568. var bill = main.data, html = '<table class="table table-condensed table-bordered table-striped">', g = null;
  569. if(main.group) {
  570. for(k in bill) {
  571. g = bill[k];
  572. html += '<tr><td colspan="2" class="text-center text-success"><strong>' + k + '</strong>&nbsp;<span class="glyphicon glyphicon-chevron-down"></span></td></tr>';
  573. for(b in g) {
  574. html += '<tr>';
  575. html += '<td class="text-right special"><strong>' + b + '</strong></td>';
  576. html += '<td class="text-center">' + g[b] + '</td>';
  577. html += '</tr>';
  578. };
  579. }
  580. } else {
  581. for(b in bill) {
  582. html += '<tr>';
  583. html += '<td class="text-right special"><strong>' + b + '</strong></td>';
  584. html += '<td class="text-center">' + bill[b] + '</td>';
  585. html += '</tr>';
  586. };
  587. }
  588. html += '</table>';
  589. container.html(html);
  590. };
  591. // parse bill detail 把相关单据明细表数据展现到页面中
  592. var parseBillDetail = function(detail, container){
  593. var html = '<table id="bill-detail-table" class="table table-condensed table-bordered table-striped">';
  594. for(c in detail) {
  595. html += '<tr>';
  596. html += '<td class="text-right special"><strong>' + c + '</strong></td>';
  597. if(detail[c] && detail[c].length > 0) {
  598. $.each(detail[c], function(i, p){
  599. html += '<td class="text-center">' + p + '</td>';
  600. });
  601. } else {
  602. html += '<td class="text-center text-muted">(无)</td>';
  603. }
  604. html += '</tr>';
  605. }
  606. html += '</table>';
  607. container.html(html);
  608. var table = container.children('table');
  609. freezeTable(table, 0, 1, pageWidth());
  610. var flag = false;
  611. $(window).resize(function() {
  612. if (flag)
  613. return ;
  614. setTimeout(function() {
  615. adjustTableSize(table.attr('id'), pageWidth());
  616. flag = false;
  617. }, 100);
  618. flag = true;
  619. });
  620. };
  621. //id参数,对应allprocess_view_undo视图中的id字段,resourceAssignment表中的ra_id字段
  622. var id = getUrlParam('id');
  623. // caller参数,billtask\mrptask\kbitask 类型的任务为ResourceAssignment!Bill , projecttask\worktask 为 WorkRecord
  624. var caller = getUrlParam('caller');
  625. if(id && caller) {
  626. getTask(caller, id);// 获取任务的信息和(如有)相关单据
  627. }
  628. if(id) {
  629. getRecord(id);// 获取任务的操作记录
  630. }
  631. });