Commit 20ebfd87 authored by limengyang's avatar limengyang

feat(lmy):上传优化

parent dac7a2e0
import { tmallabHttp } from '/@/utils/http/axios';
import { ContentTypeEnum } from '/@/enums/httpEnum';
enum Api {
GetStatus = '/system/opsProduct/IsOpsSupplier',
List = '/system/opsProduct/getList',
......@@ -80,14 +79,15 @@ export const regionalSpotManageOpsEditProductApi = (data) =>
/**
* @description: 批量上传
*/
export const regionalSpotManageUploadOpsProductApi = (data) =>
tmallabHttp.post(
export const regionalSpotManageUploadOpsProductApi = (data, file) =>
tmallabHttp.uploadFile(
{
url: Api.UploadOpsProduct,
method: 'POST',
data,
headers: { 'Content-Type': ContentTypeEnum.FORM_DATA },
baseURL: import.meta.env.VITE_GLOB_TMALLAB_URL,
},
{ errorMessageMode: 'message' },
{ file, data },
);
/**
......
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
import axios from 'axios';
import {
Form,
FormItem,
......@@ -14,7 +13,7 @@
} from 'ant-design-vue';
import { UploadOutlined } from '@ant-design/icons-vue';
import { useRouter } from 'vue-router';
import { getAuthCache, getTmallabToken } from '/@/utils/auth';
import { getAuthCache } from '/@/utils/auth';
import {
regionalSpotManageBrandListApi,
regionalSpotManageGroupListApi,
......@@ -23,11 +22,11 @@
regionalSpotManageGetGhsAreaListApi,
regionalSpotManageOpsDeleteProductApi,
regionalSpotManageOpsEditProductApi,
regionalSpotManageUploadOpsProductApi,
} from '/@/api/regionalSpotManage';
import addProductModal from './addProduct.vue';
const config = import.meta.env;
const userInfo: any = getAuthCache('USER__INFO__');
const Token = getTmallabToken() as unknown as string;
const ghsCode = userInfo.supplier.ghsCode;
const ghsName = userInfo.supplier.ghsName;
const router = useRouter();
......@@ -394,22 +393,14 @@
const confirmImport = async () => {
if (!productExcelList.value.length) return message.error('请上传文件');
if (!impotrCheckboxValue.value.length) return message.error('请选择现货区域');
const data: FormData = new FormData();
data.append('ghsCode', ghsCode);
data.append('ghsName', ghsName);
data.append('file', productExcelList.value[0]);
data.append('areaIds', impotrCheckboxValue.value.join(',') as any);
const param: FormData = new FormData();
param.append('ghsCode', ghsCode);
param.append('ghsName', ghsName);
param.append('file', productExcelList.value[0]);
param.append('areaIds', impotrCheckboxValue.value.join(',') as any);
importLoading.value = true;
const res = await axios.post(
config.VITE_GLOB_TMALLAB_URL + '/excel/excelNew/uploadOpsProduct',
data,
{
headers: {
Token: Token,
},
},
);
// const res = await regionalSpotManageUploadOpsProductApi(param);
const res: any = await regionalSpotManageUploadOpsProductApi(param, productExcelList.value[0]);
console.log(res);
if (res.data.success) {
message.success('批量导入成功');
importCancel();
......
......@@ -16,12 +16,12 @@
<template>
<div>
<ManageList />
<!-- <a-spin v-if="loading" style="height: 150px; width: 100%; line-height: 150px" />
<!-- <ManageList /> -->
<a-spin v-if="loading" style="height: 150px; width: 100%; line-height: 150px" />
<ManageList v-if="show && !loading" />
<div v-if="!show && !loading" class="status">
<img src="../../assets/images/logo.png" alt="" srcset="" />
</div> -->
</div>
</div>
</template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment