起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 736|回复: 8

[结贴] 组件开发

[复制链接]

184

主题

707

帖子

2333

积分

金牌会员

Rank: 6Rank: 6

积分
2333
QQ
发表于 2016-5-23 11:03:59 | 显示全部楼层 |阅读模式
。config.js 如下
define(function(require) {
        return {
                properties: {
                        classificationLevel: "string",
                        classificationDuration: "string",
                        drafter: "string",
                        classificationAuthor: "string",
                        issuer: "string",
                        classificationOrg: "string",
                        classificationBasis: "string",
                        classificationId: "string",
                        classificationStatus: "string",
                        issuedNumber: "string",
                        copys: "string",
                        operationControl: "string",
                        maxLength: "integer",
                        data: "string",
                        masterId: "string",
                        accessScopeDescribe: "string"
                },
                events:["onClassificationSucess","onClassificationError","onBeforeSave","onAfterSave"],
                binds:{"bind-ref": "ref"}
        };
});



设计时 组件XML如下
<?xml version="1.0" encoding="utf-8"?>

<elements>
        <element name="$UI/LW/components/lw/classification/classification"
                tag-name="*" text="密级标识组件" icon="bizData.gif"
                binding-component="$UI/LW/components/lw/classification/classification"
                component-type="data" parent-range="$UI/system/components/justep/model/model"
                design-view="web-designer">
                <!-- 定义要可视化编辑的属性 -->
                <properties>
                        <property name="xid" text="编号" required="true" />
                        <property name="concept" text="概念" readonly="true"
                                editor-ref="" default-value="classifiComp" />
                        <property name="reader" text="加载数据Action" readonly="true"
                                editor-ref=""
                                default-value="/LW/classificationManagementSystem/logic/action/queryClassifiCompAction" />
                        <property name="writer" text="新增数据Action" readonly="true"
                                editor-ref=""
                                default-value="/LW/classificationManagementSystem/logic/action/queryClassifiCompAction" />
                        <property name="creator" text="加载数据Action" readonly="true"
                                editor-ref=""
                                default-value="/LW/classificationManagementSystem/logic/action/queryClassifiCompAction" />
                        <property name="bind-ref" text="引用" editor-ref="dataRef"
                                editor-parameter='{"hasLabel":"false"}' />
                        <property name="limit" text="条数" data-type="integer"
                                default-value="5" />
                        <property name="confirmClassification" text="定密后提示"
                                default-value="true" editor-ref="booleanList" data-type="boolean" />
                        <property name="maxLength" text="允许输入最大长度" data-type="integer" />
                        <group name="master" text="主从选项">
                                <property name="data" path="master/@data" text="主数据"
                                        is-id-ref="true" type="complex" editor-ref="contextComponent"
                                        editor-parameter="data" />
                                <property name="column" path="master/@relation" text="关联关系"
                                        type="complex" editor-ref="dataRef"
                                        editor-parameter='{"isRelation":"true","data":"xid","hasLabel":"false"}' />
                        </group>
                </properties>
                <property-editors>
                        <property-editor name="mappingDialog" type="dialog">
                                <dialog-page class-name="EditMappingPage" />
                        </property-editor>
                </property-editors>
                <!-- 内部组件描述 -->
                <inner-component-config>
                        <item name="$UI/system/components/justep/data/bizData"
                                exclude-properties="writer,creator,columns,updateMode,directDelete,confirmDelete,relation,data,confirmDeleteText,confirmRefresh,confirmRefreshText,autoNew,nodeLevelRelation">
                                <properties />
                        </item>
                </inner-component-config>
                <!-- 定义当前组件的事件 -->
                <events>
                        <!-- 定义模板 -->
                        <!-- <event name="onAfterRefresh" text="刷新后"/> -->
                        <!-- <event name="onSaveError" text="保存失败"/> <event name="onSaveCreateParam"
                                text="创建保存参数"/> <event name="onAfterSave" text="保存后"/> <event name="onSaveCommit"
                                text="保存事务提交"/> -->
                        <event name="onClassificationSucess" text="标密成功" />
                        <event name="onClassificationError" text="标密失败" />
                        <event name="onBeforeSave" text="保存前" />
                        <event name="onAfterSave" text="保存后" />
                </events>
                <templates>
                        <!-- 默认模板,创建当前组件时会生成模板中的节点代码 -->
                        <template name="default"><![CDATA[
                        <div component="$UI/LW/components/lw/classification/classification" autoLoad="true" >
                        </div>          
                         ]]></template>
                </templates>
        </element>
</elements>


111.PNG


