后台商家端批量发货下载以及上传excel

master
lemon橪 2021-06-13 17:56:16 +08:00
parent 0837f5d9d9
commit a59ae41108
6 changed files with 216 additions and 157 deletions

View File

@ -17,14 +17,14 @@ export default {
* @description api请求基础路径 * @description api请求基础路径
*/ */
api_dev: { api_dev: {
common: "https://common-api.pickmall.cn", // common: "https://common-api.pickmall.cn",
buyer: "https://buyer-api.pickmall.cn", // buyer: "https://buyer-api.pickmall.cn",
seller: "https://store-api.pickmall.cn", // seller: "https://store-api.pickmall.cn",
manager: "https://admin-api.pickmall.cn" // manager: "https://admin-api.pickmall.cn"
// common: 'http://192.168.0.109:8890', common: 'http://192.168.0.100:8890',
// buyer: 'http://192.168.0.109:8888', buyer: 'http://192.168.0.100:8888',
// seller: 'http://192.168.0.109:8889', seller: 'http://192.168.0.100:8889',
// manager: 'http://192.168.0.109:8887' manager: 'http://192.168.0.100:8887'
}, },
api_prod: { api_prod: {
common: "https://common-api.pickmall.cn", common: "https://common-api.pickmall.cn",

View File

@ -8,13 +8,14 @@
</Button> </Button>
</div> </div>
<div class="model-title-view-btn"> <div class="model-title-view-btn">
<Poptip placement="bottom" width="100"> <!-- TODO 后期会补全 目前版本暂无 -->
<!-- <Poptip placement="bottom" width="100">
<Button size="default" @click="creatQrCode"></Button> <Button size="default" @click="creatQrCode"></Button>
<div slot="content" class="default-view-content"> <div slot="content" class="default-view-content">
<div>临时预览</div> <div>临时预览</div>
<div ref="qrCodeUrl"></div> <div ref="qrCodeUrl"></div>
</div> </div>
</Poptip> </Poptip> -->
<Button size="default" type="primary" @click="handleSpinShow"></Button> <Button size="default" type="primary" @click="handleSpinShow"></Button>
<Modal title="保存中" v-model="saveDialog" :closable="true" :mask-closable="false" :footer-hide="true"> <Modal title="保存中" v-model="saveDialog" :closable="true" :mask-closable="false" :footer-hide="true">

View File

@ -1,129 +1,130 @@
// 统一请求路径前缀在libs/axios.js中修改 // 统一请求路径前缀在libs/axios.js中修改
import {getRequest, postRequest, putRequest} from '@/libs/axios'; import { getRequest, postRequest, putRequest ,postRequestWithNoForm } from "@/libs/axios";
import { baseUrl } from "@/libs/axios.js";
// 下载待发货的订单列表 // 下载待发货的订单列表
export const verificationCode = (verificationCode) => { export const verificationCode = verificationCode => {
return getRequest(`/orders/getOrderByVerificationCode/${verificationCode}`) return getRequest(`/orders/getOrderByVerificationCode/${verificationCode}`);
} };
// 下载待发货的订单列表 // 下载待发货的订单列表
export const downLoadDeliverExcel = (params) => { export const downLoadDeliverExcel = params => {
return getRequest(`/orders/downLoadDeliverExcel`, params) return getRequest(`/orders/downLoadDeliverExcel`, params, 'blob');
} };
// 上传待发货的订单列表
export const uploadDeliverExcel = params => {
return postRequestWithNoForm(`/orders/batchDeliver`, params );
};
// 获取普通订单列表 // 获取普通订单列表
export const getOrderList = (params) => { export const getOrderList = params => {
return getRequest(`/orders`, params) return getRequest(`/orders`, params);
} };
// 获取普通订单详细信息 // 获取普通订单详细信息
export const getOrderDetail = (sn) => { export const getOrderDetail = sn => {
return getRequest(`/orders/${sn}`) return getRequest(`/orders/${sn}`);
} };
// 调整订单金额 // 调整订单金额
export const modifyOrderPrice = (sn, params) => { export const modifyOrderPrice = (sn, params) => {
return putRequest(`/orders/update/${sn}/price`, params) return putRequest(`/orders/update/${sn}/price`, params);
} };
// 取消订单 // 取消订单
export const cancelOrder = (sn, params) => { export const cancelOrder = (sn, params) => {
return postRequest(`/orders/${sn}/cancel`, params) return postRequest(`/orders/${sn}/cancel`, params);
} };
// 修改收货地址 // 修改收货地址
export const editOrderConsignee = (sn, params) => { export const editOrderConsignee = (sn, params) => {
return postRequest(`/orders/update/${sn}/consignee`, params) return postRequest(`/orders/update/${sn}/consignee`, params);
} };
//获取投诉列表 //获取投诉列表
export const getComplainPage = (params) => { export const getComplainPage = params => {
return getRequest(`/complain`, params) return getRequest(`/complain`, params);
} };
//获取投诉详情 //获取投诉详情
export const getComplainDetail = (id) => { export const getComplainDetail = id => {
return getRequest(`/complain/${id}`) return getRequest(`/complain/${id}`);
} };
//添加交易投诉对话 //添加交易投诉对话
export const addOrderComplaint = (params) => { export const addOrderComplaint = params => {
return postRequest(`/complain/communication/`, params) return postRequest(`/complain/communication/`, params);
} };
//添加交易投诉对话 //添加交易投诉对话
export const appeal = (params) => { export const appeal = params => {
return putRequest(`/complain/appeal`, params) return putRequest(`/complain/appeal`, params);
} };
//获取订单日志 //获取订单日志
export const getOrderLog = (sn, params) => { export const getOrderLog = (sn, params) => {
return getRequest(`/orderLog/${sn}`, params) return getRequest(`/orderLog/${sn}`, params);
} };
// 订单发货 // 订单发货
export const orderDelivery = (sn, params) => { export const orderDelivery = (sn, params) => {
return postRequest(`/orders/${sn}/delivery`, params) return postRequest(`/orders/${sn}/delivery`, params);
} };
// 获取商家选中的物流公司 // 获取商家选中的物流公司
export const getLogisticsChecked = () => { export const getLogisticsChecked = () => {
return getRequest(`/logistics/getChecked`) return getRequest(`/logistics/getChecked`);
} };
// 订单核验 // 订单核验
export const orderTake = (sn, verificationCode) => { export const orderTake = (sn, verificationCode) => {
return putRequest(`/orders/take/${sn}/${verificationCode}`) return putRequest(`/orders/take/${sn}/${verificationCode}`);
} };
// 售后服务单 // 售后服务单
export const afterSaleOrderPage = (params) => { export const afterSaleOrderPage = params => {
return getRequest(`/afterSale/page`, params) return getRequest(`/afterSale/page`, params);
} };
// 售后服务单详情 // 售后服务单详情
export const afterSaleOrderDetail = (sn) => { export const afterSaleOrderDetail = sn => {
return getRequest(`/afterSale/${sn}`) return getRequest(`/afterSale/${sn}`);
} };
// 商家审核 // 商家审核
export const afterSaleSellerReview = (sn, params) => { export const afterSaleSellerReview = (sn, params) => {
return putRequest(`/afterSale/review/${sn}`, params) return putRequest(`/afterSale/review/${sn}`, params);
} };
// 商家确认收货 // 商家确认收货
export const afterSaleSellerConfirm = (sn, params) => { export const afterSaleSellerConfirm = (sn, params) => {
return putRequest(`/afterSale/confirm/${sn}`, params) return putRequest(`/afterSale/confirm/${sn}`, params);
} };
// 商家换货业务发货 // 商家换货业务发货
export const afterSaleSellerDelivery = (sn, params) => { export const afterSaleSellerDelivery = (sn, params) => {
return postRequest(`/afterSale/${sn}/delivery`, params) return postRequest(`/afterSale/${sn}/delivery`, params);
} };
//查询物流 //查询物流
export const getTraces = (sn, params) => { export const getTraces = (sn, params) => {
return postRequest(`/orders/getTraces/${sn}`, params) return postRequest(`/orders/getTraces/${sn}`, params);
} };
//售后单查询物流 //售后单查询物流
export const getSellerDeliveryTraces = (sn, params) => { export const getSellerDeliveryTraces = (sn, params) => {
return getRequest(`/afterSale/getSellerDeliveryTraces/${sn}`, params) return getRequest(`/afterSale/getSellerDeliveryTraces/${sn}`, params);
} };
//售后单查询物流 //售后单查询物流
export const getAfterSaleTraces = (sn, params) => { export const getAfterSaleTraces = (sn, params) => {
return getRequest(`/afterSale/getDeliveryTraces/${sn}`, params) return getRequest(`/afterSale/getDeliveryTraces/${sn}`, params);
} };
//获取发票列表 //获取发票列表
export const getReceiptPage = (params) => { export const getReceiptPage = params => {
return getRequest(`/receipt`, params) return getRequest(`/receipt`, params);
} };
//获取发票列表 //获取发票列表
export const invoicing = (id) => { export const invoicing = id => {
return postRequest(`receipt/${id}/invoicing`) return postRequest(`receipt/${id}/invoicing`);
} };

View File

@ -22,10 +22,10 @@ export default {
// buyer: 'https://buyer-api.pickmall.cn', // buyer: 'https://buyer-api.pickmall.cn',
// seller: 'https://store-api.pickmall.cn', // seller: 'https://store-api.pickmall.cn',
// manager: 'https://admin-api.pickmall.cn', // manager: 'https://admin-api.pickmall.cn',
common: 'http://192.168.0.109:8890', common: 'http://192.168.0.100:8890',
buyer: 'http://192.168.0.109:8888', buyer: 'http://192.168.0.100:8888',
seller: 'http://192.168.0.109:8889', seller: 'http://192.168.0.100:8889',
manager: 'http://192.168.0.109:8887' manager: 'http://192.168.0.100:8887'
}, },
api_prod: { api_prod: {
common: 'https://common-api.pickmall.cn', common: 'https://common-api.pickmall.cn',

View File

@ -4,28 +4,34 @@ import { getStore, setStore } from "./storage";
import { router } from "../router/index"; import { router } from "../router/index";
import { Message } from "view-design"; import { Message } from "view-design";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import {handleRefreshToken} from "@/api/index" import { handleRefreshToken } from "@/api/index";
// 统一请求路径前缀 // 统一请求路径前缀
export const baseUrl = (process.env.NODE_ENV === 'development' ? config.api_dev.seller : config.api_prod.seller) + config.baseUrlPrefix; export const baseUrl =
export const commonUrl = (process.env.NODE_ENV === 'development' ? config.api_dev.common : config.api_prod.common); (process.env.NODE_ENV === "development"
? config.api_dev.seller
: config.api_prod.seller) + config.baseUrlPrefix;
export const commonUrl =
process.env.NODE_ENV === "development"
? config.api_dev.common
: config.api_prod.common;
var isRefreshToken = 0; var isRefreshToken = 0;
const refreshToken = getTokenDebounce() const refreshToken = getTokenDebounce();
const service = axios.create({ const service = axios.create({
timeout: 10000, timeout: 10000,
baseURL: baseUrl baseURL: baseUrl
}) });
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
if (config.method == 'get') { if (config.method == "get") {
config.params = { config.params = {
_t: Date.parse(new Date()) / 1000, _t: Date.parse(new Date()) / 1000,
...config.params ...config.params
} };
} }
const uuid = getStore('uuid'); const uuid = getStore("uuid");
config.headers['uuid'] = uuid; config.headers["uuid"] = uuid;
return config; return config;
}, },
err => { err => {
@ -85,30 +91,32 @@ service.interceptors.response.use(
}, },
async error => { async error => {
// 返回状态码不为200时候的错误处理 // 返回状态码不为200时候的错误处理
if (error.response) { if (error.response) {
if (error.response.status === 401) { if (error.response.status === 401) {
// 这种情况一般调到登录页 // 这种情况一般调到登录页
} else if (error.response.status === 403) { } else if (error.response.status === 403) {
isRefreshToken++; isRefreshToken++;
if(isRefreshToken === 1) { if (isRefreshToken === 1) {
const getTokenRes = await refreshToken(); const getTokenRes = await refreshToken();
if (getTokenRes === 'success') { // 刷新token if (getTokenRes === "success") {
// 刷新token
if (isRefreshToken === 1) { if (isRefreshToken === 1) {
error.response.config.headers.accessToken = getStore('accessToken') error.response.config.headers.accessToken = getStore(
return service(error.response.config) "accessToken"
);
return service(error.response.config);
} else { } else {
router.go(0) router.go(0);
} }
} else { } else {
Cookies.set("userInfo", ""); Cookies.set("userInfo", "");
router.push('/login') router.push("/login");
} }
isRefreshToken = 0 isRefreshToken = 0;
} }
} else { } else {
// 其他错误处理 // 其他错误处理
Message.error(error.response.data.message) Message.error(error.response.data.message);
} }
} }
@ -119,59 +127,65 @@ service.interceptors.response.use(
// 防抖闭包来一波 // 防抖闭包来一波
function getTokenDebounce() { function getTokenDebounce() {
let lock = false let lock = false;
let success = false let success = false;
return function () { return function() {
if (!lock) { if (!lock) {
lock = true lock = true;
let oldRefreshToken = getStore("refreshToken"); let oldRefreshToken = getStore("refreshToken");
handleRefreshToken(oldRefreshToken).then(res => { handleRefreshToken(oldRefreshToken)
if (res.success) { .then(res => {
let { if (res.success) {
accessToken, let { accessToken, refreshToken } = res.result;
refreshToken setStore("accessToken", accessToken);
} = res.result; setStore("refreshToken", refreshToken);
setStore("accessToken", accessToken);
setStore("refreshToken", refreshToken);
success = true success = true;
lock = false lock = false;
} else { } else {
success = false success = false;
lock = false lock = false;
// router.push('/login') // router.push('/login')
} }
}).catch((err) => { })
success = false .catch(err => {
lock = false success = false;
}) lock = false;
});
} }
return new Promise(resolve => { return new Promise(resolve => {
// 一直看lock,直到请求失败或者成功 // 一直看lock,直到请求失败或者成功
const timer = setInterval(() => { const timer = setInterval(() => {
if (!lock) { if (!lock) {
clearInterval(timer) clearInterval(timer);
if (success) { if (success) {
resolve('success') resolve("success");
} else { } else {
resolve('fail') resolve("fail");
} }
} }
}, 500) // 轮询时间间隔 }, 500); // 轮询时间间隔
}) });
} };
} }
export const getRequest = (url, params) => { export const getRequest = (url, params, resBlob) => {
let accessToken = getStore("accessToken"); let accessToken = getStore("accessToken");
return service({ let data = {
method: "get", method: "get",
url: `${url}`, url: `${url}`,
params: params, params: params,
headers: { headers: {
accessToken: accessToken accessToken: accessToken
} },
}); responseType: "blob"
};
if (resBlob != "blob") {
delete data.responseType;
}
return service(data);
}; };
export const postRequest = (url, params, headers) => { export const postRequest = (url, params, headers) => {
@ -232,29 +246,28 @@ export const postRequestWithHeaders = (url, params) => {
}); });
}; };
export const putRequest = (url, params, headers) => {
export const putRequest = (url, params,headers) => {
let accessToken = getStore("accessToken"); let accessToken = getStore("accessToken");
return service({ return service({
method: "put", method: "put",
url: `${url}`, url: `${url}`,
data: params, data: params,
transformRequest: headers transformRequest: headers
? undefined ? undefined
: [ : [
function(data) { function(data) {
let ret = ""; let ret = "";
for (let it in data) { for (let it in data) {
ret += ret +=
encodeURIComponent(it) + encodeURIComponent(it) +
"=" + "=" +
encodeURIComponent(data[it]) + encodeURIComponent(data[it]) +
"&"; "&";
}
ret = ret.substring(0, ret.length - 1);
return ret;
} }
ret = ret.substring(0, ret.length - 1); ],
return ret;
}
],
headers: { headers: {
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
accessToken: accessToken, accessToken: accessToken,
@ -337,4 +350,3 @@ export const postRequestWithNoToken = (url, params) => {
params: params params: params
}); });
}; };

View File

@ -17,8 +17,8 @@
</div> </div>
<!-- 上传 --> <!-- 上传 -->
<div v-if="item.checked && index ==1" class="tpl"> <div v-if="item.checked && index ==1" class="tpl">
<Upload name="file" style="width:50%; height:400px;" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" multiple type="drag" :action="action" <Upload :before-upload="handleUpload" name="files" style="width:50%; height:400px;"
:headers="accessToken"> accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" multiple type="drag" :action="action" :headers="accessToken">
<div style="padding: 50px 0"> <div style="padding: 50px 0">
<Icon type="ios-cloud-upload" size="102" style="color: #3399ff"></Icon> <Icon type="ios-cloud-upload" size="102" style="color: #3399ff"></Icon>
<h2>选择或拖拽文件上传</h2> <h2>选择或拖拽文件上传</h2>
@ -41,7 +41,7 @@
<script> <script>
import JsonExcel from "vue-json-excel"; import JsonExcel from "vue-json-excel";
import { getLogisticsChecked } from "@/api/order.js"; import { downLoadDeliverExcel, uploadDeliverExcel } from "@/api/order.js";
import { baseUrl } from "@/libs/axios.js"; import { baseUrl } from "@/libs/axios.js";
export default { export default {
components: { components: {
@ -49,6 +49,7 @@ export default {
}, },
data() { data() {
return { return {
file: "",
action: baseUrl + "/orders/batchDeliver", // action: baseUrl + "/orders/batchDeliver", //
accessToken: {}, // token accessToken: {}, // token
// //
@ -72,7 +73,8 @@ export default {
}; };
}, },
mounted() { mounted() {
this.accessToken.accessToken =this.getStore("accessToken"); this.accessToken.accessToken = this.getStore("accessToken");
console.log(this.accessToken.accessToken);
}, },
methods: { methods: {
// //
@ -83,8 +85,51 @@ export default {
val.checked = true; val.checked = true;
}, },
async downLoad() {
let res = await getLogisticsChecked(); handleUpload(file) {
this.file = file;
this.upload();
return false;
},
/**
* 上传文件
*/
async upload() {
let fd = new FormData();
fd.append("files", this.file);
await uploadDeliverExcel(fd);
},
/**
* 下载excel
*/
downLoad() {
downLoadDeliverExcel()
.then((res) => {
const blob = new Blob([res], {
type: "application/vnd.ms-excel;charset=utf-8",
});
//<a> Firefox Chrome download
//IE10blobdownload
if ("download" in document.createElement("a")) {
//adownload
const link = document.createElement("a"); //a
link.download = "批量发货导入模板.xls"; //a
link.style.display = "none";
link.href = URL.createObjectURL(blob);
document.body.appendChild(link);
link.click(); //
URL.revokeObjectURL(link.href); //url
document.body.removeChild(link); //
} else {
navigator.msSaveBlob(blob, fileName);
}
})
.catch((err) => {
console.log(err);
});
}, },
}, },
}; };