| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.scm.reserve.SetBarcode', {
- extend: 'Ext.app.Controller',
- requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil', 'erp.util.RenderUtil'],
- views:[
- 'scm.reserve.setBarcode.Viewport','scm.reserve.setBarcode.Form','scm.reserve.setBarcode.GridPanel','core.trigger.AddDbfindTrigger',
- 'core.trigger.DbfindTrigger','core.form.FtField','core.form.FtFindField','core.form.ConDateField',
- 'core.trigger.TextAreaTrigger','core.form.YnField', 'core.form.MonthDateField','core.form.ConMonthDateField','core.button.Close',
- 'core.grid.YnColumn','core.form.DateHourMinuteField','core.button.GenerateBarcode','core.button.PrintAll','core.button.DeleteAllDetails',
- 'core.button.PrintAllPackage','core.button.GeneratePaCode'
- ],
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- FormUtil: Ext.create('erp.util.FormUtil'),
- init:function(){
- var me = this;
- me.resized = false;
- var LODOP = null;
- var postStatuscode = window.parent.Ext.getCmp("pi_statuscode").value;
- this.control({
- 'erpSetBarcodeGridPanel':{
- itemclick : function(selModel, record){ //判断出入库是否已过帐,已过帐不允许对明细行进行操作,后台也需要判断
- if(caller == 'ProdInOut!BarcodeIn' && postStatuscode != 'POSTED' && postStatuscode!='已过帐'){
- if(record.data.bi_pdaget != 1){
- this.GridUtil.onGridItemClick(selModel, record);
- }
- }
- },
- afterrender:function(m){
- var grid =Ext.getCmp("setBarcodeGridPanel");
- Ext.each(grid.columns, function(c){
- if(c.dataIndex == 'bi_printstatus'){
- c.editor = null;
- }
- });
- },
- beforeedit: function(){//如果是单件管控则明细行中的入库数量不允许修改
- var grid =Ext.getCmp("setBarcodeGridPanel");
- var pr_tracekind = Ext.getCmp("pr_tracekind").value;
- if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
- Ext.each(grid.columns, function(c){
- if(c.dataIndex == 'bi_inqty'||c.dataIndex == 'bi_outqty'){
- c.editor = null;
- }
- });
- }
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- me.FormUtil.onClose();
- }
- },
- 'textfield[name=pd_outqty]':{
- afterrender:function(m){
- if(caller =='ProdInOut!BarcodeIn'){
- m.hide();
- }
- }
-
- },
- 'textfield[name=pd_qty]':{
- afterrender:function(m){
- if(caller =='ProdInOut!BarcodeOut'){
- m.hide();
- }
- }
- },
- 'dbfindtrigger[name=bi_location]':{
- afterrender:function (m){
- Ext.Ajax.request({//是否启用仓位
- url : basePath + "common/getFieldData.action",
- params: {
- caller:'configs',
- field:'data',
- condition:"code='UseLocationOrNot' and caller='BarCodeSetting'"
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.data == 'N' || res.data == 0){//不启用仓位
- m.allowBlank = true;
- m.hide();
- }
- }
- })
- }
- },
- 'textfield[name=pd_inqty]':{
- afterrender:function(m){
- if(caller == 'ProdInOut!BarcodeOut'){
- m.hide();
- }
- }
-
- },
- 'button[id=generateBarcodebtn]':{
- afterrender: function(btn){
- if(caller == 'ProdInOut!BarcodeOut'){
- btn.hide();
- }
- if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
- btn.disable(true);
- }
- },
- click:function(btn){
- //产生新的条码并插到grid行中
- var form = Ext.getCmp("setBarcodeform");
- var pd_inqty = Ext.getCmp("pd_inqty");
- if(pd_inqty && (Number(pd_inqty.value)=='0' ||Number(pd_inqty.value) == 0)){
- showError("批总量不允许为0!");return;
- }
- if(pd_inqty && (Number(pd_inqty.value) > Number(Ext.getCmp("pd_qty").value))){
- showError("批总量不允许大于来料总量");return;
- }
- var r = form.getValues();
- var keys = Ext.Object.getKeys(r);
- Ext.each(keys, function(k){
- f = form.down('#' + k);
- if(f && f.logic == 'ignore') {
- delete r[k];
- }
- });
- var param = unescape(escape(Ext.JSON.encode(r)));
- Ext.Ajax.request({
- url : basePath + "scm/reserve/generateBarcode.action",
- params: {
- caller: caller,
- formStore:param
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }else {
- window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
- }
- }
- })
- },
- enable:function(btn){
- var pr_tracekind = Ext.getCmp("pr_tracekind").value;
- if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
- btn.setDisabled(true);
- }
- }
- } ,
- 'button[id=save]': {
- afterrender: function(btn){
- if(caller == 'ProdInOut!BarcodeOut'){
- btn.hide();
- }
- if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
- btn.disable(true);
- }
- },
- click: function (btn){
- var grid =Ext.getCmp("setBarcodeGridPanel");
- if( grid.selModel.getCount() == 0 ){
- showError("没有需要处理的数据!");
- return;
- }
- var params = new Object();
- var items = grid.selModel.getSelection();
- Ext.each(items, function(item, index){
- if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
- item.index = this.data[grid.keyField];
- grid.multiselected.push(item);
- }
- var records = Ext.Array.unique(grid.multiselected);
- if(records.length > 0){
- params.caller = caller;
- var data = new Array();
- var bool = false;
- Ext.each(records, function(record, index){
- if((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)){
- bool = true;
- var o = new Object();
- if(grid.keyField){
- o[grid.keyField] = record.data[grid.keyField];
- }
- if(grid.toField){
- Ext.each(grid.toField, function(f, index){
- var v = Ext.getCmp(f).value;
- if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
- o[f] = v;
- }
- });
- }
- if(grid.necessaryFields){
- Ext.each(grid.necessaryFields, function(f, index){
- var v = record.data[f];
- if(Ext.isDate(v)){
- v = Ext.Date.toString(v);
- }
- o[f] = v;
- });
- }
- data.push(o);
- }
- });
- if(bool){
- params.gridStore = unescape(Ext.JSON.encode(data).replace(/\\/g,"%"));
- me.FormUtil.setLoading(true);
- Ext.Ajax.request({
- url : basePath + "scm/reserve/saveBarcode.action",
- params: params,
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.setLoading(false);
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }else {
- window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
- }
- }
- })
- } else {
- showError("没有需要处理的数据!");
- }
- }
-
- })
- }
- },
-
- 'button[id=batchGenBarcode]':{
- afterrender: function(btn){
- if(caller == 'ProdInOut!BarcodeOut'){
- btn.hide();
- }
- },
- enable: function (btn){
- if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
- btn.disable(true);
- }
- },
- click: function (btn){
- //产生新的条码并插到grid行中
- var form = Ext.getCmp("setBarcodeform");
- var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
- if((pr_zxbzs == 0) || pr_zxbzs < 0 ){
- showError("最小包装数必须大于0!");
- return ;
- }
- var pr_tracekind = Ext.getCmp("pr_tracekind").value;
- if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
- if(pr_zxbzs!=1){
- showError("单件管控类型的物料最小包装数只能为1 !");
- return ;
- }
- }
- var pd_inqty = Ext.getCmp("pd_inqty");
- if(pd_inqty && (Number(pd_inqty.value)=='0' ||Number(pd_inqty.value) == 0)){
- showError("批总量不允许为0!");return;
- }
- if(pd_inqty && (Number(pd_inqty.value) > Number(Ext.getCmp("pd_qty").value))){
- showError("批总量不允许大于来料总量");return;
- }
- var r = form.getValues();
- var keys = Ext.Object.getKeys(r);
- Ext.each(keys, function(k){
- f = form.down('#' + k);
- if(f && f.logic == 'ignore') {
- delete r[k];
- }
- });
- var param = unescape(escape(Ext.JSON.encode(r)));
- me.FormUtil.setLoading(true);
- Ext.Ajax.request({
- url : basePath + "scm/reserve/batchGenBarcode.action",
- params: {
- caller: caller,
- formStore:param
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.setLoading(false);
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }else {
- window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
- }
- }
- })
- }
- },
- 'button[id=batchGenBarOBcode]':{
- afterrender: function(btn){
- if(caller == 'ProdInOut!BarcodeOut'){
- btn.hide();
- }
- },
- enable: function (btn){
- if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
- btn.disable(true);
- }
- },
- click: function (btn){
- //产生新的条码并插到grid行中
- var form = Ext.getCmp("setBarcodeform");
- var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
- if((pr_zxbzs == 0) || pr_zxbzs < 0 ||pr_zxbzs ==null){
- showError("最小包装数必须大于0!");
- return ;
- }
- var pr_tracekind = Ext.getCmp("pr_tracekind").value;
- if(pr_tracekind == 1 || pr_tracekind == "单件管控"){
- if(pr_zxbzs!=1){
- showError("单件管控类型的物料最小包装数只能为1 !");
- return ;
- }
- }
- var pd_inqty = Ext.getCmp("pd_inqty");
- if(pd_inqty && (Number(pd_inqty.value) > Number(Ext.getCmp("pd_qty").value))){
- showError("批总量不允许大于来料总量");return;
- }
- if(Ext.getCmp("pk_qty").value == ''|| Ext.getCmp("pk_qty").value == 0
- ||Ext.getCmp("pk_qty").value == '0' ||Ext.getCmp("pk_qty").value == null){
- showError("请输入箱内总数");return ;
- }else {
- var pk_qty = Ext.getCmp("pk_qty").value;
- var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
- if(pr_zxbzs == ''||pr_zxbzs == 0 || pr_zxbzs == '0'||pr_zxbzs ==null){
- showError("请输入最小包装数");return ;
- }else {
- if(pk_qty%pr_zxbzs !=0 ){
- showError("箱内总数必须是最小包装数的整数倍!");return ;
- }
- }
- }
- var r = form.getValues();
- var keys = Ext.Object.getKeys(r);
- Ext.each(keys, function(k){
- f = form.down('#' + k);
- if(f && f.logic == 'ignore') {
- delete r[k];
- }
- });
- var param = unescape(escape(Ext.JSON.encode(r)));
- me.FormUtil.setLoading(true);
- Ext.Ajax.request({
- url : basePath + "scm/reserve/batchGenBarOBcode.action",
- params: {
- caller: caller,
- formStore:param
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.setLoading(false);
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }else {
- window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
- }
- }
- })
- }
- },
- //删除全部明细
- 'erpDeleteAllDetailsButton':{
- afterrender: function(btn){
- if(caller == 'ProdInOut!BarcodeOut'){
- btn.hide();
- }
- if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
- btn.disable(true);
- }
- },
- click:function (btn){
- var grid =Ext.getCmp("setBarcodeGridPanel");
- var items = grid.store.data.items;
- var bool = false;
- Ext.each(items, function(item, index){
- if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
- bool = true;
- }
- })
- if(!bool){
- showError("没有需要处理的数据!");
- return;
- }else{
- warnMsg("确定清空所有明细", function(btn){
- if(btn == 'yes'){
- Ext.Ajax.request({
- url : basePath + "scm/reserve/deleteAllBarDetails.action",
- params: {
- caller: window.parent.caller,
- no:Ext.getCmp("bi_piid").value,
- detno:Ext.getCmp("bi_pdno").value
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- var str = res.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
- str = str.replace('AFTERSUCCESS', '');
- window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
- }
- showError(str);return;
- }else {
- window.location.href = basePath +'jsps/scm/reserve/setBarcode.jsp?_noc=1&whoami='+caller+'&formCondition='+formCondition+'&gridCondition='+gridCondition;
- }
- }
- })
- }else{
- return ;
- }
- })
- }
- }
- },
- //打印条码
- 'erpPrintAllButton':{
- afterrender: function(){
- },
- click: function (btn){
- var win = new Ext.window.Window({
- id : 'win',
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- title: '打印模板选择',
- modal : true,
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami='+lps_barcaller +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- }]
-
- });
- win.show();
- }
- },
- 'erpGeneratePaCodeButton':{//生成包装箱号,要先提示生成条码之后再生成包装箱号
- afterrender: function(btn){
- if(caller == 'ProdInOut!BarcodeOut'){
- btn.hide();
- }
- if(postStatuscode == 'POSTED' || postStatuscode=='已过帐'){
- btn.disable(true);
- }
- },
- click : function (btn){
- if(Ext.getCmp("pk_qty").value == ''|| Ext.getCmp("pk_qty").value == 0
- ||Ext.getCmp("pk_qty").value == '0' ||Ext.getCmp("pk_qty").value == null){
- showError("请输入箱内总数");return ;
- }else {
- var pk_qty = Ext.getCmp("pk_qty").value;
- var pr_zxbzs = Ext.getCmp("pr_zxbzs").value;
- if(pr_zxbzs == ''||pr_zxbzs == 0 || pr_zxbzs == '0'||pr_zxbzs ==null){
- showError("请输入最小包装数");return ;
- }else {
- if(pk_qty%pr_zxbzs !=0 ){
- showError("箱内总数必须是最小包装数的整数倍!");return ;
- }
- }
- var form = Ext.getCmp("setBarcodeform");
- var r = form.getValues();
- var keys = Ext.Object.getKeys(r);
- Ext.each(keys, function(k){
- f = form.down('#' + k);
- if(f && f.logic == 'ignore') {
- delete r[k];
- }
- });
- var param = unescape(escape(Ext.JSON.encode(r)));
- Ext.Ajax.request({
- url : basePath + "scm/reserve/generatePaCode.action",
- params :{
- caller: caller,
- data : param
- },
- method : 'post',
- callback : function(options, success, response) {
- var res = new Ext.decode(response.responseText);
- if (res.exceptionInfo != null) {
- showError(res.exceptionInfo);
- return;
- }else {
- var grid =Ext.getCmp("setBarcodeGridPanel");
- gridCondition = (gridCondition == null) ? "" : gridCondition.replace(/IS/g,"=");
- grid.GridUtil.loadNewStore(grid,{caller:caller,condition:gridCondition});
- }
- }
- });
- }
- }
- },
- 'erpPrintAllPackageButton':{//打印全部箱号
- click : function (btn){
- var win = new Ext.window.Window({
- id : 'win',
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- title: '打印模板选择',
- modal : true,
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami='+lps_obcaller +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- }]
-
- });
- win.show();
- }
- }
- });
- }
- });
-
|