uploadCarLoadRecord.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // pages/voyages/uploadDischarge/uploadDischarge.js
  2. import {
  3. postApi
  4. } from "../../../apis/api"
  5. import {
  6. uploadImage
  7. } from "../../../utils/uploadImage"
  8. Page({
  9. data: {
  10. weighTime: '',
  11. carNum: '',
  12. receivingUnit: '',
  13. grossWeight: 0,
  14. tare: 0,
  15. netWeight: 0,
  16. fileObj: {}
  17. },
  18. async uploadBill(e) {
  19. let {
  20. type
  21. } = e.currentTarget.dataset
  22. let postData = {
  23. type,
  24. voyageId: this.data.voyageId
  25. }
  26. let res = await uploadImage("/voyage/uploadVoyageWayBill", postData)
  27. let {
  28. fileKey,
  29. viewUrl,
  30. downloadUrl
  31. } = res.result
  32. this.setData({
  33. fileKey,
  34. viewUrl,
  35. downloadUrl
  36. })
  37. },
  38. preview(e) {
  39. wx.previewImage({
  40. urls: [e.currentTarget.dataset.src],
  41. })
  42. },
  43. reupload(e) {
  44. wx.showModal({
  45. content: "是否重新上传?",
  46. confirmText: "确定",
  47. cancelText: "取消",
  48. success: res => {
  49. if (res.confirm) {
  50. this.uploadBill(e)
  51. }
  52. }
  53. })
  54. },
  55. async submit() {
  56. let {
  57. weighTime,
  58. carNum,
  59. receivingUnit,
  60. grossWeight,
  61. tare,
  62. netWeight,
  63. portId,
  64. voyageId,
  65. fileKey,
  66. viewUrl,
  67. downloadUrl
  68. } = this.data
  69. let postData = {
  70. loginAccountId: wx.getStorageSync('loginAccountId'),
  71. voyageId,
  72. portId,
  73. carNum,
  74. receivingUnit,
  75. grossWeight,
  76. tare,
  77. netWeight,
  78. weighTime: weighTime.replaceAll('-', '/') + " 00:00:00",
  79. fileKey,
  80. viewUrl,
  81. downloadUrl
  82. }
  83. let res = await postApi("/voyage/addCarLoadRecord", postData)
  84. wx.setStorageSync('addStatus', 'success')
  85. wx.navigateBack()
  86. },
  87. onLoad(options) {
  88. this.setData({
  89. voyageId: options.voyageId,
  90. portId: options.portId
  91. })
  92. },
  93. })