Edit.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React, { Component } from 'react'
  2. import { Modal, Upload, Button, message } from 'antd'
  3. import { FormItem } from 'wptpc-design'
  4. export default class Index extends Component {
  5. uploadProps = {
  6. name: 'csvFile',
  7. headers: {
  8. credentials: 'include'
  9. },
  10. beforeUpload: file => {
  11. if (!file.name.endsWith('.csv')) {
  12. message.warning('请上传 cxv 格式的文件')
  13. return false
  14. }
  15. if (file == null) {
  16. message.warn('请选择名单文件')
  17. return false
  18. }
  19. this.props.onChange('csvFile', file)
  20. return false
  21. }
  22. };
  23. render() {
  24. const { showModal, params, onChange, onOk, onCancel, batchRemark, fetching} = this.props;
  25. const formSetting = [ {
  26. label: '名单文件',
  27. key: 'file',
  28. render: () => {
  29. return (
  30. <div style={{ marginLeft: '120px' }}>
  31. <Upload {...this.uploadProps}>
  32. <Button type="primary">上传名单文件</Button>
  33. </Upload>
  34. <p>文件类型:.csv</p>
  35. <p>{batchRemark}</p>
  36. </div>
  37. )
  38. }
  39. },
  40. {
  41. label: '是否启用',
  42. type: 'select',
  43. key: 'valid',
  44. options: [
  45. { value: "0", label: '禁用' },
  46. { value: "1", label: '启用' },
  47. ],
  48. isRequired: true,
  49. placeholder: '请选择'
  50. }];
  51. return (
  52. <Modal
  53. title={`批量导入`}
  54. visible={showModal}
  55. onOk={onOk}
  56. onCancel={onCancel}
  57. okButtonProps={{ disabled: fetching }}
  58. destroyOnClose
  59. >
  60. <FormItem formSetting={formSetting} params={params} onChange={onChange} />
  61. </Modal>
  62. );
  63. }
  64. }