examine.js 4.2 KB

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