update 完成表单中上传控件的使用

This commit is contained in:
2021-06-22 11:00:21 +08:00
parent f31f79d59d
commit f05f476789
17 changed files with 883 additions and 106 deletions

View File

@@ -16,6 +16,7 @@ export default class index extends Component {
actived: '0',
loading: true,
record: null,
saveDisabled: true,
saving: false,
}
@@ -42,6 +43,16 @@ export default class index extends Component {
*/
componentDidMount() {}
/**
* 接收到所有子组件已加载完成,并启用提交按钮
*/
call(child, index) {
this.children[index] = child
if (this.children.filter(p => p).length === tabs.filter(p => p.show).length) {
this.setState({ saveDisabled: false })
}
}
async onSubmit() {
for (const child of this.children) {
try {
@@ -62,7 +73,7 @@ export default class index extends Component {
}
render() {
const { actived, loading, record, saving } = this.state
const { actived, loading, record, saveDisabled, saving } = this.state
return (
<div className="yo-form-page">
@@ -77,6 +88,7 @@ export default class index extends Component {
取消
</Button>
<Button
disabled={saveDisabled}
loading={saving}
type="primary"
onClick={() => this.onSubmit()}
@@ -125,7 +137,7 @@ export default class index extends Component {
is={tab.component}
record={record}
loading={loading}
onRef={c => this.children.push(c)}
onRef={child => this.call(child, i)}
/>
</div>
)