# 任务组

业务逻辑总是错综复杂的，而点击一个按钮，会有一系列的任务要完成。所以就需要任务组这个功能。

结合上面的章节，我们知道，RCRE中有dataCustomer的功能，并且，我们把每一个dataCustomer的配置，称之为任务。

而任务组就是使用一个配置，让多个dataCustomer按照一定的顺序来进行，如果执行过程中遇到一些错误，就会中断。

## 定义任务组

使用groups属性来定义任务组，groups必须是一个数组，数组中每一个元素都是每一个任务组的配置。每个任务组必须要有name和steps这两个属性。

name是任务组的名称，steps是任务组里面每个任务的执行顺序。

假如现在已经有3个不同的dataCustomer配置： A， B， C。

如果想让一次点击之后，按照 `A -> B -> C` 的顺序依次执行。就可以把steps配置成 `["A", "B", "C"]`

如果中间某个任务执行失败，就不会继续执行。

```json
{
    "body": [
        {
            "type": "container",
            "model": "basicMissionGroup",
            "dataCustomer": {
                "customers": [{
                     "mode": "message",
                     "name": "popMessage",
                     "config": "#ES{$trigger.popMessage.message}"
                }, {
                    "mode": "modal",
                    "name": "confirmMessage",
                    "config": "#ES{$trigger.confirmMessage.confirm}"
                }],
                "groups": [
                    {
                        "name": "popMessageGroup",
                        "steps": ["popMessage", "confirmMessage", "popMessage"]
                    }
                ]
            },
            "children": [
                {
                    "type": "row",
                    "width": 400,
                    "children": [
                        {
                            "type": "text",
                            "text": "弹出的类型:"
                        },
                        {
                            "type": "select",
                            "name": "mode",
                            "options": [{
                                "key": "success",
                                "value": "success"
                            }, {
                                "key": "info",
                                "value": "info"
                            }, {
                                "key": "error",
                                "value": "error"
                            }, {
                                "key": "warning",
                                "value": "warning"
                            }, {
                                "key": "loading",
                                "value": "loading"
                            }]
                        }      
                    ]
                },
                {
                    "type": "row",
                    "width": 400,
                    "children": [
                        {
                            "type": "text",
                            "text": "弹出的文字："
                        },
                        {
                            "type": "input",
                            "name": "content",
                            "defaultValue": "helloWorld"
                        }
                    ]
                },
                {
                    "type": "button",
                    "text": "点击触发任务组",
                    "trigger": [{
                        "event": "onClick",
                        "targetCustomer": "popMessageGroup",
                        "params": {
                            "message": {
                                "content": "#ES{$data.content}",
                                "mode": "#ES{$data.mode}"
                            },
                            "confirm": {
                                "title": "确认继续？",
                                "content": [{
                                    "type": "text",
                                    "text": "再来个helloworld"
                                }]
                            }
                        }
                    }]
                }
            ]
        }
    ]
}
```

## 获取上一个任务返回值
在ExpressionString中使用$prev就能得到返回的值。


