后台商家端批量发货下载以及上传excel
parent
0837f5d9d9
commit
a59ae41108
|
@ -17,14 +17,14 @@ export default {
|
|||
* @description api请求基础路径
|
||||
*/
|
||||
api_dev: {
|
||||
common: "https://common-api.pickmall.cn",
|
||||
buyer: "https://buyer-api.pickmall.cn",
|
||||
seller: "https://store-api.pickmall.cn",
|
||||
manager: "https://admin-api.pickmall.cn"
|
||||
// common: 'http://192.168.0.109:8890',
|
||||
// buyer: 'http://192.168.0.109:8888',
|
||||
// seller: 'http://192.168.0.109:8889',
|
||||
// manager: 'http://192.168.0.109:8887'
|
||||
// common: "https://common-api.pickmall.cn",
|
||||
// buyer: "https://buyer-api.pickmall.cn",
|
||||
// seller: "https://store-api.pickmall.cn",
|
||||
// manager: "https://admin-api.pickmall.cn"
|
||||
common: 'http://192.168.0.100:8890',
|
||||
buyer: 'http://192.168.0.100:8888',
|
||||
seller: 'http://192.168.0.100:8889',
|
||||
manager: 'http://192.168.0.100:8887'
|
||||
},
|
||||
api_prod: {
|
||||
common: "https://common-api.pickmall.cn",
|
||||
|
|
|
@ -8,13 +8,14 @@
|
|||
</Button>
|
||||
</div>
|
||||
<div class="model-title-view-btn">
|
||||
<Poptip placement="bottom" width="100">
|
||||
<!-- TODO 后期会补全 目前版本暂无 -->
|
||||
<!-- <Poptip placement="bottom" width="100">
|
||||
<Button size="default" @click="creatQrCode">预览模板</Button>
|
||||
<div slot="content" class="default-view-content">
|
||||
<div>临时预览</div>
|
||||
<div ref="qrCodeUrl"></div>
|
||||
</div>
|
||||
</Poptip>
|
||||
</Poptip> -->
|
||||
<Button size="default" type="primary" @click="handleSpinShow">保存模板</Button>
|
||||
|
||||
<Modal title="保存中" v-model="saveDialog" :closable="true" :mask-closable="false" :footer-hide="true">
|
||||
|
|
|
@ -1,129 +1,130 @@
|
|||
// 统一请求路径前缀在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) => {
|
||||
return getRequest(`/orders/getOrderByVerificationCode/${verificationCode}`)
|
||||
}
|
||||
|
||||
|
||||
export const verificationCode = verificationCode => {
|
||||
return getRequest(`/orders/getOrderByVerificationCode/${verificationCode}`);
|
||||
};
|
||||
|
||||
// 下载待发货的订单列表
|
||||
export const downLoadDeliverExcel = (params) => {
|
||||
return getRequest(`/orders/downLoadDeliverExcel`, params)
|
||||
}
|
||||
export const downLoadDeliverExcel = params => {
|
||||
return getRequest(`/orders/downLoadDeliverExcel`, params, 'blob');
|
||||
};
|
||||
|
||||
|
||||
// 上传待发货的订单列表
|
||||
export const uploadDeliverExcel = params => {
|
||||
return postRequestWithNoForm(`/orders/batchDeliver`, params );
|
||||
};
|
||||
|
||||
// 获取普通订单列表
|
||||
export const getOrderList = (params) => {
|
||||
return getRequest(`/orders`, params)
|
||||
}
|
||||
export const getOrderList = params => {
|
||||
return getRequest(`/orders`, params);
|
||||
};
|
||||
|
||||
// 获取普通订单详细信息
|
||||
export const getOrderDetail = (sn) => {
|
||||
return getRequest(`/orders/${sn}`)
|
||||
}
|
||||
export const getOrderDetail = sn => {
|
||||
return getRequest(`/orders/${sn}`);
|
||||
};
|
||||
|
||||
// 调整订单金额
|
||||
export const modifyOrderPrice = (sn, params) => {
|
||||
return putRequest(`/orders/update/${sn}/price`, params)
|
||||
}
|
||||
return putRequest(`/orders/update/${sn}/price`, params);
|
||||
};
|
||||
|
||||
// 取消订单
|
||||
export const cancelOrder = (sn, params) => {
|
||||
return postRequest(`/orders/${sn}/cancel`, params)
|
||||
}
|
||||
return postRequest(`/orders/${sn}/cancel`, params);
|
||||
};
|
||||
|
||||
// 修改收货地址
|
||||
export const editOrderConsignee = (sn, params) => {
|
||||
return postRequest(`/orders/update/${sn}/consignee`, params)
|
||||
}
|
||||
return postRequest(`/orders/update/${sn}/consignee`, params);
|
||||
};
|
||||
//获取投诉列表
|
||||
export const getComplainPage = (params) => {
|
||||
return getRequest(`/complain`, params)
|
||||
}
|
||||
export const getComplainPage = params => {
|
||||
return getRequest(`/complain`, params);
|
||||
};
|
||||
|
||||
//获取投诉详情
|
||||
export const getComplainDetail = (id) => {
|
||||
return getRequest(`/complain/${id}`)
|
||||
}
|
||||
export const getComplainDetail = id => {
|
||||
return getRequest(`/complain/${id}`);
|
||||
};
|
||||
|
||||
//添加交易投诉对话
|
||||
export const addOrderComplaint = (params) => {
|
||||
return postRequest(`/complain/communication/`, params)
|
||||
}
|
||||
export const addOrderComplaint = params => {
|
||||
return postRequest(`/complain/communication/`, params);
|
||||
};
|
||||
|
||||
//添加交易投诉对话
|
||||
export const appeal = (params) => {
|
||||
return putRequest(`/complain/appeal`, params)
|
||||
}
|
||||
export const appeal = params => {
|
||||
return putRequest(`/complain/appeal`, params);
|
||||
};
|
||||
|
||||
//获取订单日志
|
||||
export const getOrderLog = (sn, params) => {
|
||||
return getRequest(`/orderLog/${sn}`, params)
|
||||
}
|
||||
return getRequest(`/orderLog/${sn}`, params);
|
||||
};
|
||||
|
||||
// 订单发货
|
||||
export const orderDelivery = (sn, params) => {
|
||||
return postRequest(`/orders/${sn}/delivery`, params)
|
||||
}
|
||||
return postRequest(`/orders/${sn}/delivery`, params);
|
||||
};
|
||||
|
||||
// 获取商家选中的物流公司
|
||||
export const getLogisticsChecked = () => {
|
||||
return getRequest(`/logistics/getChecked`)
|
||||
}
|
||||
return getRequest(`/logistics/getChecked`);
|
||||
};
|
||||
|
||||
// 订单核验
|
||||
export const orderTake = (sn, verificationCode) => {
|
||||
return putRequest(`/orders/take/${sn}/${verificationCode}`)
|
||||
}
|
||||
return putRequest(`/orders/take/${sn}/${verificationCode}`);
|
||||
};
|
||||
|
||||
// 售后服务单
|
||||
export const afterSaleOrderPage = (params) => {
|
||||
return getRequest(`/afterSale/page`, params)
|
||||
}
|
||||
export const afterSaleOrderPage = params => {
|
||||
return getRequest(`/afterSale/page`, params);
|
||||
};
|
||||
|
||||
// 售后服务单详情
|
||||
export const afterSaleOrderDetail = (sn) => {
|
||||
return getRequest(`/afterSale/${sn}`)
|
||||
}
|
||||
export const afterSaleOrderDetail = sn => {
|
||||
return getRequest(`/afterSale/${sn}`);
|
||||
};
|
||||
|
||||
// 商家审核
|
||||
export const afterSaleSellerReview = (sn, params) => {
|
||||
return putRequest(`/afterSale/review/${sn}`, params)
|
||||
}
|
||||
return putRequest(`/afterSale/review/${sn}`, params);
|
||||
};
|
||||
|
||||
// 商家确认收货
|
||||
export const afterSaleSellerConfirm = (sn, params) => {
|
||||
return putRequest(`/afterSale/confirm/${sn}`, params)
|
||||
}
|
||||
return putRequest(`/afterSale/confirm/${sn}`, params);
|
||||
};
|
||||
|
||||
// 商家换货业务发货
|
||||
export const afterSaleSellerDelivery = (sn, params) => {
|
||||
return postRequest(`/afterSale/${sn}/delivery`, params)
|
||||
}
|
||||
return postRequest(`/afterSale/${sn}/delivery`, params);
|
||||
};
|
||||
//查询物流
|
||||
export const getTraces = (sn, params) => {
|
||||
return postRequest(`/orders/getTraces/${sn}`, params)
|
||||
}
|
||||
return postRequest(`/orders/getTraces/${sn}`, params);
|
||||
};
|
||||
//售后单查询物流
|
||||
export const getSellerDeliveryTraces = (sn, params) => {
|
||||
return getRequest(`/afterSale/getSellerDeliveryTraces/${sn}`, params)
|
||||
}
|
||||
return getRequest(`/afterSale/getSellerDeliveryTraces/${sn}`, params);
|
||||
};
|
||||
//售后单查询物流
|
||||
export const getAfterSaleTraces = (sn, params) => {
|
||||
return getRequest(`/afterSale/getDeliveryTraces/${sn}`, params)
|
||||
}
|
||||
return getRequest(`/afterSale/getDeliveryTraces/${sn}`, params);
|
||||
};
|
||||
//获取发票列表
|
||||
export const getReceiptPage = (params) => {
|
||||
return getRequest(`/receipt`, params)
|
||||
}
|
||||
export const getReceiptPage = params => {
|
||||
return getRequest(`/receipt`, params);
|
||||
};
|
||||
|
||||
//获取发票列表
|
||||
export const invoicing = (id) => {
|
||||
return postRequest(`receipt/${id}/invoicing`)
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const invoicing = id => {
|
||||
return postRequest(`receipt/${id}/invoicing`);
|
||||
};
|
||||
|
|
|
@ -22,10 +22,10 @@ export default {
|
|||
// buyer: 'https://buyer-api.pickmall.cn',
|
||||
// seller: 'https://store-api.pickmall.cn',
|
||||
// manager: 'https://admin-api.pickmall.cn',
|
||||
common: 'http://192.168.0.109:8890',
|
||||
buyer: 'http://192.168.0.109:8888',
|
||||
seller: 'http://192.168.0.109:8889',
|
||||
manager: 'http://192.168.0.109:8887'
|
||||
common: 'http://192.168.0.100:8890',
|
||||
buyer: 'http://192.168.0.100:8888',
|
||||
seller: 'http://192.168.0.100:8889',
|
||||
manager: 'http://192.168.0.100:8887'
|
||||
},
|
||||
api_prod: {
|
||||
common: 'https://common-api.pickmall.cn',
|
||||
|
|
|
@ -4,28 +4,34 @@ import { getStore, setStore } from "./storage";
|
|||
import { router } from "../router/index";
|
||||
import { Message } from "view-design";
|
||||
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 commonUrl = (process.env.NODE_ENV === 'development' ? config.api_dev.common : config.api_prod.common);
|
||||
export const baseUrl =
|
||||
(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;
|
||||
const refreshToken = getTokenDebounce()
|
||||
const refreshToken = getTokenDebounce();
|
||||
const service = axios.create({
|
||||
timeout: 10000,
|
||||
baseURL: baseUrl
|
||||
})
|
||||
});
|
||||
service.interceptors.request.use(
|
||||
config => {
|
||||
if (config.method == 'get') {
|
||||
if (config.method == "get") {
|
||||
config.params = {
|
||||
_t: Date.parse(new Date()) / 1000,
|
||||
...config.params
|
||||
}
|
||||
};
|
||||
}
|
||||
const uuid = getStore('uuid');
|
||||
config.headers['uuid'] = uuid;
|
||||
const uuid = getStore("uuid");
|
||||
config.headers["uuid"] = uuid;
|
||||
return config;
|
||||
},
|
||||
err => {
|
||||
|
@ -85,30 +91,32 @@ service.interceptors.response.use(
|
|||
},
|
||||
async error => {
|
||||
// 返回状态码不为200时候的错误处理
|
||||
|
||||
if (error.response) {
|
||||
if (error.response.status === 401) {
|
||||
// 这种情况一般调到登录页
|
||||
} else if (error.response.status === 403) {
|
||||
isRefreshToken++;
|
||||
if(isRefreshToken === 1) {
|
||||
if (isRefreshToken === 1) {
|
||||
const getTokenRes = await refreshToken();
|
||||
if (getTokenRes === 'success') { // 刷新token
|
||||
if (getTokenRes === "success") {
|
||||
// 刷新token
|
||||
if (isRefreshToken === 1) {
|
||||
error.response.config.headers.accessToken = getStore('accessToken')
|
||||
return service(error.response.config)
|
||||
error.response.config.headers.accessToken = getStore(
|
||||
"accessToken"
|
||||
);
|
||||
return service(error.response.config);
|
||||
} else {
|
||||
router.go(0)
|
||||
router.go(0);
|
||||
}
|
||||
} else {
|
||||
Cookies.set("userInfo", "");
|
||||
router.push('/login')
|
||||
router.push("/login");
|
||||
}
|
||||
isRefreshToken = 0
|
||||
isRefreshToken = 0;
|
||||
}
|
||||
} else {
|
||||
// 其他错误处理
|
||||
Message.error(error.response.data.message)
|
||||
Message.error(error.response.data.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,59 +127,65 @@ service.interceptors.response.use(
|
|||
|
||||
// 防抖闭包来一波
|
||||
function getTokenDebounce() {
|
||||
let lock = false
|
||||
let success = false
|
||||
return function () {
|
||||
let lock = false;
|
||||
let success = false;
|
||||
return function() {
|
||||
if (!lock) {
|
||||
lock = true
|
||||
lock = true;
|
||||
let oldRefreshToken = getStore("refreshToken");
|
||||
handleRefreshToken(oldRefreshToken).then(res => {
|
||||
if (res.success) {
|
||||
let {
|
||||
accessToken,
|
||||
refreshToken
|
||||
} = res.result;
|
||||
setStore("accessToken", accessToken);
|
||||
setStore("refreshToken", refreshToken);
|
||||
handleRefreshToken(oldRefreshToken)
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
let { accessToken, refreshToken } = res.result;
|
||||
setStore("accessToken", accessToken);
|
||||
setStore("refreshToken", refreshToken);
|
||||
|
||||
success = true
|
||||
lock = false
|
||||
} else {
|
||||
success = false
|
||||
lock = false
|
||||
// router.push('/login')
|
||||
}
|
||||
}).catch((err) => {
|
||||
success = false
|
||||
lock = false
|
||||
})
|
||||
success = true;
|
||||
lock = false;
|
||||
} else {
|
||||
success = false;
|
||||
lock = false;
|
||||
// router.push('/login')
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
success = false;
|
||||
lock = false;
|
||||
});
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
// 一直看lock,直到请求失败或者成功
|
||||
const timer = setInterval(() => {
|
||||
if (!lock) {
|
||||
clearInterval(timer)
|
||||
clearInterval(timer);
|
||||
if (success) {
|
||||
resolve('success')
|
||||
resolve("success");
|
||||
} else {
|
||||
resolve('fail')
|
||||
resolve("fail");
|
||||
}
|
||||
}
|
||||
}, 500) // 轮询时间间隔
|
||||
})
|
||||
}
|
||||
}, 500); // 轮询时间间隔
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const getRequest = (url, params) => {
|
||||
export const getRequest = (url, params, resBlob) => {
|
||||
let accessToken = getStore("accessToken");
|
||||
return service({
|
||||
let data = {
|
||||
method: "get",
|
||||
url: `${url}`,
|
||||
params: params,
|
||||
headers: {
|
||||
accessToken: accessToken
|
||||
}
|
||||
});
|
||||
},
|
||||
responseType: "blob"
|
||||
};
|
||||
if (resBlob != "blob") {
|
||||
delete data.responseType;
|
||||
}
|
||||
|
||||
|
||||
return service(data);
|
||||
};
|
||||
|
||||
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");
|
||||
return service({
|
||||
method: "put",
|
||||
url: `${url}`,
|
||||
data: params,
|
||||
transformRequest: headers
|
||||
? undefined
|
||||
: [
|
||||
function(data) {
|
||||
let ret = "";
|
||||
for (let it in data) {
|
||||
ret +=
|
||||
encodeURIComponent(it) +
|
||||
"=" +
|
||||
encodeURIComponent(data[it]) +
|
||||
"&";
|
||||
? undefined
|
||||
: [
|
||||
function(data) {
|
||||
let ret = "";
|
||||
for (let it in data) {
|
||||
ret +=
|
||||
encodeURIComponent(it) +
|
||||
"=" +
|
||||
encodeURIComponent(data[it]) +
|
||||
"&";
|
||||
}
|
||||
ret = ret.substring(0, ret.length - 1);
|
||||
return ret;
|
||||
}
|
||||
ret = ret.substring(0, ret.length - 1);
|
||||
return ret;
|
||||
}
|
||||
],
|
||||
],
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
accessToken: accessToken,
|
||||
|
@ -337,4 +350,3 @@ export const postRequestWithNoToken = (url, params) => {
|
|||
params: params
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
</div>
|
||||
<!-- 上传 -->
|
||||
<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"
|
||||
:headers="accessToken">
|
||||
<Upload :before-upload="handleUpload" name="files" style="width:50%; height:400px;"
|
||||
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" multiple type="drag" :action="action" :headers="accessToken">
|
||||
<div style="padding: 50px 0">
|
||||
<Icon type="ios-cloud-upload" size="102" style="color: #3399ff"></Icon>
|
||||
<h2>选择或拖拽文件上传</h2>
|
||||
|
@ -41,7 +41,7 @@
|
|||
|
||||
<script>
|
||||
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";
|
||||
export default {
|
||||
components: {
|
||||
|
@ -49,6 +49,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
file: "",
|
||||
action: baseUrl + "/orders/batchDeliver", // 上传接口
|
||||
accessToken: {}, // 验证token
|
||||
// 步骤集合
|
||||
|
@ -72,7 +73,8 @@ export default {
|
|||
};
|
||||
},
|
||||
mounted() {
|
||||
this.accessToken.accessToken =this.getStore("accessToken");
|
||||
this.accessToken.accessToken = this.getStore("accessToken");
|
||||
console.log(this.accessToken.accessToken);
|
||||
},
|
||||
methods: {
|
||||
// 点击选择步骤
|
||||
|
@ -83,8 +85,51 @@ export default {
|
|||
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 属性
|
||||
//IE10以上支持blob但是依然不支持download
|
||||
if ("download" in document.createElement("a")) {
|
||||
//支持a标签download的浏览器
|
||||
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);
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue