receipt_create.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * @description: 创建报销单
  3. * @Author: CP
  4. * @Date: 2020-11-13 12:03:08
  5. * @FilePath: \cld\global\vue\fee\receipt_create.js
  6. */
  7. new Vue({
  8. el: '#receipt_create',
  9. data: data,
  10. // mounted: function () {
  11. // SetReceiptData(this);
  12. // },
  13. methods: {
  14. // 报销单选择菜单栏
  15. selectReceipt: function (event, menu) {
  16. // 是否选中
  17. selected = event.target.classList.toggle("active");
  18. menu.show = !menu.show
  19. },
  20. // 报销单导航栏
  21. navigation: function (receiptTypeMenu, menu) {
  22. receiptTypeMenu.forEach(element => {
  23. element.active = false;
  24. });
  25. menu.active = !menu.active;
  26. },
  27. // 验证费用表单
  28. checkReceipt: function (event) {
  29. checkReceipt(event, this);
  30. // dev 不提交
  31. // event.preventDefault();
  32. },
  33. // 附件上传
  34. enclosurFile: function (event) {
  35. let form_data = new FormData();
  36. let file_data = event.target.files[0];
  37. form_data.append("Filename", file_data.name);
  38. form_data.append("Filedata", file_data);
  39. // let index = this.enclosurFiles.length;
  40. let objData = this.enclosurFiles;
  41. $.ajax({
  42. type: "POST",
  43. url: "/swfupload",
  44. dataType: "json",
  45. processData: false,
  46. contentType: false,
  47. data: form_data
  48. }).success(function (msg) {
  49. let file = {
  50. name: file_data.name,
  51. size: toDecimal2(file_data.size / 1024) + 'kb',
  52. path: msg.filename
  53. }
  54. objData.push(file);
  55. }).fail(function (msg) {
  56. this.alertDia("附件上传失败");
  57. });
  58. },
  59. enclosurFileDel(index) {
  60. this.enclosurFiles.splice(index, 1)
  61. },
  62. alertDia(msg) {
  63. this.displayStsates = 'block'
  64. this.aletMsg = msg
  65. // 延迟2秒后消失 自己可以更改时间
  66. window.setTimeout(() => {
  67. this.displayStsates = 'none'
  68. }, 3500)
  69. },
  70. },
  71. computed: {
  72. receiptPrice: function () {
  73. let num = 0.00;
  74. if (this.receiptTypeMenu[0].show) {
  75. num += Number(officePrice(this.receiptTypeMenu[0]));
  76. }
  77. if (this.receiptTypeMenu[1].show) {
  78. num += Number(travePrice(this.receiptTypeMenu[1].traveList));
  79. }
  80. if (this.receiptTypeMenu[2].show) {
  81. num += Number(trainPrice(this.receiptTypeMenu[2].train));
  82. }
  83. return num.toFixed(2);
  84. }
  85. },
  86. })