1.2.6 • Published 5 years ago

yyuap-template v1.2.6

Weekly downloads
88
License
MIT
Repository
-
Last release
5 years ago

New Template

参数说明类型默认值是否必须
templateComponentName模板显示位置的dom的idString
url模板服务地址Stringhttp://workbench.yyuap.com
nexuskey模板的必要参数nexuskeyString
funcnode模板的必要参数funcnodeString
templateType模板的类型String空字符串
hideButton隐藏表单的操作按钮Booleanfalse
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为控件设置值
1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.1-npm

5 years ago

1.1.99-caep

5 years ago

1.1.99

6 years ago

1.1.9

6 years ago

1.1.0

6 years ago

1.0.99

6 years ago

1.0.98

6 years ago

1.0.97

6 years ago

1.0.96

6 years ago

1.0.95

6 years ago

1.0.94

6 years ago

1.0.93

6 years ago

1.0.92

6 years ago

1.0.91

6 years ago

1.0.90

6 years ago

1.0.89

6 years ago

1.0.88

6 years ago

1.0.87

6 years ago

1.0.86

6 years ago

1.0.85

6 years ago

1.0.84

6 years ago

1.0.83

6 years ago

1.0.82

6 years ago

1.0.81

6 years ago

1.0.80

6 years ago

1.0.79

6 years ago

1.0.78

6 years ago

1.0.77

6 years ago

1.0.76

6 years ago

1.0.75

6 years ago

1.0.74

6 years ago

1.0.73

6 years ago

1.0.72

6 years ago

1.0.71

6 years ago

1.0.70

6 years ago

1.0.69

6 years ago

1.0.68

6 years ago

1.0.67

6 years ago

1.0.66

6 years ago

1.0.65

6 years ago

1.0.64

6 years ago

1.0.63

6 years ago

1.0.62

6 years ago

1.0.61

6 years ago

1.0.60

6 years ago

1.0.59

6 years ago

1.0.58

6 years ago

1.0.57

6 years ago

1.0.56

6 years ago

1.0.55

6 years ago

1.0.54

6 years ago

1.0.53

6 years ago

1.0.52

6 years ago

1.0.51

6 years ago

1.0.50

6 years ago

1.0.49

6 years ago

1.0.48

6 years ago

1.0.47

6 years ago

1.0.46

6 years ago

1.0.45

6 years ago

1.0.44

6 years ago

1.0.43

6 years ago

1.0.42

6 years ago

1.0.41

6 years ago

1.0.40

6 years ago

1.0.39

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.1

7 years ago