DocumentRoom.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.officialDocument.fileManagement.DocumentRoom', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'oa.officialDocument.fileManagement.documentRoom.DocumentRoom','oa.officialDocument.fileManagement.documentRoom.DocumentRoomTreePanel','common.datalist.GridPanel','common.datalist.Toolbar',
  9. 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print',
  10. 'core.button.Upload','core.button.Update','core.button.Delete','core.button.ResAudit','core.button.DeleteDetail',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'erpDocumentRoomTreePanel': {
  17. itemmousedown: function(selModel, record){
  18. if(record.get('leaf')){
  19. Ext.getCmp('deldr').setDisabled(false);
  20. Ext.getCmp('updatedr').setDisabled(false);
  21. var id=record.get('id');
  22. condition="drd_drid="+id;
  23. Ext.getCmp('pagingtoolbar').child('#inputItem').setValue(1);
  24. page=1;
  25. Ext.getCmp('grid').getCount(caller,condition);
  26. } else {
  27. Ext.getCmp('deldr').setDisabled(true);
  28. Ext.getCmp('updatedr').setDisabled(true);
  29. Ext.getCmp('grid').getCount(caller,'drd_drid=0');
  30. }
  31. }
  32. },
  33. 'button[id=delete]': {
  34. click: function(){
  35. me.vastDelete();
  36. }
  37. },
  38. 'button[id=add]': {
  39. click: function(){
  40. var treegrid = Ext.getCmp('tree');
  41. var items = treegrid.selModel.selected.items;
  42. console.log(items);
  43. if(items.length > 0 && items[0].data.id !=0){
  44. var grid = Ext.getCmp('grid');
  45. var flag = new Array();
  46. var urlcondition = 'urlcondition=';
  47. Ext.each(grid.store.data.items, function(){
  48. flag.push(this.data.drd_dept_id);
  49. });
  50. if(flag.length > 0){
  51. urlcondition += 'or_id not in (' + flag.join(',') + ')';
  52. }
  53. var dr_id = items[0].data.id;
  54. var win = new Ext.window.Window({
  55. id : 'win',
  56. title: "添加使用部门",
  57. height: "80%",
  58. width: "50%",
  59. maximizable : false,
  60. buttonAlign : 'left',
  61. layout : 'anchor',
  62. items: [{
  63. tag : 'iframe',
  64. frame : true,
  65. anchor : '100% 100%',
  66. layout : 'fit',
  67. html : '<iframe id="iframe_' + dr_id + '" src="' + basePath + 'jsps/oa/officialDocument/fileManagement/addHrorg.jsp?whoami=HrOrg!Add&' + urlcondition + '&id=' + dr_id + '" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  68. }]
  69. });
  70. win.show();
  71. }
  72. }
  73. },
  74. 'button[id=deldr]': {
  75. click: function(){
  76. var treegrid = Ext.getCmp('tree');
  77. var items = treegrid.selModel.selected.items;
  78. if(items.length > 0 && items[0].data.id !=0){
  79. warnMsg('确定要删除'+items[0].data.text, function(btn){
  80. if(btn == 'yes'){
  81. // me.getActiveTab().setLoading(true);//loading...
  82. Ext.Ajax.request({
  83. url : basePath + 'oa/officialDocument/fileManagement/deleteDocumentRoom.action',
  84. params: {
  85. id: items[0].data.id
  86. },
  87. method : 'post',
  88. callback : function(options,success,response){
  89. // me.getActiveTab().setLoading(false);
  90. var localJson = new Ext.decode(response.responseText);
  91. if(localJson.exceptionInfo){
  92. showError(localJson.exceptionInfo);return;
  93. }
  94. if(localJson.success){
  95. delSuccess(function(){
  96. window.location.href = window.location.href;
  97. });//@i18n/i18n.js
  98. } else {
  99. delFailure();
  100. }
  101. }
  102. });
  103. }
  104. });
  105. }
  106. }
  107. },
  108. 'button[id=adddr]': {
  109. click: function(){
  110. var win = new Ext.window.Window({
  111. id : 'win',
  112. title: "添加档案室",
  113. height: "50%",
  114. width: "50%",
  115. maximizable : false,
  116. buttonAlign : 'left',
  117. layout : 'anchor',
  118. items: [{
  119. tag : 'iframe',
  120. frame : true,
  121. anchor : '100% 100%',
  122. layout : 'fit',
  123. html : '<iframe id="iframe_' + new Date() + '" src="' + basePath + 'jsps/oa/officialDocument/fileManagement/newDocumentRoom.jsp" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  124. }]
  125. });
  126. win.show();
  127. }
  128. },
  129. 'button[id=updatedr]': {
  130. click: function(){
  131. var treegrid = Ext.getCmp('tree');
  132. var items = treegrid.selModel.selected.items;
  133. console.log(items);
  134. if(items.length > 0){
  135. var win = new Ext.window.Window({
  136. id : 'win',
  137. title: "修改档案室",
  138. height: "50%",
  139. width: "50%",
  140. maximizable : false,
  141. buttonAlign : 'left',
  142. layout : 'anchor',
  143. items: [{
  144. tag : 'iframe',
  145. frame : true,
  146. anchor : '100% 100%',
  147. layout : 'fit',
  148. html : '<iframe id="iframe_' + new Date() + '" src="' + basePath + 'jsps/oa/officialDocument/fileManagement/newDocumentRoom.jsp?formCondition=dr_idIS' + items[0].data.id + '&gridCondition=" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  149. }]
  150. });
  151. win.show();
  152. }
  153. }
  154. },
  155. });
  156. },
  157. vastDelete: function(){
  158. var treegrid = Ext.getCmp('tree');
  159. var items = treegrid.selModel.selected.items;
  160. var dr_id = items[0].data.id;
  161. var grid = Ext.getCmp('grid');
  162. var records = grid.selModel.getSelection();
  163. if(records.length > 0){
  164. var id = new Array();
  165. Ext.each(records, function(record, index){
  166. id[index] = record.data[keyField];
  167. });
  168. var main = parent.Ext.getCmp("content-panel");
  169. main.getActiveTab().setLoading(true);//loading...
  170. Ext.Ajax.request({
  171. url : basePath + 'common/vastDelete.action',
  172. params: {
  173. caller: caller,
  174. id: id
  175. },
  176. method : 'post',
  177. callback : function(options,success,response){
  178. main.getActiveTab().setLoading(false);
  179. var localJson = new Ext.decode(response.responseText);
  180. if(localJson.exceptionInfo){
  181. showError(localJson.exceptionInfo);
  182. return "";
  183. }
  184. if(localJson.success){
  185. Ext.Msg.alert("提示", "删除成功!", function(){
  186. Ext.getCmp('grid').getCount('DocumentRoomDept',"drd_drid=" + dr_id);
  187. });
  188. }
  189. }
  190. });
  191. }
  192. }
  193. });