receipt_create_fn.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * @description: 创建报销单业务处理
  3. * @Author: CP
  4. * @Date: 2020-11-13 15:20:41
  5. * @FilePath: \cld\global\vue\fee\receipt_create_fn.js
  6. */
  7. // 验证费用表单
  8. function checkReceipt(event, obj) {
  9. let flag = false;
  10. //1.选择办事处费用
  11. if (obj.receiptTypeMenu[0].show) {
  12. if (obj.receiptTypeMenu[0].officeExplain[0].officeExplain == "") {
  13. obj.alertDia("请填写 办事处相关费用 报销说明");
  14. flag = true;
  15. }
  16. }
  17. //2.选择办事处费用
  18. if (obj.receiptTypeMenu[2].show) {
  19. if (obj.receiptTypeMenu[2].trainExplain[0].trainExplain == "") {
  20. obj.alertDia("请填写 内部培训费用 报销说明");
  21. flag = true;
  22. }
  23. }
  24. // 选择费用类型
  25. if (obj.receiptTypeMenu[0].show === false && obj.receiptTypeMenu[1].show === false && obj.receiptTypeMenu[2].show === false) {
  26. obj.alertDia("请选择 费用类型");
  27. flag = true;
  28. }
  29. // 设置参数
  30. // 1.办事处相关费用
  31. let officeData_input_dom = obj.$refs.officeData_input;
  32. officeData_input_dom.value="";
  33. if (obj.receiptTypeMenu[0].show) {
  34. officeData_input_dom.value=JSON.stringify(obj.receiptTypeMenu[0]);
  35. }
  36. // 2.差旅相关费用
  37. let traveData_input_dom = obj.$refs.traveData_input;
  38. traveData_input_dom.value="";
  39. if (obj.receiptTypeMenu[1].show) {
  40. traveData_input_dom.value=JSON.stringify(obj.receiptTypeMenu[1]);
  41. }
  42. // 3.差旅相关费用
  43. let trainData_input_dom = obj.$refs.trainData_input;
  44. trainData_input_dom.value="";
  45. if (obj.receiptTypeMenu[2].show) {
  46. trainData_input_dom.value=JSON.stringify(obj.receiptTypeMenu[2]);
  47. }
  48. // 4.附件内容相关
  49. let enclosurFiles_input_dom = obj.$refs.enclosurFiles_input;
  50. enclosurFiles_input_dom.value="";
  51. if(obj.enclosurFiles.length!=0){
  52. enclosurFiles_input_dom.value=JSON.stringify(obj.enclosurFiles);
  53. }
  54. // 校验设置后的参数
  55. if( obj.verifyId===""){
  56. obj.alertDia("请选择 审批组");
  57. flag = true;
  58. }
  59. if (flag) {
  60. event.preventDefault();
  61. }
  62. // // 1-2日常费用
  63. // let officeDailyData_input_dom = obj.$refs.officeDailyData_input;
  64. // // 1-2填写过金额
  65. // let daily = [];
  66. // obj.receiptTypeMenu[0].daily.forEach(element => {
  67. // if (element.price != 0) {
  68. // daily.push(element);
  69. // }
  70. // });
  71. // officeDailyData_input_dom.value = JSON.stringify(daily);
  72. // let officeOtherData_input_dom = obj.$refs.officeOtherData_input;
  73. // let other = [];
  74. // obj.receiptTypeMenu[0].other.forEach(element => {
  75. // if (element.price != 0) {
  76. // other.push(element);
  77. // }
  78. // });
  79. // officeOtherData_input_dom.value = JSON.stringify(other);
  80. // let officeExplain_input_dom = obj.$refs.officeExplain_input;
  81. // officeExplain_input_dom.value = obj.receiptTypeMenu[0].officeExplain[0].officeExplain;
  82. }
  83. // 办事处相关费用合计
  84. function officePrice(obj) {
  85. sum = 0;
  86. obj.daily.forEach(element => {
  87. sum += Number(element.price);
  88. });
  89. obj.other.forEach(element => {
  90. sum += Number(element.price);
  91. });
  92. return sum.toFixed(2);
  93. }
  94. // 差旅相关费用
  95. function travePrice(obj) {
  96. let sum = 0;
  97. obj.forEach(element => {
  98. element.tripList.forEach(elementlv2 => {
  99. elementlv2.tripItem.forEach(elementlv3 => {
  100. sum += Number(elementlv3.price);
  101. });
  102. });
  103. });
  104. return sum.toFixed(2);
  105. }
  106. // 内部培训费用
  107. function trainPrice(obj) {
  108. let sum = 0;
  109. obj.forEach(element => {
  110. sum += Number(element.price);
  111. });
  112. return sum.toFixed(2);
  113. }
  114. //
  115. function NewTraveItem() {
  116. let newTripItem = new Array();
  117. accountItem.trave.forEach(element => {
  118. newTripItem.push({
  119. "name": element.name,
  120. "price": 0.00,
  121. "remark": "",
  122. });
  123. });
  124. return newTripItem;
  125. }
  126. function toDecimal2(x) {
  127. var f = parseFloat(x);
  128. if (isNaN(f)) {
  129. return false;
  130. }
  131. var f = Math.round(x * 100) / 100;
  132. var s = f.toString();
  133. var rs = s.indexOf('.');
  134. if (rs < 0) {
  135. rs = s.length;
  136. s += '.';
  137. }
  138. while (s.length <= rs + 2) {
  139. s += '0';
  140. }
  141. return s;
  142. }
  143. function delEnclosurByKey(id){
  144. var url = "/ajaxRemEnclousur";
  145. $.ajax({
  146. url : url,
  147. type : "post",
  148. cache : false,
  149. dataType : "json",
  150. data : {
  151. key : id
  152. },
  153. global : true,
  154. success : function(data) {
  155. if (data.status == 1) {
  156. $('#'+id).remove();
  157. }
  158. },
  159. error : function(err) {
  160. }
  161. });
  162. }