index-1-x.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import React from 'react'
  2. import SchemaForm, { FormButtonGroup, Submit, Reset } from '@uform/next'
  3. import Index from '../index'
  4. import {
  5. Button,
  6. Collapse,
  7. Message,
  8. Upload,
  9. Input,
  10. Select,
  11. DatePicker,
  12. Icon,
  13. Checkbox,
  14. NumberPicker,
  15. TimePicker,
  16. Radio,
  17. Form,
  18. Tab
  19. } from '@alifd/next'
  20. // style
  21. import '@alifd/next/dist/next.css'
  22. SchemaForm.FormButtonGroup = FormButtonGroup
  23. SchemaForm.Submit = Submit
  24. SchemaForm.Reset = Reset
  25. const renderSchema = {}
  26. const props = {
  27. UI: {
  28. version: '1.x',
  29. Button,
  30. Accordion: Collapse,
  31. Toast: Message,
  32. Upload,
  33. Input,
  34. Select,
  35. Icon,
  36. DatePicker,
  37. TimePicker,
  38. Checkbox,
  39. NumberPicker,
  40. Radio,
  41. RadioGroup: Radio.Group,
  42. TabPane: Tab.Item,
  43. Form,
  44. Tab
  45. },
  46. // 主题: dark/light,默认dark
  47. // themeStyle: 'light',
  48. // 是否展示布局组件,默认为false
  49. showLayoutField: false,
  50. showPreviewBtn: true,
  51. showSourceCodeBtn: true,
  52. // 控制返回按钮点击事件
  53. onBackBtnClick: () => {
  54. alert('点击了返回')
  55. },
  56. // 额外全局按钮
  57. globalButtonList: [
  58. // {
  59. // key: 'submit',
  60. // title: '自定义保存',
  61. // render: (props) => {
  62. // return <Badge dot>{props.children}</Badge>
  63. // },
  64. // props: {
  65. // // loading: true,
  66. // },
  67. // }, {
  68. // key: 'cancel',
  69. // title: '取消',
  70. // props: {
  71. // onClick: () => {
  72. // alert('点击取消');
  73. // }
  74. // },
  75. // }
  76. ],
  77. // 是否展示全局配置
  78. showGlobalCfg: true,
  79. // 全局配置额外项
  80. extraGlobalCfgList: [
  81. {
  82. name: 'labelCol',
  83. title: 'label宽度占比',
  84. type: 'string'
  85. },
  86. {
  87. name: 'wrapperCol',
  88. title: 'wrapper宽度占比',
  89. type: 'string'
  90. },
  91. {
  92. name: 'editable',
  93. title: '表单是否可编辑',
  94. description:
  95. '若设置为false,则可快速搭建出表单详情页,只需设置每个组件的默认值',
  96. type: 'boolean'
  97. }
  98. ],
  99. globalCfg: {},
  100. supportFieldList: [],
  101. includeFieldListKeyList: [
  102. 'input',
  103. 'multipleInput',
  104. 'number',
  105. 'radio',
  106. 'checkbox',
  107. 'date',
  108. 'month',
  109. 'daterange',
  110. 'time'
  111. ],
  112. // 渲染引擎
  113. renderEngine: SchemaForm,
  114. schema: renderSchema,
  115. // onChange: (data) => {
  116. // console.info('index onChange data', data);
  117. // },
  118. onSubmit: data => {
  119. alert(`保存数据:${JSON.stringify(data)}`)
  120. console.info('index onSubmit data', data)
  121. }
  122. }
  123. class Comp extends React.Component {
  124. constructor(props) {
  125. super(props)
  126. this.state = {
  127. schema: renderSchema
  128. }
  129. }
  130. render() {
  131. return (
  132. <div style={{ marginTop: -20 }}>
  133. <Index {...props} schema={this.state.schema} />
  134. </div>
  135. )
  136. }
  137. }
  138. export default Comp