123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.common.QueryQ', {
- extend : 'Ext.app.Controller',
- views : ['common.query.ViewportQ', 'common.query.GridPanel', 'common.query.CheckForm', 'core.trigger.DbfindTrigger',
- 'core.form.FtField', 'core.form.ConDateField', 'core.form.YnField', 'core.form.FtDateField','core.form.YearDateField',
- 'core.form.MonthDateField','core.form.FtFindField', 'core.grid.YnColumn', 'core.grid.TfColumn', 'core.button.Refresh',
- 'core.form.ConMonthDateField', 'core.trigger.TextAreaTrigger','core.form.ConDateHourMinuteFieldQ','core.form.ConDateHourMinuteField'],
- init : function() {
- var me=this;
- this.control({
- 'erpQueryFormPanel' : {
- alladded : function(form) {
- var items = form.items.items, autoQuery = false;
- Ext.each(items, function() {
- var val = getUrlParam(this.name);
- if(!Ext.isEmpty(val)) {
- this.setValue(val);
- autoQuery = true;
- if(this.xtype == 'dbfindtrigger') {
- this.autoDbfind('form', caller, this.name, this.name + " like '%" + val + "%'");
- }
- }
- });
- if(autoQuery) {
- setTimeout(function(){
- form.onQuery();
- }, 1000);
- }
- }
- },
- 'button[name=refresh]':{
- click: function(btn){
- var form = me.getForm(btn);
- if (caller == 'ALMonth!Query'){
- var month = Ext.getCmp('am_yearmonth');
- var condition=month.secondVal;
- Ext.Ajax.request({
- url: basePath + 'fa/ars/CmQueryController/refreshQuery.action',
- params: {
- condition:condition
- },
- method: 'post',
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.success) {
- form.onQuery();
- }else{
-
- }
- }
- });
- }else{
- form.onQuery();
- }
- }
- },
- 'erpQueryGridPanel' : {
- storeloaded: function(grid){
- me.getProductWh(grid);
- }
- },
- 'monthdatefield': {
- afterrender: function(f) {
- var type = '';
- if(f.name == 'cd_yearmonth') {
- type = 'MONTH-T';
- }
- if(f.name == 'cmc_yearmonth') {
- type = 'MONTH-A';
- }
- if(f.name == 'cm_yearmonth') {
- type = 'MONTH-A';
- }
- if(f.name == 'am_yearmonth') {
- type = 'MONTH-B';
- }
- if(type != '' && Ext.isEmpty(getUrlParam(f.name))) {
- this.getCurrentMonth(f, type);
- }
- }
- },
- 'conmonthdatefield': {
- afterrender: function(f) {
- var type = '';
- if(f.name == 'cd_yearmonth') {
- type = 'MONTH-T';
- }
- if(f.name == 'cmc_yearmonth') {
- type = 'MONTH-A';
- }
- if(f.name == 'cm_yearmonth') {
- type = 'MONTH-A';
- }
- if(f.name == 'am_yearmonth') {
- type = 'MONTH-B';
- }
- if(type != '' && Ext.isEmpty(getUrlParam(f.name))) {
- this.getCurrentMonth(f, type);
- }
- }
- }
- });
- },
- onGridItemClick : function(selModel, record) {
- if (caller == 'CustMonth!ARLI!Query') {
- var cmid = record.data['cm_id'];
- if (cmid > 0) {
- var panel = Ext.getCmp(caller + "cm_id" + "=" + cmid);
- 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);// 用于单据翻页
- 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);
- }
- }
- }
- if(caller=='Sale!saledetailDet'){
- this.schedule(record);
- }
- },
- schedule: function(record) {
- var width = Ext.isIE ? screen.width*0.7*0.9 : '80%',
- height = Ext.isIE ? screen.height*0.75 : '100%';
- var sd_id = record.get('sd_id');
- Ext.Ajax.request({
- url : basePath + "scm/sale/checkSaleDetailDet.action",
- params: {
- whereString: "sd_id="+sd_id
- },
- method : 'post',
- async: false,
- callback:function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- }
- }
- });
- Ext.create('Ext.Window', {
- width: width,
- height: height,
- autoShow: true,
- layout: 'anchor',
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_dbfind" src="' + basePath + 'jsps/scm/sale/saleDetail.jsp?formCondition=sd_id='
- + sd_id + '&gridCondition=sdd_sdid=' + sd_id + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- }]
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- 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);
- }
- }
- });
- },
- getProductWh: function(grid) {
- var prodfield = 'pr_code';
- if(prodfield) {
- var codes = [];
- grid.store.each(function(d){
- codes.push("'" + d.get(prodfield) + "'");
- });
- Ext.Ajax.request({
- url: basePath + 'scm/product/getProductwh.action',
- params: {
- codes: codes.join(',')
- },
- callback: function (opt, s, r) {
- if(s) {
- var rs = Ext.decode(r.responseText);
- if(rs.data) {
- grid.productwh = rs.data;
- }
- }
- }
- });
- }
- }
- });
|