examine.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // pages/voyageManage/myDaily/examine/examine.js
  2. const {
  3. postApi
  4. } = require("../../../../apis/api")
  5. const app = getApp()
  6. Page({
  7. data: {
  8. voyageId: 0,
  9. currentBillItem: {},
  10. tab: -1,
  11. currentDischargeIndex: 0,
  12. dischargeTime: "",
  13. ocrList: []
  14. },
  15. previewImage(e) {
  16. let {
  17. src
  18. } = e.currentTarget.dataset
  19. wx.previewImage({
  20. current: src, // 当前显示图片的http链接
  21. urls: [src] // 需要预览的图片http链接列表
  22. })
  23. },
  24. changeTab(e) {
  25. let {
  26. tab
  27. } = e.currentTarget.dataset
  28. if (tab == 1) {
  29. wx.showModal({
  30. title: "是否确认上传运单?",
  31. success: async e => {
  32. if (e.confirm) {
  33. this.setData({
  34. tab
  35. })
  36. await this.distributeBills()
  37. } else {
  38. this.setData({
  39. tab: -1
  40. })
  41. }
  42. }
  43. })
  44. } else if (tab == 2) {
  45. wx.showModal({
  46. title: "是否确认上传磅单?",
  47. success: async e => {
  48. if (e.confirm) {
  49. this.setData({
  50. tab
  51. })
  52. } else {
  53. this.setData({
  54. tab: -1
  55. })
  56. }
  57. }
  58. })
  59. } else if (tab == 4) {
  60. wx.showModal({
  61. title: "是否确认上传汽车磅单?",
  62. success: async e => {
  63. if (e.confirm) {
  64. this.setData({
  65. tab
  66. })
  67. } else {
  68. this.setData({
  69. tab: -1
  70. })
  71. }
  72. }
  73. })
  74. } else if (tab == 5) {
  75. wx.showModal({
  76. title: "确认不通过?",
  77. success: async e => {
  78. if (e.confirm) {
  79. this.setData({
  80. tab
  81. })
  82. this.distributeBills()
  83. } else {
  84. this.setData({
  85. tab: -1
  86. })
  87. }
  88. }
  89. })
  90. }
  91. },
  92. async distributeBills() {
  93. let arr = []
  94. for (let i of this.data.currentBillItem.shipownerUploadFiles) {
  95. if (i.checked) arr.push(i.id)
  96. }
  97. let type = this.data.tab
  98. let postData = {
  99. recordIds: arr.join(','),
  100. voyageId: this.data.voyageId,
  101. type,
  102. }
  103. if (type == 2) {
  104. if (!this.check()) return
  105. let {
  106. dischargeTime,
  107. dischargeTons,
  108. dischargePieces,
  109. currentBillItem,
  110. currentDischargeIndex
  111. } = this.data
  112. postData.poundBillData = {
  113. dischargeTime: dischargeTime.replaceAll("-", "/") + " 00:00:00",
  114. dischargeTons,
  115. dischargePieces,
  116. portId: currentBillItem.discPorts[currentDischargeIndex].portId
  117. }
  118. }
  119. if (type == 4) {
  120. let {
  121. ocrList,
  122. currentDischargeIndex,
  123. currentBillItem
  124. } = this.data
  125. for (let i of ocrList) {
  126. i.portId = currentBillItem.discPorts[currentDischargeIndex].portId
  127. }
  128. postData.carLoadDatas = ocrList
  129. }
  130. let res = await postApi('/bill/distribute', postData)
  131. wx.switchTab({
  132. url: '/pages/voyageManage/voyageManage',
  133. })
  134. },
  135. reject() {
  136. },
  137. check() {
  138. if (!this.data.dischargeTime) {
  139. wx.showToast({
  140. title: '请选择卸货时间',
  141. icon: "error"
  142. })
  143. return
  144. }
  145. if (!this.data.dischargeTons) {
  146. wx.showToast({
  147. title: '请选择卸货吨位',
  148. icon: "error"
  149. })
  150. return
  151. }
  152. return true
  153. },
  154. async ocr() {
  155. wx.showLoading({
  156. title: "正在识别"
  157. })
  158. let arr = []
  159. for (let i of this.data.currentBillItem.shipownerUploadFiles) {
  160. if (i.checked) arr.push(i.id)
  161. }
  162. let res = await postApi("/bill/ocr", {
  163. recordIds: arr.join(',')
  164. })
  165. wx.hideLoading({
  166. success: (res) => {},
  167. })
  168. this.setData({
  169. ocrList: res.data.result
  170. })
  171. },
  172. ocrInputBlur(e) {
  173. console.log(e)
  174. let {
  175. index,
  176. param
  177. } = e.currentTarget.dataset
  178. let {
  179. value
  180. } = e.detail
  181. let {
  182. ocrList
  183. } = this.data
  184. ocrList[index][param] = value
  185. },
  186. bindDiscPortChange(e) {
  187. console.log(e)
  188. this.setData({
  189. currentDischargeIndex: e.detail.value
  190. })
  191. },
  192. onLoad(options) {
  193. this.setData({
  194. voyageId: options.id,
  195. currentBillItem: app.globalData.currentBillItem
  196. })
  197. },
  198. })