Commit ad050307 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

🐞 fix: 更改导入物料

parent 288f3e88
......@@ -14,7 +14,7 @@ interface UploadImportProps {
/** 检查的接口 */
checkfetch?: string,
/** 导入的接口 */
importfetch?: Promise<unknown>,
importfetch?: string,
/** 完成导入 */
onClose?: (e) => void,
/** 成功导入后返回数据 */
......@@ -79,7 +79,7 @@ const UploadImport: React.FC<UploadImportProps> = (props: any) => {
fileList.forEach(file => {
formData.append('file', file);
});
uploadFileExcel(formData).then(res => {
uploadFileExcel( importfetch ,formData).then(res => {
if (res.code !== 1000) {
setStep(4)
return
......@@ -103,7 +103,14 @@ const UploadImport: React.FC<UploadImportProps> = (props: any) => {
</>
const continueImport = () => {
setStep(0)
setExceptionCheck(false)
}
const handleClose = () => {
continueImport()
onClose()
}
return (
<Modal
title={title}
......@@ -111,6 +118,7 @@ const UploadImport: React.FC<UploadImportProps> = (props: any) => {
footer={null}
bodyStyle={{ padding: 0, position: 'relative' }}
visible={visible}
onCancel={onClose}
>
{step === 0 && (
<>
......@@ -173,7 +181,7 @@ const UploadImport: React.FC<UploadImportProps> = (props: any) => {
extra={
<>
<Button type='primary' onClick={continueImport}>继续导入</Button>
<Button onClick={onClose}>导入完成</Button>
<Button onClick={handleClose}>导入完成</Button>
</>
}
/>
......
......@@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';
import { Modal, Result, Progress, Upload, Button } from 'antd';
import { FileExcelOutlined } from '@ant-design/icons';
import styles from './index.less';
import { UPLOAD_TYPE } from '@/constants'
import { PublicApi } from '@/services/api';
interface Uploader {
......@@ -20,7 +19,7 @@ const UploadModal: React.FC<Uploader> = props => {
const [file, setFile] = useState();
const [fileList, setFileList] = useState([]);
const downLoadTemplate = () => { };
const downLoadTemplate = () => {};
const step0Description = (
<>
......@@ -149,19 +148,14 @@ const UploadModal: React.FC<Uploader> = props => {
const beforeUpload = file => {
let extension = file.name.split('.')[1];
if (!['xlsx', 'xls'].includes(extension)) {
if (['xlsx', 'xls'].includes[extension]) {
setTimeout(() => {
setExceptionCheck(true);
}, 250);
}
const flag = ['xlsx', 'xls'].includes(extension)
return flag;
return false;
};
const handleChange = ({file}) => {
console.log(file)
}
// 上传
const handleUpload = (type: string, file?: any, step: number = 0) => {
let title = '';
......@@ -184,7 +178,7 @@ const UploadModal: React.FC<Uploader> = props => {
if (step === 1) return false;
};
const exportErrorLog = () => { };
const exportErrorLog = () => {};
const handleClose = () => {
setModalStep(0);
......@@ -210,19 +204,20 @@ const UploadModal: React.FC<Uploader> = props => {
icon={<FileExcelOutlined />}
title={step0Description}
extra={
<Upload
action="/api/purchase/purchase/inquiry/import/excel/check"
showUploadList={false}
beforeUpload={beforeUpload}
onChange={handleChange}
>
<Button type="primary">导入</Button>
</Upload>
// <>
// <Button type="primary" onClick={() => handleUpload('upload')}>
// 导入
// </Button>
// </>
// <Upload
// name="file"
// action=""
// fileList={fileList}
// beforeUpload={file => beforeUpload(file)}
// customRequest={file => console.log(file)}
// >
// <Button type="primary">导入</Button>
// </Upload>
<>
<Button type="primary" onClick={() => handleUpload('upload')}>
导入
</Button>
</>
}
/>
</>
......
......@@ -122,6 +122,8 @@ const Material: React.FC<Iprops> = (props: any) => {
key: 'category',
dataIndex: 'category',
render: (text: any, record: any, index: number) => (
<>
{ materielMode === 1 && (
<Form.Item
style={{ margin: 0 }}
name={`category_${index + 1}`}
......@@ -137,7 +139,18 @@ const Material: React.FC<Iprops> = (props: any) => {
notFoundContent={<Spin size="small" />}
/>
</Form.Item>
)}
{ materielMode === 2 && (
<Form.Item
style={{ margin: 0 }}
name={`category_${index + 1}`}
initialValue={text}
rules={[{ required: true, message: '请输入' }]}
>
<Input onChange={(e) => handleEdit(e, 'category', index)} />
</Form.Item>
)}
</>
),
},
{
......@@ -304,6 +317,7 @@ const Material: React.FC<Iprops> = (props: any) => {
visible={flag}
title='导入'
checkfetch='/api/purchase/purchase/inquiry/import/excel/check'
importfetch='/api/purchase/purchase/inquiry/import/excel'
fetchData={fetchData}
onClose={() => setFlag(false)}
/>
......
......@@ -19,9 +19,8 @@ export async function uploadFile(params) {
})
}
export async function uploadFileExcel(params) {
return umiRequest('/purchase/inquiry/import/excel', {
prefix: '/api/purchase',
export async function uploadFileExcel(url, params) {
return umiRequest(url, {
method: 'post',
data: params,
requestType: 'form'
......
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