Commit bd2b9fc0 by zhaochengxiang

盘点

parent 955d14d6
...@@ -74,6 +74,6 @@ ...@@ -74,6 +74,6 @@
"last 1 safari version" "last 1 safari version"
] ]
}, },
"proxy": "http://139.198.127.28:17279", "proxy": "http://192.168.0.38:8089",
"homepage": "http://myhost/data-govern" "homepage": "http://myhost/data-govern"
} }
...@@ -225,5 +225,5 @@ export function auditTask(payload) { ...@@ -225,5 +225,5 @@ export function auditTask(payload) {
} }
export function uploadDataAssetExcel(payload) { export function uploadDataAssetExcel(payload) {
return PostFile("/dataassetmanager/dataAssetCheckApi/uploadDataAssetExcel", payload); return PostFile("/dataassetmanager/dataAssetCheckApi/uploadDataAssetExcel", payload, 'reportFile');
} }
\ No newline at end of file
...@@ -163,16 +163,16 @@ export function Post(url, payload) { ...@@ -163,16 +163,16 @@ export function Post(url, payload) {
) )
} }
export function PostFile(url, payload) { export function PostFile(url, payload, fileName='file') {
const { fileList = null, params = null } = payload||{}; const { fileList = null, params = null } = payload||{};
const env = LocalStorage.get('assetsEnv')??debugEnv; const env = LocalStorage.get('assetsEnv')??debugEnv;
let formData = new FormData(); let formData = new FormData();
(fileList||[]).forEach(file=> { (fileList||[]).forEach(file=> {
formData.append('file', file); formData.append(fileName, file);
}); });
return fileplain.post(url, formData, { params: {...params, env} } ).then( return fileplain.post(url, formData, { params: {...params, env} } ).then(
callback callback
) )
} }
\ No newline at end of file
...@@ -22,7 +22,7 @@ const FC = (props) => { ...@@ -22,7 +22,7 @@ const FC = (props) => {
}, },
}; };
const handleOk = async (status = '-1') => { const handleOk = async (status = '1') => {
try { try {
const values = await form.validateFields(); const values = await form.validateFields();
...@@ -74,7 +74,9 @@ const FC = (props) => { ...@@ -74,7 +74,9 @@ const FC = (props) => {
<Space> <Space>
<Button onClick={() => onCancel && onCancel() }>取消</Button> <Button onClick={() => onCancel && onCancel() }>取消</Button>
<Button type="primary" onClick={() => {handleOk()}} loading={confirmLoading}>确定</Button> <Button type="primary" onClick={() => {handleOk()}} loading={confirmLoading}>确定</Button>
<Button type="danger" onClick={() => {handleOk('-1')}} loading={confirmLoading}>驳回</Button> {
(action==='审核') && <Button type="danger" onClick={() => {handleOk('-1')}} loading={confirmLoading}>驳回</Button>
}
</Space> </Space>
} }
> >
......
import React, { useEffect, useState, useContext } from 'react';
import { Modal, Form, Input, Select, Space, Button, Upload } from 'antd';
import { UploadOutlined, DownloadOutlined } from '@ant-design/icons';
import LocalStorage from 'local-storage';
import { AppContext } from '../../../App';
import { dispatch } from '../../../model';
import { showMessage } from '../../../util';
const FC = (props) => {
const { visible, onCancel, task } = props;
const [form] = Form.useForm();
const [confirmLoading, setConfirmLoading] = useState(false);
const [ fileList, setFileList ] = useState([]);
const { user } = useContext(AppContext);
const downloadTemplate = () => {
const env = LocalStorage.get('assetsEnv');
window.open(`/api/dataassetmanager/dataAssetCheckApi/getDataAssetTemplate?env=${env}`);
}
const uploadProps = {
onRemove: file => {
const index = fileList.indexOf(file);
const newFileList = fileList.slice();
newFileList.splice(index, 1);
setFileList(newFileList);
},
beforeUpload: file => {
const isLt2OM = file.size / 1024 / 1024 < 20;
if (!isLt2OM) {
showMessage('error', '上传文件必须小于20M');
setFileList([]);
return false;
}
setFileList([file]);
return false;
},
fileList: fileList || [],
accept:".xlsx",
};
const handleOk = async (status = '-1') => {
if ((fileList||[]).length === 0) {
showMessage('info', '请先上传盘点文件');
return;
}
setConfirmLoading(true);
dispatch({
type: 'assetmanage.uploadDataAssetExcel',
payload: { fileList: fileList },
callback: fileId => {
setConfirmLoading(false);
dispatch({
type: 'assetmanage.saveTask',
payload: {
data: {
...task,
dataAssetExcel: {
fileId
}
}
},
callback: data => {
setConfirmLoading(false);
reset();
onCancel?.(true);
},
error: () => {
setConfirmLoading(false);
}
});
},
error: () => {
setConfirmLoading(false);
}
});
}
const reset = () => {
setConfirmLoading(false);
setFileList([]);
}
return (
<Modal
visible={visible}
title={`盘点${task?.title}`}
width={650}
confirmLoading={confirmLoading}
onCancel={() => {
reset();
onCancel && onCancel();
}}
footer={
<Space>
<Button onClick={() => onCancel && onCancel() }>取消</Button>
<Button type="primary" onClick={() => {handleOk()}} loading={confirmLoading}>确定</Button>
</Space>
}
>
<Form layout='inline'>
<Form.Item label='盘点文件上传:'>
<Button className='mr-2' icon={<DownloadOutlined />} onClick={ downloadTemplate }>
模版下载
</Button>
<Upload style={{ display: 'inline' }} {...uploadProps }>
<Button icon={
<UploadOutlined />}>
选择文件上传
</Button>
</Upload>
</Form.Item>
</Form>
</Modal>
);
}
export default FC;
\ No newline at end of file
...@@ -3,6 +3,7 @@ import { Button, Table, Space } from 'antd'; ...@@ -3,6 +3,7 @@ import { Button, Table, Space } from 'antd';
import UpdateTask from './UpdateTask'; import UpdateTask from './UpdateTask';
import AuditTask from './AuditTask'; import AuditTask from './AuditTask';
import CheckTask from './CheckTask';
import { dispatch } from '../../../model'; import { dispatch } from '../../../model';
export const status = { export const status = {
...@@ -33,7 +34,11 @@ const FC = (props) => { ...@@ -33,7 +34,11 @@ const FC = (props) => {
visible: false, visible: false,
task: undefined, task: undefined,
action: undefined, action: undefined,
}) });
const [checkTaskParams, setCheckTaskParams] = useState({
visible: false,
task: undefined,
});
const onActionClick = (task, action) => { const onActionClick = (task, action) => {
if (action === '详情') { if (action === '详情') {
...@@ -41,7 +46,7 @@ const FC = (props) => { ...@@ -41,7 +46,7 @@ const FC = (props) => {
} else if (action === '修改') { } else if (action === '修改') {
} else if (action === '盘点') { } else if (action === '盘点') {
setCheckTaskParams({...checkTaskParams, task, visible: true});
} else { } else {
setAuditTaskParams({...auditTaskParams, action, task, visible: true}); setAuditTaskParams({...auditTaskParams, action, task, visible: true});
} }
...@@ -143,6 +148,11 @@ const FC = (props) => { ...@@ -143,6 +148,11 @@ const FC = (props) => {
refresh && getTasks(); refresh && getTasks();
} }
const onCheckTaskCancel = (refresh = false) => {
setCheckTaskParams({...checkTaskParams, visible: false});
refresh && getTasks();
}
return ( return (
<div> <div>
<div> <div>
...@@ -168,6 +178,12 @@ const FC = (props) => { ...@@ -168,6 +178,12 @@ const FC = (props) => {
action={auditTaskParams.action} action={auditTaskParams.action}
onCancel={onAuditTaskCancel} onCancel={onAuditTaskCancel}
/> />
<CheckTask
visible={checkTaskParams.visible}
task={checkTaskParams.task}
onCancel={onCheckTaskCancel}
/>
</div> </div>
) )
} }
......
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