From 5c1e5f8ce5e53c187f100f5d786a77991198960a Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期二, 18 三月 2025 15:23:44 +0800
Subject: [PATCH] 修改 # 物料导入导出添加动态扩展字段
---
rsf-admin/src/page/components/ImportModal.jsx | 35 +++++++++++++++++++++++++++--------
1 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/rsf-admin/src/page/components/ImportModal.jsx b/rsf-admin/src/page/components/ImportModal.jsx
index 3775169..70f84cf 100644
--- a/rsf-admin/src/page/components/ImportModal.jsx
+++ b/rsf-admin/src/page/components/ImportModal.jsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from 'react';
+import { useEffect, useState, createContext, useContext } from 'react';
import { Box, CircularProgress, Stack, Typography } from '@mui/material';
import Alert from '@mui/material/Alert';
import Dialog from '@mui/material/Dialog';
@@ -13,14 +13,16 @@
Form,
Toolbar,
useRefresh,
- useTranslate
+ useTranslate,
+ useNotify
} from 'react-admin';
import { Link } from 'react-router-dom';
import DialogCloseButton from './DialogCloseButton';
import { usePapaParse } from './usePapaParse';
import MatnrList from '../basicInfo/matnr/MatnrList';
+import request from '@/utils/request'
-const ImportModal = ({ open, onClose, importTemp, useCodeImport, onceBatch = 10 }) => {
+const ImportModal = ({ open, onClose, importTemp, useCodeImport, onceBatch = 10, value, parmas = {} }) => {
const refresh = useRefresh();
const translate = useTranslate();
@@ -31,6 +33,7 @@
});
const [file, setFile] = useState(null);
+ const notify = useNotify();
useEffect(() => {
if (importer.state === 'complete') {
@@ -46,9 +49,25 @@
if (!file) {
return;
}
+ const form = new FormData();
+ for (const key in parmas) {
+ if (parmas.hasOwnProperty(key)) {
+ form.append(key, parmas[key]);
+ }
+ }
+ form.append('file', file);
+ const { data: { code, data, msg } } = await request.post(`/${value}/import`, form)
- parseCsv(file);
+ if (code === 200) {
+ handleClose()
+ } else {
+ notify(msg);
+
+ }
+
};
+
+
const handleClose = () => {
reset();
@@ -210,12 +229,12 @@
</Dialog>
);
}
-{/**涓嬭浇鎵撳嵃妯℃澘锛屼紶鍏ype绫诲瀷锛岃皟鐢ㄤ笅杞芥ā鏉挎帴鍙� */}
+{/**涓嬭浇鎵撳嵃妯℃澘锛屼紶鍏ype绫诲瀷锛岃皟鐢ㄤ笅杞芥ā鏉挎帴鍙� */ }
const downloadTemplate = (type) => {
// 涓嬭浇鐗╂枡妯℃澘
- if (type != undefined && type == 'matnr') {
-
- }
+ if (type != undefined && type == 'matnr') {
+
+ }
console.log('======>');
console.log(type);
}
--
Gitblit v1.9.1