MeetingRoomInfo.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.meeting.MeetingRoomInfo', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'oa.meeting.MeetingRoomInfo','core.form.Panel','core.trigger.MultiDbfindTrigger','common.datalist.GridPanel','common.datalist.Toolbar',
  8. 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print',
  9. 'core.button.Upload','core.button.Update','core.button.Delete','core.button.ResAudit','core.button.ResSubmit',
  10. 'core.form.YnField','core.trigger.DbfindTrigger','common.query.Form'
  11. ],
  12. init:function(){
  13. var me = this;
  14. this.control({
  15. 'erpDatalistGridPanel': {
  16. afterrender: function(grid){
  17. grid.onGridItemClick = function(){//改为点击button进入详细界面
  18. me.onGridItemClick(grid.selModel.lastSelected);
  19. };
  20. }
  21. },
  22. 'button[id=delete]': {
  23. click: function(){
  24. me.vastDelete();
  25. }
  26. },
  27. 'button[id=add]': {
  28. click: function(){
  29. me.newMeetingRoom();
  30. }
  31. },
  32. 'erpSaveButton': {
  33. click: function(btn){
  34. var form = me.getForm(btn);
  35. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  36. me.BaseUtil.getRandomNumber();//自动添加编号
  37. }
  38. this.FormUtil.beforeSave(this);
  39. }
  40. },
  41. 'erpCloseButton': {
  42. click: function(btn){
  43. this.FormUtil.beforeClose(this);
  44. }
  45. },
  46. 'erpAddButton': {
  47. click: function(btn){
  48. me.FormUtil.onAdd('addMeetingRoom', '新增会议室', 'jsps/oa/meeting/meetingRoom.jsp');
  49. }
  50. },
  51. 'erpUpdateButton': {
  52. click: function(btn){
  53. this.FormUtil.onUpdate(this);
  54. }
  55. },
  56. 'erpDeleteButton': {
  57. click: function(btn){
  58. me.FormUtil.onDelete((Ext.getCmp('mr_id').value));
  59. }
  60. },
  61. 'erpAuditButton': {
  62. click: function(btn){
  63. this.FormUtil.onAudit(Ext.getCmp('mr_id').value);
  64. }
  65. },
  66. 'erpResAuditButton': {
  67. click: function(btn){
  68. this.FormUtil.onResAudit(Ext.getCmp('mr_id').value);
  69. }
  70. },
  71. 'erpSubmitButton': {
  72. click: function(btn){
  73. this.FormUtil.onSubmit(Ext.getCmp('mr_id').value);
  74. }
  75. },
  76. 'erpResSubmitButton': {
  77. click: function(btn){
  78. this.FormUtil.onResSubmit(Ext.getCmp('mr_id').value);
  79. }
  80. }
  81. });
  82. },
  83. getForm: function(btn){
  84. return btn.ownerCt.ownerCt;
  85. },
  86. newMeetingRoom: function(){
  87. var win = new Ext.window.Window({
  88. id : 'win',
  89. title: "会议室设置",
  90. height: "100%",
  91. width: "100%",
  92. maximizable : false,
  93. buttonAlign : 'left',
  94. layout : 'anchor',
  95. items: [{
  96. tag : 'iframe',
  97. frame : true,
  98. anchor : '80% 80%',
  99. layout : 'fit',
  100. html : '<iframe id="iframe_' + new Date() + '" src="' + basePath + 'jsps/oa/meeting/new.jsp" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  101. }]
  102. });
  103. win.show();
  104. },
  105. onGridItemClick: function(record){
  106. var me = this;
  107. if(keyField != null && keyField != ''){
  108. var value = record.data[keyField];
  109. var formCondition = keyField + "IS" + value ;
  110. var gridCondition = pfField + "IS" + value;
  111. var panel = Ext.getCmp(caller + keyField + "=" + value);
  112. var main = parent.Ext.getCmp("content-panel");
  113. if(!main){
  114. main = parent.parent.Ext.getCmp("content-panel");
  115. }
  116. if(!panel){
  117. var title = "";
  118. if (value.toString().length>4) {
  119. title = value.toString().substring(value.toString().length-4);
  120. } else {
  121. title = value;
  122. }
  123. var myurl = '';
  124. if(contains(url, '?', true)){
  125. myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
  126. } else {
  127. myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
  128. }
  129. myurl += "&datalistId=" + main.getActiveTab().id;
  130. main.getActiveTab().currentStore = me.getCurrentStore(value);//用于单据翻页
  131. panel = {
  132. title : me.BaseUtil.getActiveTab().title+'('+title+')',
  133. tag : 'iframe',
  134. tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
  135. frame : true,
  136. border : false,
  137. layout : 'fit',
  138. iconCls : 'x-tree-icon-tab-tab1',
  139. html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  140. closable : true,
  141. listeners : {
  142. close : function(){
  143. if(!main){
  144. main = parent.parent.Ext.getCmp("content-panel");
  145. }
  146. main.setActiveTab(main.getActiveTab().id);
  147. }
  148. }
  149. };
  150. this.openTab(panel, caller + keyField + "=" + record.data[keyField]);
  151. }else{
  152. main.setActiveTab(panel);
  153. }
  154. }
  155. },
  156. openTab : function (panel,id){
  157. var o = (typeof panel == "string" ? panel : id || panel.id);
  158. var main = parent.Ext.getCmp("content-panel");
  159. if(!main) {
  160. main =parent.parent.Ext.getCmp("content-panel");
  161. }
  162. var tab = main.getComponent(o);
  163. if (tab) {
  164. main.setActiveTab(tab);
  165. } else if(typeof panel!="string"){
  166. panel.id = o;
  167. var p = main.add(panel);
  168. main.setActiveTab(p);
  169. }
  170. },
  171. getCurrentStore: function(value){
  172. var grid = Ext.getCmp('grid');
  173. var items = grid.store.data.items;
  174. var array = new Array();
  175. var o = null;
  176. Ext.each(items, function(item, index){
  177. o = new Object();
  178. o.selected = false;
  179. if(index == 0){
  180. o.prev = null;
  181. } else {
  182. o.prev = items[index-1].data[keyField];
  183. }
  184. if(index == items.length - 1){
  185. o.next = null;
  186. } else {
  187. o.next = items[index+1].data[keyField];
  188. }
  189. var v = item.data[keyField];
  190. o.value = v;
  191. if(v == value)
  192. o.selected = true;
  193. array.push(o);
  194. });
  195. return array;
  196. },
  197. vastDelete: function(){
  198. var grid = Ext.getCmp('grid');
  199. var records = grid.selModel.getSelection();
  200. if(records.length > 0){
  201. var id = new Array();
  202. Ext.each(records, function(record, index){
  203. id[index] = record.data[keyField];
  204. });
  205. var main = parent.Ext.getCmp("content-panel");
  206. main.getActiveTab().setLoading(true);//loading...
  207. Ext.Ajax.request({
  208. url : basePath + 'common/vastDelete.action',
  209. params: {
  210. caller: caller,
  211. id: id
  212. },
  213. method : 'post',
  214. callback : function(options,success,response){
  215. main.getActiveTab().setLoading(false);
  216. var localJson = new Ext.decode(response.responseText);
  217. if(localJson.exceptionInfo){
  218. showError(localJson.exceptionInfo);
  219. return "";
  220. }
  221. if(localJson.success){
  222. Ext.Msg.alert("提示", "删除成功!", function(){
  223. window.location.href = window.location.href;
  224. });
  225. }
  226. }
  227. });
  228. }
  229. }
  230. });