| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- // 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
- })
- },
- })
|