

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Amazon Connect 座席工作区中的自定义视图
<a name="view-resources-custom-view"></a>

使用 APIs 您可以创建自己的视图资源。View 资源包括 CloudFormation CloudTrail、和标记支持。

## 查看 API 示例
<a name="view-resources-custom-view-example"></a>

**视图描述**

此视图将两张卡片嵌套在一个容器中，并在其右侧放置了一个跳过按钮。

**CLI 命令**

```
aws connect create-view --name CustomerManagedCardsNoContainer \
--status PUBLISHED --content file://view-content.json \
--instance-id $INSTANCE_ID --region $REGION
```

**view-content.json**

```
{
  "Template": <stringified-template-json>
  "Actions": ["CardSelected", "Skip"]
}
```

**模板 JSON（未进行字符串化）**

```
{
    "Head": {
        "Title": "CustomerManagedFormView",
        "Configuration": {
            "Layout": {
                "Columns": ["10", "2"] // Default column width for each component is 12, which is also the width of the entire view.
            }
        }
    },
    "Body": [
        {
            "_id": "card-container",
            "Type": "Container",
            "Props": {},
            "Content": [
                {
                    "_id": "cafe_card",
                    "Type": "Card",
                    "Props": {
                        
                        "Id": "cafe-card",
                        "Heading": "Cafe Card",
                        "Icon": "Cafe",
                        "Status": "Status Field",
                        "Description": "This is the cafe card.",
                        "Action": "CardSelected" // Note that these actions also appear in the view-content.json file.
                          
                    },
                    "Content": []
                },
                {
                    "_id": "no_icon_card",
                    "Type": "Card",
                    "Props": {
                        "Id": "NoIconCard",
                        "Heading": "$.NoIconCardHeading",
                        "Status": "Status Field",
                        "Description": "This is the icon card.",
                        "Action": "CardSelected" // Note that these actions also appear in the view-content.json file.
                    },
                    "Content": []
                }
            ]
        },
        {
            "_id": "button",
            "Type": "Button",
            "Props": { "Action": "Skip" }, // Note that these actions also appear in the view-content.json file.
            "Content": ["Skip"]
        }
    ]
}
```

## 视图
<a name="view-resources-custom-the-view"></a>

**输入**

`$.NoIconCardHeading` 指示字段 `NoIconCardHeading` 的输入是呈现视图所必需的。

假设 `NoIconCardHeading` 设置为 `No Icon Card`。

**外观**

![\[Agent Workspace 视图卡片的图像。\]](http://docs.aws.amazon.com/zh_cn/connect/latest/adminguide/images/view-resources-custom-the-view.png)


## 视图输出示例
<a name="view-resources-custom-view-output-example"></a>

视图输出两条主要数据：`Action` 获取的数据和 `Output` 数据。

将视图与[“显示视图”数据块](https://docs.aws.amazon.com/connect/latest/adminguide/show-view-block.html)一起使用时，`Action` 表示一个分支，并且 `Output` 数据设置为 `$.Views.ViewResultData` 流属性，如“显示视图”数据块文档中所述。

**场景 1：选择 **Cafe Card** 卡**

```
"Action": "CardSelected"
"Output": {
    "Heading": "CafeCard",
    "Id": "CafeCard"
}
```

**场景 2：选择 **Skip** 按钮**

```
"Action": "Skip"
"Output": {
    "action": "Button"
}
```

## 表单视图输出示例
<a name="view-resources-custom-form-view-output-example"></a>

使用 **AWS 管理的视图（表单视图）**时，表单数据的结果将位于下方。*FormData*

```
{
   FormData: {
       email: "a@amazon.com"
   }
}
```

您可以访问显示视图数据块中的数据，例如 `$.Views.ViewResultData.FormData.email`。

使用**自定义视图（带有表单组件）**时，表单数据的结果将直接显示在输出下方。

```
{
    email: "a@amazon.com"
}
```

您可以访问显示视图数据块中的数据，例如 `$.Views.ViewResultData.email`。