Commit dac7a2e0 authored by limengyang's avatar limengyang

feat(lmy):批量上传

parent 642db372
<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,
...@@ -13,7 +14,7 @@ ...@@ -13,7 +14,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 } from '/@/utils/auth'; import { getAuthCache, getTmallabToken } from '/@/utils/auth';
import { import {
regionalSpotManageBrandListApi, regionalSpotManageBrandListApi,
regionalSpotManageGroupListApi, regionalSpotManageGroupListApi,
...@@ -22,11 +23,11 @@ ...@@ -22,11 +23,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();
...@@ -357,7 +358,7 @@ ...@@ -357,7 +358,7 @@
// =====================批量导入 start======================= // =====================批量导入 start=======================
const productExcelList = ref<any[]>([]); const productExcelList = ref<any[]>([]);
const importVisible = ref(false); const importVisible = ref(false);
const impotrCheckboxValue = ref([]); const impotrCheckboxValue = ref<any[]>([]);
const batchImport = () => { const batchImport = () => {
importVisible.value = true; importVisible.value = true;
allAreaList.value.forEach((v) => { allAreaList.value.forEach((v) => {
...@@ -393,18 +394,27 @@ ...@@ -393,18 +394,27 @@
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 param: FormData = new FormData(); const data: FormData = new FormData();
param.append('ghsCode', ghsCode); data.append('ghsCode', ghsCode);
param.append('ghsName', ghsName); data.append('ghsName', ghsName);
param.append('file', productExcelList.value[0]); data.append('file', productExcelList.value[0]);
param.append('areaIds', impotrCheckboxValue.value as any); data.append('areaIds', impotrCheckboxValue.value.join(',') as any);
importLoading.value = true; importLoading.value = true;
const res = await regionalSpotManageUploadOpsProductApi(param); const res = await axios.post(
if (res.success) { config.VITE_GLOB_TMALLAB_URL + '/excel/excelNew/uploadOpsProduct',
data,
{
headers: {
Token: Token,
},
},
);
// const res = await regionalSpotManageUploadOpsProductApi(param);
if (res.data.success) {
message.success('批量导入成功'); message.success('批量导入成功');
importCancel(); importCancel();
} else { } else {
message.error(res.message); message.error(res.data.message);
} }
importLoading.value = false; importLoading.value = false;
}; };
......
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