# yyuap-template

> template project which is based on tinper

Latest version **1.2.6** (published 2019-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install yyuap-template
pnpm add yyuap-template
yarn add yyuap-template
bun add yyuap-template
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.6 |
| Published | 2019-11-05 |
| First published | 2018-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.0.0 |
| Dependencies | 21 |
| Unpacked size | 1.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zhouleim |
| Maintainers | litongf, zhouleim |
| Keywords | yyuap, template |

## Links

- npm: https://www.npmjs.com/package/yyuap-template
- Repository: git@git.yonyou.com:litongf/new-template
- npm.io page: https://npm.io/package/yyuap-template

## Dependencies (21)

- [axios](https://npm.io/package/axios.md) ^0.19.0
- [c-url](https://npm.io/package/c-url.md) ^1.0.0
- [react](https://npm.io/package/react.md) ^15.3.0
- [moment](https://npm.io/package/moment.md) ^2.22.1
- [bee-form](https://npm.io/package/bee-form.md) ^2.0.6
- [bee-panel](https://npm.io/package/bee-panel.md) ^1.0.0
- [react-dom](https://npm.io/package/react-dom.md) ^15.3.0
- [yyuap-ref](https://npm.io/package/yyuap-ref.md) ^1.1.53
- [bee-layout](https://npm.io/package/bee-layout.md) ^1.2.7
- [bee-select](https://npm.io/package/bee-select.md) ^1.0.4
- [classnames](https://npm.io/package/classnames.md) ^2.2.5
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.0
- [tinper-bee](https://npm.io/package/tinper-bee.md) ^1.2.9
- [fetch-jsonp](https://npm.io/package/fetch-jsonp.md) ^1.1.3
- [bee-checkbox](https://npm.io/package/bee-checkbox.md) ^1.0.9
- [object-assign](https://npm.io/package/object-assign.md) ^4.1.1
- [bee-datepicker](https://npm.io/package/bee-datepicker.md) ^1.0.31
- [react-scrollbar](https://npm.io/package/react-scrollbar.md) ^0.5.1
- [promise-polyfill](https://npm.io/package/promise-polyfill.md) ^6.0.2
- [array.prototype.fill](https://npm.io/package/array.prototype.fill.md) ^1.0.2
- [@yonyou/ac-input-locale](https://npm.io/package/@yonyou/ac-input-locale.md) ^1.10.18

## Recent versions

- 1.2.6 (latest) — 2019-11-05
- 1.2.1 (beta) — 2019-08-15
- 1.2.5 — 2019-11-05
- 1.2.4 — 2019-10-30
- 1.2.3 — 2019-10-28
- 1.2.2 — 2019-09-18
- 1.2.1-npm — 2019-08-15
- 1.1.99-caep — 2019-08-15
- 1.1.99 — 2019-03-29
- 1.1.9 — 2019-03-28
- 1.1.0 — 2018-12-27
- 1.0.99 — 2018-12-26
- 1.0.98 — 2018-12-26
- 1.0.97 — 2018-12-26
- 1.0.96 — 2018-12-25
- … 85 more at https://npm.io/package/yyuap-template/versions

## README

## New Template

|参数|说明|类型|默认值|是否必须
|:---|:-----|:----|:------|:------|
|templateComponentName|模板显示位置的dom的id|String||是|
|url|模板服务地址|String|http://workbench.yyuap.com|否|
|nexuskey|模板的必要参数nexuskey|String||是|
|funcnode|模板的必要参数funcnode| String||是|
|templateType|模板的类型| String|空字符串|否|
|hideButton|隐藏表单的操作按钮| Boolean|false|否|
|onSave|点击保存按钮的回调函数|Function||是|
|onCancel|点击取消按钮的回调函数|Function||是|
|onDelete|点击取消按钮的回调函数|Function||是|
|onHeadFormDataChange|当主表发生变化时的回调函数| Function||是|
|onBodyFormDataChange|当子表发生变化时的回调函数| Function||是|
|handleComponentCallback|控件值发生变化时触发的回调函数|Function||是|

### 如何使用

* npm方式安装
```
    npm install yyuap-template
    注：如果采用es6的方式引入使用需要配置相应的css-loader等进行css样式的解析。
```
* 通过require或者script方式。可参考demo
```
    cdn地址: https://design.yonyoucloud.com/static/ui-templates/1.0.22/js/uiTemplate.js
```
```    
    需要引用build文件夹下面的uiTemplate.js
    <script type="text/javascript" src="https://design.yonyoucloud.com/static/ui-templates/1.0.22/js/uiTemplate.js"></script>
    此时会获得uiTempalte方法可直接实例化使用。
```

```
编写配置参数
const options = {
    // 模板生成dom的id
    templateComponentName : 'root',
    nexuskey : 'psn', // 实例模板
    funcnode : '001PSN_TEST', // 实例模板
    templateType:"hr",
    afterInit : function () {
        template.updateTemplateData()
    },
    // 保存的回调方法
    onSave : function (params) {
        console.log(params.rowData);
        params.doSave();
    },
    // 取消的回调方法
    onCancel : function (params) {
        params.doCancel();
    },
    // 删除行的回调方法
    onDelete : function (rowData) {
        console.log(rowData);
    },
    onHeadFormDataChange : function (headFormData) {
        console.log(headFormData);
    },
    onBodyFormDataChange : function (bodyFormData) {
        console.log(bodyFormData);
    },
    // 当输入控件的值发生改变时回调此方法来进行一些关联性的赋值操作
    handleComponentCallback : function (params) {
        if (params.itemCode === 'staff.staff_bankacc.bank') {
            params.setValue({itemCode:'staff.staff_bankacc.bankname',value:params.currentRef.id})
        }                                                   
        if (params.itemCode === 'adminorg.orgmgr') { // A控件改变B控件，同时通知改变C控件
            params.setValue({itemCode:'adminorg.branchleader',value:params.id,nextComponent:{itemCode:"adminorg.region",value:params.value}})
        }                                                   
        if (params.itemCode === 'adminorg.branchleader') {// B控件改变C控件
            params.setValue({itemCode:'adminorg.region',value:params.value.id})
        }                                                   
    }
}
// 初始化
var template = new uiTemplate(options);
// 开始创建
template.startCreate();
```
## 提供的API能力
```
在 new uiTempalte()之后会得到一个模板的实例化对象。这个实例带有如下方法：
```
```
1、updateTemplateData ---- 更新模板数据
2、setFormEdit ---- 设置表单为编辑状态 *(如果想在模板创建完成后立即设置为编辑状态，请放到afterInit方法中执行)*
3、setFormNotEdit ---- 设置表单为非编辑状态
4、saveForm ---- 获取保存数据(只有表单校验通过后返回json数据，否则页面会做出相应提示)
5、getTemplateInfo ---- 获取模板信息（返回json）
6、getValueByItemCode ---- 需要传入itemCode,根据itemCode返回value
7、setReferenceParamByItemCode ---- 运行时为参照控件追加参数（建议放到afterInit中执行设置）
8、resetForm ---- 将主表清空
9、setValueByItemCode ---- 根据itemCode为控件设置值
```

---
_Source: https://npm.io/package/yyuap-template · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
