跟我一起学extjs5(40--增加一个自定义模块[1建立表和bean文件])
跟我一起学extjs5(40--增加一个自定义模块[1建立表和bean文件])
/****** 对象: Table [dbo].[Agreement] 脚本日期: 10/16/2014 14:13:11 ******/ CREATE TABLE [dbo].[Agreement]( [tf_agreementId] [int] NOT NULL, [tf_code] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_customerNme] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_orderId] [int] NULL, [tf_signDate] [datetime] NOT NULL, [tf_productName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_salesman] [nchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL, [tf_number] [int] NOT NULL, [tf_allLength] [money] NULL, [tf_unitPrice] [money] NOT NULL, [tf_unitText] [nvarchar](10) COLLATE Chinese_PRC_CI_AS NULL, [tf_discount] [money] NOT NULL CONSTRAINT [DF_Agreement_tf_discount] DEFAULT ((1)), [tf_amount] AS (round(([tf_number]*[tf_unitPrice])*[tf_discount],(2))), [tf_receivedPrice] [money] NULL, [tf_receivedPercent] AS (case when ([tf_number]*[tf_unitPrice])*[tf_discount]<>(0) then [tf_receivedPrice]/round(([tf_number]*[tf_unitPrice])*[tf_discount],(2)) else (0) end), [tf_finished] [bit] NULL, [tf_isImportant] [bit] NULL, [tf_beginDate] [datetime] NULL, [tf_endDate] [datetime] NULL, [tf_remark] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK_Agreement] PRIMARY KEY CLUSTERED ( [tf_agreementId] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO /****** 对象: Index [IX_Agreement_tf_name] 脚本日期: 10/16/2014 14:13:53 ******/ CREATE UNIQUE NONCLUSTERED INDEX [IX_Agreement_tf_name] ON [dbo].[Agreement] ( [tf_name] ASC )WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
package com.jfok.server.hibernate.app; import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import org.hibernate.annotations.GenericGenerator; import com.jfok.server.common.annotation.FieldDefine; import com.jfok.server.common.annotation.TableDefine; /** * 一个用于演示单个模块所有自定义属性的类 * * @author jfok * * 2014.10.16 * */ @SuppressWarnings("serial") @Entity @org.hibernate.annotations.Entity(dynamicUpdate = true) @TableDefine(group = "合同管理", id = 2010, title = "销售合同") public class Agreement implements Serializable { @Id @GeneratedValue(generator = "increment") @GenericGenerator(name = "increment", strategy = "increment") @FieldDefine(title = "ID号", number = 10, hidden = true) private Integer tf_agreementId; @FieldDefine(title = "合同编码", number = 20) @Column(nullable = false, length = 20) private String tf_code; // 这个字段是这个模块的namefields字段,在删除等操作时会提示显示这个字段的信息 @FieldDefine(title = "合同名称", nameField = true, number = 30) @Column(length = 50, nullable = false) private String tf_name; // 因为是一个独白模块,没有做相应的客户单位,产品名称的表来关联 @FieldDefine(title = "客户单位名称", number = 40) @Column(length = 50, nullable = false) private String tf_customerNme; @FieldDefine(title = "顺序号", number = 50) private Integer tf_orderId; @FieldDefine(title = "签订日期", number = 60) @Column(nullable = false) private Date tf_signDate; @FieldDefine(title = "产品名称", number = 70) @Column(length = 50, nullable = false) private String tf_productName; @FieldDefine(title = "销售员", number = 80) @Column(length = 10, nullable = false) private String tf_salesman; @FieldDefine(title = "数量", number = 90) @Column(nullable = false) private Integer tf_number; @FieldDefine(title = "总长度", number = 100) private Double tf_allLength; @FieldDefine(title = "单价", number = 110, money = true) private Double tf_unitPrice; @FieldDefine(title = "计量单位", number = 120) @Column(length = 10) private String tf_unitText; // 默认折扣是 1.00,即不打折 @FieldDefine(title = "折扣", number = 130, percent = true) private Double tf_discount = 1.0; @FieldDefine(title = "总金额", number = 140, money = true, remark = "总金额=数量*单价*折扣") @Column(updatable = false, insertable = false) private Double tf_amount; @FieldDefine(title = "已收金额", number = 150, money = true) private Double tf_receivedPrice; @FieldDefine(title = "已收比例", number = 160, percent = true, remark = "已收比例=已收金额/总金额") @Column(updatable = false, insertable = false) private Double tf_receivedPercent; @FieldDefine(title = "是否完成", number = 170) private Boolean tf_finished; @FieldDefine(title = "是否重要", number = 180) private Boolean tf_isImportant; @FieldDefine(title = "开始时间", number = 190) private Date tf_beginDate; @FieldDefine(title = "结束时间", number = 200) private Date tf_endDate; @FieldDefine(title = "备注", number = 290) private String tf_remark; public Agreement() { } //getter and setter }
<!-- 合同管理 --> <mapping class="com.jfok.server.hibernate.app.Agreement" />
根据我这套系统的最终设计目标,新增一个模块只要做上面二步就行了,那么下面我们来具体的实现一下过程。
{ text : '导入', handler : function() { Ext.MessageBox.prompt('增加模块', '请输入要增加模块的类名称:', function(btn, text) { if (btn == 'ok') { Ext.Ajax.request({ scope : this, url : 'systemframe/addmodule.do', params : { moduleName : text }, success : function(response) { if (response.responseText) Ext.MessageBox.show({ title : '导入失败', msg : '导入模块失败<br/><br/>' + response.responseText, buttons : Ext.MessageBox.OK, icon : Ext.MessageBox.ERROR }); else { Ext.toastInfo('增加模块', '模块:' + text + '的定义和grid,form定义已经到加系统中!'); } }, failure : function() { window.alert(text + '保存失败!') } }) } }) } }
现在可以来导入Agreement 的信息了。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。