| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.oa.meeting.MeetingRoomInfo', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'oa.meeting.MeetingRoomInfo','core.form.Panel','core.trigger.MultiDbfindTrigger','common.datalist.GridPanel','common.datalist.Toolbar',
- 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print',
- 'core.button.Upload','core.button.Update','core.button.Delete','core.button.ResAudit','core.button.ResSubmit',
- 'core.form.YnField','core.trigger.DbfindTrigger','common.query.Form'
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpDatalistGridPanel': {
- afterrender: function(grid){
- grid.onGridItemClick = function(){//改为点击button进入详细界面
- me.onGridItemClick(grid.selModel.lastSelected);
- };
- }
- },
- 'button[id=delete]': {
- click: function(){
- me.vastDelete();
- }
- },
- 'button[id=add]': {
- click: function(){
- me.newMeetingRoom();
- }
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn);
- if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
- me.BaseUtil.getRandomNumber();//自动添加编号
- }
- this.FormUtil.beforeSave(this);
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- this.FormUtil.beforeClose(this);
- }
- },
- 'erpAddButton': {
- click: function(btn){
- me.FormUtil.onAdd('addMeetingRoom', '新增会议室', 'jsps/oa/meeting/meetingRoom.jsp');
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- this.FormUtil.onUpdate(this);
- }
- },
- 'erpDeleteButton': {
- click: function(btn){
- me.FormUtil.onDelete((Ext.getCmp('mr_id').value));
- }
- },
- 'erpAuditButton': {
- click: function(btn){
- this.FormUtil.onAudit(Ext.getCmp('mr_id').value);
- }
- },
- 'erpResAuditButton': {
- click: function(btn){
- this.FormUtil.onResAudit(Ext.getCmp('mr_id').value);
- }
- },
- 'erpSubmitButton': {
- click: function(btn){
- this.FormUtil.onSubmit(Ext.getCmp('mr_id').value);
-
- }
- },
- 'erpResSubmitButton': {
- click: function(btn){
- this.FormUtil.onResSubmit(Ext.getCmp('mr_id').value);
- }
- }
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- newMeetingRoom: function(){
- var win = new Ext.window.Window({
- id : 'win',
- title: "会议室设置",
- height: "100%",
- width: "100%",
- maximizable : false,
- buttonAlign : 'left',
- layout : 'anchor',
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '80% 80%',
- layout : 'fit',
- html : '<iframe id="iframe_' + new Date() + '" src="' + basePath + 'jsps/oa/meeting/new.jsp" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
- }]
- });
- win.show();
- },
- onGridItemClick: function(record){
- var me = this;
- if(keyField != null && keyField != ''){
- var value = record.data[keyField];
- var formCondition = keyField + "IS" + value ;
- var gridCondition = pfField + "IS" + value;
- var panel = Ext.getCmp(caller + keyField + "=" + value);
- var main = parent.Ext.getCmp("content-panel");
- if(!main){
- main = parent.parent.Ext.getCmp("content-panel");
- }
- if(!panel){
- var title = "";
- if (value.toString().length>4) {
- title = value.toString().substring(value.toString().length-4);
- } else {
- title = value;
- }
- var myurl = '';
- if(contains(url, '?', true)){
- myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
- } else {
- myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
- }
- myurl += "&datalistId=" + main.getActiveTab().id;
- main.getActiveTab().currentStore = me.getCurrentStore(value);//用于单据翻页
- panel = {
- title : me.BaseUtil.getActiveTab().title+'('+title+')',
- tag : 'iframe',
- tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
- frame : true,
- border : false,
- layout : 'fit',
- iconCls : 'x-tree-icon-tab-tab1',
- html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
- closable : true,
- listeners : {
- close : function(){
- if(!main){
- main = parent.parent.Ext.getCmp("content-panel");
- }
- main.setActiveTab(main.getActiveTab().id);
- }
- }
- };
- this.openTab(panel, caller + keyField + "=" + record.data[keyField]);
- }else{
- main.setActiveTab(panel);
- }
- }
- },
- openTab : function (panel,id){
- var o = (typeof panel == "string" ? panel : id || panel.id);
- var main = parent.Ext.getCmp("content-panel");
- if(!main) {
- main =parent.parent.Ext.getCmp("content-panel");
- }
- var tab = main.getComponent(o);
- if (tab) {
- main.setActiveTab(tab);
- } else if(typeof panel!="string"){
- panel.id = o;
- var p = main.add(panel);
- main.setActiveTab(p);
- }
- },
- getCurrentStore: function(value){
- var grid = Ext.getCmp('grid');
- var items = grid.store.data.items;
- var array = new Array();
- var o = null;
- Ext.each(items, function(item, index){
- o = new Object();
- o.selected = false;
- if(index == 0){
- o.prev = null;
- } else {
- o.prev = items[index-1].data[keyField];
- }
- if(index == items.length - 1){
- o.next = null;
- } else {
- o.next = items[index+1].data[keyField];
- }
- var v = item.data[keyField];
- o.value = v;
- if(v == value)
- o.selected = true;
- array.push(o);
- });
- return array;
- },
- vastDelete: function(){
- var grid = Ext.getCmp('grid');
- var records = grid.selModel.getSelection();
- if(records.length > 0){
- var id = new Array();
- Ext.each(records, function(record, index){
- id[index] = record.data[keyField];
- });
- var main = parent.Ext.getCmp("content-panel");
- main.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'common/vastDelete.action',
- params: {
- caller: caller,
- id: id
- },
- method : 'post',
- callback : function(options,success,response){
- main.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- return "";
- }
- if(localJson.success){
- Ext.Msg.alert("提示", "删除成功!", function(){
- window.location.href = window.location.href;
- });
- }
- }
- });
- }
- }
- });
|