// pages/voyageManage/myDaily/examine/examine.js const { postApi } = require("../../../../apis/api") const app = getApp() Page({ data: { voyageId: 0, currentBillItem: {}, tab: -1, currentDischargeIndex: 0, dischargeTime: "", ocrList: [{}], isAcc: false }, showAcc() { this.setData({ isAcc: true }) }, previewImage(e) { let { src } = e.currentTarget.dataset wx.previewImage({ current: src, // 当前显示图片的http链接 urls: [src] // 需要预览的图片http链接列表 }) }, changeTab(e) { let { tab } = e.currentTarget.dataset if (tab == 1) { wx.showModal({ title: "是否确认上传运单?", success: async e => { if (e.confirm) { this.setData({ tab }) await this.distributeBills() } else { this.setData({ tab: -1 }) } } }) } else if (tab == 2) { wx.showModal({ title: "是否确认上传磅单?", success: async e => { if (e.confirm) { this.setData({ tab }) } else { this.setData({ tab: -1 }) } } }) } else if (tab == 4) { wx.showModal({ title: "是否确认上传汽车磅单?", success: async e => { if (e.confirm) { this.setData({ tab }) } else { this.setData({ tab: -1 }) } } }) } else if (tab == 5) { wx.showModal({ title: "确认不通过?", success: async e => { if (e.confirm) { this.setData({ tab }) this.distributeBills() } else { this.setData({ tab: -1 }) } } }) } }, addOne() { this.data.ocrList.push({}) this.setData({ ocrList: this.data.ocrList }) }, deleteOne(e) { let { index } = e.currentTarget.dataset this.data.ocrList.splice(index, 1) this.setData({ ocrList: this.data.ocrList }) }, async distributeBills() { let arr = [] for (let i of this.data.currentBillItem.shipownerUploadFiles) { if (i.checked) arr.push(i.id) } let type = this.data.tab let recordIds = arr.join(',') let postData = { recordIds, voyageId: this.data.voyageId, type, } if (type == 2) { if (!this.check()) return let { dischargeTime, dischargeTons, dischargePieces, currentBillItem, currentDischargeIndex } = this.data postData.poundBillData = { dischargeTime: dischargeTime.replaceAll("-", "/") + " 00:00:00", dischargeTons, dischargePieces, portId: currentBillItem.discPorts[currentDischargeIndex].portId } } if (type == 4) { let { ocrList, currentDischargeIndex, currentBillItem } = this.data ocrList = ocrList.filter(item => { return JSON.stringify(item) != "{}" }) if (ocrList.length == 0) { wx.showToast({ title: '记录不能为空!', icon: "error" }) return } for (let i of ocrList) { i.portId = currentBillItem.discPorts[currentDischargeIndex].portId i.recordId = recordIds } postData.carLoadDatas = ocrList } let res = await postApi('/bill/distribute', postData) wx.switchTab({ url: '/pages/voyageManage/voyageManage', }) }, reject() { }, check() { if (!this.data.dischargeTime) { wx.showToast({ title: '请选择卸货时间', icon: "error" }) return } if (!this.data.dischargeTons) { wx.showToast({ title: '请填写卸货吨位', icon: "error" }) return } return true }, async ocr() { wx.showLoading({ title: "正在识别" }) let arr = [] for (let i of this.data.currentBillItem.shipownerUploadFiles) { if (i.checked) arr.push(i.id) } let res = await postApi("/bill/ocr", { recordIds: arr.join(',') }) wx.hideLoading({ success: (res) => {}, }) this.setData({ ocrList: res.data.result }) }, ocrInputBlur(e) { let { index, param } = e.currentTarget.dataset let { value } = e.detail let { ocrList } = this.data ocrList[index][param] = value }, bindDiscPortChange(e) { console.log(e) this.setData({ currentDischargeIndex: e.detail.value }) }, onLoad(options) { this.setData({ voyageId: options.id, currentBillItem: app.globalData.currentBillItem }) }, })