DataDictionaryGrid.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. Ext.define('erp.view.ma.DataDictionaryGrid',{
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.dictionarygrid',
  4. layout : 'fit',
  5. id: 'grid',
  6. emptyText : $I18N.common.grid.emptyText,
  7. columnLines : true,
  8. autoScroll : true,
  9. dockedItems: [{
  10. xtype: 'toolbar',
  11. dock: 'top',
  12. items: [{
  13. xtype:'button',
  14. iconCls:'x-button-icon-add',
  15. itemId:'column_add',
  16. text:'添加'
  17. },{
  18. xtype:'button',
  19. iconCls:'x-button-icon-delete2',
  20. itemId:'column_delete',
  21. text:'删除'
  22. }]
  23. }],
  24. bodyStyle: 'background-color:#f1f1f1;',
  25. plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
  26. clicksToEdit: 1,
  27. listeners:{
  28. beforeedit:function(e){
  29. var g=e.grid,r=e.record,f=e.field;
  30. if(g.binds){
  31. var bool=true;
  32. Ext.Array.each(g.binds,function(item){
  33. if(Ext.Array.contains(item.fields,f)){
  34. Ext.each(item.refFields,function(field){
  35. if(r.get(field)!=null && r.get(field)!=0 && r.get(field)!='' && r.get(field)!='0'){
  36. bool=false;
  37. }
  38. });
  39. }
  40. });
  41. return bool;
  42. }
  43. }
  44. }
  45. }), Ext.create('erp.view.core.plugin.CopyPasteMenu')],
  46. GridUtil: Ext.create('erp.util.GridUtil'),
  47. BaseUtil: Ext.create('erp.util.BaseUtil'),
  48. dbfinds: [],
  49. caller: null,
  50. condition: null,
  51. gridCondition:null,
  52. columnLines:true,
  53. plugins: [Ext.create('erp.view.core.grid.HeaderFilter'),Ext.create('Ext.grid.plugin.CellEditing', {
  54. clicksToEdit: 1,
  55. })],
  56. necessaryFields:['column_name','data_type'],
  57. initComponent : function(){
  58. var me=this;
  59. Ext.apply(me,{
  60. columns:[{
  61. dataIndex:'column_name',
  62. cls: "x-grid-header-1",
  63. text:'列名',
  64. sortable:false,
  65. renderer:function(val){
  66. if(val != null && val.toString().trim() != ''){
  67. return val;
  68. } else {
  69. return '<img src="' + basePath + 'resource/images/icon/need.png" title="必填字段">' +
  70. '<span style="color:blue;padding-left:2px;" title="必填字段">' + val + '</span>';
  71. }
  72. },
  73. width:200,
  74. filter: {xtype:"textfield", filterName:"column_name"},
  75. editor:{
  76. xtype:'textfield',
  77. field:'column_name'
  78. }
  79. },{
  80. dataIndex:'data_type',
  81. cls: "x-grid-header-1",
  82. text:'数据类型',
  83. sortable:false,
  84. width:120,
  85. filter: {xtype:"textfield", filterName:"data_type"},
  86. renderer:function(val,meta,record){
  87. if(val){
  88. if(val=='VARCHAR2'){
  89. if(!record.get('data_length')){
  90. record.set('data_length',20);
  91. }
  92. }else if(val=='CLOB' || val=='DATE' || val=='TIMESTAMP'){
  93. if(record.get('data_length') && record.get('data_length')!=7) record.set('data_length',null);
  94. }
  95. }
  96. return val;
  97. },
  98. editor:{
  99. xtype:'combo',
  100. editable:false,
  101. queryMode: 'local',
  102. displayField: 'type',
  103. valueField: 'type',
  104. store:Ext.create('Ext.data.Store',{
  105. fields:['type'],
  106. data:[{type:'VARCHAR2'},{
  107. type:'NUMBER'
  108. },{
  109. type:'DATE'
  110. },{
  111. type:'CLOB'
  112. },{
  113. type:'TIMESTAMP'
  114. },{
  115. type:'FLOAT'
  116. }]
  117. })
  118. }
  119. },{
  120. dataIndex:'comments',
  121. cls: "x-grid-header-1",
  122. text:'注释',
  123. sortable:false,
  124. format:'',
  125. flex:1,
  126. filter: {xtype:"textfield", filterName:"comments"},
  127. editor:{
  128. xtype:'textfield',
  129. format:''
  130. },
  131. renderer:function(val){
  132. if(val != null && val.toString().trim() != ''){
  133. return val;
  134. } else {
  135. return '<img src="' + basePath + 'resource/images/icon/need.png" title="必填字段">' +
  136. '<span style="color:blue;padding-left:2px;" title="必填字段">' + val + '</span>';
  137. }
  138. }
  139. },{
  140. text:'其他属性',
  141. columns:[{
  142. dataIndex:'data_length',
  143. cls: "x-grid-header-1",
  144. text:'字段长度',
  145. sortable:false,
  146. width:100,
  147. xtype:'numbercolumn',
  148. format:0,
  149. editor:{
  150. xtype:'numberfield',
  151. hideTrigger:true,
  152. name:'data_length'
  153. },
  154. renderer:function(val,meta,record){
  155. if(val){
  156. if(record.get('data_type')=='DATE' && val==7) return null;
  157. }
  158. return val;
  159. },
  160. },{
  161. dataIndex:'data_precision',
  162. cls: "x-grid-header-1",
  163. text:'字段精度',
  164. sortable:false,
  165. width:100,
  166. editor:{
  167. xtype:'numberfield',
  168. hideTrigger:true
  169. }
  170. },{
  171. dataIndex:'nullable',
  172. cls: "x-grid-header-1",
  173. text:'允许为空',
  174. sortable:false,
  175. width:80,
  176. editor:{
  177. xtype:'combo',
  178. queryMode: 'local',
  179. displayField: 'type',
  180. valueField: 'type',
  181. editable:false,
  182. store:Ext.create('Ext.data.Store',{
  183. fields:['type'],
  184. data:[{type:'Y'},
  185. {type:'N'}]
  186. })
  187. }
  188. },{
  189. dataIndex:'data_default',
  190. cls: "x-grid-header-1",
  191. text:'默认值',
  192. sortable:false,
  193. flex:100,
  194. editor:{
  195. xtype:'textfield'
  196. }
  197. }]
  198. }],
  199. store:Ext.create('Ext.data.Store',{
  200. fields:['column_name','data_type',{name:'data_length',type:'int',format:0},'data_precision','nullable','data_default',{name:'comments',type:'string',format:''}],
  201. proxy: {
  202. type: 'ajax',
  203. url: basePath+'/common/getDetail.action',
  204. extraParams :{
  205. tablename:tablename
  206. },
  207. reader: {
  208. type: 'json',
  209. root: 'list',
  210. idProperty:'column_name'
  211. }
  212. },
  213. autoLoad: true
  214. })
  215. })
  216. this.callParent(arguments);
  217. }
  218. });