examine.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. addOne() {
  99. this.data.ocrList.push({})
  100. this.setData({
  101. ocrList: this.data.ocrList
  102. })
  103. },
  104. deleteOne(e) {
  105. let {
  106. index
  107. } = e.currentTarget.dataset
  108. this.data.ocrList.splice(index, 1)
  109. this.setData({
  110. ocrList: this.data.ocrList
  111. })
  112. },
  113. async distributeBills() {
  114. let arr = []
  115. for (let i of this.data.currentBillItem.shipownerUploadFiles) {
  116. if (i.checked) arr.push(i.id)
  117. }
  118. let type = this.data.tab
  119. let recordIds = arr.join(',')
  120. let postData = {
  121. recordIds,
  122. voyageId: this.data.voyageId,
  123. type,
  124. }
  125. if (type == 2) {
  126. if (!this.check()) return
  127. let {
  128. dischargeTime,
  129. dischargeTons,
  130. dischargePieces,
  131. currentBillItem,
  132. currentDischargeIndex
  133. } = this.data
  134. postData.poundBillData = {
  135. dischargeTime: dischargeTime.replaceAll("-", "/") + " 00:00:00",
  136. dischargeTons,
  137. dischargePieces,
  138. portId: currentBillItem.discPorts[currentDischargeIndex].portId
  139. }
  140. }
  141. if (type == 4) {
  142. let {
  143. ocrList,
  144. currentDischargeIndex,
  145. currentBillItem
  146. } = this.data
  147. ocrList = ocrList.filter(item => {
  148. return JSON.stringify(item) != "{}"
  149. })
  150. if (ocrList.length == 0) {
  151. wx.showToast({
  152. title: '记录不能为空!',
  153. icon: "error"
  154. })
  155. return
  156. }
  157. for (let i of ocrList) {
  158. i.portId = currentBillItem.discPorts[currentDischargeIndex].portId
  159. i.recordId = recordIds
  160. }
  161. postData.carLoadDatas = ocrList
  162. }
  163. let res = await postApi('/bill/distribute', postData)
  164. wx.switchTab({
  165. url: '/pages/voyageManage/voyageManage',
  166. })
  167. },
  168. reject() {
  169. },
  170. check() {
  171. if (!this.data.dischargeTime) {
  172. wx.showToast({
  173. title: '请选择卸货时间',
  174. icon: "error"
  175. })
  176. return
  177. }
  178. if (!this.data.dischargeTons) {
  179. wx.showToast({
  180. title: '请填写卸货吨位',
  181. icon: "error"
  182. })
  183. return
  184. }
  185. return true
  186. },
  187. async ocr() {
  188. wx.showLoading({
  189. title: "正在识别"
  190. })
  191. let arr = []
  192. for (let i of this.data.currentBillItem.shipownerUploadFiles) {
  193. if (i.checked) arr.push(i.id)
  194. }
  195. let res = await postApi("/bill/ocr", {
  196. recordIds: arr.join(',')
  197. })
  198. wx.hideLoading({
  199. success: (res) => {},
  200. })
  201. this.setData({
  202. ocrList: res.data.result
  203. })
  204. },
  205. ocrInputBlur(e) {
  206. let {
  207. index,
  208. param
  209. } = e.currentTarget.dataset
  210. let {
  211. value
  212. } = e.detail
  213. let {
  214. ocrList
  215. } = this.data
  216. ocrList[index][param] = value
  217. },
  218. bindDiscPortChange(e) {
  219. console.log(e)
  220. this.setData({
  221. currentDischargeIndex: e.detail.value
  222. })
  223. },
  224. onLoad(options) {
  225. this.setData({
  226. voyageId: options.id,
  227. currentBillItem: app.globalData.currentBillItem
  228. })
  229. },
  230. })