| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.make.SNRange', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- views:[
- 'pm.make.SNRange','core.form.Panel','pm.make.SNRangeGrid','common.datalist.Toolbar',
- 'core.button.DownloadTemp','core.button.SNimport','core.button.ClearSN','core.button.UpExcel',
- 'core.button.Close'
- ],
- init:function(){
- var me = this;
- me.BaseUtil = Ext.create('erp.util.BaseUtil');
- me.GridUtil = Ext.create('erp.util.GridUtil');
- this.control({
- 'erpDownloadTempButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('re_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- var grid = Ext.getCmp('grid1');
- if(grid){
- me.BaseUtil.exportGrid(grid);
- }
- }
- },
- 'erpSNimportButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('re_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- var grid = Ext.getCmp('grid1');
- btn.upexcel = function(field){
- if(grid){
- btn.getForm().submit({
- url: basePath + 'pm/make/upexcel.action?caller='+caller,
- waitMsg: "正在解析Excel",
- success: function(fp, o){
- field.reset();
- grid.ilid = o.result.ilid;
- me.checkdata(grid);
- },
- failure: function(fp, o){
- if(o.result.size){
- showError(o.result.error + " " + Ext.util.Format.fileSize(o.result.size));
- field.reset();
- } else {
- showError(o.result.error);
- field.reset();
- }
- }
- });
-
- }
- };
- }
- },
- 'erpClearSNButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('re_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- var reid = Ext.getCmp('re_id').value;
- var grid = Ext.getCmp('grid1');
- if(grid&&grid.getStore().getCount()==0){
- showError('明细行为空,不需要清除');
- }else{
- me.clearSN(reid);
- }
- }
- }
- })
- },
- /**
- * 数据校验
- */
- checkdata: function(grid){
- var me = this;
- var p = Ext.create('Ext.ProgressBar', {
- width: '60%',
- text: '准备校验中...',
- floating: true,
- renderTo: Ext.getBody()
- }).show();
- grid.setLoading(true);
- // 校验+清除校验环境
- me.onCheck(grid, p, function(){
- //刷新grid.renderer
- me.getCheckResult(grid, p);
- });
- },
- onCheck: function(grid, process, callback) {
- process.updateProgress(0.4, '准备完毕,正在校验...', true);
- Ext.Ajax.request({
- url: basePath + 'pm/make/checkInitData.action',
- timeout: 300000,
- params: {
- id: grid.ilid,
- caller : caller
- },
- method: 'post',
- callback: function(opt, s, r){
- var res = Ext.decode(r.responseText);
- if(!res) {
- grid.setLoading(false);
- p.destroy();
- Ext.Msg.alert('发现错误', '连接超时');
- } else if(res.success) {
- process.updateProgress(0.8, '校验完成,正在获取校验结果...', true);
- callback.call();
- }
- }
- });
- },
- /**
- * 从数据库取校验结果
- */
- getCheckResult: function(grid, p){
- var reid = Ext.getCmp('re_id').value;
- grid.setLoading(true);
- Ext.Ajax.request({
- url: basePath + 'pm/make/checkOrInsert.action',
- timeout: 60000,
- params: {
- id: grid.ilid,
- reid:reid
- },
- method: 'post',
- callback: function(opt, s, r){
- p.destroy();
- grid.setLoading(false);
- var res = r.responseText;
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- } else {
- Ext.Msg.alert("提示","导入成功!",function(){
- window.location.reload();
- });
- }
- }
- });
- },
- clearSN: function(id){
- var mm = this;
- Ext.Ajax.request({
- url : basePath + "pm/make/cleardetail.action",
- params: {
- id : id,
- caller : caller
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }else{
- Ext.Msg.alert("提示","清除成功!",function(){
- window.location.reload();
- });
- }
- }
- });
- }
- });
|