editModel.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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: 'file',
  7. headers: {
  8. credentials: 'include'
  9. },
  10. beforeUpload: file => {
  11. if (!file.name.endsWith('.pmml') && !file.name.endsWith('.model')) {
  12. message.warning('请上传pmml或model格式的文件')
  13. return false
  14. }
  15. if (file == null) {
  16. message.warn('请选择模型文件')
  17. return false
  18. }
  19. this.props.onChange('file', file)
  20. return false
  21. }
  22. };
  23. render () {
  24. const { showModal, params, onChange, onOk, onCancel, fetching } = this.props
  25. const formSetting = [{
  26. label: '模型名称',
  27. type: 'input',
  28. key: 'name'
  29. },
  30. {
  31. label: '模型描述',
  32. type: 'textarea',
  33. key: 'description'
  34. },
  35. {
  36. label: '模型版本',
  37. type: 'input',
  38. key: 'version'
  39. }, {
  40. label: '',
  41. key: 'file',
  42. render: () => {
  43. return (
  44. <div style={{ marginLeft: '120px' }}>
  45. <Upload {...this.uploadProps}>
  46. <Button type="primary">上传模型文件</Button>
  47. </Upload>
  48. <p>文件类型:.pmml or .model</p>
  49. </div>
  50. )
  51. }
  52. }]
  53. return (
  54. <Modal
  55. title={'模型上传'}
  56. visible={showModal}
  57. onOk={onOk}
  58. onCancel={onCancel}
  59. okButtonProps={{ disabled: fetching }}
  60. destroyOnClose
  61. >
  62. <FormItem formSetting={formSetting} params={params} onChange={onChange} />
  63. </Modal>
  64. )
  65. }
  66. }