提交 15096493 authored 作者: 刘旭's avatar 刘旭

完成导入产品线功能

上级 ab31c6be
......@@ -38,3 +38,6 @@ export const getProductLineReAdd = (data: any) =>
// 产品线-导入
export const productLineUpload = (data: any) =>
request('/wx/productLine/upload', 'POST', data);
export const getLineSpecification = (data: any) =>
request('/wx/productLine/getSpecification', 'POST', data);
\ No newline at end of file
......@@ -724,8 +724,6 @@ export default {
that.checkInpath(index1);
// 如果全部选完
that.checkSelectShop();
console.log(this.goodsInfo, 'all');
}
},
// 检测是否已经选完sku
......
......@@ -177,7 +177,18 @@ let initProductLine = (lineId: number) => {
// 获取产品线详细数据
getProductLineIndex({ lineId }).then((res: any) => {
if (res.data.code === 200) {
handleEditProductLineData(res.data.data)
console.log(res.data.data);
if (res.data.data.cartList.length > 20) {
uni.navigateTo({
url: './importProductLine',
success: () => {
setTimeout(() => {
uni.$emit('importProductLineData', { data: res.data.data })
}, 300);
}
})
}
else handleEditProductLineData(res.data.data)
}
});
};
......@@ -606,6 +617,7 @@ let uploadLine = () => {
count: 0,
extension: ['.xlsx'],
success(res: any) {
let fileName = res.tempFiles[0].name
flag.value = false;
uni.showLoading({
title: '加载中'
......@@ -617,18 +629,17 @@ let uploadLine = () => {
header: { Authorization: uni.getStorageSync('token') },
success(uploadFileRes: any) {
uni.hideLoading()
let res = JSON.parse(uploadFileRes.data)
if (res.code === 200) {
if (res.data.cartList.length <= 20) {
console.log(res);
let fileRes = JSON.parse(uploadFileRes.data)
if (!fileRes.data.isError) {
if (fileRes.data.cartList.length <= 20) {
// 判断是否为导入产品线
isUpload.value = res.data.isUpload
isUpload.value = fileRes.data.isUpload
// 清空标题
store.title = '';
setTitleRef.value.title = store.title;
lineId.value = null
// console.log(res.data.isUpload);
handleEditProductLineData(res.data)
handleEditProductLineData(fileRes.data)
} else {
uni.showToast({
title: '导入商品数量超出上限,跳转页面后,将只用于下单或加入购物车',
......@@ -638,13 +649,29 @@ let uploadLine = () => {
url: './importProductLine',
success: () => {
setTimeout(() => {
uni.$emit('importProductLineData', { data: res.data })
uni.$emit('importProductLineData', { data: fileRes.data })
}, 300);
}
})
}
})
}
} else {
flag.value = true;
let key = fileRes.data.key
uni.downloadFile({
url: baseUrl + '/wx/productLine/error/download/' + key,
header: { 'Authorization': uni.getStorageSync('token') },
success: (res: any) => {
let downloadElement = document.createElement('a');
downloadElement.href = res.tempFilePath;
downloadElement.download = fileName; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
window.URL.revokeObjectURL(res.tempFilePath); //释放掉blob对象
}
})
}
},
fail() {
......
......@@ -77,7 +77,7 @@ let orderBtnList = ref([
},
{
url: '/static/my/wenjianshengchengguize.png',
text: '待生',
text: '待生',
badge: 1,
type: 'error',
},
......
......@@ -2,8 +2,8 @@ const CONFIG: any = {
// 开发环境配置
development: {
assetsPath: 'http://192.168.60:81', // 静态资源路径
// baseUrl: 'http://192.168.0.9:8089', // 后台接口请求地址
baseUrl: 'http://192.168.0.60:81', // 后台接口请求地址
baseUrl: 'http://192.168.0.9:8089', // 后台接口请求地址
// baseUrl: 'http://192.168.0.60:81', // 后台接口请求地址
hostUrl: 'http://192.168.0.60:81', // H5地址(前端运行地址)
websocketUrl: '', // websocket服务端地址
},
......
......@@ -2,8 +2,8 @@ import config from './config';
const baseUrl = config.baseUrl;
// 封装公共申请办法
function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?: object | any) {
return new Promise(function(resolve, reject) {
function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?: object | any, responseType?: string) {
return new Promise(function (resolve, reject) {
let header: any;
uni.showLoading({
title: '加载中...',
......@@ -34,6 +34,7 @@ function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?:
method: method,
data: data,
header: header,
responseType,
success(res: any) {
uni.hideLoading();
if (res.data.code == 200) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论