Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增强字段间联动能力 #79

Open
w3cmark opened this issue Dec 22, 2019 · 0 comments
Open

增强字段间联动能力 #79

w3cmark opened this issue Dec 22, 2019 · 0 comments
Milestone

Comments

@w3cmark
Copy link
Contributor

w3cmark commented Dec 22, 2019

场景:有A、B两个下拉选择的字段,如果B字段是依赖A字段的选择结果而变化

目前配置:

const config = {
    type: 'form',
    resource: {
        fields: {
            platform: {
                type: 'select',
                label: '应用平台',
                props: {
                    options: {
                        android: 'android',
                        iphone: 'iphone'
                    }
                }
            },
            version: {
                type: 'select',
                label: '集成版本',
                rules: [{
                    required: true
                }],
                props: {
                    multiple: false,
                    filterable: true,
                    options: []
                }
            },
        }
    },
    actions: {
        fieldChange: async function({
            name,
            value
        }) {
            if (name === 'platform') {
                this.fields.version = '';
                // ams.getVersion是一个获取下拉选项
                this.fields.version.props.options = await ams.getVersion.call(this, value);
            }
        }
    }
}

目前需要自己利用fieldChange来监听A字段的修改,然后再手动写B字段的请求,比较麻烦

@w3cmark w3cmark added this to the v1.0 milestone Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant