amis/docs/zh-CN/components/form/tabs-transfer.md
2022-03-28 10:57:15 +08:00

8.1 KiB
Raw Blame History

title description type group menuName icon
TabsTransfer 组合穿梭器 0 null TabsTransfer 组合穿梭器

穿梭器Transfer的基础上扩充了左边的展示形式,支持 Tabs 的形式展示。对应的 options 的顶级数据,顶层 options 的成员支持 selectMode 配置这个 tab 下面的选项怎么展示。title 可以配置 tab 的标题。

{
  "type": "form",
  "api": "/api/mock2/form/saveForm",
  "body": [
    {
    "label": "组合穿梭器",
    "type": "tabs-transfer",
    "name": "a",
    "sortable": true,
    "selectMode": "tree",
    "options": [
      {
        "label": "成员",
        "selectMode": "tree",
        "searchable": true,
        "children": [
          {
            "label": "法师",
            "children": [
              {
                "label": "诸葛亮",
                "value": "zhugeliang"
              }
            ]
          },
          {
            "label": "战士",
            "children": [
              {
                "label": "曹操",
                "value": "caocao"
              },
              {
                "label": "钟无艳",
                "value": "zhongwuyan"
              }
            ]
          },
          {
            "label": "打野",
            "children": [
              {
                "label": "李白",
                "value": "libai"
              },
              {
                "label": "韩信",
                "value": "hanxin"
              },
              {
                "label": "云中君",
                "value": "yunzhongjun"
              }
            ]
          }
        ]
      },
      {
        "label": "用户",
        "selectMode": "chained",
        "children": [
          {
            "label": "法师",
            "children": [
              {
                "label": "诸葛亮",
                "value": "zhugeliang2"
              }
            ]
          },
          {
            "label": "战士",
            "children": [
              {
                "label": "曹操",
                "value": "caocao2"
              },
              {
                "label": "钟无艳",
                "value": "zhongwuyan2"
              }
            ]
          },
          {
            "label": "打野",
            "children": [
              {
                "label": "李白",
                "value": "libai2"
              },
              {
                "label": "韩信",
                "value": "hanxin2"
              },
              {
                "label": "云中君",
                "value": "yunzhongjun2"
              }
            ]
          }
        ]
      }
    ]
  }
  ]
}

自定义选项展示

{
  "type": "form",
  "api": "/api/mock2/form/saveForm",
  "body": [
    {
      "label": "组合穿梭器",
      "type": "tabs-transfer",
      "name": "a",
      "sortable": true,
      "selectMode": "tree",
      "menuTpl": "<div class='flex justify-between'><span>${label}</span><span class='text-muted m-r text-sm'>${tag}</span></div>",
      "valueTpl": "${label}(${value})",
      "options": [
        {
          "label": "成员",
          "selectMode": "list",
          "searchable": true,
          "children": [
            {
              "label": "诸葛亮",
              "value": "zhugeliang",
              "tag": "法师",
            },
            {
              "label": "曹操",
              "value": "caocao",
              "tag": "战士",
            },
            {
              "label": "钟无艳",
              "value": "zhongwuyan",
              "tag": "战士",
            },
            {
              "label": "李白",
              "value": "libai",
              "tag": "打野"
            },
            {
              "label": "韩信",
              "value": "hanxin",
              "tag": "打野"
            },
            {
              "label": "云中君",
              "value": "yunzhongjun",
              "tag": "打野"
            }
          ]
        },
        {
          "label": "用户",
          "selectMode": "list",
          "children": [
            {
              "label": "诸葛亮",
              "value": "zhugeliang",
              "tag": "法师",
            },
            {
              "label": "曹操",
              "value": "caocao",
              "tag": "战士",
            },
            {
              "label": "钟无艳",
              "value": "zhongwuyan",
              "tag": "战士",
            },
            {
              "label": "李白",
              "value": "libai",
              "tag": "打野"
            },
            {
              "label": "韩信",
              "value": "hanxin",
              "tag": "打野"
            },
            {
              "label": "云中君",
              "value": "yunzhongjun",
              "tag": "打野"
            }
          ]
        }
      ]
    }
  ]
}

数据懒加载

{
  "type": "form",
  "api": "/api/mock2/form/saveForm",
  "body": [
    {
    "label": "组合穿梭器",
    "type": "tabs-transfer",
    "name": "a",
    "sortable": true,
    "selectMode": "tree",
    "options": [
      {
        "label": "成员",
        "selectMode": "associated",
        "searchable": true,
        "leftMode": "tree",
        "children": [
          {
            ref: "user",
            "children": [
              {
                "label": "诸葛亮",
                "value": "zhugeliang2"
              },
              {
                "label": "上官婉儿",
                "value": "shangguan"
              }
            ]
          },
          {
            "ref": "a",
            "children": [
              {
                "label": "A-1",
                "value": "a1"
              },
              {
                "label": "A-2",
                "value": "a2"
              }
            ]
          },
          {
            "ref": "b",
            "children": [
              {
                "label": "B-1",
                "value": "b1"
              }
            ]
          },
          {
            "ref": "c",
            "children": [
              {
                "label": "C-1",
                "value": "c1"
              }
            ]
          },
          {
            "ref": "d",
            "children": [
              {
                "label": "D-1",
                "value": "d1"
              }
            ]
          },
          {
            "ref": "e",
            "children": [
              {
                "label": "E-1",
                "value": "e1"
              },
              {
                "label": "E-2",
                "value": "e2"
              }
            ]
          }
        ],
        "leftOptions": [
          {
            "defer": true,
            "deferApi": "/api/mock2/form/getOptions",
            "label": "DEFER"
          },
          {
            "label": "法师",
            "value": "user"
          }
        ]
      },
      {
        "label": "用户",
        "selectMode": "chained",
        "children": [
          {
            "label": "法师",
            "children": [
              {
                "label": "诸葛亮",
                "value": "zhugeliang2"
              }
            ]
          },
          {
            "label": "战士",
            "children": [
              {
                "label": "曹操",
                "value": "caocao2"
              },
              {
                "label": "钟无艳",
                "value": "zhongwuyan2"
              }
            ]
          },
          {
            "label": "打野",
            "children": [
              {
                "label": "李白",
                "value": "libai2"
              },
              {
                "label": "韩信",
                "value": "hanxin2"
              },
              {
                "label": "云中君",
                "value": "yunzhongjun2"
              }
            ]
          }
        ]
      }
    ]
  }
  ]
}

属性表

更多配置请参考穿梭器Transfer