[go: up one dir, main page]

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

当列表接口某个字段field返回数组的数据时,使用下拉select展示数据,点击并进行相应的数据;当返回无数据时,使用button按钮进行展示,效果如下图 #89

Open
EdwardQ opened this issue Dec 24, 2019 · 1 comment

Comments

@EdwardQ
Copy link
EdwardQ commented Dec 24, 2019

image

@EdwardQ
Copy link
Author
EdwardQ commented Dec 26, 2019

自定义一个select当field,通过changeConfig去控制field当类型,用on去捕获button按钮当事件,用select的change事件监听select的选择改变

{
    resource: {
        fields: {
            select: {
                ctx: 'edit',
                type: 'select',
                label: '选择',
                style: {
                    // 设置field的宽度
                    width: '95px',
                },
                props: {
                    // 设置列的宽度
                    width: 105,
                    multiple: false,
                    size: 'mini',
                    options: []
                },
                changeConfig: function(field, data) {
                    // 用于select展示
                    data.select = '内容配置'
                    if (data.id < 3) {
                        field.props.options = [
                            {
                                value: 'a',
                                label: 'test1'
                            }
                        ]
                    } else {
                        field.type = 'button'
                        field.label = '内容配置'
                    }=
                    return field
                },
                on: {
                    change(...arg) {
                        console.log('arg', arg)
                    }
                },
                event: 'goButton'
            }
        }
    },
    actions: {
        goButton({ $prevReturn }) {
            console.log($prevReturn)
        }
    }
}

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