| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- // pages/voyages/uploadDischarge/uploadDischarge.js
- import {
- postApi
- } from "../../../apis/api"
- import {
- uploadImage
- } from "../../../utils/uploadImage"
- Page({
- data: {
- dischargeTime: '',
- dischargeTons: 0,
- dischargePieces: 0,
- fileList: [],
- },
- async uploadBill(e) {
- let {
- type
- } = e.currentTarget.dataset
- let postData = {
- type,
- voyageId: this.data.voyageId
- }
- let res = await uploadImage("/voyage/uploadVoyageWayBill", postData)
- let {
- id,
- viewUrl
- } = res.result
- this.data.fileList.push({
- id,
- viewUrl
- })
- this.setData({
- fileList: this.data.fileList
- })
- },
- async submit() {
- let {
- dischargeTime,
- dischargeTons,
- dischargePieces,
- fileList,
- portId,
- voyageId
- } = this.data
- let arr = []
- for (let i of fileList) {
- arr.push(i.id)
- }
- let postData = {
- loginAccountId: wx.getStorageSync('loginAccountId'),
- voyageId,
- portId,
- dischargeTons,
- dischargePieces,
- dischargeTime: dischargeTime.replaceAll('-', '/') + " 00:00:00",
- voyageFileIds: arr.join(',')
- }
- let res = await postApi("/voyage/addDischarge", postData)
- wx.setStorageSync('addStatus', 'success')
- wx.navigateBack()
- },
- preview(e) {
- wx.previewImage({
- urls: [e.currentTarget.dataset.src],
- })
- },
- remove(e) {
- wx.showModal({
- content: "移除当前图片?",
- success: res => {
- if (res.confirm) {
- this.data.fileList.splice(e.currentTarget.dataset.index, 1)
- this.setData({
- fileList: this.data.fileList
- })
- }
- }
- })
- },
- onLoad(options) {
- this.setData({
- voyageId: options.voyageId,
- portId: options.portId
- })
- },
- })
|