DocGrid.js.svn-base 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. Ext.define('erp.view.oa.doc.DocGrid', {
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.docgrid',
  4. id:'docgrid',
  5. columns:[{
  6. text:'ID',
  7. dataIndex:'dl_id',
  8. width:0,
  9. },{
  10. cls : "x-grid-header-1",
  11. text: '文档名称',
  12. dataIndex: 'dl_name',
  13. flex: 1,
  14. readOnly:true,
  15. renderer:function(val, meta, record){
  16. var style=record.data.dl_style;
  17. if(style!='目录') return '<img src="'+basePath+'jsps/oa/doc/resources/images/docico/icon-'+style+'.gif">' + val;
  18. else return '<img src="'+basePath+'resource/images/icon/folder_Close.gif">'+val;
  19. }
  20. },{
  21. cls : "x-grid-header-1",
  22. text: '锁定状态',
  23. dataIndex: 'dl_locked',
  24. width:100,
  25. readOnly:true,
  26. renderer:function(val, meta, record){
  27. if(val==-1) return '<img src="'+basePath+'resource/images/icon/lock.png">';
  28. else return '';
  29. }
  30. },{
  31. cls : "x-grid-header-1",
  32. text: '文件类型',
  33. dataIndex: 'dl_style',
  34. width:100
  35. },{
  36. cls : "x-grid-header-1",
  37. text:'文件大小',
  38. dataIndex: 'dl_size',
  39. width:100,
  40. readOnly:true,
  41. renderer:function(val,meta,record){
  42. if(record.data.dl_kind==-1){
  43. return "/";
  44. }else {
  45. var f = parseFloat(val);
  46. if (isNaN(f)) {
  47. return;
  48. }
  49. f = Ext.util.Format.number(Math.round(val*100)/(100*1024*1024),'0.00');
  50. return f+" MB";
  51. }
  52. }
  53. },{
  54. cls : "x-grid-header-1",
  55. text:'更新时间',
  56. dataIndex:'dl_createtime',
  57. readOnly:true,
  58. width:150,
  59. xtype:"datecolumn",
  60. format:"Y-m-d H:i:s"
  61. },{
  62. cls:'x-grid-header-1',
  63. text:'创建者',
  64. dataIndex:'dl_creator',
  65. width:100,
  66. readOnly:true
  67. },{
  68. cls : "x-grid-header-1",
  69. text:'是否文件夹',
  70. dataIndex: 'dl_kind',
  71. width:0,
  72. flex: 0,
  73. readOnly:true
  74. }],
  75. store: Ext.create('Ext.data.Store', {
  76. fields: [{
  77. name: 'dl_id',
  78. type: 'number'
  79. },{
  80. name:'dl_name',
  81. type:'string'
  82. },{
  83. name: 'dl_locked',
  84. type: 'number'
  85. },{
  86. name:'dl_style',
  87. type:'string'
  88. },{
  89. name:'dl_size',
  90. type:'float'
  91. },{
  92. name:'dl_createtime',
  93. type:'date'
  94. },{
  95. name:'dl_creator',
  96. type:'string'
  97. },{
  98. name:'dl_kind',
  99. type:'number'
  100. }],
  101. sorters: [{
  102. property : 'dl_createtime',
  103. direction: 'DESC'
  104. }]
  105. }),
  106. selModel: Ext.create('Ext.selection.CheckboxModel',{
  107. listeners:{
  108. 'select': function(selModel, record){
  109. //selModel.view.ownerCt.selectAllPower(record);
  110. },
  111. 'deselect': function(selModel, record){
  112. //selModel.view.ownerCt.deselectAllPower(record);
  113. }
  114. },
  115. onHeaderClick: function(headerCt, header, e) {
  116. var grid = headerCt.ownerCt;
  117. if (header.isCheckerHd) {
  118. var isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');
  119. if (!isChecked) {
  120. grid.store.each(function(item){
  121. grid.selectAllPower(item);
  122. });
  123. grid.selModel.selectAll();
  124. } else {
  125. grid.store.each(function(item){
  126. grid.deselectAllPower(item);
  127. });
  128. grid.selModel.deselectAll();
  129. }
  130. }
  131. }
  132. }),
  133. initComponent: function(){
  134. this.addEvents(
  135. 'rowdblclick',
  136. 'select'
  137. );
  138. this.callParent(arguments);
  139. this.on('selectionchange', this.onSelect, this);
  140. },
  141. getItemData: function(parentId,record){
  142. var me = this;
  143. me.setLoading(true);
  144. var condition=parentId==5?"dl_statuscode='DELETED'":"dl_statuscode='AUDITED'";
  145. Ext.Ajax.request({
  146. url : basePath + 'oa/docuemtlist/getDocumentsByParentId.action',
  147. params: {
  148. parentId:parentId,
  149. condition:condition,
  150. _self: false
  151. },
  152. method : 'post',
  153. callback : function(options,success,response){
  154. me.setLoading(false);
  155. var res = new Ext.decode(response.responseText);
  156. if(res.exception || res.exceptionInfo){
  157. showError(res.exceptionInfo);
  158. return;
  159. }
  160. me.store.loadData(res.docs);
  161. if(record!=null) me.getSelectionModel().select(record.index);
  162. }
  163. });
  164. },
  165. onRowDblClick: function(view, record, item, index, e) {
  166. this.fireEvent('rowdblclick', this, this.store.getAt(index));
  167. },
  168. onSelect: function(model, selections){
  169. var selected = selections[0];
  170. if (selected) {
  171. this.fireEvent('select', this, selected);
  172. }
  173. },
  174. onLoad: function(){
  175. this.getSelectionModel().select(0);
  176. },
  177. loadFeed: function(url){
  178. var store = this.store;
  179. store.getProxy().extraParams.feed = url;
  180. store.load();
  181. },
  182. formatTitle: function(value, p, record){
  183. return Ext.String.format('<div class="topic"><b>{0}</b><span class="author">{1}</span></div>', value, record.get('author') || "Unknown");
  184. }
  185. });