name: instance_cc
amis_schema: |-
  {
      "type": "service",
      "body": [
          {
              "type": "button",
              "label": "传阅",
              "id": "u:instance_cc",
              "className": "  ",
              "onEvent": {
                  "click": {
                      "actions": [
                          {
                              "actionType": "dialog",
                              "dialog": {
                                  "type": "dialog",
                                  "title": {
                                      "type": "tpl",
                                      "id": "u:0bce3c33b6e5",
                                      "tpl": "<p>传阅<a href=\"https://www.steedos.cn/docs/user/workflow#%E5%A6%82%E4%BD%95%E4%BC%A0%E9%98%85\" target=\"_blank\" rel=\"noopener\"> ?&nbsp;</a></p>"
                                  },
                                  "body": [
                                      {
                                          "type": "tpl",
                                          "tpl": "<p>当前步骤: ${record.step.name}</p>",
                                          "inline": false,
                                          "id": "u:11bcfab80ce9",
                                          "className": "m-b-sm"
                                      },
                                      {
                                        "type": "form",
                                        "title": "表单",
                                        "debug": false,
                                        "body": [
                                            {
                                                "type": "steedos-select-user",
                                                "label": "传阅对象",
                                                "name": "users",
                                                "id": "u:c3ad733db360",
                                                "multiple": true,
                                                "mode": "normal",
                                                "required": true
                                            },
                                            {
                                                "type": "textarea",
                                                "label": "传阅说明",
                                                "name": "description",
                                                "id": "u:1dc7e49e6e7d",
                                                "minRows": 3,
                                                "maxRows": 20
                                            }
                                        ],
                                        "id": "u:742f9c0dc8a1",
                                        "mode": "normal",
                                          "api": {
                                                "url": "${context.rootUrl}/api/workflow/v2/cc_do",
                                                "method": "post",
                                                "dataType": "json",
                                                "data": {
                                                    "&": "$$",
                                                    "record": "${record}"
                                                },
                                                "requestAdaptor": "console.log(\"api\", api);\n api.data = {instanceId: api.body.record._id, traceId: api.body.record.approve.trace, approveId: api.body.record.approve._id, usersId: api.body.users, description: api.body.description}; return api;",
                                                "adaptor": "console.log('payload', payload);\nreturn payload;",
                                                "headers": {
                                                    "Authorization": "Bearer ${context.tenantId},${context.authToken}"
                                                },
                                                "messages": {
                                                    "success": "传阅成功!",
                                                    "failed": "传阅失败"
                                                }
                                            },
                                            "onEvent": {
                                                "submitSucc": {
                                                    "actions": [
                                                       {
                                                        "actionType": "broadcast",
                                                        "args": {
                                                            "eventName": "@data.@instanceDetail.changed"
                                                        },
                                                        "data": {
                                                            
                                                        }
                                                      },
                                                       {
                                                          "componentId": "",
                                                          "args": {},
                                                          "actionType": "closeDialog"
                                                        }
                                                    ]
                                                }
                                            }
                                        }
                                  ],
                                  "id": "u:519ca64b1934",
                                  "actions": [
                                      {
                                          "type": "button",
                                          "label": "取消",
                                          "onEvent": {
                                              "click": {
                                                  "actions": [
                                                      {
                                                          "componentId": "",
                                                          "args": {},
                                                          "actionType": "closeDialog"
                                                      }
                                                  ]
                                              }
                                          },
                                          "id": "u:1d0d136fe2f0"
                                      },
                                      {
                                          "type": "button",
                                          "label": "确定",
                                          "onEvent": {
                                              "click": {
                                                  "actions": [
                                                        {
                                                          "args": {},
                                                          "actionType": "validate",
                                                          "componentId": "u:742f9c0dc8a1"
                                                      },
                                                      {
                                                        "componentId": "u:742f9c0dc8a1",
                                                        "args": {
                                                        },
                                                        "actionType": "submit"
                                                       }
                                                  ]
                                              }
                                          },
                                          "id": "u:f7f767bed23f",
                                          "level": "primary"
                                      }
                                  ]
                              }
                          }
                      ],
                      "weight": 0
                  }
              },
              "hiddenOn": "!(\n\t(record.box === 'inbox' && record.state === 'pending' && \n  \t\t(_.includes(record.cc_users, context.user.userId) \n         || (record.step?.disableCC != true && record.step?.step_type != 'start')))\n  \t||\n  \t(record.box === 'outbox' && record.state === 'pending' &&\n    \t(record.lastCCStep?.disableCC != true && record.lastCCStep?.step_type != 'start')\n    )\n  \n)"
          }
      ],
      "regions": [
          "body"
      ],
      "data": {
      },
      "bodyClassName": "p-0",
      "id": "u:7414f3c8128c"
  }
is_enable: true
label: 传阅
'on': record_only
type: amis_button
visible: true
