DocTabPanel.js.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. Ext.define('erp.view.oa.doc.DocTabPanel',{
  2. extend: 'Ext.tab.Panel',
  3. alias: 'widget.erpDocTabPanel',
  4. id: 'doctab',
  5. collapsible :false,
  6. header :false,
  7. defaults: {
  8. autoScroll:true
  9. },
  10. activeTab: 0,
  11. region: 'south',
  12. tabBar:{
  13. cls:'bg_tabs',
  14. },
  15. GridUtil: Ext.create('erp.util.GridUtil'),
  16. BaseUtil: Ext.create('erp.util.BaseUtil'),
  17. split: true,
  18. plain:true,
  19. flex:2,
  20. minHeight: 80,
  21. border: false,
  22. autoShow: true,
  23. currentDoc:null,
  24. currentType:-1,
  25. powers:{SEE:'dp_see',CONTROL:'dp_control',DOWNLOAD:'dp_download'},
  26. defaultItems:[{
  27. title:'目录信息',
  28. id:0,
  29. indexId:0,
  30. DocId:-1,
  31. groupType:-1,
  32. layout:'fit',
  33. items:[{
  34. xtype:'form',
  35. id:'folderForm',
  36. layout:'column',
  37. autoScroll:true,
  38. bodyPadding: 5,
  39. bodyStyle:'background:#fafafa;',
  40. defaults: {
  41. anchor: '100%',
  42. readOnly:true,
  43. columnWidth:0.33,
  44. labelStyle:'font-weight: bold; ',
  45. 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;',
  46. },
  47. defaultType: 'textfield',
  48. items:[{
  49. fieldLabel: '目录名称',
  50. name: 'dl_name',
  51. value:'目录名称'
  52. },{
  53. fieldLabel: '目录',
  54. name: 'dl_virtualpath'
  55. },{
  56. fieldLabel: '文档数',
  57. name: 'em_code'
  58. },{
  59. fieldLabel:'创建时间',
  60. name:'dl_createtime',
  61. xtype:'datetimefield',
  62. format :'Y-m-d H:i:s'
  63. },{
  64. fieldLabel:'目录描述',
  65. name:'dl_remark',
  66. },{
  67. fieldLabel:'目录ID',
  68. name:'dl_id'
  69. }]
  70. }]
  71. },{
  72. title:'目录订阅',
  73. id:1,
  74. indexId:1,
  75. DocId:-1,
  76. groupType:-1,
  77. bodyStyle:'background:#fafafa;',
  78. items:[{
  79. xtype:'button',
  80. text:'订阅本目录',
  81. cls:'button1 pill',
  82. style:'margin-left:20px;margin-top:5px;',
  83. handler:function(btn){
  84. if(btn.text=='订阅本目录'){
  85. btn.setText('取消订阅本目录');
  86. }else btn.setText('订阅本目录');
  87. }
  88. },{
  89. xtype:'button',
  90. text:'批量订阅',
  91. cls:'button1 pill',
  92. style:'margin-left:20px;margin-top:5px;'
  93. },{
  94. xtype:'textfield',
  95. labelWidth:150,
  96. style:'margin-left:20px',
  97. labelStyle:'font-weight: bold;',
  98. 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;',
  99. fieldLabel:'已订阅本目录的用户',
  100. value:'无'
  101. }]
  102. },{
  103. title:'权限管理',
  104. id:2,
  105. indexId:2,
  106. DocId:-1,
  107. groupType:-1,
  108. layout:'fit',
  109. listeners:{
  110. activate:function(tab){
  111. tab.items.items[0].loadNewStore();
  112. }
  113. },
  114. items:[{
  115. xtype:'gridpanel',
  116. columns:DOC.columns.PowerColumns,
  117. powerSet:['dp_control','dp_see','dp_save','dp_read','dp_delete','dp_print','dp_download','dp_upload'],
  118. tbar: [{
  119. xtype:'button',
  120. text:'设置权限',
  121. cls:'button1 pill',
  122. id:'setpower',
  123. style:'margin-left:20px; margin-top:5px;',
  124. }],
  125. features : [Ext.create('Ext.grid.feature.GroupingSummary',{
  126. groupHeaderTpl: '{name} (共:{rows.length}条)'
  127. })],
  128. autoScroll:true,
  129. region: 'south',
  130. layout : 'fit',
  131. plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
  132. clicksToEdit: 1
  133. })],
  134. store: Ext.create('Ext.data.Store', {
  135. groupField: 'dp_type',
  136. fields:DOC.fields.PowerFields
  137. }),
  138. loadNewStore:function(){
  139. var docpanel=Ext.getCmp('doctab');
  140. docpanel.loadPowerStore(this,{
  141. caller:'DocumentListPower',
  142. condition:"dp_dclid="+CurrentFolderId
  143. });
  144. }
  145. }]
  146. },{
  147. title:'文档链接',
  148. id:3,
  149. indexId:3,
  150. DocId:-1,
  151. groupType:-1,
  152. items:[{
  153. xtype:'gridpanel',
  154. columns:DOC.columns.LinkColumns
  155. }]
  156. },{
  157. title:'文档信息',
  158. groupType:0,
  159. id:4,
  160. indexId:4,
  161. DocId:-1,
  162. hidden:true,
  163. layout:'fit',
  164. items:[{
  165. xtype:'form',
  166. id:'docForm',
  167. layout:'column',
  168. autoScroll:true,
  169. bodyStyle:'background:#fafafa;',
  170. bodyPadding: 5,
  171. defaults: {
  172. anchor: '100%',
  173. readOnly:true,
  174. columnWidth:0.33,
  175. labelWidth:70,
  176. labelStyle:'font-weight: bold; ',
  177. 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;',
  178. },
  179. listeners :{
  180. afterrender:function(form){
  181. var docpanel=Ext.getCmp('doctab');
  182. var data=docpanel.currentDoc!=null?docpanel.currentDoc:Ext.getCmp('docgrid').getSelectionModel();
  183. form.getForm().setValues(docpanel.currentDoc);
  184. }
  185. },
  186. defaultType: 'textfield',
  187. items:[{
  188. fieldLabel: '编号',
  189. name: 'dl_code'
  190. },{
  191. fieldLabel: '文档名称',
  192. name: 'dl_name'
  193. },{
  194. fieldLabel: '目录',
  195. name: 'dl_virtualpath'
  196. },{
  197. xtype: 'container',
  198. layout:'column',
  199. items:[{
  200. name:'dl_version',
  201. xtype:'textfield',
  202. labelWidth:70,
  203. labelStyle:'font-weight: bold; ',
  204. fieldLabel:'版本号',
  205. 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;',
  206. columnWidth:0.5
  207. },{
  208. xtype:'button',
  209. id:'updatedoc',
  210. text:'修改',
  211. cls:'button1 pill',
  212. style:'margin-left:5px;',
  213. columnWidth:0.2
  214. },{
  215. xtype:'button',
  216. text:'历史',
  217. cls:'button1 pill',
  218. style:'margin-left:5px;',
  219. columnWidth:0.2
  220. }]
  221. },{
  222. fieldLabel:'大小',
  223. name:'dl_size'
  224. },{
  225. fieldLabel:'目录描述',
  226. name:'dl_remark',
  227. },{
  228. fieldLabel:'创建人',
  229. name:'dl_creator'
  230. },{
  231. fieldLabel:'创建时间',
  232. name:'dl_createtime',
  233. xtype:'datetimefield',
  234. format :'Y-m-d H:i:s'
  235. },{
  236. fieldLabel:'当前状态',
  237. name:'dl_status'
  238. },{
  239. xtype: 'container',
  240. layout:'column',
  241. items:[{
  242. name:'dl_locked',
  243. xtype:'textfield',
  244. labelWidth:70,
  245. labelStyle:'font-weight: bold; ',
  246. fieldLabel:'锁定状态',
  247. 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;',
  248. columnWidth:0.7,
  249. listeners:{
  250. change:function(field,newvalue){
  251. newvalue=(newvalue==0 || newvalue=='未锁定')?'未锁定':'已锁定';
  252. field.setValue(newvalue);
  253. var lockbutton=Ext.getCmp('lockbutton'),buttontext=newvalue=='未锁定'?'锁定':'解锁';
  254. lockbutton.setText(buttontext);
  255. }
  256. }
  257. },{
  258. xtype:'button',
  259. text:'锁定',
  260. id:'lockbutton',
  261. cls:'button1 pill',
  262. style:'margin-left:5px;',
  263. columnWidth:0.2
  264. }]
  265. },{
  266. fieldLabel:'点击数',
  267. name:'dl_hits'
  268. },{
  269. fieldLabel:'目录ID',
  270. name:'dl_id'
  271. }]
  272. }]
  273. },{
  274. title:'修订版管理',
  275. groupType:0,
  276. id:5,
  277. indexId:5,
  278. DocId:-1,
  279. hidden:true,
  280. items:[{
  281. xtype:'gridpanel',
  282. columns:DOC.columns.HistoryColumns,
  283. store:Ext.create('Ext.data.Store', {
  284. fields:DOC.fields.VersionFields,
  285. data:[]
  286. })
  287. }],
  288. listeners:{
  289. activate:function(tab){
  290. var docpanel=Ext.getCmp('doctab');
  291. var data=docpanel.currentDoc!=null?docpanel.currentDoc:Ext.getCmp('docgrid').getSelectionModel();
  292. docpanel.loadNewStore(tab.items.items[0],{
  293. caller:'DocumentVersion',
  294. condition:"dv_dlid="+data.dl_id
  295. });
  296. }
  297. }
  298. },{
  299. title:'文档评论',
  300. groupType:0,
  301. id:6,
  302. indexId:6,
  303. DocId:-1,
  304. hidden:true,
  305. autoScroll:true,
  306. listeners:{
  307. activate:function(tab){
  308. var docpanel=Ext.getCmp('doctab');
  309. var data=docpanel.currentDoc!=null?docpanel.currentDoc:Ext.getCmp('docgrid').getSelectionModel();
  310. docpanel.loadNewStore(tab.items.items[0],{
  311. caller:'DocumentReview',
  312. condition:"dr_dlid="+data.dl_id
  313. });
  314. }
  315. },
  316. items:[{
  317. xtype:'gridpanel',
  318. columns:DOC.columns.ReviewColumns,
  319. store:Ext.create('Ext.data.Store', {
  320. fields:DOC.fields.ReviewFields,
  321. data:[]
  322. })
  323. },{
  324. xtype:'form',
  325. style:'padding-top:15px;',
  326. autoScroll:true,
  327. border: false,
  328. height:150,
  329. layout:'column',
  330. defaults:{
  331. columnWidth:0.33
  332. },
  333. bodyStyle:'background:#fafafa;',
  334. items:[{
  335. xtype:'textfield',
  336. 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;'
  337. },{
  338. xtype: 'textareafield',
  339. fieldLabel: '<div align="center" class="WindowTitle">发表评论</div>',
  340. labelCls:'x-form-item-label x-form-item-label-top',
  341. name:'talk',
  342. id:'talk',
  343. labelSeparator:'',
  344. style:'padding-left:50px',
  345. allowBlank: false,
  346. width:300
  347. }],
  348. buttonAlign:'center',
  349. buttons:[{
  350. text:'保存',
  351. cls:'button1 pill',
  352. style:'margin-top:5px;',
  353. xtype:'button',
  354. handler:function(btn){
  355. var doctab=btn.ownerCt.ownerCt.ownerCt;
  356. var o={
  357. dr_remark:Ext.getCmp('talk').value,
  358. dr_dlid:doctab.ownerCt.currentDoc.dl_id
  359. };
  360. Ext.Ajax.request({
  361. url : basePath + 'oa/Doc/review.action',
  362. params : {
  363. formStore:unescape(Ext.JSON.encode(o).replace(/\\/g,"%"))
  364. },
  365. method : 'post',
  366. callback : function(options,success,response){
  367. var localJson = new Ext.decode(response.responseText);
  368. if(localJson.exceptionInfo){
  369. var str = localJson.exceptionInfo;
  370. showError(str);
  371. }else {
  372. showResult('提示','评论成功!',btn);
  373. var grid=doctab.items.items[0];
  374. Ext.getCmp('talk').reset();
  375. doctab.ownerCt.loadNewStore(grid,{
  376. caller:'DocumentReview',
  377. condition:"dr_dlid="+doctab.ownerCt.currentDoc.dl_id
  378. })
  379. }
  380. }
  381. });
  382. }
  383. }]
  384. }]
  385. },{
  386. title:'文档审计',
  387. groupType:0,
  388. id:7,
  389. indexId:7,
  390. DocId:-1,
  391. hidden:true,
  392. items:[{
  393. xtype:'gridpanel',
  394. columns:DOC.columns.LogColumns
  395. }]
  396. },{
  397. title:'摘要及省略图',
  398. groupType:0,
  399. id:8,
  400. indexId:8,
  401. DocId:-1,
  402. hidden:true,
  403. items:[{
  404. xtype:'button',
  405. text:'增加文档摘要',
  406. cls:'button1 pill',
  407. style:'margin-left:20px;margin-top:10px;',
  408. handler:function(btn){
  409. }
  410. },{
  411. xtype:'button',
  412. text:'打印图片',
  413. cls:'button1 pill',
  414. style:'margin-left:20px;margin-top:10px;'
  415. }]
  416. },{
  417. title:'关联文档',
  418. groupType:0,
  419. id:9,
  420. indexId:9,
  421. DocId:-1,
  422. hidden:true,
  423. items:[{
  424. xtype: 'container',
  425. layout:'column',
  426. style:'margin-top:5px;background:transparent;',
  427. bodyStyle:'background:transparent;',
  428. items:[{
  429. xtype:'textfield',
  430. 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;',
  431. columnWidth:0.33
  432. },{
  433. name:'code',
  434. xtype:'textfield',
  435. labelWidth:70,
  436. labelStyle:'font-weight: bold; ',
  437. fieldLabel:'文档编号',
  438. columnWidth:0.2
  439. },{
  440. xtype:'button',
  441. id:'addrelatedoc',
  442. text:'增加关联文档',
  443. cls:'button1 pill',
  444. style:'margin-left:5px;',
  445. columnWidth:0.1
  446. }]
  447. },{
  448. xtype:'gridpanel',
  449. columns:DOC.columns.RelateColumns
  450. }]
  451. },{
  452. title:'借阅情况',
  453. groupType:0,
  454. id:10,
  455. indexId:10,
  456. DocId:-1,
  457. hidden:true,
  458. items:[{
  459. xtype:'gridpanel',
  460. columns:DOC.columns.BorrowColumns
  461. }]
  462. }],
  463. defaults:{
  464. active:function(tab){
  465. var dlid=tab.ownerCt.currentDoc.data.dl_id;
  466. if(tab.DocId !=tab.ownerCt.currentDoc.data.dl_id){
  467. //说明切换了
  468. tab.ownerCt.changeTab();
  469. tab.DocId=dlid;
  470. }
  471. }
  472. },
  473. initComponent : function(){
  474. this.items=this.defaultItems;
  475. this.addEvents({
  476. tabItemChange: true
  477. });
  478. this.callParent(arguments);
  479. },
  480. listeners:{
  481. tabItemChange:function(tabpanel,record){
  482. if(record && record.data !=this.currentDoc){
  483. this.currentDoc=record.data;
  484. var kind=record.data.dl_kind ==0?0:-1;
  485. if(record.data.dl_kind!=this.currentType){
  486. this.changeItems(record,kind);
  487. }else this.changeItems(record);
  488. }
  489. }
  490. },
  491. changeItems:function(record,type){
  492. if(type!=null){
  493. Ext.Array.each(this.items.items,function(item){
  494. if(item.groupType!=type){
  495. item.tab.hide();
  496. }else {
  497. if(item.title=='权限管理'){
  498. var doctab=Ext.getCmp('doctab');
  499. var bool=doctab.checkPowerByFolderId(CurrentFolderId,doctab.powers.CONTROL);
  500. if(bool) item.tab.show(); else item.tab.hide();
  501. }else item.tab.show();
  502. }
  503. });
  504. if(this.currentType!=type && this.activeTab.indexId>3)
  505. this.setActiveTab(this.activeTab.indexId-4);
  506. else if(this.currentType!=type && this.activeTab.indexId<4)
  507. this.setActiveTab(this.activeTab.indexId+4);
  508. else {
  509. var tab=this.getActiveTab();
  510. tab.fireEvent('activate', tab);
  511. }
  512. this.currentType=type;
  513. }else {
  514. if(this.currentType==-1){
  515. Ext.getCmp('folderForm').getForm().setValues(record.data);
  516. }else {
  517. Ext.getCmp('docForm').getForm().setValues(record.data);
  518. }
  519. }
  520. },
  521. loadNewStore: function(grid, param){
  522. var me = this;
  523. Ext.Ajax.request({//拿到grid的columns
  524. url : basePath + "common/loadNewGridStore.action",
  525. params: param,
  526. method : 'post',
  527. callback : function(options,success,response){
  528. var res = new Ext.decode(response.responseText);
  529. if(res.exceptionInfo){
  530. showError(res.exceptionInfo);return;
  531. }
  532. var data = res.data;
  533. if(!data || data.length == 0){
  534. grid.store.removeAll();
  535. } else {
  536. grid.store.loadData(data);
  537. }
  538. //自定义event
  539. grid.addEvents({
  540. storeloaded: true
  541. });
  542. grid.fireEvent('storeloaded', grid, data);
  543. }
  544. });
  545. },
  546. loadPowerStore: function(grid, param){
  547. var me = this;
  548. Ext.Ajax.request({//拿到grid的columns
  549. url : basePath + "common/loadNewGridStore.action",
  550. params: param,
  551. method : 'post',
  552. callback : function(options,success,response){
  553. var res = new Ext.decode(response.responseText);
  554. if(res.exceptionInfo){
  555. showError(res.exceptionInfo);return;
  556. }
  557. var data = res.data;
  558. Ext.each(res.data, function(item){
  559. Ext.each(grid.powerSet, function(pp){
  560. item[pp] = item[pp] == 1;
  561. });
  562. });
  563. if(!data || data.length == 0){
  564. grid.store.removeAll();
  565. } else {
  566. grid.store.loadData(data);
  567. }
  568. //自定义event
  569. grid.addEvents({
  570. storeloaded: true
  571. });
  572. grid.fireEvent('storeloaded', grid, data);
  573. }
  574. });
  575. },
  576. checkPowerByFolderId:function(folderId,type){
  577. var me = this,bool=false;
  578. Ext.Ajax.request({//拿到grid的columns
  579. url : basePath + "doc/CheckPowerByFolderId.action",
  580. params: {
  581. folderId:folderId,
  582. type:type
  583. },
  584. async:false,
  585. method : 'post',
  586. callback : function(options,success,response){
  587. var res = new Ext.decode(response.responseText);
  588. bool=res.bool;
  589. }
  590. });
  591. return bool;
  592. }
  593. });