| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.bom.ProdRelation', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'core.form.Panel','pm.bom.ProdRelation','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField',
- 'core.button.Save','core.button.Add','core.button.Submit','core.button.ResAudit',
- 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
- 'core.button.ResSubmit','core.button.Banned','core.button.ResBanned',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField'
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpGridPanel2': {
- itemclick: this.onGridItemClick
- },
- 'erpSaveButton': {
- click: function(btn){
- var me = this;
- var form = me.getForm(btn);
- if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
- me.BaseUtil.getRandomNumber();//自动添加编号
- }
- this.FormUtil.beforeSave(this);
- }
- },
- 'erpDeleteButton' : {
- click: function(btn){
- warnMsg("确定要删除单据吗?", function(btn){
- if(btn == 'yes'){
- var id= Ext.getCmp('prr_thisid').value;
- me.setLoading(true);
- Ext.Ajax.request({
- url : basePath + 'pm/bom/deleteProdRelation.action',
- params: {
- id: id
- },
- method : 'post',
- callback : function(options,success,response){
- me.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- delSuccess(function(){
- me.FormUtil.beforeClose(me);
- });//@i18n/i18n.js
- } else {
- delFailure();
- }
- }
- });
- }
- });
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- this.FormUtil.onUpdate(this);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addProdRelation', '新增物料标准替代库', 'jsps/pm/bom/prodRelation.jsp');
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- me.FormUtil.beforeClose(me);
- }
- },
- 'erpSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('prr_usestatuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- var me = this;
- var id= Ext.getCmp('prr_thisid').value;
- me.setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'pm/bom/submitProdRelation.action',
- params: {
- id: id
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- showError(str);
- }else {
- if(localJson.MultiAssign){
- me.showAssignWin(localJson.assigns,localJson.nodeId);
- }else {
- showMessage('提示', '提交成功!', 1000);
- window.location.reload();
- }
- }
- }
- });
- }
- },
- 'erpResSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('prr_usestatuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- var me = this;
- var id= Ext.getCmp('prr_thisid').value;
- me.setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'pm/bom/resSubmitProdRelation.action',
- params: {
- id: id
- },
- method : 'post',
- callback : function(options,success,response){
- me.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- showMessage('提示', '反提交成功!', 1000);
- window.location.reload();
- }
- }
- });
- }
- },
- 'erpAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('prr_usestatuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- var me = this;
- var id= Ext.getCmp('prr_thisid').value;
- me.setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'pm/bom/auditProdRelation.action',
- params: {
- id: id
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- showError(str);
- }else {
- if(localJson.MultiAssign){
- me.showAssignWin(localJson.assigns,localJson.nodeId);
- }else {
- showMessage('提示', '审核成功!', 1000);
- window.location.reload();
- }
- }
- }
- });
- }
- },
- 'erpResAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('prr_usestatuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- var me = this;
- var id= Ext.getCmp('prr_thisid').value;
- me.setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'pm/bom/resAuditProdRelation.action',
- params: {
- id: id
- },
- method : 'post',
- callback : function(options,success,response){
- me.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- showMessage('提示', '反审核成功!', 1000);
- window.location.reload();
- }
- }
- });
- }
- },
- 'erpBannedButton': {
- click: function(m){
- var me = this;
- me.turn('ProdRelation!Banned', ' prr_thisid=' + Ext.getCmp('prr_thisid').value +' and prr_usestatuscode=\'AUDITED\'', 'pm/bom/bannedProdRelation.action');
- }
- },
- 'dbfindtrigger[name=ra_topid]':{
- afterrender: function(){
- var id = Ext.getCmp('prr_thisid').value;
- if(id != null & id != ''){
- this.getProdRelationStore('prr_thisid=' + id);
- }
- },
- aftertrigger: function(){
- var id = Ext.getCmp('prr_thisid').value;
- if(id != null & id != ''){
- this.getProdRelationStore('prr_thisid=' + id);
- }
- }
- }
- });
- },
- onGridItemClick: function(selModel, record){//grid行选择
- this.GridUtil.onGridItemClick(selModel, record);
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- turn: function(nCaller, condition, url){
- var win = new Ext.window.Window({
- id : 'win',
- height: "100%",
- width: "80%",
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/common/editorColumn.jsp?caller=' + nCaller
- + "&condition=" + condition +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- }],
- buttons : [{
- name: 'confirm',
- text : $I18N.common.button.erpConfirmButton,
- iconCls: 'x-button-icon-confirm',
- cls: 'x-btn-gray',
- listeners: {
- buffer: 500,
- click: function(btn) {
- var grid = Ext.getCmp('win').items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow.Ext.getCmp("editorColumnGridPanel");
- btn.setDisabled(true);
- grid.updateAction(url);
- window.location.reload();
- }
- }
- }, {
- text : $I18N.common.button.erpCloseButton,
- iconCls: 'x-button-icon-close',
- cls: 'x-btn-gray',
- handler : function(){
- Ext.getCmp('win').close();
- }
- }]
- });
- win.show();
- },
- getProdRelationStore: function(condition){
- var me = this;
- var grid = Ext.getCmp('grid');
- grid.store.removeAll(false);
- me.BaseUtil.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({//拿到grid的columns
- url : basePath + "common/singleGridPanel.action",
- params: {
- caller: "ProdRelation",
- condition: condition
- },
- method : 'post',
- callback : function(options,success,response){
- me.BaseUtil.getActiveTab().setLoading(false);
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- }
- var data = [];
- if(!res.data || res.data.length == 2){
- me.GridUtil.add10EmptyItems(grid);
- } else {
- data = Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']'));
- if(data.length > 0){
- grid.store.loadData(data);
- }
- }
- }
- });
- },
- setLoading : function(b) {
- var mask = this.mask;
- if (!mask) {
- this.mask = mask = new Ext.LoadMask(Ext.getBody(), {
- msg : "处理中,请稍后...",
- msgCls : 'z-index:10000;'
- });
- }
- if (b)
- mask.show();
- else
- mask.hide();
- }
- });
|