amis icon indicating copy to clipboard operation
amis copied to clipboard

如何将curd表单选中的一行数据传递给父form表单进行处理

Open iceycc opened this issue 5 years ago • 4 comments

实现场景:

表单中的一项,需要从一个table表格中选中一行获取数据。如何将table选中的一行数据传递给改表单再提交。

存在的问题:

无法将curd表单中选中的一项数据传给父form表单进行提交

当前方案:

// code here...
{
  "type": "form",
  "label": "上传视频",
  "name": "storage_id",
  "required": false,
  "form": {
    "title": "表单",
    "name": "understandingChooseVideo",
    "size": "lg",
    "closeOnEsc": false,
    "showCloseButton": true,
    "data": {
      "&": "$$"
    },
    "controls": [
      {
        "type": "text",
        "label": "文本框",
        "name": "file_name",
        "required": true,
        "size": "md"
      },
      {
        "type": "submit",
        "label": "提交",
        "level": "primary",
        "mode": "inline",
        "actionType": "ajax",
        "api": {
          "method": "get",
          "url": "/resource/storage/list" // 搜索获取视频列表
        }
      },
      {
        "type": "container",
        "label": "",
        "controls": [
          {
            "type": "crud",
            "api": "",
            "columns": [
              {
                "name": "id",
                "label": "ID",
                "type": "text"
              },
              {
                "name": "file_url_mp4",
                "label": "视频",
                "type": "video",
                "autoPlay": false,
                "src": "https://media.w3.org/2010/05/sintel/trailer_hd.mp4",
                "poster": "https://video-react.js.org/assets/poster.png",
                "width": 200
              },
              {
                "name": "file_name",
                "label": "视频名称",
                "type": "text"
              },
              {
                "type": "plain",
                "tpl": "内容",
                "inline": false,
                "label": "时长",
                "name": "file_duration"
              },
              {
                "type": "plain",
                "tpl": "内容",
                "inline": false,
                "label": "大小",
                "name": "file_size"
              }
            ],
            "messages": {},
            "itemActions": [
              {
                "label": "保存",
                "type": "submit",
                "actionType": "submit",
                "api": "update",
                "hiddenOnHover": false,
                "size": "md",
                "level": "primary",
                "close": true,
                "target": "understandingChooseVideo", // 期望:选中某一项点击保存时将该行数据传递给父表单
                "reload": ""
              }
            ],
            "hideQuickSaveBtn": false,
            "syncResponse2Query": true,
            "autoJumpToTopOnPagerChange": false
          }
        ]
      }
    ],
    "autoFocus": true,
    "mode": "normal",
    "initApi": "",
    "closeDialogOnSubmit": false,
    "disabledOn": "",
    "target": ""
  },
  "labelField": "storage_id",
  "btnLabel": "选择视频"
}

iceycc avatar Dec 25 '20 03:12 iceycc

编辑表格中一列的值一般用这个,https://baidu.gitee.io/amis/docs/components/crud?page=1#%E5%BC%B9%E6%A1%86%E4%B8%8E%E6%95%B0%E6%8D%AE%E9%93%BE

RickCole21 avatar Dec 25 '20 03:12 RickCole21

编辑表格中一列的值一般用这个,https://baidu.gitee.io/amis/docs/components/crud?page=1#%E5%BC%B9%E6%A1%86%E4%B8%8E%E6%95%B0%E6%8D%AE%E9%93%BE

现在是想将表格中选中的数据和表单结合

iceycc avatar Dec 25 '20 03:12 iceycc

哦那试一下picker,https://baidu.gitee.io/amis/docs/components/form/picker

RickCole21 avatar Dec 25 '20 07:12 RickCole21

哦那试一下picker,https://baidu.gitee.io/amis/docs/components/form/picker

可以了,谢谢,大佬

iceycc avatar Dec 25 '20 08:12 iceycc