123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- Ext.define('erp.view.oa.doc.DocGrid', {
- extend: 'Ext.grid.Panel',
- alias: 'widget.docgrid',
- id:'docgrid',
- columns:[{
- text:'ID',
- dataIndex:'dl_id',
- width:0,
- },{
- cls : "x-grid-header-1",
- text: '文档名称',
- dataIndex: 'dl_name',
- flex: 1,
- readOnly:true,
- renderer:function(val, meta, record){
- var style=record.data.dl_style;
- if(style!='目录') return '<img src="'+basePath+'jsps/oa/doc/resources/images/docico/icon-'+style+'.gif">' + val;
- else return '<img src="'+basePath+'resource/images/icon/folder_Close.gif">'+val;
- }
- },{
- cls : "x-grid-header-1",
- text: '锁定状态',
- dataIndex: 'dl_locked',
- width:100,
- readOnly:true,
- renderer:function(val, meta, record){
- if(val==-1) return '<img src="'+basePath+'resource/images/icon/lock.png">';
- else return '';
- }
- },{
- cls : "x-grid-header-1",
- text: '文件类型',
- dataIndex: 'dl_style',
- width:100
- },{
- cls : "x-grid-header-1",
- text:'文件大小',
- dataIndex: 'dl_size',
- width:100,
- readOnly:true,
- renderer:function(val,meta,record){
- if(record.data.dl_kind==-1){
- return "/";
- }else {
- var f = parseFloat(val);
- if (isNaN(f)) {
- return;
- }
- f = Ext.util.Format.number(Math.round(val*100)/(100*1024*1024),'0.00');
- return f+" MB";
- }
- }
- },{
- cls : "x-grid-header-1",
- text:'更新时间',
- dataIndex:'dl_createtime',
- readOnly:true,
- width:150,
- xtype:"datecolumn",
- format:"Y-m-d H:i:s"
- },{
- cls:'x-grid-header-1',
- text:'创建者',
- dataIndex:'dl_creator',
- width:100,
- readOnly:true
- },{
- cls : "x-grid-header-1",
- text:'是否文件夹',
- dataIndex: 'dl_kind',
- width:0,
- flex: 0,
- readOnly:true
- }],
- store: Ext.create('Ext.data.Store', {
- fields: [{
- name: 'dl_id',
- type: 'number'
- },{
- name:'dl_name',
- type:'string'
- },{
- name: 'dl_locked',
- type: 'number'
- },{
- name:'dl_style',
- type:'string'
- },{
- name:'dl_size',
- type:'float'
- },{
- name:'dl_createtime',
- type:'date'
- },{
- name:'dl_creator',
- type:'string'
- },{
- name:'dl_kind',
- type:'number'
- }],
- sorters: [{
- property : 'dl_createtime',
- direction: 'DESC'
- }]
- }),
- selModel: Ext.create('Ext.selection.CheckboxModel',{
- listeners:{
- 'select': function(selModel, record){
- //selModel.view.ownerCt.selectAllPower(record);
- },
- 'deselect': function(selModel, record){
- //selModel.view.ownerCt.deselectAllPower(record);
- }
- },
- onHeaderClick: function(headerCt, header, e) {
- var grid = headerCt.ownerCt;
- if (header.isCheckerHd) {
- var isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');
- if (!isChecked) {
- grid.store.each(function(item){
- grid.selectAllPower(item);
- });
- grid.selModel.selectAll();
- } else {
- grid.store.each(function(item){
- grid.deselectAllPower(item);
- });
- grid.selModel.deselectAll();
- }
- }
- }
- }),
- initComponent: function(){
- this.addEvents(
- 'rowdblclick',
- 'select'
- );
- this.callParent(arguments);
- this.on('selectionchange', this.onSelect, this);
- },
- getItemData: function(parentId,record){
- var me = this;
- me.setLoading(true);
- var condition=parentId==5?"dl_statuscode='DELETED'":"dl_statuscode='AUDITED'";
- Ext.Ajax.request({
- url : basePath + 'oa/docuemtlist/getDocumentsByParentId.action',
- params: {
- parentId:parentId,
- condition:condition,
- _self: false
- },
- method : 'post',
- callback : function(options,success,response){
- me.setLoading(false);
- var res = new Ext.decode(response.responseText);
- if(res.exception || res.exceptionInfo){
- showError(res.exceptionInfo);
- return;
- }
- me.store.loadData(res.docs);
- if(record!=null) me.getSelectionModel().select(record.index);
- }
- });
- },
- onRowDblClick: function(view, record, item, index, e) {
- this.fireEvent('rowdblclick', this, this.store.getAt(index));
- },
- onSelect: function(model, selections){
- var selected = selections[0];
- if (selected) {
- this.fireEvent('select', this, selected);
- }
- },
- onLoad: function(){
- this.getSelectionModel().select(0);
- },
- loadFeed: function(url){
- var store = this.store;
- store.getProxy().extraParams.feed = url;
- store.load();
- },
- formatTitle: function(value, p, record){
- return Ext.String.format('<div class="topic"><b>{0}</b><span class="author">{1}</span></div>', value, record.get('author') || "Unknown");
- }
- });
|