DocPanel.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. Ext.define('erp.view.oa.doc.DocPanel',{
  2. extend: 'Ext.panel.Panel',
  3. alias: 'widget.erpDocPanel',
  4. id:'docpanel',
  5. requires:['erp.view.oa.doc.DocGrid'],
  6. collapsible :false,
  7. defaults: {
  8. autoScroll:true
  9. },
  10. style:'margin-top:-5px;',
  11. flex: 4,
  12. width:800,
  13. layout:'fit',
  14. autoShow: true,
  15. currentItem:null,
  16. frame: true,
  17. layout:'fit',
  18. dockedItems: [{
  19. xtype: 'toolbar',
  20. dock: 'top',
  21. style:'font-size:18px;',
  22. layout:'column',
  23. cls:'maintoolbar',
  24. defaults:{
  25. style:'margin-left:10px;margin-top:2px;',
  26. },
  27. items: [/*{
  28. id:'upload',
  29. text:'上传',
  30. tooltip:'上传文件' ,
  31. xtype:'form',
  32. layout:'column',
  33. bodyStyle: 'background: transparent no-repeat 0 0;border: none;margin-left:40px;',
  34. items: [{
  35. xtype: 'filefield',
  36. name: 'file',
  37. buttonOnly: true,
  38. hideLabel: true,
  39. anchor: '100%',
  40. width:90,
  41. id:'attachfile',
  42. msgTarget: 'side',
  43. frame:false,
  44. buttonConfig: {
  45. text: '上传',
  46. cls: 'x-btn',
  47. },
  48. listeners: {
  49. change: function(field){
  50. var filename = '';
  51. if(contains(field.value, "\\", true)){
  52. filename = field.value.substring(field.value.lastIndexOf('\\') + 1);
  53. } else {
  54. filename = field.value.substring(field.value.lastIndexOf('/') + 1);
  55. }
  56. field.ownerCt.getForm().submit({
  57. url: basePath + 'common/upload.action?em_code=' + em_code,
  58. waitMsg: "正在解析文件信息",
  59. success: function(fp,o){
  60. if(o.result.error){
  61. showError(o.result.error);
  62. } else {
  63. Ext.Msg.alert("恭喜", filename + " 上传成功!");
  64. field.setDisabled(true);
  65. var record=Ext.getCmp('grid').selModel.lastSelected;
  66. if(record){
  67. record.set('attachs',filename+";"+o.result.filepath);
  68. }
  69. }
  70. }
  71. });
  72. }
  73. }}]
  74. },*/{
  75. xtype:'button',
  76. id:'uploadDoc',
  77. text:'上传',
  78. cls:"button icon arrowup"
  79. },{
  80. xtype:'button',
  81. id:'downloadDoc',
  82. text:'下载',
  83. disabled:true,
  84. cls:"button icon arrowdown"
  85. },{
  86. xtype:'button',
  87. id:'read',
  88. text:'阅读',
  89. disabled:true,
  90. tooltip:'阅读文件',
  91. cls:"button icon chat"//,
  92. /*handler:function(btn){
  93. showResult('提示','当前文件类型不支持在线预览,请先下载!',btn);
  94. }*/
  95. },{
  96. xtype:'button',
  97. text:'发送',
  98. id:'publish',
  99. disabled:true,
  100. cls:"button icon mail",
  101. tooltip:'发送文件',
  102. hidden:true
  103. },{
  104. xtype:'button',
  105. id:'rename',
  106. text:'重命名',
  107. disabled:true,
  108. cls:"button icon edit",
  109. tooltip:'重命名文件'
  110. }, {xtype:'button',
  111. id:'delete',
  112. text:'删除',
  113. disabled:true,
  114. tooltip:'删除文件',
  115. cls:"button danger icon trash"
  116. },{
  117. xtype:'button',
  118. id:'move',
  119. text:'移动',
  120. tooltip:'移动文件',
  121. disabled:true,
  122. cls:'button icon move',
  123. handler:function(button){
  124. var win = Ext.getCmp('movewin');
  125. var docpanel=Ext.getCmp('doctab');
  126. if(!win){
  127. win=Ext.create('Ext.window.Window',{
  128. width: 550,
  129. height:350,
  130. closeAction: 'destroy',
  131. id:'movewin',
  132. layout:'fit',
  133. title:'<div align="center" class="WindowTitle">移动文件</div>',
  134. listeners:{
  135. hide:function(win){
  136. win.destroy();
  137. }
  138. },
  139. items:[{
  140. xtype: 'erpDocumentTreePanel',
  141. bodyStyle:"background-color:#FAFAFA;",
  142. id:'foldertree',
  143. store: Ext.create('Ext.data.TreeStore', {
  144. root: {
  145. expanded: true,
  146. children: [{
  147. text: '公共文档',
  148. expanded: false,
  149. url:"/公共文档",
  150. id:0
  151. }]
  152. }
  153. })
  154. }],
  155. buttonAlign:'center',
  156. buttons:[{
  157. cls:'x-btn-ok',
  158. handler:function(btn){
  159. var grid=Ext.getCmp('docgrid'),me=this;
  160. var items = grid.selModel.getSelection();
  161. var select= Ext.getCmp('foldertree').getSelectionModel();
  162. if(items.length<1) showResult('提示','请选择需要移动的文档!',btn);
  163. if(select.selected.items.length<1) showResult('提示','请选择需要移动到文件夹!',btn);
  164. warnMsg('确认移动选中文档或文件夹?', function(btn){
  165. if(btn == 'yes'){
  166. var data=new Array();
  167. Ext.Array.each(items,function(item){
  168. data.push(Ext.JSON.encode(item.data));
  169. });
  170. Ext.Ajax.request({
  171. url : basePath + 'oa/doc/moveDoc.action',
  172. params : {
  173. data :unescape(data.toString()),
  174. folderId : select.lastSelected.data.id
  175. },
  176. method : 'post',
  177. callback : function(options,success,response){
  178. var localJson = new Ext.decode(response.responseText);
  179. if(localJson.exceptionInfo){
  180. var str = localJson.exceptionInfo;
  181. showError(str);
  182. }else {
  183. var docpanel=Ext.getCmp('docpanel');
  184. docpanel.loadNewStore(CurrentFolderId);
  185. showResult('提示','移动成功!',btn);
  186. me.up('window').close();
  187. }
  188. }
  189. });
  190. }
  191. });
  192. }
  193. },{
  194. cls:'x-btn-close',
  195. handler:function(btn){
  196. this.up('window').close();
  197. }
  198. }]
  199. });
  200. }
  201. var el=button.getEl();
  202. button.getEl().dom.disabled = true;
  203. if (win.isVisible()) {
  204. win.hide(el, function() {
  205. el.dom.disabled = false;
  206. });
  207. } else {
  208. win.show(el, function() {
  209. el.dom.disabled = false;
  210. Ext.getBody().disabled=true;
  211. });
  212. }
  213. }
  214. },{
  215. xtype:'button',
  216. id:'relate',
  217. text:'关联',
  218. tooltip:'关联文件',
  219. disabled:true,
  220. cls:'button icon fork',
  221. handler:function(button){
  222. var win = Ext.getCmp('relatewin');
  223. var docpanel=Ext.getCmp('doctab');
  224. if(!win){
  225. win=Ext.create('Ext.window.Window',{
  226. width: 450,
  227. height:200,
  228. closeAction: 'hide',
  229. id:'relatewin',
  230. title:'<div align="center" class="WindowTitle">关联文档</div>',
  231. listeners:{
  232. hide:function(win){
  233. win.destroy();
  234. }
  235. },
  236. bodyStyle:'background:#F0F0F0;color:#515151;',
  237. items:[{
  238. xtype:'textfield',
  239. fieldLabel:'关联编号',
  240. name:'relatecode',
  241. allowBlank:false,
  242. cls:'form-field-allowBlank',
  243. fieldStyle : "background:#FFFAFA;color:#515151;",
  244. id:'relatecode'
  245. }],
  246. buttonAlign:'center',
  247. buttons:[{
  248. cls:'x-btn-ok',
  249. handler:function(btn){
  250. var grid=Ext.getCmp('docgrid'),me=this,relatecode=Ext.getCmp('relatecode');
  251. var items = grid.selModel.getSelection();
  252. if(items.length<1) showResult('提示','请选择需要移动的文档!',btn);
  253. if(!relatecode.getValue()) showResult('提示','请先选择需要设置关联的文档!',btn);
  254. warnMsg('确认移动选中文档或文件夹?', function(btn){
  255. if(btn == 'yes'){
  256. var data=new Array();
  257. Ext.Array.each(items,function(item){
  258. data.push(Ext.JSON.encode(item.data));
  259. });
  260. Ext.Ajax.request({
  261. url : basePath + 'oa/doc/relateDoc.action',
  262. params : {
  263. data :unescape(data.toString()),
  264. relateCode : relatecode.getValue()
  265. },
  266. method : 'post',
  267. callback : function(options,success,response){
  268. var localJson = new Ext.decode(response.responseText);
  269. if(localJson.exceptionInfo){
  270. var str = localJson.exceptionInfo;
  271. showError(str);
  272. }else {
  273. var docpanel=Ext.getCmp('docpanel');
  274. docpanel.loadNewStore(CurrentFolderId);
  275. showResult('提示','移动成功!',btn);
  276. me.up('window').close();
  277. }
  278. }
  279. });
  280. }
  281. });
  282. }
  283. },{
  284. cls:'x-btn-close',
  285. handler:function(btn){
  286. this.up('window').close();
  287. }
  288. }]
  289. });
  290. }
  291. var el=button.getEl();
  292. button.getEl().dom.disabled = true;
  293. if (win.isVisible()) {
  294. win.hide(el, function() {
  295. el.dom.disabled = false;
  296. });
  297. } else {
  298. win.show(el, function() {
  299. el.dom.disabled = false;
  300. Ext.getBody().disabled=true;
  301. });
  302. }
  303. }
  304. },{
  305. xtype:'button',
  306. id:'switch',
  307. text:'切换',
  308. tooltip:'切换查看方式 ',
  309. cls:'button icon loop',
  310. scanType:'list'
  311. }]
  312. }],
  313. initComponent : function(){
  314. this.getGridItem(this);
  315. this.callParent(arguments);
  316. },
  317. getViewItem : function(panel) {
  318. var grid=Ext.getCmp('docgrid');
  319. },
  320. getGridItem: function(panel){
  321. return this.items=[{
  322. xtype:'docgrid'
  323. }];
  324. },
  325. loadNewStore:function(parentId,record){
  326. var me=this;
  327. me.items.items[0].getItemData(parentId,record);
  328. },
  329. reSetButton:function(panel){
  330. var grid=Ext.getCmp('docgrid');
  331. var selects=grid.getSelectionModel().getSelection();
  332. var bar=panel.dockedItems.items[0];
  333. Ext.Array.each(bar.items.items,function(item){
  334. if(item.text!='上传'){
  335. item.setDisabled(selects.length==0);
  336. }
  337. });
  338. }
  339. });