liqingcheng11 2021-06-03 21:27 采纳率: 0%
浏览 78

客户退货如果商品数目大于库存数,怎么写预警和弹窗??

 输入完毕出现库存成负数了

这是退货的js代码

/*!
 * 退货出库
 */
Ext.onReady(function(){
	
	Ext.QuickTips.init();
	
	var SpxxObj = [
		{ name:'spid', type:'string'},
		{ name:'spname', type:'string'},
		{ name:'xinghao', type:'string'},
		{ name:'dw', type:'string'},
		{ name:'jhprice', type:'string'},
		{ name:'chprice', type:'string'},
		{ name:'minnum', type:'string'},
		{ name:'csname', type:'string'},
		{ name:'bz', type:'string'},
		{ name:'lbid', type:'int'},
		{ name:'lbname', type:'string'}
	];
	
	//退货商品数据
	var thspStore = new Ext.data.JsonStore({
	    url: 'spxx_findPageSpxx.do',
	    root: 'root',
	    totalProperty: 'total',
	    fields: SpxxObj,
	    listeners:{beforeload:function(a){a.baseParams={start:v_start, limit:v_limit};}}
	});
	
	//退货商品列表
    var thspGrid = new Ext.grid.GridPanel({
    	id:'djspGrid',
        store: thspStore,
        cm: new Ext.grid.ColumnModel({
			defaults: {	menuDisabled : true},//禁止表头菜单
			columns:[new Ext.grid.RowNumberer(),
				{header: '商品编号', width: 100, sortable:true, dataIndex: 'spid'},
	            {header: '商品名称', width: 200, sortable:true, dataIndex: 'spname'},
	            {header: '商品型号', width: 150, sortable:true, dataIndex: 'xinghao'},
	            {header: '单位', width: 100, sortable:true, dataIndex: 'dw'},
	            {header: '单价', width: 100, sortable:true, align:'right', renderer:zhMoney, dataIndex: 'cbj'},
	            {header: '数量', width: 100, sortable:true, align:'center', dataIndex: 'sl'},
	            {header: '总金额', width: 100, sortable:true, align:'right', renderer:zhMoney, dataIndex: 'zj'}]
        }),
        stripeRows: true, 	//行分隔符
        columnLines : true, //列分隔符
        margins:'20',
        style:'border:1px solid',
		region:'center',
        iconCls:'',
        
        tbar:[{
        	text:'添加',
        	iconCls:'btn-add',
        	handler: function(){
        		bsspWindow.show();
        	}
        },'-',{
        	text:'修改',
        	iconCls:'btn-edit',
        	handler: function(){
        		var record= thspGrid.getSelectionModel().getSelected(); 
				if(!record){
                	Ext.Msg.alert('信息提示','请选择要修改的商品');
				}else{
	        		addJhWindow.show();
	        		addJhWindow.buttons[0].setVisible(false);
	        		record.set("update","true");
					addJhForm.getForm().loadRecord(record);
				}
        	}
        },'-',{
        	text:'删除',
        	iconCls:'btn-remove',
        	handler: function(){
        		var record= thspGrid.getSelectionModel().getSelected();
				if(!record){
                	Ext.Msg.alert('信息提示','请选择要删除的商品');  
				}else{
					Ext.MessageBox.confirm('删除提示', '是否删除该记录?', function(c) {
						var djForm = Ext.getCmp("djForm").getForm();
						var yfje = djForm.findField("yfje").getValue();
						var sfje = djForm.findField("sfje").getValue();
						djForm.findField("yfje").setValue(yfje-record.get("zj"));
						djForm.findField("sfje").setValue(sfje-record.get("zj"));
						thspStore.remove(record);
					});
				}
        	}
        }],
        
        listeners:{
        	rowdblclick:function(){
        		var record= thspGrid.getSelectionModel().getSelected(); 
				if(record){
	        		addJhWindow.show();
	        		addJhWindow.buttons[0].setVisible(false);
	        		record.set("update","true");
					addJhForm.getForm().loadRecord(record);
				}
        	}
        }
    });
    
	//供应商下拉数据
    var gysStore = new Ext.data.JsonStore({
		url: 'gys_findGysComb.do',
	    root: 'root',
	    totalProperty: 'total',
	    fields: ['value','text'],
	    listeners:{
	    	load:function(s){
	    		r = s.getAt(0);
	    		if(r){
	    			Ext.getCmp("gyscombo").onSelect(r, 0);
	    		}
	    	}
	    }
	});
		
	//退货表单
	var thdForm = new Ext.FormPanel({
		id:'djForm',
		region:'north',
		height: 110,
		border : false,
		layout : 'form',
		labelWidth:60,
		padding : 20,
		items:[{
			id:"thdfieldset",
			xtype:"fieldset",
			title:"单号:",
			padding:'0 20 0 15',
			items:[{
				layout:"column",
				defaults:{
					xtype:"container",
					autoEl:"div",
					columnWidth:0.2,
					labelAlign:'right',
					layout:"form"
				},
				items:[{
					items:[{
							width:100,
							id:'gyscombo',
							xtype:'combo',
							hiddenName:'gysid',
							fieldLabel:'供应商',
							mode: 'local',
							triggerAction: 'all',
							valueField :'value',
							displayField: 'text',
							allowBlank : false,
							editable : false,
							store : gysStore,
							listeners:{
								select : function(a,b){
									thdForm.getForm().findField("gysname").setValue(b.data.text);
								}
							}
					}]
				},{
					items:[{
						xtype:"numberfield",
						name:'yfje',
						fieldLabel:"应付金额",
						style:"background:#F6F6F6",
						readOnly:true,
						anchor:"90%",
						maxLength :200
					}]
				},{
					items:[{
						xtype:"numberfield",
						name:'sfje',
						fieldLabel:"实付金额",
						allowBlank : false,
						anchor:"90%",
						maxLength :200
					}]
				},{columnWidth:0.1},{
					items:[{
						id:'thriqi',
						xtype:"datefield",
						name:'riqi',
						fieldLabel:"收货日期",
						format:'Y-m-d',
						allowBlank : false,
						value:new Date(),
						anchor:"90%",
						listeners:{
							select : function(a,b){
								getCode(b.format("Y-m-d"));
							}
						}
					}]
				}]
			},{
				layout:"column",
				defaults:{
					xtype:"container",
					autoEl:"div",
					labelAlign:'right',
					layout:"form"
				},
				items:[{
					columnWidth:.4,
					items:[{
						xtype:"textfield",
						name:'bz',
						fieldLabel:"备   注",
						anchor:"95%",
						maxLength :200
					}]
				},{
					columnWidth:0.4,
					items:[{
						xtype:'combo',
						hiddenName:'jystate',
						fieldLabel:'是否付款',
						mode: 'local',
						triggerAction: 'all',
						valueField :'value',
						displayField: 'text',
						allowBlank : false,
						editable : false,
						anchor:"45%",
						value:'1',
						store : new Ext.data.SimpleStore({
						    fields: ['value', 'text'],
						    data : [['1','已付'],['0','未付']]
						})
					}]
				},{
					columnWidth:.2,
					items:[{
						width:75,
						xtype:"button",
						text:'保存',
						handler:function(){
							var f = thdForm.getForm();
							if (f.isValid()) {
								if(thspStore.getCount()<=0){
									Ext.Msg.alert("信息提示","请添加商品");
									return;
								}
								var jsonArray = [];
						        thspStore.each(function(item) {
						            jsonArray.push(item.data);
						        });
								f.submit({
									url : 'jh_saveOrUpdateThd.do',
									params :{djsps:Ext.encode(jsonArray) },
									success : function(form, action) {
										Ext.Msg.alert("信息提示","数据保存成功",function(){
											getCode();
											f.findField("bz").setValue("");
											f.findField("yfje").setValue("");
											f.findField("sfje").setValue("");
											f.clearInvalid();
											thspStore.removeAll();
										});
									},
									failure : function(form, action) {
										if(action.result && action.result.errors){
											Ext.Msg.alert('信息提示',action.result.errors);
										}else{
											Ext.Msg.alert('信息提示','连接失败');
										}
									}
								});
							}
						}
					}]
				}]
			},{
				xtype:'hidden',
				name:'djid'
			},{
				xtype:'hidden',
				name:'gysname'
			}]
		}]
	});
	//设置单据编号
	var getCode = function(){
		var ymd = Ext.getCmp("thriqi").getValue().format("Y-m-d");
		Ext.Ajax.request({
   			url : "jh_getDjCode.do",
   			params : {tab:'Thd',ymd:ymd},
   			success : function(o) {
   				if(o.responseText){
   					var code = "TH"+o.responseText;
   					Ext.getCmp("thdfieldset").setTitle("单号:"+code);
   					thdForm.getForm().findField("djid").setValue(code);
   				}
   			}
   		});
	};
	
	//布局
    new Ext.Viewport({
		layout:'fit',
		items:[{
			frame:true,
			title:'退货出库',
			iconCls:'menu-12',
			layout:'border',
			items:[thdForm,thspGrid]
		}],
		listeners:{
			render:function(){
				getCode();
				gysStore.load();
			}
		}
	});
	

	

});

这是退货的jsp页面

<%@ page language="java" pageEncoding="UTF-8"%>
<html>
  <head>
  	<title>退货出库</title>
    <link rel="stylesheet" type="text/css" href="../../ext/resources/css/ext-all.css">
    <link rel="stylesheet" type="text/css" href="../../css/ext-icon.css">
    <script type="text/javascript" src="../../ext/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="../../ext/ext-all.js"></script>
    <script type="text/javascript" src="../../ext/ext-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../ext/ux/SearchField.js"></script>
    <script type="text/javascript" src="../../js/utils.js"></script>
    <script type="text/javascript" src="../kucun/spxx.js"></script>
    <script type="text/javascript" src="tuihuo.js"></script>
  </head>
  <body>
  </body>
</html>
  • 写回答

4条回答 默认 最新

  • CSDN专家-微编程 2021-06-03 21:51
    关注

    前端可以通过javaScript或者JQuery的方法获取这两个输入框的数值比如 document.getElementById()

    进行比较两个数值,如果数量大于库存,则弹出警告窗 alert("库存数量不足")

    如果库存大于或等于数量,则正常进行

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作