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

[请教] resource fields 显示了 API 的 部分字段, editItemDialog 希望编辑 API Item 的全部字段 #108

Closed
ly525 opened this issue Jan 13, 2020 · 2 comments

Comments

@ly525
Copy link
Contributor

ly525 commented Jan 13, 2020

问题1

请教个问题,和 list item 编辑有关,因为不知道如何描述标题,我就直接在微信群提问了,感谢

需求背景:
以在线demo 为例:https://vipshop.github.io/ams/example/#/cases-sence/add-item-action

表格现在是显示 全部的字段,而实际的需求是:
假如后端接口返回了 10个字段,其实显示在表格中,只是常见的 5个字段即可(配置在 resource 的 fields 字段中)

在【弹窗编辑】中希望可以编辑的 10个 fields ,这个需要怎么做呢?

image

问题2

image

editItemDialog 这个可以举一个例子吗?如何传入 Object 作为参数

@w3cmark
Copy link
Contributor

w3cmark commented Jan 13, 2020

问题1: 你在resource里定义了10个字段,然后把不想显示的5个字段的hidden设置为true,在想显示的block,再定义同名的field,设置hidden为false

问题2: confirm、editItemDialog这些都是action,如果是在events里传参只能传字符串,如果是需要传复杂的参数,可以通过callAction()来调用和传参

@ly525
Copy link
Contributor Author

ly525 commented Mar 4, 2020

问题1: 你在resource里定义了10个字段,然后把不想显示的5个字段的hidden设置为true,在想显示的block,再定义同名的field,设置hidden为false

问题2: confirm、editItemDialog这些都是action,如果是在events里传参只能传字符串,如果是需要传复杂的参数,可以通过callAction()来调用和传参

对问题2的回答做一些补充:

actions: {
    addItem: function({ item }) {
      this.callAction('addItemDialog')
    },
    'editItem': function() {
      // 唤起编辑 Dialog
      this.callAction('editItemDialog')
    },
}

@ly525 ly525 closed this as completed Mar 4, 2020
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

2 participants