DataDictionaryGrid.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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(record.get('data_type')=='CLOB' || record.get('data_type')=='BLOB') return null;
  156. if(val){
  157. if(record.get('data_type')=='DATE' && val==7 ) return null;
  158. }
  159. return val;
  160. }
  161. },{
  162. dataIndex:'data_precision',
  163. cls: "x-grid-header-1",
  164. text:'字段精度',
  165. sortable:false,
  166. width:100,
  167. editor:{
  168. xtype:'numberfield',
  169. hideTrigger:true
  170. }
  171. },{
  172. dataIndex:'nullable',
  173. cls: "x-grid-header-1",
  174. text:'允许为空',
  175. sortable:false,
  176. width:80,
  177. editor:{
  178. xtype:'combo',
  179. queryMode: 'local',
  180. displayField: 'type',
  181. valueField: 'type',
  182. editable:false,
  183. store:Ext.create('Ext.data.Store',{
  184. fields:['type'],
  185. data:[{type:'Y'},
  186. {type:'N'}]
  187. })
  188. }
  189. },{
  190. dataIndex:'data_default',
  191. cls: "x-grid-header-1",
  192. text:'默认值',
  193. sortable:false,
  194. flex:100,
  195. editor:{
  196. xtype:'textfield'
  197. }
  198. }]
  199. }],
  200. store:Ext.create('Ext.data.Store',{
  201. fields:['column_name','data_type',{name:'data_length',type:'int',format:0},'data_precision','nullable','data_default',{name:'comments',type:'string',format:''}],
  202. proxy: {
  203. type: 'ajax',
  204. url: basePath+'/common/getDetail.action',
  205. extraParams :{
  206. tablename:tablename
  207. },
  208. reader: {
  209. type: 'json',
  210. root: 'list',
  211. idProperty:'column_name'
  212. }
  213. },
  214. autoLoad: true
  215. })
  216. })
  217. this.callParent(arguments);
  218. }
  219. });