8000 input-table如何自定义按钮 · Issue #12068 · baidu/amis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
input-table如何自定义按钮 #12068
Open
@g1045857717

Description

@g1045857717

描述问题:

input-table如何自定义按钮

截图或视频:

Image

  1. 粘贴有问题的完整 amis schema 代码:
{
  "type": "input-table",
  "id": "u:8bb6beca827a",
  "mode": "normal",
  "name": "specialWorkTrainPlanItems",
  "label": "",
  "columns": [
    {
      "id": "u:dae9fc22a451",
      "name": "userId",
      "type": "mapping",
      "label": "姓名",
      "quickEdit": {
        "id": "u:bd07592963cc",
        "mode": "inline",
        "name": "userId",
        "type": "picker",
        "label": "",
        "source": {
          "url": "/crud/list/system?mode=sys_user_kv",
          "method": "post",
          "adaptor": "",
          "messages": {},
          "requestAdaptor": "\r\nlet flag = context.op == 'loadOptions';\r\n\r\nif (!flag) {\r\n  let newURL = api.url.replace(/\\/list(\\/|$)/, \"/page$1\");\r\n  api.url = newURL;\r\n}\r\n\r\nreturn api;\r\n\r\n"
        },
        "labelTpl": "",
        "multiple": false,
        "required": true,
        "themeCss": {
          "pickControlClassName": {
            "--Pick-base-icon": ""
          },
          "pickValueIconClassName": {}
        },
        "labelField": "realName",
        "valueField": "userId",
        "placeholder": "请选择",
        "pickerSchema": {
          "id": "u:bc4b21aae034",
          "mode": "table",
          "filter": {
            "id": "u:bdb0c4ba3e80",
            "api": {
              "url": "/crud/page/system?mode=sys_user_kv",
              "method": "post",
              "adaptor": "",
              "messages": {},
              "requestAdaptor": ""
            },
            "body": [
              {
                "id": "u:8f8474192182",
                "name": "queryParams.expr1/realName",
                "type": "input-text",
                "label": "姓名",
                "value": "",
                "clearable": true
              },
              {
                "id": "u:4adb004c4f5c",
                "name": "queryParams.expr1/_op",
                "type": "input-text",
                "label": "姓名查询条件",
                "value": "full_like",
                "hidden": true,
                "clearable": true
              }
            ],
            "feat": "Insert",
            "debug": false,
            "title": "查询条件",
            "dsType": "api",
            "actions": [
              {
                "id": "u:a2000bbd2faf",
                "type": "submit",
                "label": "搜索",
                "level": "default",
                "primary": true,
                "disabledOnAction": false
              }
            ],
            "onEvent": {
              "click": {
                "weight": 0,
                "actions": []
              }
            },
            "labelAlign": "left",
            "canAccessSuperData": false
          },
          "source": "",
          "columns": [
            {
              "id": "u:d5a99508e565",
              "name": "realName",
              "type": "text",
              "label": "姓名",
              "placeholder": "-"
            }
          ],
          "pageField": "page",
          "labelField": "realName",
          "valueField": "userId",
          "perPageField": "perPage",
          "defaultParams": {
            "page": "1",
            "perPage": "10"
          },
          "footerToolbar": [
            {
              "type": "statistics"
            },
            {
              "type": "pagination"
            },
            {
              "id": "u:4dea2285dbe8",
              "tpl": "内容",
              "type": "switch-per-page",
              "wrapperComponent": ""
            }
          ],
          "headerToolbar": [
            {
              "type": "bulk-actions"
            },
            {
              "id": "u:f3138a14de00",
              "tpl": "用户",
              "type": "tpl",
              "wrapperComponent": ""
            }
          ],
          "autoFillHeight": true,
          "perPageAvailable": [
            10,
            20,
            30,
            50
          ],
          "alwaysShowPagination": true,
          "keepItemSelectionOnPageChange": false
        },
        "modalClassName": "app-popover :AMISCSSWrapper",
        "overflowConfig": {
          "maxTagCount": -1
        }
      },
      "placeholder": "-"
    },
    {
      "id": "u:9eb1ecc55800",
      "name": "trainRes",
      "type": "mapping",
      "label": "培训结果",
      "quickEdit": {
        "id": "u:65c895e840dd",
        "name": "trainRes",
        "type": "select",
        "label": "",
        "source": {
          "url": "/crud/list/system?mode=sys_dict",
          "method": "post",
          "adaptor": "",
          "messages": {},
          "requestAdaptor": "",
          "data": {
            "dictGroup": "special_work_train_plan_item_res"
          }
        },
        "multiple": false,
        "themeCss": {
          "selectControlClassName": {
            "border:default": {
              "top-border-style": "var(--borders-style-1)",
              "top-border-width": "var(--borders-width-1)",
              "left-border-style": "var(--borders-style-1)",
              "left-border-width": "var(--borders-width-1)",
              "right-border-style": "var(--borders-style-1)",
              "right-border-width": "var(--borders-width-1)",
              "bottom-border-style": "var(--borders-style-1)",
              "bottom-border-width": "var(--borders-width-1)"
            }
          }
        },
        "labelField": "label",
        "valueField": "value",
        "mode": "popOver",
        "step": 1,
        "keyboard": true,
        "clearable": true
      },
      "placeholder": "-"
    },
    {
      "id": "u:15b675710ad8",
      "name": "trainCondition",
      "type": "mapping",
      "label": "培训情况",
      "quickEdit": false,
      "placeholder": "-",
      "popOver": {
        "mode": "dialog"
      },
      "copyable": true,
      "map": {
        "*": "通配值"
      }
    },
    {
      "id": "u:3b2d201baccb",
      "name": "fileName",
      "type": "input-file",
      "label": "相关附件",
      "placeholder": "-",
      "drag": false,
      "proxy": true,
      "style": {
        "display": "block",
        "position": "static"
      },
      "width": "",
      "accept": "",
      "onEvent": {
        "remove": {
          "weight": 0,
          "actions": [
            {
              "args": {
                "value": "${''}"
              },
              "actionType": "setValue",
              "componentId": "u:d74339588ec9",
              "ignoreError": false
            }
          ]
        },
        "success": {
          "weight": 0,
          "actions": [
            {
              "args": {},
              "script": "/* 自定义JS使用说明:\n      * 1.动作执行函数doAction,可以执行所有类型的动作\n      * 2.通过上下文对象context可以获取当前组件实例,例如context.props可以获取该组件相关属性\n      * 3.事件对象event,在doAction之后执行event.stopPropagation();可以阻止后续动作执行\n      */\nconst value = event.data.value;\nconst index = event.data.index;\nconsole.log(event, \"event\");\nconsole.log(context, \"context\");\ndoAction({\n      componentName: \"specialWorkTrainPlanItems\",\n      actionType: 'setValue',\n      args: {\n            \"index\": index,\n            \"value\": {\n                  'fileUrl': value\n            },\n      }\n});\n",
              "actionType": "custom",
              "ignoreError": false
            }
          ]
        }
      },
      "autoFill": {},
      "btnLabel": "文件上传",
      "multiple": false,
      "receiver": {
        "url": "/file/upload",
        "method": "post",
        "adaptor": "",
        "dataType": "form-data",
        "messages": {},
        "requestAdaptor": ""
      },
      "useChunk": false,
      "className": "item_upload",
      "delimiter": ",",
      "autoUpload": true,
      "uploadType": "fileReceptor",
      "valueField": "name",
      "downloadUrl": "/api/file/download?key=${fileUrl}&Authorization=${ls:access_token}",
      "isFixedWidth": false,
      "isFixedHeight": false
    },
    {
      "id": "u:a0da673bdcaf",
      "name": "fileUrl",
      "type": "text",
      "label": "",
      "placeholder": "-",
      "width": 0,
      "align": "center",
      "fixed": "",
      "vAlign": "middle",
      "disabled": true,
      "quickEdit": {
        "id": "u:df52843da302",
        "body": [
          {
            "id": "u:d74339588ec9",
            "name": "fileUrl",
            "type": "hidden",
            "value": "555",
            "hidden": false,
            "inline": false,
            "static": false,
            "visible": true,
            "disabled": true,
            "readOnly": false
          }
        ],
        "feat": "Insert",
        "mode": "popOver",
        "type": "wrapper",
        "style": {
          "display": "block",
          "position": "static"
        },
        "actions": [
          {
            "type": "submit",
            "label": "提交",
            "primary": true
          }
        ],
        "isFixedWidth": false,
        "isFixedHeight": false
      },
      "textOverflow": "default",
      "drag": false,
      "proxy": true,
      "style": {
        "display": "block",
        "position": "static"
      },
      "accept": "",
      "onEvent": {
        "remove": {
          "weight": 0,
          "actions": [
            {
              "args": {
                "value": "${''}"
              },
              "actionType": "setValue",
              "componentId": "u:d74339588ec9",
              "ignoreError": false
            }
          ]
        },
        "success": {
          "weight": 0,
          "actions": [
            {
              "args": {},
              "script": "/* 自定义JS使用说明:\n      * 1.动作执行函数doAction,可以执行所有类型的动作\n      * 2.通过上下文对象context可以获取当前组件实例,例如context.props可以获取该组件相关属性\n      * 3.事件对象event,在doAction之后执行event.stopPropagation();可以阻止后续动作执行\n      */\nconst value = event.data.value;\nconst index = event.data.index;\nconsole.log(event, \"event\");\nconsole.log(context, \"context\");\ndoAction({\n      componentName: \"safetyBookItems\",\n      actionType: 'setValue',\n      args: {\n            \"index\": index,\n            \"value\": {\n                  'fileUrl': value\n            },\n      }\n});\n",
              "actionType": "custom",
              "componentId": "",
              "ignoreError": false
            }
          ]
        }
      },
      "autoFill": {},
      "btnLabel": "文件上传",
      "multiple": false,
      "receiver": {
        "url": "/file/upload",
        "method": "post",
        "adaptor": "",
        "dataType": "form-data",
        "messages": {},
        "requestAdaptor": ""
      },
      "useChunk": false,
      "className": "item_upload",
      "delimiter": ",",
      "autoUpload": true,
      "uploadType": "fileReceptor",
      "valueField": "name",
      "downloadUrl": "/api/file/download?key=${fileUrl}&Authorization=${ls:access_token}",
      "isFixedWidth": false,
      "isFixedHeight": false
    },
    {
      "id": "u:b6ada85bdcf1",
      "name": "id",
      "type": "mapping",
      "label": "",
      "quickEdit": {
        "id": "u:41cc62bd998b",
        "body": [
          {
            "id": "u:e44209713d32",
            "name": "id",
            "type": "hidden",
            "value": ""
          }
        ],
        "feat": "Insert",
        "mode": "popOver",
        "type": "wrapper",
        "style": {
          "display": "block",
          "position": "static"
        },
        "actions": [
          {
            "type": "submit",
            "label": "提交",
            "primary": true
          }
        ],
        "isFixedWidth": false,
        "isFixedHeight": false
      },
      "placeholder": "-"
    },
    {
      "id": "u:e4a6dc66d473",
      "name": "specialWorkPersonId",
      "type": "mapping",
      "label": "",
      "quickEdit": {
        "id": "u:28841c827dcd",
        "body": [
          {
            "id": "u:95f78e766836",
            "name": "specialWorkPersonId",
            "type": "hidden",
            "value": ""
          }
        ],
        "feat": "Insert",
        "mode": "popOver",
        "type": "wrapper",
        "style": {
          "display": "block",
          "position": "static"
        },
        "actions": [
          {
            "type": "submit",
            "label": "提交",
            "primary": true
          }
        ],
        "isFixedWidth": false,
        "isFixedHeight": false
      },
      "placeholder": "-"
    }
  ],
  "onEvent": {
    "rowDbClick": {
      "weight": 0,
      "actions": [
        {
          "ignoreError": false,
          "actionType": "custom",
          "script": "/* 自定义JS使用说明:\n      * 1.动作执行函数doAction,可以执行所有类型的动作\n      * 2.通过上下文对象context可以获取当前组件实例,例如context.props可以获取该组件相关属性\n      * 3.事件对象event,在doAction之后执行event.stopPropagation();可以阻止后续动作执行\n      */\nconsole.log(\"event\", event);\n      doAction({\n      actionType: 'toast',\n      args: {\n      msg: myMsg\n      }\n      });\n      "
        }
      ]
    }
  },
  "perPage": 20,
  "deleteApi": {
    "url": "/crud/delete/specialWorkManage?mode=special_work_train_plan_item&pk=${id}",
    "method": "post",
    "adaptor": "",
    "messages": {},
    "requestAdaptor": ""
  },
  "removable": true,
  "showIndex": true,
  "strictMode": true,
  "affixHeader": false,
  "needConfirm": false,
  "footerAddBtn": {
    "id": "u:845a85c826a8",
    "icon": "fa fa-plus",
    "label": "新增",
    "disabledOnAction": false
  },
  "columnsTogglable": false,
  "showFooterAddBtn": true,
  "addable": true,
  "copyable": true,
  "showTableAddBtn": true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0