baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.44k stars 2.53k forks source link

卡片列表增加鼠标移入和移出事件 #10921

Open liuling1314 opened 2 months ago

liuling1314 commented 2 months ago

是否关联于某个问题吗:

预期的解决方案:

当前卡片列表时间展示的事件太少,如鼠标移入和移出等,现在的事件只支持table,或者有没有其它方式可以实现 这两个事件

其他可接受方案:

请简单描述其他你可以接受的效果...

任何附加信息:

请添加任何可以补充说明上述问题的材料,例如图片或视频等...

lhtuling commented 2 months ago

测了下,换个思路轻松实现! bd6a06986318e31a413639991fdad953

7c3e7add582920539cb4b579652bb8e9

Amis低代码前端框架交流群【QQ 1群】:717791727 Amis低代码前端框架交流群【QQ 2群】:721182449

{
  "type": "page",
  "title": "增删改查示例",
  "body": [
    {
      "type": "crud",
      "id": "u:4796e27fe0ee",
      "api": "https://aisuda.bce.baidu.com/amis/api/sample",
      "mode": "cards",
      "defaultParams": {
        "perPage": 12
      },
      "filter": {
        "title": "条件搜索",
        "submitText": "",
        "body": [
          {
            "type": "input-text",
            "name": "keywords",
            "placeholder": "通过关键字搜索",
            "addOn": {
              "label": "搜索",
              "type": "submit",
              "id": "u:16f7564f6fe0"
            },
            "id": "u:dd3766c60e14"
          },
          {
            "type": "plain",
            "text": "这只是个示例, 目前搜索对查询结果无效.",
            "id": "u:cb1ac07182d2"
          }
        ],
        "id": "u:1c278f059bf1",
        "actions": [
          {
            "type": "submit",
            "label": "提交",
            "primary": true,
            "id": "u:5b1672eba77f"
          }
        ],
        "feat": "Insert",
        "labelAlign": "left"
      },
      "bulkActions": [
        {
          "label": "批量删除",
          "actionType": "ajax",
          "api": "delete:/amis/api/sample/${ids|raw}",
          "confirmText": "确定要批量删除?",
          "id": "u:6b3eeae493e9"
        },
        {
          "label": "批量修改",
          "actionType": "dialog",
          "dialog": {
            "title": "批量编辑",
            "name": "sample-bulk-edit",
            "body": {
              "type": "form",
              "api": "/amis/api/sample/bulkUpdate2",
              "body": [
                {
                  "type": "hidden",
                  "name": "ids"
                },
                {
                  "type": "input-text",
                  "name": "engine",
                  "label": "Engine"
                }
              ]
            }
          },
          "id": "u:e00f4c475139"
        }
      ],
      "quickSaveApi": "/amis/api/sample/bulkUpdate",
      "quickSaveItemApi": "/amis/api/sample/$id",
      "draggable": true,
      "card": {
        "type": "container",
        "body": [
          {
            "header": {
              "title": "$engine",
              "subTitle": "$platform",
              "subTitlePlaceholder": "暂无说明",
              "avatar": "<%= data.avatar || \"https://internal-amis-res.cdn.bcebos.com/images/2019-12/1575350573496/4873dbfaf6a5.png\" %>",
              "avatarClassName": "pull-left thumb b-3x m-r"
            },
            "actions": [
              {
                "type": "button",
                "label": "查看",
                "actionType": "dialog",
                "dialog": {
                  "title": "查看",
                  "body": {
                    "type": "form",
                    "body": [
                      {
                        "type": "static",
                        "name": "engine",
                        "label": "Engine"
                      },
                      {
                        "type": "divider"
                      },
                      {
                        "type": "static",
                        "name": "browser",
                        "label": "Browser"
                      },
                      {
                        "type": "divider"
                      },
                      {
                        "type": "static",
                        "name": "platform",
                        "label": "Platform(s)"
                      },
                      {
                        "type": "divider"
                      },
                      {
                        "type": "static",
                        "name": "version",
                        "label": "Engine version"
                      },
                      {
                        "type": "divider"
                      },
                      {
                        "type": "static",
                        "name": "grade",
                        "label": "CSS grade"
                      },
                      {
                        "type": "divider"
                      },
                      {
                        "type": "html",
                        "html": "<p>添加其他 <span>Html 片段</span> 需要支持变量替换(todo).</p>"
                      }
                    ]
                  }
                },
                "id": "u:9e5b6187c523"
              },
              {
                "type": "button",
                "label": "编辑",
                "actionType": "dialog",
                "dialog": {
                  "title": "编辑",
                  "body": {
                    "type": "form",
                    "name": "sample-edit-form",
                    "api": "/amis/api/sample/$id",
                    "body": [
                      {
                        "type": "input-text",
                        "name": "engine",
                        "label": "Engine",
                        "required": true
                      },
                      {
                        "type": "divider"
                      },
                      {
                        "type": "input-text",
                        "name": "browser",
                        "label": "Browser",
                        "required": true
                      },
                      {
                        "type": "divider"
                      },
                      {
                        "type": "input-text",
                        "name": "platform",
                        "label": "Platform(s)",
                        "required": true
                      },
                      {
                        "type": "divider"
                      },
                      {
                        "type": "input-text",
                        "name": "version",
                        "label": "Engine version"
                      },
                      {
                        "type": "divider"
                      },
                      {
                        "type": "input-text",
                        "name": "grade",
                        "label": "CSS grade"
                      }
                    ]
                  }
                },
                "id": "u:bf598f881223"
              },
              {
                "type": "button",
                "label": "删除",
                "actionType": "ajax",
                "confirmText": "您确认要删除?",
                "api": "delete:/amis/api/sample/$id",
                "id": "u:737b69b4f7e5"
              }
            ],
            "body": [
              {
                "name": "engine",
                "label": "engine",
                "sortable": true,
                "quickEdit": true,
                "id": "u:e825484ca14b"
              },
              {
                "name": "browser",
                "label": "Browser",
                "id": "u:5df021037121"
              },
              {
                "name": "platform",
                "label": "Platform",
                "id": "u:09f67e759663"
              },
              {
                "name": "version",
                "label": "version",
                "id": "u:318328b60cda"
              }
            ],
            "id": "u:da1b9be0a705",
            "type": "card"
          }
        ],
        "id": "u:3618186b87c5",
        "style": {
          "display": "block",
          "position": "static"
        },
        "isFixedHeight": false,
        "isFixedWidth": false,
        "wrapperCustomStyle": {
          "root": {
            "width": "100%"
          }
        },
        "quickEdit": false,
        "popOver": false,
        "copyable": false,
        "themeCss": {
          "baseControlClassName": {
            "padding-and-margin:default": {
              "marginTop": "var(--sizes-size-0)",
              "marginRight": "var(--sizes-size-0)",
              "marginBottom": "var(--sizes-size-0)",
              "marginLeft": "var(--sizes-size-0)",
              "paddingTop": "var(--sizes-size-0)",
              "paddingRight": "var(--sizes-size-0)",
              "paddingBottom": "var(--sizes-size-0)",
              "paddingLeft": "var(--sizes-size-0)"
            },
            "border:default": {
              "top-border-width": "var(--borders-width-1)",
              "left-border-width": "var(--borders-width-1)",
              "right-border-width": "var(--borders-width-1)",
              "bottom-border-width": "var(--borders-width-1)"
            }
          }
        },
        "onEvent": {
          "mouseenter": {
            "weight": 0,
            "actions": [
              {
                "ignoreError": false,
                "script": "const myMsg = event.data.engine;\r\ndoAction({\r\n  actionType: 'toast',\r\n  args: {\r\n    msg: myMsg\r\n  }\r\n});\r\n\r\n\r\ndebugger",
                "actionType": "custom",
                "args": {}
              }
            ]
          }
        }
      },
      "perPageAvailable": [
        5,
        10,
        20,
        50,
        100
      ],
      "messages": {}
    }
  ],
  "id": "u:61da0ab84836",
  "asideResizor": false,
  "pullRefresh": {
    "disabled": true
  },
  "remark": "bla bla bla"
}