123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.common.QueryDetail', {
- extend : 'Ext.app.Controller',
- requires: ['erp.util.BaseUtil'],
- views : [ 'common.queryDetail.Viewport', 'common.datalist.GridPanel', 'common.query.Form', 'core.trigger.DbfindTrigger',
- 'core.form.FtField', 'core.form.ConDateField', 'core.form.YnField', 'core.form.FtDateField','common.datalist.Toolbar',
- 'core.form.MonthDateField','core.form.FtFindField', 'core.grid.YnColumn', 'core.grid.TfColumn',
- 'core.form.ConMonthDateField' ],
- init : function() {
- this.BaseUtil = Ext.create('erp.util.BaseUtil');
- this.control({
- 'erpQueryFormPanel button[id=query]' : {
- click : function(btn) {
- var grid = Ext.getCmp('grid');
- var form = btn.ownerCt.ownerCt;
- var urlcondition = grid.defaultCondition || '';
- condition = form.spellCondition(urlcondition);
- grid.formCondition = condition;
- grid.getCount(null, condition);
- }
- },
- 'erpQueryFormPanel': {
- afterrender: function(f) {
- f.down('button[name=query]').handler = Ext.emptyFn;
- f.down('button[name=export]').handler = function(btn){
- var grid = Ext.getCmp('grid');
- var condition = grid.getCondition() || '';
- condition = f.spellCondition(condition);
- if(Ext.isEmpty(condition)) {
- condition = '1=1';
- }
- grid.BaseUtil.createExcel(caller, 'datalist', condition);
- };
- }
- },
- 'erpDatalistGridPanel' : {
- itemclick : this.onGridItemClick,
- afterrender:function(grid){
- if(Ext.isIE){
- document.body.attachEvent('onkeydown', function(){
- if(window.event.ctrlKey && window.event.keyCode == 67){//Ctrl + C
- var e = window.event;
- if(e.srcElement) {
- window.clipboardData.setData('text', e.srcElement.innerHTML);
- }
- }
- });
- } else {
- grid.getEl().dom.addEventListener("mouseover", function(e){
- if(e.ctrlKey){
- var Contextvalue=e.target.textContent==""?e.target.value:e.target.textContent;
- textarea_text = parent.document.getElementById("textarea_text");
- textarea_text.value=Contextvalue;
- textarea_text.focus();
- textarea_text.select();
- }
- });
- }
- }
- },
- 'monthdatefield': {
- afterrender: function(f) {
- var type = '';
- if(f.name == 'cd_yearmonth') {
- type = 'MONTH-T';
- }
- if(type != '') {
- this.getCurrentMonth(f, type);
- }
- }
- }
- });
- },
- onGridItemClick: function(selModel, record){//grid行选择
- if(keyField != null && keyField != ''){//有些datalist不需要打开明细表,这些表在datalist表里面不用配dl_keyField
- if(keyField.indexOf('+') > 0) {//多条件传入查询界面//vd_vsid@vd_id+vd_class@vd_class
- this.openQueryUrl(record);
- } else {
- this.openUrl(record);
- }
- }
- },
- openUrl: function(record) {
- var me = this, value = record.data[keyField];
- var formCondition = keyField + "IS" + value ;
- var gridCondition = pfField + "IS" + value;
- if(!Ext.isEmpty(pfField) && pfField.indexOf('+') > -1) {//多条件传入维护界面//vd_vsid@vd_id+vd_class@vd_class
- var arr = pfField.split('+'),ff = [],k = [];
- Ext.Array.each(arr, function(r){
- ff = r.split('@');
- k.push(ff[0] + 'IS\'' + record.get(ff[1]) + '\'');
- });
- gridCondition = k.join(' AND ');
- }
- var panelId = caller + keyField + "_" + value + gridCondition;
- var panel = Ext.getCmp(panelId);
- 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(me.BaseUtil.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);//用于单据翻页
- if(main._mobile) {
- main.addPanel(me.BaseUtil.getActiveTab().title+'('+title+')', myurl, panelId);
- } else {
- 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" style="border-width: 0px;padding: 0px;" 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, panelId);
- }
- }else{
- main.setActiveTab(panel);
- }
- },
- openQueryUrl: function(record) {
- var me = this, arr = keyField.split('+'),ff = [],k = [];//vd_vsid@vd_id+vd_class@vd_class
- Ext.Array.each(arr, function(r){
- ff = r.split('@');
- k.push(ff[0] + '=' + record.get(ff[1]));
- });
- var myurl = k.join('&');
- var panelId = caller + "_" + myurl;
- var panel = Ext.getCmp(panelId);
- var main = parent.Ext.getCmp("content-panel");
- if(!main){
- main = parent.parent.Ext.getCmp("content-panel");
- }
- if(!panel){
- var title = me.BaseUtil.getActiveTab().title + '-查询';
- if(contains(url, '?', true)){
- myurl = url + '&' + myurl;
- } else {
- myurl = url + '?' + myurl;
- }
- if (main._mobile) {
- main.addPanel(title, myurl, panelId);
- } else {
- panel = {
- title : title,
- tag : 'iframe',
- tabConfig: {tooltip: title},
- frame : true,
- border : false,
- layout : 'fit',
- iconCls : 'x-tree-icon-tab-tab1',
- html : '<iframe src="' + myurl + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" 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, panelId);
- }
- } else {
- main.setActiveTab(panel);
- }
- },
- openTab : function (panel,id){
- var o = (typeof panel == "string" ? panel : id || panel.id);
- var main = parent.Ext.getCmp("content-panel");
- /*var tab = main.getComponent(o); */
- 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;
- },
- getFilterCondition: function(){
- var fields = Ext.getCmp('grid').plugins[0].fields;
- var items = new Array();
- Ext.each(Ext.Object.getKeys(fields), function(key){
- var item = fields[key];
- if(item.value != null && item.value.toString().trim() != ''){
- items.push({
- xtype: item.xtype,
- id: item.itemId,
- fieldLabel: item.fieldLabel,
- fieldStyle: item.fieldStyle,
- value: item.value,
- columnWidth: 0.5,
- cls: 'form-field-border',
- listeners: {
- change: function(f){
- Ext.getCmp(item.id).setValue(f.value);
- }
- }
- });
- }
- });
- return items;
- },
- getCurrentMonth: function(f, type) {
- Ext.Ajax.request({
- url: basePath + 'fa/getMonth.action',
- params: {
- type: type
- },
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.data) {
- f.setValue(rs.data.PD_DETNO);
- }
- }
- });
- }
- });
|