name: instance_reassign
is_enable: true
label: 转签核
'on': record_only
type: amis_button
visible: true
amis_schema: |-
  {
    "type": "service",
    "bodyClassName": "p-0",
    "regions": [
      "body"
    ],
    "body": [
      {
        "type": "button",
        "label": "转签核",
        "id": "u:instance_reassign",
        "hiddenOn": "!(this.record.box === 'monitor' && this.record.state == 'pending' && this.flowPermissions.includes('admin'))",
        "onEvent": {
          "click": {
            "weight": 0,
            "actions": [
              {
                "args": {},
                "actionType": "dialog",
                "dialog": {
                  "type": "dialog",
                  "title": "转签核",
                  "body": [
                    {
                      "type": "form",
                      "title": "表单",
                      "mode": "normal",
                      "body": [
                        {
                          "type": "tpl",
                          "tpl": "当前步骤: <p class='font-medium inline'>${record.currentStep.name}</p>",
                          "inline": true,
                          "wrapperComponent": "",
                          "id": "u:1f7dd93080d3"
                        },
                        {
                          "type": "steedos-select-user",
                          "label": "处理人",
                          "name": "users",
                          "id": "u:c3ad733db360",
                          "multiple": true,
                          "mode": "normal",
                          "required": true
                        },
                        {
                          "type": "textarea",
                          "label": false,
                          "name": "reason",
                          "id": "u:bffe87a42168",
                          "minRows": 3,
                          "maxRows": 20,
                          "placeholder": "请填写重定位的理由"
                        }
                      ],
                      "id": "u:1779a48caedb",
                      "wrapWithPanel": false,
                      "debug": false,
                      "api": {
                        "url": "${context.rootUrl}/api/workflow/reassign",
                        "method": "post",
                        "messages": {
                          "success": "转签核成功",
                          "failed": "转签核失败"
                        },
                        "dataType": "json",
                        "requestAdaptor": "\nconst { record, users, reason } = api.data;\napi.data = {\n  \"Instances\": [{\n    _id: record._id, inbox_users: users, reassign_reason: reason\n  }]\n}\n\nreturn api;"
                      },
                      "onEvent": {
                        "submitFail": {
                          "weight": 0,
                          "actions": []
                        },
                        "submitSucc": {
                          "weight": 0,
                          "actions": [
                            {
                              "args": {
                                "eventName": "@data.@instanceDetail.changed"
                              },
                              "actionType": "broadcast",
                              "data": {}
                            }
                          ]
                        }
                      }
                    }
                  ],
                  "showCloseButton": true,
                  "showErrorMsg": true,
                  "showLoading": true,
                  "id": "u:7f102d206724"
                }
              }
            ]
          }
        }
      }
    ],
    "data": {
      "context": {
        "rootUrl": "http://127.0.0.1:5300",
        "tenantId": "63ed8fb288feeecd0165843d",
        "userId": "1852bcb9-a3cb-4d04-905b-1cd12e4cdb3b",
        "authToken": "4c6a0b7d705b6fcab7f09d08006e644e30a37d3b5e198a056e85d7383ced3f492a097a30b63ad8e42d1c08"
      },
      "app_id": "",
      "tab_id": "",
      "object_name": "",
      "dataComponentId": "",
      "record_id": "",
      "record": {},
      "permissions": {}
    },
    "id": "u:fbe25e9811ea"
  }