Ext.define('erp.view.oa.doc.DocTabPanel',{ extend: 'Ext.tab.Panel', alias: 'widget.erpDocTabPanel', id: 'doctab', collapsible :false, header :false, defaults: { autoScroll:true }, activeTab: 0, region: 'south', tabBar:{ cls:'bg_tabs', }, GridUtil: Ext.create('erp.util.GridUtil'), BaseUtil: Ext.create('erp.util.BaseUtil'), split: true, plain:true, flex:2, minHeight: 80, border: false, autoShow: true, currentDoc:null, currentType:-1, powers:{SEE:'dp_see',CONTROL:'dp_control',DOWNLOAD:'dp_download'}, defaultItems:[{ title:'目录信息', id:0, indexId:0, DocId:-1, groupType:-1, layout:'fit', items:[{ xtype:'form', id:'folderForm', layout:'column', autoScroll:true, bodyPadding: 5, bodyStyle:'background:#fafafa;', defaults: { anchor: '100%', readOnly:true, columnWidth:0.33, labelStyle:'font-weight: bold; ', fieldStyle : 'background:#fafafa;border-bottom:none;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;border-bottom-style:1px solid;border-left:none;', }, defaultType: 'textfield', items:[{ fieldLabel: '目录名称', name: 'dl_name', value:'目录名称' },{ fieldLabel: '目录', name: 'dl_virtualpath' },{ fieldLabel: '文档数', name: 'em_code' },{ fieldLabel:'创建时间', name:'dl_createtime', xtype:'datetimefield', format :'Y-m-d H:i:s' },{ fieldLabel:'目录描述', name:'dl_remark', },{ fieldLabel:'目录ID', name:'dl_id' }] }] },{ title:'目录订阅', id:1, indexId:1, DocId:-1, groupType:-1, bodyStyle:'background:#fafafa;', items:[{ xtype:'button', text:'订阅本目录', cls:'button1 pill', style:'margin-left:20px;margin-top:5px;', handler:function(btn){ if(btn.text=='订阅本目录'){ btn.setText('取消订阅本目录'); }else btn.setText('订阅本目录'); } },{ xtype:'button', text:'批量订阅', cls:'button1 pill', style:'margin-left:20px;margin-top:5px;' },{ xtype:'textfield', labelWidth:150, style:'margin-left:20px', labelStyle:'font-weight: bold;', fieldStyle : 'background:#fafafa;border-bottom:none;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;border-bottom-style:1px solid;border-left:none;', fieldLabel:'已订阅本目录的用户', value:'无' }] },{ title:'权限管理', id:2, indexId:2, DocId:-1, groupType:-1, layout:'fit', listeners:{ activate:function(tab){ tab.items.items[0].loadNewStore(); } }, items:[{ xtype:'gridpanel', columns:DOC.columns.PowerColumns, powerSet:['dp_control','dp_see','dp_save','dp_read','dp_delete','dp_print','dp_download','dp_upload'], tbar: [{ xtype:'button', text:'设置权限', cls:'button1 pill', id:'setpower', style:'margin-left:20px; margin-top:5px;', }], features : [Ext.create('Ext.grid.feature.GroupingSummary',{ groupHeaderTpl: '{name} (共:{rows.length}条)' })], autoScroll:true, region: 'south', layout : 'fit', plugins: [Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 })], store: Ext.create('Ext.data.Store', { groupField: 'dp_type', fields:DOC.fields.PowerFields }), loadNewStore:function(){ var docpanel=Ext.getCmp('doctab'); docpanel.loadPowerStore(this,{ caller:'DocumentListPower', condition:"dp_dclid="+CurrentFolderId }); } }] },{ title:'文档链接', id:3, indexId:3, DocId:-1, groupType:-1, items:[{ xtype:'gridpanel', columns:DOC.columns.LinkColumns }] },{ title:'文档信息', groupType:0, id:4, indexId:4, DocId:-1, hidden:true, layout:'fit', items:[{ xtype:'form', id:'docForm', layout:'column', autoScroll:true, bodyStyle:'background:#fafafa;', bodyPadding: 5, defaults: { anchor: '100%', readOnly:true, columnWidth:0.33, labelWidth:70, labelStyle:'font-weight: bold; ', fieldStyle : 'background:#fafafa;border-bottom:none;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;border-bottom-style:1px solid;border-left:none;', }, listeners :{ afterrender:function(form){ var docpanel=Ext.getCmp('doctab'); var data=docpanel.currentDoc!=null?docpanel.currentDoc:Ext.getCmp('docgrid').getSelectionModel(); form.getForm().setValues(docpanel.currentDoc); } }, defaultType: 'textfield', items:[{ fieldLabel: '编号', name: 'dl_code' },{ fieldLabel: '文档名称', name: 'dl_name' },{ fieldLabel: '目录', name: 'dl_virtualpath' },{ xtype: 'container', layout:'column', items:[{ name:'dl_version', xtype:'textfield', labelWidth:70, labelStyle:'font-weight: bold; ', fieldLabel:'版本号', fieldStyle : 'background:#fafafa;border-bottom:none;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;border-bottom-style:1px solid;border-left:none;', columnWidth:0.5 },{ xtype:'button', id:'updatedoc', text:'修改', cls:'button1 pill', style:'margin-left:5px;', columnWidth:0.2 },{ xtype:'button', text:'历史', cls:'button1 pill', style:'margin-left:5px;', columnWidth:0.2 }] },{ fieldLabel:'大小', name:'dl_size' },{ fieldLabel:'目录描述', name:'dl_remark', },{ fieldLabel:'创建人', name:'dl_creator' },{ fieldLabel:'创建时间', name:'dl_createtime', xtype:'datetimefield', format :'Y-m-d H:i:s' },{ fieldLabel:'当前状态', name:'dl_status' },{ xtype: 'container', layout:'column', items:[{ name:'dl_locked', xtype:'textfield', labelWidth:70, labelStyle:'font-weight: bold; ', fieldLabel:'锁定状态', fieldStyle : 'background:#fafafa;border-bottom:none;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;border-bottom-style:1px solid;border-left:none;', columnWidth:0.7, listeners:{ change:function(field,newvalue){ newvalue=(newvalue==0 || newvalue=='未锁定')?'未锁定':'已锁定'; field.setValue(newvalue); var lockbutton=Ext.getCmp('lockbutton'),buttontext=newvalue=='未锁定'?'锁定':'解锁'; lockbutton.setText(buttontext); } } },{ xtype:'button', text:'锁定', id:'lockbutton', cls:'button1 pill', style:'margin-left:5px;', columnWidth:0.2 }] },{ fieldLabel:'点击数', name:'dl_hits' },{ fieldLabel:'目录ID', name:'dl_id' }] }] },{ title:'修订版管理', groupType:0, id:5, indexId:5, DocId:-1, hidden:true, items:[{ xtype:'gridpanel', columns:DOC.columns.HistoryColumns, store:Ext.create('Ext.data.Store', { fields:DOC.fields.VersionFields, data:[] }) }], listeners:{ activate:function(tab){ var docpanel=Ext.getCmp('doctab'); var data=docpanel.currentDoc!=null?docpanel.currentDoc:Ext.getCmp('docgrid').getSelectionModel(); docpanel.loadNewStore(tab.items.items[0],{ caller:'DocumentVersion', condition:"dv_dlid="+data.dl_id }); } } },{ title:'文档评论', groupType:0, id:6, indexId:6, DocId:-1, hidden:true, autoScroll:true, listeners:{ activate:function(tab){ var docpanel=Ext.getCmp('doctab'); var data=docpanel.currentDoc!=null?docpanel.currentDoc:Ext.getCmp('docgrid').getSelectionModel(); docpanel.loadNewStore(tab.items.items[0],{ caller:'DocumentReview', condition:"dr_dlid="+data.dl_id }); } }, items:[{ xtype:'gridpanel', columns:DOC.columns.ReviewColumns, store:Ext.create('Ext.data.Store', { fields:DOC.fields.ReviewFields, data:[] }) },{ xtype:'form', style:'padding-top:15px;', autoScroll:true, border: false, height:150, layout:'column', defaults:{ columnWidth:0.33 }, bodyStyle:'background:#fafafa;', items:[{ xtype:'textfield', fieldStyle : 'background:#fafafa;border-bottom:none;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;border-bottom-style:1px solid;border-left:none;' },{ xtype: 'textareafield', fieldLabel: '
发表评论
', labelCls:'x-form-item-label x-form-item-label-top', name:'talk', id:'talk', labelSeparator:'', style:'padding-left:50px', allowBlank: false, width:300 }], buttonAlign:'center', buttons:[{ text:'保存', cls:'button1 pill', style:'margin-top:5px;', xtype:'button', handler:function(btn){ var doctab=btn.ownerCt.ownerCt.ownerCt; var o={ dr_remark:Ext.getCmp('talk').value, dr_dlid:doctab.ownerCt.currentDoc.dl_id }; Ext.Ajax.request({ url : basePath + 'oa/Doc/review.action', params : { formStore:unescape(Ext.JSON.encode(o).replace(/\\/g,"%")) }, method : 'post', callback : function(options,success,response){ var localJson = new Ext.decode(response.responseText); if(localJson.exceptionInfo){ var str = localJson.exceptionInfo; showError(str); }else { showResult('提示','评论成功!',btn); var grid=doctab.items.items[0]; Ext.getCmp('talk').reset(); doctab.ownerCt.loadNewStore(grid,{ caller:'DocumentReview', condition:"dr_dlid="+doctab.ownerCt.currentDoc.dl_id }) } } }); } }] }] },{ title:'文档审计', groupType:0, id:7, indexId:7, DocId:-1, hidden:true, items:[{ xtype:'gridpanel', columns:DOC.columns.LogColumns }] },{ title:'摘要及省略图', groupType:0, id:8, indexId:8, DocId:-1, hidden:true, items:[{ xtype:'button', text:'增加文档摘要', cls:'button1 pill', style:'margin-left:20px;margin-top:10px;', handler:function(btn){ } },{ xtype:'button', text:'打印图片', cls:'button1 pill', style:'margin-left:20px;margin-top:10px;' }] },{ title:'关联文档', groupType:0, id:9, indexId:9, DocId:-1, hidden:true, items:[{ xtype: 'container', layout:'column', style:'margin-top:5px;background:transparent;', bodyStyle:'background:transparent;', items:[{ xtype:'textfield', fieldStyle : 'background:transparent;border-bottom:none;padding:2px 2px;vertical-align:middle;border-top:none;border-right:none;border-bottom-style:1px solid;border-left:none;', columnWidth:0.33 },{ name:'code', xtype:'textfield', labelWidth:70, labelStyle:'font-weight: bold; ', fieldLabel:'文档编号', columnWidth:0.2 },{ xtype:'button', id:'addrelatedoc', text:'增加关联文档', cls:'button1 pill', style:'margin-left:5px;', columnWidth:0.1 }] },{ xtype:'gridpanel', columns:DOC.columns.RelateColumns }] },{ title:'借阅情况', groupType:0, id:10, indexId:10, DocId:-1, hidden:true, items:[{ xtype:'gridpanel', columns:DOC.columns.BorrowColumns }] }], defaults:{ active:function(tab){ var dlid=tab.ownerCt.currentDoc.data.dl_id; if(tab.DocId !=tab.ownerCt.currentDoc.data.dl_id){ //说明切换了 tab.ownerCt.changeTab(); tab.DocId=dlid; } } }, initComponent : function(){ this.items=this.defaultItems; this.addEvents({ tabItemChange: true }); this.callParent(arguments); }, listeners:{ tabItemChange:function(tabpanel,record){ if(record && record.data !=this.currentDoc){ this.currentDoc=record.data; var kind=record.data.dl_kind ==0?0:-1; if(record.data.dl_kind!=this.currentType){ this.changeItems(record,kind); }else this.changeItems(record); } } }, changeItems:function(record,type){ if(type!=null){ Ext.Array.each(this.items.items,function(item){ if(item.groupType!=type){ item.tab.hide(); }else { if(item.title=='权限管理'){ var doctab=Ext.getCmp('doctab'); var bool=doctab.checkPowerByFolderId(CurrentFolderId,doctab.powers.CONTROL); if(bool) item.tab.show(); else item.tab.hide(); }else item.tab.show(); } }); if(this.currentType!=type && this.activeTab.indexId>3) this.setActiveTab(this.activeTab.indexId-4); else if(this.currentType!=type && this.activeTab.indexId<4) this.setActiveTab(this.activeTab.indexId+4); else { var tab=this.getActiveTab(); tab.fireEvent('activate', tab); } this.currentType=type; }else { if(this.currentType==-1){ Ext.getCmp('folderForm').getForm().setValues(record.data); }else { Ext.getCmp('docForm').getForm().setValues(record.data); } } }, loadNewStore: function(grid, param){ var me = this; Ext.Ajax.request({//拿到grid的columns url : basePath + "common/loadNewGridStore.action", params: param, method : 'post', callback : function(options,success,response){ var res = new Ext.decode(response.responseText); if(res.exceptionInfo){ showError(res.exceptionInfo);return; } var data = res.data; if(!data || data.length == 0){ grid.store.removeAll(); } else { grid.store.loadData(data); } //自定义event grid.addEvents({ storeloaded: true }); grid.fireEvent('storeloaded', grid, data); } }); }, loadPowerStore: function(grid, param){ var me = this; Ext.Ajax.request({//拿到grid的columns url : basePath + "common/loadNewGridStore.action", params: param, method : 'post', callback : function(options,success,response){ var res = new Ext.decode(response.responseText); if(res.exceptionInfo){ showError(res.exceptionInfo);return; } var data = res.data; Ext.each(res.data, function(item){ Ext.each(grid.powerSet, function(pp){ item[pp] = item[pp] == 1; }); }); if(!data || data.length == 0){ grid.store.removeAll(); } else { grid.store.loadData(data); } //自定义event grid.addEvents({ storeloaded: true }); grid.fireEvent('storeloaded', grid, data); } }); }, checkPowerByFolderId:function(folderId,type){ var me = this,bool=false; Ext.Ajax.request({//拿到grid的columns url : basePath + "doc/CheckPowerByFolderId.action", params: { folderId:folderId, type:type }, async:false, method : 'post', callback : function(options,success,response){ var res = new Ext.decode(response.responseText); bool=res.bool; } }); return bool; } });