| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- const {
- postApi
- } = require("../../../../apis/api")
- const {
- uploadImage
- } = require('../../../../utils/uploadImage')
- const app = getApp()
- // pages/voyageManage/myBills/myLab.js
- Page({
- data: {
- currentPortId: -1,
- currentPage: 1,
- size: 20,
- isFreshing: false,
- total: 0,
- labList: []
- },
- async getVoyageDetail() {
- let res = await postApi('voyage/detail', {
- voyageId: this.data.voyageId
- })
- let {
- voyage,
- } = res.data.result
- this.setData({
- ...voyage,
- currentPortId: voyage?.voyageDetails[0].portId
- })
- this.getLabList()
- },
- changePort(e) {
- let currentPortId = e.target.dataset.id
- this.setData({
- currentPortId,
- })
- this.getLabList()
- },
- scrollDownList() {
- this.setData({
- total: 0,
- currentPage: 1,
- labList: []
- })
- this.getLabList()
- },
- scrollList() {
- if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
- this.data.currentPage += 1
- this.getLabList(true)
- },
- async getLabList(isScroll) {
- this.setData({
- isFreshing: true
- })
- let res = await postApi('voyage/getLabList', {
- voyageId: this.data.voyageId,
- portId: this.data.currentPortId,
- currentPage: this.data.currentPage,
- size: this.data.size
- })
- this.setData({
- currentPage: this.data.currentPage,
- isFreshing: false
- })
- if (res.data.status == 0) {
- for (let i of res.data.result) {
- i.billingDate = i.billingDate.substring(0, 10)
- }
- if (isScroll) {
- this.setData({
- labList: [...this.data.labList, ...res.data.result],
- total: res.data.total
- })
- } else {
- this.setData({
- labList: res.data.result,
- total: res.data.total
- })
- }
- } else {
- this.setData({
- labList: [],
- total: 0
- })
- wx.showToast({
- icon: "none",
- title: res.data.msg,
- })
- }
- },
- async uploadLab() {
- let res = await uploadImage('voyage/uploadVoyageWayBill', {
- voyageId: this.data.voyageId,
- type: 5
- })
- if (res.status == 0) {
- let {
- viewUrl,
- downloadUrl,
- fileKey,
- voyageId
- } = res.result
- let res1 = await postApi('/voyage/addLab', {
- viewUrl,
- downloadUrl,
- fileKey,
- voyageId,
- portId: this.data.currentPortId
- })
- this.getLabList()
- }
- },
- goToDetail(e) {
- let {
- item
- } = e.currentTarget.dataset
- app.globalData.currentLab = item
- wx.navigateTo({
- url: '/pages/voyageManage/myBills/labDetail/labDetail',
- })
- },
- onLoad(options) {
- let {
- id: voyageId
- } = options
- this.setData({
- voyageId
- })
- },
- onShow() {
- this.getVoyageDetail()
- }
- })
|