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

完成导入产品线功能

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