123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 |
- /**
- *条码拆分
- */
- Ext.define('erp.view.core.button.BreakingBatch', {
- extend : 'Ext.Button',
- alias : 'widget.erpBreakingBatchButton',
- iconCls : 'x-button-icon-check',
- cls : 'x-btn-gray',
- id : 'BreakingBatch',
- text : $I18N.common.button.erpBreakingBatchButton,
- style : {
- marginLeft : '10px'
- },
- width:100,
- initComponent : function() {
- this.callParent(arguments);
- },
- handler: function(btn){
- var me = this;
- var bool = false;
- var or_barcode;
- var or_baremain;
- var grid = Ext.getCmp('batchDealGridPanel');
- var items = grid.selModel.getSelection();
- var id ;
- Ext.each(items, function(item, index){
- if(this.data['bar_id'] != null && this.data['bar_id'] != ''
- && this.data['bar_id'] != '0' && this.data['bar_id'] != 0){
- id = this.data['bar_id'];
- or_barcode = this.data['bar_code'];
- or_baremain = this.data['bar_remain'];
- bool = true;
- }
- });
- if(bool){
- if(items.length == 1){
- var win = new Ext.window.Window({
- id: 'win',
- height: '40%',
- width: '50%',
- maximizable: false,
- title:'<span>条码拆分</span>',
- buttonAlign: 'center',
- layout: 'column',
- bodyStyle:"background-color:#F5F5F5;",
- items: [{
- xtype:'displayfield',
- name:'barcode',
- fieldLabel:'条码',
- id : 'barcode',
- readOnly:true,
- columnWidth:1,
- labelWidth:60,
- allowBlank : false,
- style:'border:none;'
- },{
- name:'bar_remain',
- fieldLabel:'数量',
- id : 'bar_remain',
- readOnly:true,
- labelWidth:60,
- allowBlank : false,
- columnWidth:.3,
- xtype:'displayfield'
- },{
- fieldLabel:"需拆分数量",
- labelStyle:"color:red;",
- labelWidth:80,
- xtype:"numberfield",
- minValue: 0,
- allowBlank:false,
- columnWidth:.45,
- name : 'barNumber',
- id:'barNumber',
- autoStripChars:true,
- hideTrigger:true
- },
- {
- xtype:'displayfield',
- name:'barcode1',
- fieldLabel:'新条码1',
- id : 'barcode1',
- readOnly:true,
- columnWidth:.75,
- labelWidth:60,
- allowBlank : false
- },
- {
- xtype:'displayfield',
- name:'number1',
- fieldLabel:'数量',
- id : 'number1',
- readOnly:true,
- columnWidth:.25,
- labelWidth:40,
- allowBlank : false
- },
- {
- xtype:'displayfield',
- name:'barcode2',
- fieldLabel:'新条码2',
- id : 'barcode2',
- readOnly:true,
- columnWidth:.75,
- labelWidth:60,
- allowBlank : false
- },{
- xtype:'displayfield',
- name:'number2',
- fieldLabel:'数量',
- id : 'number2',
- readOnly:true,
- columnWidth:.25,
- labelWidth:40,
- allowBlank : false
- },
- {
- xtype:'displayfield',
- name:'barid',
- fieldLabel:'bar_id',
- id : 'barid',
- readOnly:true,
- columnWidth:0,
- hidden:true
- }],
- buttons : [{
- text : '确定',
- id :'confirm',
- handler : function(btn) {
- var number = Ext.getCmp('barNumber').value;
- var bar_remain = Ext.getCmp("bar_remain").value;
- if (!number) {
- Ext.Msg.alert('温馨提示',
- '请输入拆分数量');
- return;
- }else if (number <= 0) {
- Ext.Msg.alert('温馨提示',
- '拆分数量必须大于0');
- return;
- }else if(number >= bar_remain){
- Ext.Msg.alert('温馨提示',
- '需拆分数量必须小于条码原数量');
- return;
- }
- if (id) {
- me.breakingBatch(id);
- }
- }
- },{
- xtype: 'checkboxfield',
- name: 'autoPrint',
- id:'autoPrint',
- boxLabel: '自动打印条码',
- style:'margin-left:50px',
- checked:true
- },{
- text : '打印新条码',
- id : 'print1',
- iconCls: 'x-button-icon-print',
- disabled : true,
- handler : function(btn) {
- var me = this;
- caller = 'Barcode!BaPrint';
- me.idS = '';
- var lps_Barcaller = 'Barcode!Print';
- var bool = false;
- var grid = Ext.getCmp('batchDealGridPanel');
- var item = Ext.getCmp("barid").value;
- var idArray = [];
- if(item != null && item != '' && item != '0' && item != 0 ){
- idArray.push(item);
- bool = true;
- }
- if(bool){
- var idS = idArray.toString();
- //me.print(idS,lps_Barcaller);
- me.idS = idS;
- me.zplPrint(lps_Barcaller);
- }else{
- showError("没有需要打印的行,请先拆分出新条码");
- }
- },
- zplPrint:function(caller){//zpl打印语句
- // 获取选择打印文件,用户选择分辨率,和打印机
- var me = this;
- if(!me.window){
- setup_web_print(function(printers,selected_printer){
- me.window = Ext.create('Ext.window.Window', {
- autoShow: true,
- title: '选择打印模板',
- width: 400,
- height: 300,
- layout: 'anchor',
- id :'template-win0',
- closeAction:'hide',
- items: [{
- anchor:'100% 100%',
- xtype:'form',
- buttonAlign : 'center',
- items:[{
- xtype: 'combo',
- id: 'printers',
- fieldLabel: '打印机列表',
- store: Ext.create('Ext.data.Store', {
- autoLoad: true,
- fields: ['display', 'value'],
- data:printers
- }),
- queryMode: 'local',
- displayField: 'display',
- valueField: 'value',
- width:361,
- allowBlank:false,
- value:selected_printer.uid,
- selectOnFocus:true,//用户不能自己输入,只能选择列表中有的记录
- style:'margin-left:15px;margin-top:15px;'
- },{
- xtype: 'combo',
- id: 'dpi',
- fieldLabel: '打印机分辨率',
- style:'margin-left:15px;margin-top:15px;',
- store: Ext.create('Ext.data.Store', {
- fields: ['display', 'value'],
- data : [{"display": '203dpi', "value": '203'},
- {"display": '300dpi', "value": '300'},
- {"display": '600dpi', "value": '600'},
- {"display": '1200dpi', "value": '1200'}]
- }),
- displayField: 'display',
- valueField: 'value',
- queryMode: 'local',
- value:resolutionCookie||'203',
- width:361,
- allowBlank:false,
- selectOnFocus:true//用户不能自己输入,只能选择列表中有的记录
- }]
- }],
- buttonAlign: 'center',
- buttons: [{
- text: '确定',
- handler: function(b) {
- var printers = Ext.getCmp('printers');
- var dpi = Ext.getCmp('dpi');
- if(printers && printers.value!= null){
- me.zebraPrint(caller,printers.value,dpi.value);
- b.ownerCt.ownerCt.close();
- }else{
- alert("请选择打印机 ");
- }
- }
- }, {
- text: '取消',
- handler: function(b) {
- b.ownerCt.ownerCt.close();
- }
- }]
- });
- });
- }else if(me.window.isHidden()){
- me.window.show();
- }
- },
- zebraPrint:function(caller,printer,dpi){
- var me = this;
- var params = new Object();
- params['condition'] = 'bar_id in ('+me.idS +")";
- sendData(caller,printer,dpi,params);
- }
- },
- {
- text : '取消',
- id : 'cancle',
- handler : function(btn) {
- var win = btn.ownerCt.ownerCt;
- win.close();
- }
- }
- ],
- listeners : {
- beforerender:function(){
- Ext.getCmp('barcode').setValue(or_barcode);
- Ext.getCmp('bar_remain').setValue(or_baremain);
- if(Ext.getCmp("barcode1").value == null || Ext.getCmp("barcode1").value ==''){
- Ext.getCmp('barcode1').hide();
- Ext.getCmp('number1').hide();
- }
- if(Ext.getCmp("barcode2").value == null || Ext.getCmp("barcode2").value ==''){
- Ext.getCmp('barcode2').hide();
- Ext.getCmp('number2').hide();
- }
- }
- }
- });
- win.show();
- /*win.on("close",function(){
- var grid = Ext.getCmp("batchDealGridPanel");
- if(grid){
- caller = 'BarcodeStatus!query';
- grid.ownerCt.down('form').onQuery();
- }
- });*/
- }else{
- showError("只能勾选一条拆分的数据");
- }
- }else{
- showError("没有勾选需要拆分的行,请勾选");
- }
- },
- breakingBatch: function(id){
- var me=this;
- var or_remain;
- var or_barcode = Ext.getCmp("barcode").getValue(); //原条码
- var or_baremain = Ext.getCmp("bar_remain").getValue(); //原数量
- var bar_remain = Ext.getCmp("barNumber").getValue(); //输入拆分的数量
- var grid = Ext.getCmp("batchDealGridPanel");
- var barcode1 = Ext.getCmp('barcode1'); //新条码1
- var barcode2 = Ext.getCmp('barcode2'); //新条码2
- var number1 = Ext.getCmp('number1');
- var number2 = Ext.getCmp('number2');
- var bar_id = Ext.getCmp("barid"); //返回的bar_id
- var idArray = [];
- me.setLoading(true);
- Ext.Ajax.request({
- url : basePath +'scm/reserve/breakingBatch.action',
- params: {
- or_barcode:or_barcode,
- or_remain: or_baremain,
- bar_remain: bar_remain
- },
- method : 'post',
- timeout: 360000,
- callback : function(options,success,response){
- me.setLoading(false);
- var res = new Ext.decode(response.responseText);
- if(res.success){
- var data = res.data;
- Ext.MessageBox.alert('提示', '条码拆分成功!',function(){
- /*grid.ownerCt.down('form').onQuery();*/
- Ext.getCmp('barcode1').show();
- Ext.getCmp('number1').show();
- Ext.getCmp("bar_remain").setValue(or_baremain - bar_remain);
- barcode1.setValue(data[0].BAR_CODE);
- number1.setValue(data[0].BAR_REMAIN);
- idArray = [];
- idArray.push(data[0].BAR_ID);
- if(data.length > 1){
- barcode2.setValue(data[1].BAR_CODE);
- number2.setValue(data[1 ].BAR_REMAIN);
- idArray.push(data[1].BAR_ID);
- Ext.getCmp('barcode2').show();
- Ext.getCmp('number2').show();
- }
- bar_id.setValue(idArray);
- Ext.getCmp('print1').enable();
- Ext.getCmp('confirm').setDisabled(true);
- var status = Ext.getCmp('autoPrint').value;
- if(status){
- var lps_Barcaller = 'Barcode!Print';
- var item = Ext.getCmp("barid").value;
- var idArray = [];
- if(item != null && item != '' && item != '0' && item != 0 ){
- idArray.push(item);
- }
- var idS = idArray.toString();
- //me.print(idS,lps_Barcaller);
- me.idS = idS;
- me.zplPrint(lps_Barcaller);
- }
- });
- }else if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- }
- }
- });
- },
- 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();
- },
- zplPrint:function(caller){//zpl打印语句
- // 获取选择打印文件,用户选择分辨率,和打印机
- var me = this;
- if(!me.window){
- setup_web_print(function(printers,selected_printer){
- me.window = Ext.create('Ext.window.Window', {
- autoShow: true,
- title: '选择打印模板',
- width: 400,
- height: 300,
- layout: 'anchor',
- id :'template-win',
- closeAction:'hide',
- items: [{
- anchor:'100% 100%',
- xtype:'form',
- buttonAlign : 'center',
- items:[{
- xtype: 'combo',
- id: 'printers',
- fieldLabel: '打印机列表',
- store: Ext.create('Ext.data.Store', {
- autoLoad: true,
- fields: ['display', 'value'],
- data:printers
- }),
- queryMode: 'local',
- displayField: 'display',
- valueField: 'value',
- width:361,
- allowBlank:false,
- value:selected_printer.uid,
- selectOnFocus:true,//用户不能自己输入,只能选择列表中有的记录
- style:'margin-left:15px;margin-top:15px;'
- },{
- xtype: 'combo',
- id: 'dpi',
- fieldLabel: '打印机分辨率',
- style:'margin-left:15px;margin-top:15px;',
- store: Ext.create('Ext.data.Store', {
- fields: ['display', 'value'],
- data : [{"display": '203dpi', "value": '203'},
- {"display": '300dpi', "value": '300'},
- {"display": '600dpi', "value": '600'},
- {"display": '1200dpi', "value": '1200'}]
- }),
- displayField: 'display',
- valueField: 'value',
- queryMode: 'local',
- value:resolutionCookie||'203',
- width:361,
- allowBlank:false,
- selectOnFocus:true//用户不能自己输入,只能选择列表中有的记录
- }]
- }],
- buttonAlign: 'center',
- buttons: [{
- text: '确定',
- handler: function(b) {
- var printers = Ext.getCmp('printers');
- var dpi = Ext.getCmp('dpi');
- if(printers && printers.value!= null){
- me.zebraPrint(caller,printers.value,dpi.value);
- b.ownerCt.ownerCt.close();
- }else{
- alert("请选择打印机 ");
- }
- }
- }, {
- text: '取消',
- handler: function(b) {
- b.ownerCt.ownerCt.close();
- }
- }]
- });
- });
- }else if(me.window.isHidden()){
- me.window.show();
- }
- },
-
- zebraPrint:function(caller,printer,dpi){
- var me = this;
- var params = new Object();
- params['condition'] = 'bar_id in ('+me.idS +")";
- sendData(caller,printer,dpi,params);
- }
- });
|