examine.js 4.3 KB

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