# 自定义模组

## 什么是自定义模组 ?

经过一段时间的系统使用后，相信大家对系统模组都已经不陌生。目前常用的系统模组包括：组选择、账号选择、角色选择、动态页面选择、工单选择等。

这些模组在被调用时，使用者无需关心其内部业务逻辑，只需要根据标准的get/set方法以及构造的options入参来使用即可。

那么我们是否能够开发自定义模组呢？

答案是肯定的。自定义模组本质上与普通动态页面没有任何区别，唯一的不同就是他必须按照自定义模组的规范进行时间注册与封装。

## 如何创建自定义模组？

首先，我们创建一个标准的动态页面，并且在此动态页面中进行一系列的功能设计。

然后，对该动态页面进行基于自定义模组的封装。

#### （1）获取入参：

在加载命令中，获取以自定义模组方式调用本动态页面时传入的参数，例如：

```
val('var.p1', this.$instance.parameters.P1);
val('var.p2', this.$instance.parameters.P2);
// 上文中，P1和P2为调用模组的入参，入参规范下文会做详细说明

if (this.$instance.addinParam == 'layer') {
    // 模组被以浮动层方式打开
    ctl('c9').state(0);
} else {
    // 模组被以对话框方式打开
    Module.title('我的标题');
    Module.icon('我的图标');
    Module.submitAlways();    // 确定按钮始终可用
    Module.onSubmit('submit.me');
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://km.elitecrm.com/ngs/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
