change_approval.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. 'use strict';
  2. /**
  3. * 变更令-审批页js
  4. *
  5. * @author EllisRan.
  6. * @date 2018/11/22
  7. * @version
  8. */
  9. $(document).ready(() => {
  10. $('#sp-back input[name="status"]').click(function (e) {
  11. if($(e.target).is('label')){
  12. return;
  13. }
  14. if (parseInt($(this).val()) === 4) {
  15. $('.change-approval-stop').show();
  16. $('.change-approval-back').hide();
  17. } else {
  18. $('.change-approval-stop').hide();
  19. $('.change-approval-back').show();
  20. }
  21. });
  22. // 清单输入监控并更新
  23. $('body').on('valuechange', '.clist input', function (e, previous) {
  24. const amount = $(this).val();
  25. const lid = $(this).parents('tr').data('lid');
  26. const tr = $('#list tr[data-lid="' + lid + '"]').eq(0);
  27. const unitprice = tr.children('td[data-site="4"]').text();
  28. tr.children('.amount_cost').text(amount != '' ?
  29. roundnum(parseFloat(unitprice).mul(parseFloat(amount)),totalPriceUnit) : '');
  30. // 统计总金额
  31. let totalcost = 0;
  32. $('.clist').each(function(){
  33. const utotal = $(this).find('.amount_cost').text();
  34. totalcost = utotal != '' ? parseFloat(totalcost)+parseFloat(utotal) : parseFloat(totalcost);
  35. });
  36. $('.amount_totalcost').eq(1).text(totalcost !== 0 ? roundnum(totalcost, totalPriceUnit) : '');
  37. });
  38. // 审批提交与判断
  39. $('.approval-btn').on('click', function () {
  40. // 判断审批状态
  41. let returnflag = true;
  42. if ($(this).hasClass('btn-success')) {
  43. const sdesc = $('#success-approval').find('textarea').val();
  44. if (sdesc === '') {
  45. toastr.error('审批意见不能为空!');
  46. returnflag = false;
  47. }
  48. if ($('input[name="p_code"]').val() === '') {
  49. toastr.error('批复文号不能为空!');
  50. returnflag = false;
  51. }
  52. // 判断并提交变更清单表格数据到表单中
  53. const clist = [];
  54. $('.clist input').each(function(k, v){
  55. const value = $(this).val();
  56. const lid = $(this).parents('tr').data('lid');
  57. if (value === '') {
  58. toastr.error('清单第' + (k+1) + '行审批变更数量不能为空');
  59. returnflag = false;
  60. }
  61. clist.push(lid+'_'+value);
  62. });
  63. $('#change-list-approval').val(clist.join(','));
  64. if(returnflag) {
  65. $('#success-approval').submit();
  66. }
  67. } else {
  68. const sdesc = $('#fail-approval').find('textarea').val();
  69. if (sdesc === '') {
  70. toastr.error('审批意见不能为空!');
  71. returnflag = false;
  72. }
  73. const type = $('#fail-approval').find('input[name="status"]:checked').val();
  74. if (type === undefined) {
  75. toastr.error('请选择退回类型!');
  76. returnflag = false;
  77. }
  78. if(returnflag) {
  79. $('#fail-approval').submit();
  80. }
  81. }
  82. })
  83. });