|
@@ -72,6 +72,7 @@ import download from '@/utils/download'
|
|
|
import {useUpload} from "@/components/UploadFile/src/useUpload";
|
|
|
defineOptions({ name: 'SystemUserImportForm' })
|
|
|
|
|
|
+import axios from 'axios';
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
const { httpRequest } = useUpload()
|
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
@@ -80,8 +81,7 @@ const uploadRef = ref()
|
|
|
const uploadZipRef = ref()
|
|
|
const importUrl =
|
|
|
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/md/acs/import-data'
|
|
|
-const importZipUrl =
|
|
|
- import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/md/acs/import-data'
|
|
|
+
|
|
|
const uploadHeaders = ref() // 上传 Header 头
|
|
|
const fileList = ref([]) // 文件列表
|
|
|
const updateSupport = ref(0) // 是否更新已经存在的用户数据
|
|
@@ -114,17 +114,26 @@ const submitForm = async () => {
|
|
|
message.error('请上传文件或压缩包')
|
|
|
return
|
|
|
}
|
|
|
+ const formData = new FormData();
|
|
|
+
|
|
|
+ if (fileList.value.length > 0) {
|
|
|
+ formData.append('excelFile', fileList.value[0].raw); // 确保是 .raw
|
|
|
+ }
|
|
|
|
|
|
- // 提交请求
|
|
|
- uploadHeaders.value = {
|
|
|
- Authorization: 'Bearer ' + getAccessToken(),
|
|
|
- 'tenant-id': getTenantId()
|
|
|
+ if (zipList.value.length > 0) {
|
|
|
+ formData.append('imageFile', zipList.value[0].raw); // 确保是 .raw
|
|
|
}
|
|
|
- formLoading.value = true
|
|
|
- uploadRef.value!.submit()
|
|
|
- uploadZipRef.value!.submit()
|
|
|
- console.log('1234567890',uploadHeaders.value);
|
|
|
-
|
|
|
+
|
|
|
+ formData.append('updateSupport', updateSupport.value);
|
|
|
+
|
|
|
+ await axios.post(importUrl, formData, {
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'multipart/form-data',
|
|
|
+ Authorization: 'Bearer ' + getAccessToken(),
|
|
|
+ 'tenant-id': getTenantId()
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|