我做的组件 现在 我想实现保存 主表数据 然后通过关联 保存classifiComp的数据  平台的BIZDATA没有看懂 有没有什么别的例子 或者给个思路 现在不知道代码如何实现

184

主题

707

帖子

2333

积分

金牌会员

Rank: 6Rank: 6

积分
2333
QQ
 楼主| 发表于 2016-5-23 11:08:44 | 显示全部楼层
classificomp 是我自己做的组件 运行时候JS如下

define(function(require) {
        var Request = require("$UI/system/lib/base/request");
        // 加载公共资源
        require("$UI/system/components/justep/common/res");
        // 引入jquery
//        var Model = justep.ModelBase;
        var $ = require("jquery");

        // 引入justep工具类
        var justep = require("$UI/system/lib/justep");

        // 相对路径转化为绝对路径
        var url = require.normalizeName("./classification");

        // 加载组件配置文件
        var ComponentConfig = require("./classification.config");

        // 引入css文件
        require('css!./designer/css/classification').load();

         var classification = justep.BindComponent.extend({
//        var classification = justep.ModelComponent.extend({
                // 构造函数
                constructor : function(model, config) {
                        // 调用夫类的构造方法
                        this.callParent();

                        // 属性初始化默认值,这里对应着组件配置文件中注册的属性,必须赋给一个默认值,否在在调set方法给属性赋值的时候不起作用
                        this.classificationLevel = "";
                        this.classificationDuration = "";
                        this.drafter = "";
                        this.classificationAuthor = "";
                        this.issuer = "";
                        this.classificationOrg = "";
                        this.classificationBasis = "";
                        this.classificationId = "";
                        this.classificationStatus = "";
                        this.issuedNumber = "";
                        this.copys = "";
                        this.operationControl = "";
                        this.masterId = "";
                        this.accessScopeDescribe = "";
                        this.maxLength = 5 ;
                },
       
               
                // 获取组件配置文件
                getConfig : function() {
                        return ComponentConfig;
                },

                // 构建模板,方法在通过new 的方式来动态创建组件对象的时候回调用。
                buildTemplate : function(config) {

                },

                setValue : function(row, value, id) {
                        // 密级标识属性
                        debugger;
                        if ("classificationLevel" == row) {
                                this.classificationLevel = value;
                        } else if ("classificationDuration" == row) {
                                this.classificationDuration = value;
                        } else if ("drafter" == row) {
                                this.drafter = value;
                        } else if ("classificationAuthor" == row) {
                                this.classificationAuthor = value;
                        } else if ("issuer" == row) {
                                this.issuer = value;
                        } else if ("classificationOrg" == row) {
                                this.classificationOrg = value;
                        } else if ("classificationBasis" == row) {
                                this.classificationBasis = value;
                        } else if ("classificationId" == row) {
                                this.classificationId = value;
                        } else if ("classificationStatus" == row) {
                                this.classificationStatus = value;
                        } else if ("issuedNumber" == row) {
                                this.issuedNumber = value;
                        } else if ("copys" == row) {
                                this.copys = value;
                        } else if ("operationControl" == row) {
                                this.operationControl = value;
                        } else if ("masterId" == value) {
                                this.masterId = value;
                        } else if ("accessScopeDescribe" == row) {
                                this.accessScopeDescribe = value;
                        } else if ("accessScopeDescribe" == row) {
                                this.accessScopeDescribe = value;
                        } else if ("fFileUpload" == row) {
                                this.fFileUpload = value;
                        }
                },

                // 提交
                saveData : function(options) {
                        debugger;

                        // 保存前
                        this.fireEvent("onBeforeSave", {
                                source : this
                        });

                        var onSuccess = null, onError = null, useTrans = true, ignoreInvalid = false;
                        var async = false;
                        var result = false;
                        var options = {};
                        var param = new Request.ActionParam();

                        param.setString('classificationLevel', this.classificationLevel);
                        param.setString('classificationDuration', this.classificationDuration);
                        param.setString('drafter', this.drafter);
                        param.setString('classificationAuthor', this.classificationAuthor);
                        param.setString('issuer', this.issuer);
                        param.setString('classificationOrg', this.classificationOrg);
                        param.setString('classificationBasis', this.classificationBasis);
                        param.setString('classificationId', this.classificationId);
                        param.setString('classificationStatus', this.classificationStatus);
                        param.setString('issuedNumber', this.issuedNumber);
                        param.setString('copys', this.copys);
                        param.setString('operationControl', this.operationControl);
                        param.setString('masterId', this.masterId);
                        param.setString('accessScopeDescribe', this.accessScopeDescribe);
                        param.setString('fFileUpload', this.fFileUpload);

                        var process = "/LW/classificationManagementSystem/process/classificationManagementSystem/classificationManagementSystemProcess";
                        var activity = "mainActivity";
                        options.process = process;
                        options.activity = activity;
                        options.parameters = param;
                        options.action = "insertClassifiComp";
                        var Component = this;
                        options.callback = function(data) {
                                var retText = data.response;
                                if (retText == "1") {
                                        Component.fireEvent("onClassificationSucess", {
                                                source : Component
                                        });
                                } else {
                                        Component.fireEvent("onClassificationError", {
                                                source : Component
                                        });
                                }

                        };
                        var result = Request.sendBizRequest(options);

                        /*
                         * // 保存后 Component.fireEvent("onAfterSave", { source : Component
                         * });
                         */
                },

                // 初始化时调用的方法
                doInit : function(value, bindingContext) {

                },

                doChange : function(evt) {

                },

                onSaveCommit : function(evt) {
                },

                _doClick : function(evt) {
                },

                _doChange : function(evt) {

                },
                setFiter : function(name, filter) {

                },
                refreshData : function() {

                },

                // 属性发生改变是触发的方法,主要是处理一些根据属性值更新界面的操作
                propertyChangedHandler : function(key/* 属性名 */, oldVal/* 旧值 */, value/* 新值 */) {
                        debugger;
                        alert(key);
                }

        // 更多......
        });

        // 注册组件
        justep.Component.register(url, classification);

        // 返回组件类
        return classification;
});


