提交 e03d4b19 authored 作者: 钟是志's avatar 钟是志

增加批量上传压缩包的功能

上级 0f8bd140
......@@ -55,6 +55,8 @@ export function FormListButtons(props) {
return null;
}
console.log(ConcatButtons);
return ConcatButtons.map((r, i) => {
if (r.ButtonType === 'Normal') {
const propsR = { ...r };
......
//@ts-nocheck
import React, { Component } from 'react';
import { Upload, message, Button, Modal } from 'antd';
import { getToken } from '@/webPublic/one_stop_public/utils/token';
import { uaaRequest } from "@/webPublic/one_stop_public/utils/request";
import getOneStopUploadUrl from '@/webPublic/one_stop_public/Base16/getOneStopUploadUrl';
export default class UploadZipCom extends Component{
constructor(props) {
super(props);
this.config = props.config || {};
this.state = {
confirmLoading: false,
showModal: false,
};
}
changeUrl = (info) => {
if (info.file.status === 'done') {
message.success(`${info.file.name} 上传压缩包成功,正在保存数据,请稍后`);
this.setState({ file: info.file.response, confirmLoading: true });
uaaRequest('/DataObjApi/importZip', {
dataObjId: this.props.dataObjId,
isExchange: this.config.isExchange,
nameKey: this.config.nameKey,
valueKey: this.config.valueKey,
zipPath: info.file.response,
}).then(() => {
this.setState({ confirmLoading: false });
message.success(`数据保存成功`);
});
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 上传失败`);
}
};
changeShowModal = () => {
this.setState({
showModal: !this.state.showModal,
});
};
render() {
const { confirmLoading, showModal } = this.state;
const { modalMessageHtml, modalTitle = '上传zip压缩包文件' } = this.config;
const { file } = this.state;
const props = {
name: 'file',
multiple: false,
action: getOneStopUploadUrl(),
showUploadList: false,
onChange: this.changeUrl,
headers: {
Authorization: `bearer ${getToken()}`,
},
data: {
token: getToken(),
},
};
const btn = this.config.btn ? this.config.btn : { name: '导出' };
return (
<>
<Button type='default' onClick={this.changeShowModal}>
{btn.name}
</Button>
<Modal title={modalTitle}
footer={null}
onCancel={this.changeShowModal}
visible={showModal}
>
<div style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
}}>
<div style={{ margin: '10px 0' }}>
<div dangerouslySetInnerHTML={{ __html: modalMessageHtml }}></div>
</div>
<Upload {...props}>
<Button {...btn} type='danger' loading={confirmLoading}>
点击上传
</Button>
</Upload>
</div>
</Modal>
</>
);
}
}
......@@ -49,7 +49,7 @@ import {
getGroupListApi,
} from '../../Services/apiConfig';
import { FormListButtonDiy } from '@/webPublic/one_stop_public/libs/formList/FormListButtonDiy';
import UploadZipCom from './UploadZipCom.js';
const FormItem = Form.Item;
const Popconfirm = getPopconfirm();
const Modal = getModal();
......@@ -1304,6 +1304,14 @@ class FormList extends React.Component {
selectedRows={selectedRows}
obj={obj}
/>
{this.props.value && this.props.value.uploadZipConfig
? this.props.value.uploadZipConfig.map((r, i) => (
<UploadZipCom
dataObjId={this.state.objId}
config={r}
/>
))
: ''}
{rights && !rights.includes('add') ? (
''
) : (
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论