123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- Ext.define('erp.view.oa.doc.DocPanel',{
- extend: 'Ext.panel.Panel',
- alias: 'widget.erpDocPanel',
- id:'docpanel',
- requires:['erp.view.oa.doc.DocGrid'],
- collapsible :false,
- defaults: {
- autoScroll:true
- },
- style:'margin-top:-5px;',
- flex: 4,
- width:800,
- layout:'fit',
- autoShow: true,
- currentItem:null,
- frame: true,
- layout:'fit',
- dockedItems: [{
- xtype: 'toolbar',
- dock: 'top',
- style:'font-size:18px;',
- layout:'column',
- cls:'maintoolbar',
- defaults:{
- style:'margin-left:10px;margin-top:2px;',
- },
- items: [/*{
- id:'upload',
- text:'上传',
- tooltip:'上传文件' ,
- xtype:'form',
- layout:'column',
- bodyStyle: 'background: transparent no-repeat 0 0;border: none;margin-left:40px;',
- items: [{
- xtype: 'filefield',
- name: 'file',
- buttonOnly: true,
- hideLabel: true,
- anchor: '100%',
- width:90,
- id:'attachfile',
- msgTarget: 'side',
- frame:false,
- buttonConfig: {
- text: '上传',
- cls: 'x-btn',
- },
- listeners: {
- change: function(field){
- var filename = '';
- if(contains(field.value, "\\", true)){
- filename = field.value.substring(field.value.lastIndexOf('\\') + 1);
- } else {
- filename = field.value.substring(field.value.lastIndexOf('/') + 1);
- }
- field.ownerCt.getForm().submit({
- url: basePath + 'common/upload.action?em_code=' + em_code,
- waitMsg: "正在解析文件信息",
- success: function(fp,o){
- if(o.result.error){
- showError(o.result.error);
- } else {
- Ext.Msg.alert("恭喜", filename + " 上传成功!");
- field.setDisabled(true);
- var record=Ext.getCmp('grid').selModel.lastSelected;
- if(record){
- record.set('attachs',filename+";"+o.result.filepath);
- }
- }
- }
- });
- }
- }}]
- },*/{
- xtype:'button',
- id:'uploadDoc',
- text:'上传',
- cls:"button icon arrowup"
- },{
- xtype:'button',
- id:'downloadDoc',
- text:'下载',
- disabled:true,
- cls:"button icon arrowdown"
- },{
- xtype:'button',
- id:'read',
- text:'阅读',
- disabled:true,
- tooltip:'阅读文件',
- cls:"button icon chat"//,
- /*handler:function(btn){
- showResult('提示','当前文件类型不支持在线预览,请先下载!',btn);
- }*/
- },{
- xtype:'button',
- text:'发送',
- id:'publish',
- disabled:true,
- cls:"button icon mail",
- tooltip:'发送文件',
- hidden:true
- },{
- xtype:'button',
- id:'rename',
- text:'重命名',
- disabled:true,
- cls:"button icon edit",
- tooltip:'重命名文件'
- }, {xtype:'button',
- id:'delete',
- text:'删除',
- disabled:true,
- tooltip:'删除文件',
- cls:"button danger icon trash"
- },{
- xtype:'button',
- id:'move',
- text:'移动',
- tooltip:'移动文件',
- disabled:true,
- cls:'button icon move',
- handler:function(button){
- var win = Ext.getCmp('movewin');
- var docpanel=Ext.getCmp('doctab');
- if(!win){
- win=Ext.create('Ext.window.Window',{
- width: 550,
- height:350,
- closeAction: 'destroy',
- id:'movewin',
- layout:'fit',
- title:'<div align="center" class="WindowTitle">移动文件</div>',
- listeners:{
- hide:function(win){
- win.destroy();
- }
- },
- items:[{
- xtype: 'erpDocumentTreePanel',
- bodyStyle:"background-color:#FAFAFA;",
- id:'foldertree',
- store: Ext.create('Ext.data.TreeStore', {
- root: {
- expanded: true,
- children: [{
- text: '公共文档',
- expanded: false,
- url:"/公共文档",
- id:0
- }]
- }
- })
- }],
- buttonAlign:'center',
- buttons:[{
- cls:'x-btn-ok',
- handler:function(btn){
- var grid=Ext.getCmp('docgrid'),me=this;
- var items = grid.selModel.getSelection();
- var select= Ext.getCmp('foldertree').getSelectionModel();
- if(items.length<1) showResult('提示','请选择需要移动的文档!',btn);
- if(select.selected.items.length<1) showResult('提示','请选择需要移动到文件夹!',btn);
- warnMsg('确认移动选中文档或文件夹?', function(btn){
- if(btn == 'yes'){
- var data=new Array();
- Ext.Array.each(items,function(item){
- data.push(Ext.JSON.encode(item.data));
- });
- Ext.Ajax.request({
- url : basePath + 'oa/doc/moveDoc.action',
- params : {
- data :unescape(data.toString()),
- folderId : select.lastSelected.data.id
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- showError(str);
- }else {
- var docpanel=Ext.getCmp('docpanel');
- docpanel.loadNewStore(CurrentFolderId);
- showResult('提示','移动成功!',btn);
- me.up('window').close();
- }
- }
- });
- }
- });
- }
- },{
- cls:'x-btn-close',
- handler:function(btn){
- this.up('window').close();
- }
- }]
- });
- }
- var el=button.getEl();
- button.getEl().dom.disabled = true;
- if (win.isVisible()) {
- win.hide(el, function() {
- el.dom.disabled = false;
- });
- } else {
- win.show(el, function() {
- el.dom.disabled = false;
- Ext.getBody().disabled=true;
- });
- }
- }
- },{
- xtype:'button',
- id:'relate',
- text:'关联',
- tooltip:'关联文件',
- disabled:true,
- cls:'button icon fork',
- handler:function(button){
- var win = Ext.getCmp('relatewin');
- var docpanel=Ext.getCmp('doctab');
- if(!win){
- win=Ext.create('Ext.window.Window',{
- width: 450,
- height:200,
- closeAction: 'hide',
- id:'relatewin',
- title:'<div align="center" class="WindowTitle">关联文档</div>',
- listeners:{
- hide:function(win){
- win.destroy();
- }
- },
- bodyStyle:'background:#F0F0F0;color:#515151;',
- items:[{
- xtype:'textfield',
- fieldLabel:'关联编号',
- name:'relatecode',
- allowBlank:false,
- cls:'form-field-allowBlank',
- fieldStyle : "background:#FFFAFA;color:#515151;",
- id:'relatecode'
- }],
- buttonAlign:'center',
- buttons:[{
- cls:'x-btn-ok',
- handler:function(btn){
- var grid=Ext.getCmp('docgrid'),me=this,relatecode=Ext.getCmp('relatecode');
- var items = grid.selModel.getSelection();
- if(items.length<1) showResult('提示','请选择需要移动的文档!',btn);
- if(!relatecode.getValue()) showResult('提示','请先选择需要设置关联的文档!',btn);
- warnMsg('确认移动选中文档或文件夹?', function(btn){
- if(btn == 'yes'){
- var data=new Array();
- Ext.Array.each(items,function(item){
- data.push(Ext.JSON.encode(item.data));
- });
- Ext.Ajax.request({
- url : basePath + 'oa/doc/relateDoc.action',
- params : {
- data :unescape(data.toString()),
- relateCode : relatecode.getValue()
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- showError(str);
- }else {
- var docpanel=Ext.getCmp('docpanel');
- docpanel.loadNewStore(CurrentFolderId);
- showResult('提示','移动成功!',btn);
- me.up('window').close();
- }
- }
- });
- }
- });
- }
- },{
- cls:'x-btn-close',
- handler:function(btn){
- this.up('window').close();
- }
- }]
- });
- }
- var el=button.getEl();
- button.getEl().dom.disabled = true;
- if (win.isVisible()) {
- win.hide(el, function() {
- el.dom.disabled = false;
- });
- } else {
- win.show(el, function() {
- el.dom.disabled = false;
- Ext.getBody().disabled=true;
- });
- }
- }
- },{
- xtype:'button',
- id:'switch',
- text:'切换',
- tooltip:'切换查看方式 ',
- cls:'button icon loop',
- scanType:'list'
- }]
- }],
- initComponent : function(){
- this.getGridItem(this);
- this.callParent(arguments);
- },
- getViewItem : function(panel) {
- var grid=Ext.getCmp('docgrid');
- },
- getGridItem: function(panel){
- return this.items=[{
- xtype:'docgrid'
- }];
- },
- loadNewStore:function(parentId,record){
- var me=this;
- me.items.items[0].getItemData(parentId,record);
- },
- reSetButton:function(panel){
- var grid=Ext.getCmp('docgrid');
- var selects=grid.getSelectionModel().getSelection();
- var bar=panel.dockedItems.items[0];
- Ext.Array.each(bar.items.items,function(item){
- if(item.text!='上传'){
- item.setDisabled(selects.length==0);
- }
- });
- }
- });
|