还有个问题  我如何能把 主BIZDATA的关系(a1,a2,a3)的数据 映射到  classification 种的关系中 (点击保存后 主表的数据 映射到classification表中 )
回复 支持 反对

使用道具 举报

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35880
发表于 2016-5-23 14:13:19 | 显示全部楼层
/UI2/system/components/justep/data/data.js中级联保存从表的doSlaveDataSave函数
自己跟踪看看什么地方调用的这个函数
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

184

主题

707

帖子

2333

积分

金牌会员

Rank: 6Rank: 6

积分
2333
QQ
 楼主| 发表于 2016-5-24 08:46:37 | 显示全部楼层
jishuang 发表于 2016-5-23 14:13
/UI2/system/components/justep/data/data.js中级联保存从表的doSlaveDataSave函数
自己跟踪看看什么地方调 ...

我在data.js里打DEBUGGER 调试 但是进不了调试模式  但是 我自己做的组件能进入调试模式
是不 平台自带的组件调试需要什么地方设置么?
回复 支持 反对

使用道具 举报

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35880
发表于 2016-5-24 10:40:28 | 显示全部楼层
平台的组件都用的是合并的文件,不是用的组件下面的文件
http://doc.wex5.com/?p=4496#1.2
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

184

主题

707

帖子

2333

积分

金牌会员

Rank: 6Rank: 6

积分
2333
QQ
 楼主| 发表于 2016-5-24 17:29:16 | 显示全部楼层
jishuang 发表于 2016-5-24 10:40
平台的组件都用的是合并的文件,不是用的组件下面的文件
http://doc.wex5.com/?p=4496#1.2 ...

123.png
划线的属性怎么获取 ? 在下面的方法获取不到 ?这个方法调不到啊 是在这个方法获取么?
回复 支持 反对

使用道具 举报

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35880
发表于 2016-5-24 18:04:30 | 显示全部楼层
看平台的data的实现啊
运行时的要看运行时的实现
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

184

主题

707

帖子

2333

积分

金牌会员

Rank: 6Rank: 6

积分
2333
QQ
 楼主| 发表于 2016-5-25 09:16:41 | 显示全部楼层
1,justep.BindComponent.extend 我绑定的是这个基类  不是个BIZDATA ,
2. 主表用的是平台提供的BIZDATA  我自己的组件上有个主从关系 那么他俩能关联到一起么?(平台的主从表都是用BIZDATA组件)
3。我就是想主表保存后(BIZDATA) 触发组件保存,组件在属性里获取主表的ID,和关联的信息 (这些信息在组件设计属性里关联)然后后台JAVA保存
我不知道我的思路对不?
要不大神给给思路?
回复 支持 反对

使用道具 举报

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35880
发表于 2016-5-25 10:54:49 | 显示全部楼层
1.data同样可以设置主从,不一定要用bizData设置
2.要按照平台的设置,需要自己能看懂平台data组件的实现代码,不是所以的代码都有说明的
3.3楼已经发了平台的data级联保存的时候调用的函数了,看函数的具体实现怎么关联从的
   获取bind-ref绑定的值可以参考input中bind-ref值的获取
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-3-29 21:01 , Processed in 0.085407 second(s), 26 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表