|
| 1 | +import { ProForm } from '@uiw-admin/components' |
| 2 | +import { Slider } from 'uiw' |
| 3 | + |
| 4 | +const option = [ |
| 5 | + { value: 1, label: '苹果' }, |
| 6 | + { value: 2, label: '西瓜' }, |
| 7 | + { value: 3, label: '香蕉' }, |
| 8 | + { value: 4, label: '东北大冻梨' }, |
| 9 | + { value: 5, label: '香蕉' }, |
| 10 | + { value: 6, label: '葡萄' }, |
| 11 | + { value: 6, label: '哈密瓜' }, |
| 12 | +] |
| 13 | + |
| 14 | +const Page = () => { |
| 15 | + return ( |
| 16 | + <ProForm |
| 17 | + // 表单类型 |
| 18 | + formType="card" |
| 19 | + title="基本使用(与uiw/form使用保持一致)" |
| 20 | + // 自定义组件 |
| 21 | + customWidgetsList={{ |
| 22 | + slider: Slider, |
| 23 | + }} |
| 24 | + cardProps={{ |
| 25 | + noHover: true, |
| 26 | + }} |
| 27 | + // 是否展示uiw/form提交按钮 |
| 28 | + showSaveButton |
| 29 | + // 是否展示uiw/form重置按钮 |
| 30 | + showResetButton |
| 31 | + // 提交后验证 |
| 32 | + onSubmit={(initial, current) => { |
| 33 | + console.log(111, initial, current) |
| 34 | + }} |
| 35 | + formDatas={[ |
| 36 | + { |
| 37 | + label: 'input', |
| 38 | + key: 'input', |
| 39 | + widget: 'input', |
| 40 | + initialValue: '', |
| 41 | + widgetProps: {}, |
| 42 | + help: 'input不能为空', |
| 43 | + rules: [{ required: true, message: 'input不能为空' }], |
| 44 | + }, |
| 45 | + { |
| 46 | + label: 'textarea', |
| 47 | + key: 'textarea', |
| 48 | + widget: 'textarea', |
| 49 | + span: '24', |
| 50 | + colstyle: { maxWidth: 800 }, |
| 51 | + }, |
| 52 | + { |
| 53 | + label: 'select', |
| 54 | + key: 'select', |
| 55 | + widget: 'select', |
| 56 | + option: [ |
| 57 | + { value: 1, label: '苹果' }, |
| 58 | + { value: 2, label: '西瓜' }, |
| 59 | + { value: 3, label: '香蕉' }, |
| 60 | + { value: 4, label: '东北大冻梨' }, |
| 61 | + ], |
| 62 | + }, |
| 63 | + { |
| 64 | + label: 'switch', |
| 65 | + key: 'switch', |
| 66 | + widget: 'switch', |
| 67 | + }, |
| 68 | + { |
| 69 | + label: 'radio', |
| 70 | + widget: 'radio', |
| 71 | + key: 'radio', |
| 72 | + option: [ |
| 73 | + { label: '男', value: 'man' }, |
| 74 | + { label: '女', value: 'girl' }, |
| 75 | + ], |
| 76 | + }, |
| 77 | + { |
| 78 | + label: '多选框', |
| 79 | + widget: 'checkbox', |
| 80 | + key: 'checkbox', |
| 81 | + option: [ |
| 82 | + { label: '四川菜', value: 'sichuan' }, |
| 83 | + { label: '湖北菜', value: 'hubei' }, |
| 84 | + ], |
| 85 | + }, |
| 86 | + { |
| 87 | + label: '年月日时分秒', |
| 88 | + key: 'dateInputsecond', |
| 89 | + widget: 'dateInput', |
| 90 | + widgetProps: { |
| 91 | + format: 'YYYY-MM-DD HH:mm:ss', |
| 92 | + }, |
| 93 | + }, |
| 94 | + { |
| 95 | + label: '年月日', |
| 96 | + key: 'dateInput', |
| 97 | + widget: 'dateInput', |
| 98 | + widgetProps: { |
| 99 | + format: 'YYYY-MM-DD', |
| 100 | + }, |
| 101 | + }, |
| 102 | + { |
| 103 | + label: '年月', |
| 104 | + key: 'monthPicker', |
| 105 | + widget: 'monthPicker', |
| 106 | + widgetProps: { |
| 107 | + format: 'YYYY-MM', |
| 108 | + }, |
| 109 | + }, |
| 110 | + { |
| 111 | + label: '时分秒', |
| 112 | + key: 'timePicker', |
| 113 | + widget: 'timePicker', |
| 114 | + }, |
| 115 | + { |
| 116 | + label: 'searchSelect', |
| 117 | + key: 'searchSelect', |
| 118 | + widget: 'searchSelect', |
| 119 | + option: option, |
| 120 | + widgetProps: { |
| 121 | + mode: 'multiple', |
| 122 | + allowClear: true, |
| 123 | + showSearch: true, |
| 124 | + style: { width: '100%' }, |
| 125 | + }, |
| 126 | + }, |
| 127 | + { |
| 128 | + label: '评分', |
| 129 | + key: 'rate', |
| 130 | + widget: 'rate', |
| 131 | + span: '8', |
| 132 | + }, |
| 133 | + // 只读模式下支持读取React.ReactNode |
| 134 | + { |
| 135 | + label: '自定义组件', |
| 136 | + key: 'slider', |
| 137 | + widget: 'slider', |
| 138 | + readSpan: 2, |
| 139 | + span: '16', |
| 140 | + }, |
| 141 | + { |
| 142 | + label: '上传组件', |
| 143 | + key: 'upload', |
| 144 | + widget: 'upload', |
| 145 | + span: '24', |
| 146 | + readSpan: 3, |
| 147 | + widgetProps: { |
| 148 | + uploadType: 'card', |
| 149 | + multiple: true, |
| 150 | + maxNumber: 2, |
| 151 | + showFileIcon: { |
| 152 | + showPreviewIcon: true, |
| 153 | + showRemoveIcon: true, |
| 154 | + }, |
| 155 | + }, |
| 156 | + }, |
| 157 | + ]} |
| 158 | + /> |
| 159 | + ) |
| 160 | +} |
| 161 | + |
| 162 | +export default Page |
0 commit comments