Commit 4d5cbcb2 authored by XieZhiXiong's avatar XieZhiXiong

Merge branch 'dev-srm' of http://10.0.0.22:3000/lingxi/lingxi-business-paltform into dev-srm

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