Commit 20ebfd87 authored by limengyang's avatar limengyang

feat(lmy):上传优化

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