This commit is contained in:
aihe 2024-09-02 17:06:25 +08:00
parent a89869175a
commit 4c6b6fe5d4
5 changed files with 48 additions and 15 deletions

View File

@ -1,5 +1,5 @@
import { coreRequest } from '@/common/request'
import url from "./url"
import { coreRequest, coreDownloadRequest } from '@/common/request'
import url, { host } from "./url"
// 下单-- 新增
@ -98,7 +98,7 @@ export const verifyBindMonthPayCode = (data = {})=> {
// 下载进仓单PDF
export const exportWarehouseInTpl = (data = {})=> {
return coreRequest(url.exportWarehouseInTpl, data, {}, "GET")
return coreDownloadRequest(url.exportWarehouseInTpl, data, {})
}
// 确认进仓单

View File

@ -57,7 +57,7 @@ export default {
getWxPayQrCode: `/oms2c/emisSettleBill/getWxPayQrCode`, // 获取微信支付二维码 -- DONE
sumbitWxPay: `/oms2c/emisSettleBill/sumbitWxPay`, // 账单-唤起微信立即支付 -- DONE
exportWarehouseInTpl: `/oms2c/emisWarehouseIn/exportWarehouseInTpl`, // 下载进仓单PDF-- DONE
exportWarehouseInTpl: `/oms2c/common/exportWarehouseInTpl`, // 下载进仓单PDF-- DONE
getWarehouseInList: `/oms2c/emisWarehouseIn/listSimple`, // 进仓单列表-- DONE
getWarehouseInInfo: `/oms2c/emisWarehouseIn/getWarehouseInDetail`, // 获取进仓单详情-- DONE
cusConfirmWsIn: `/oms2c/emisWarehouseIn/cusConfirmWsIn`, // 确认进仓单- DONE

View File

@ -82,6 +82,26 @@ let coreRequest = function(url, params = {}, options = {}, methodType, coreParam
})
}
const coreDownloadRequest = (url, params = {}, options = {}, methodType = 'GET', coreParams = {})=> {
let comReqData = getCommonReqData()
// 统一把emo转unicode
// emoUnicode(params)
const reqParams = {
...baseParam,
...params,
}
url = `${host}${url}`
options = {
...comReqData.header,
...options,
}
// get请求 需要转成query参
url = url + (url.indexOf('?') == -1 ? '?': '') + tansGetParamsToQuery(reqParams)
return { url, header: options }
}
export {
coreDownloadRequest,
coreRequest
}

View File

@ -113,6 +113,8 @@ const downloadFile = (url, ext = {})=> {
if (res.statusCode === 200 || res.statusCode === 400) {
console.log('下载成功');
resolve(res)
} else {
reject('下载失败')
}
},
fail: (err)=>{
@ -123,33 +125,43 @@ const downloadFile = (url, ext = {})=> {
})
}
const saveNetFile = (url) => {
return new Promise(async (resolve, reject)=> {
const saveNetFile = ({ url, header } = {}) => {
return new Promise(async (resolve, reject) => {
showLoading('正在保存文件')
try{
let dRes = await getImageInfo(url)
console.log("save:downloadFile:getImageInfo", dRes)
let { tempFilePath, path } = dRes
try {
let dRes = await downloadFile(url, { header })
console.log("saveNetFile:downloadFile==", dRes)
let {
tempFilePath,
path
} = dRes
path = path || tempFilePath
debugger
// #ifdef H5
saveAs(path)
// #endif
// let res = await saveFile({ path })
// #ifdef APP-PLUS
plus.io.convertLocalFileSystemURL(path);
plus.runtime.openFile(path); //选择软件打开文件
// #endif
// #ifdef MP-WEIXIN
debugger
await uniPromiseApi('openDocument', { filePath: path, showMenu: true, })
// #endif
hideLoading()
showToast('保存成功')
resolve(tempFilePath)
}catch(e){
} catch (e) {
hideLoading()
showToast('保存失败')
reject(e)
}
})
}
const saveFile = ({ tempFilePath })=> {

View File

@ -202,6 +202,7 @@
import BpeAddressjiamiTmp from "@/components/buns-post-edit-templates/bpe-addressjiami-tmp"
import BpeGoodstaticTmp from "@/components/buns-post-edit-templates/bpe-goodstatic-tmp"
import * as apiService from "@/common/api"
import { saveNetFile } from "@/common/untool"
export default {
components: { BpeAddressjiamiTmp, BpeGoodstaticTmp },
@ -278,7 +279,7 @@
},
async handleDownloadPdf(){
let res = await apiService.exportWarehouseInTpl({ orderSn: this.postInfo.orderSn })
debugger
let sres = await saveNetFile(res)
},
async confirmJinCang(inNo) {
let confirmStatus = '2' // 部分入仓