计算利润 利润等于售价减进价 计算后将利润自动添加的文本中,在做表单提交

<%@ page contentType="text/html;charset=utf-8"%>
<%@ page language="java" import="java.util.*"%>
<%@ page language="java" import="com.beyond.framework.common.config.*"%>
<%@ page language="java" import="com.beyond.framework.util.tools.*"%>
<%@ page language="java" import="com.beyond.framework.user.entity.*"%>
<%@ page import="com.beyond.framework.dictionary.entity.DictionaryInfo"%>
<%@page import="com.beyond.framework.jurisdiction.entity.AdminGroupInfo"%>
<%@ page language="java" import="com.mohe.retailer.goods.entity.*"%>

<%@page import="com.beyond.framework.util.tools.Global"%>
<%@ taglib uri="/pageTag" prefix="pageTag"%>

<%

String path = request.getContextPath();
UserInfo loginUserInfo = (UserInfo) session.getAttribute(SessionConfig.ADMIN_USER_INFO);


Goods goods = (Goods)request.getAttribute("goods1");
if(goods == null){
    goods = new Goods();
}
boolean isAdd = goods == null || goods.getGId() == null ? true : false;

%>

.smart-form-mh { margin: 0; outline: 0; color: #666; position: relative; }
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"
                aria-hidden="true">
                &times;
            </button>
            <h4 class="modal-title" id="myModalLabel">
                <%=isAdd?"添加":"修改" %>商品名称:
            </h4>
        </div>
        <div class="jarviswidget" id="wid-id-0" data-widget-colorbutton="false" data-widget-editbutton="false" data-widget-deletebutton="false" data-widget-sortable="false">
            <div>
                <div class="widget-body">
                    <form id="userForm" class="" 
                        action="<%=path %>/intercity/addIntercity.do" method="post">
                        <input type="hidden" name="goodsId" value="<%=Global.nvlToString(goods.getGId())%>">
                        <fieldset>
                            <div class="form-group">
                                <div class="row">
                                    <div class="col-sm-12 col-md-4">
                                        <label class="control-label">商品ID</label>
                                        <input type="text" class="form-control"  maxlength="32" name="gId" value="<%=Global.nvlToString(goods.getGId())%>">
                                    </div>
                                    <div class="col-sm-12 col-md-4">
                                        <label class="control-label">商品名称</label>
                                        <input type="text" class="form-control" maxlength="16" name="gName" value="<%=Global.nvlToString(goods.getGName())%>">
                                    </div>
                                </div>
                            </div>      
                        </fieldset>
                        <fieldset>
                            <div class="form-group">
                                <div class="row">
                                    <div class="col-sm-12 col-md-4">
                                        <label class="control-label">进货价格</label>
                                        <input type="text" class="form-control" maxlength="32" name="gPurchaseprice"  value="<%=Global.nvlToString(goods.getGPurchaseprice())%>">
                                    </div>
                                    <div class="col-sm-12 col-md-4">
                                        <label class="control-label">销售价格</label>
                                        <input type="text" class="form-control" maxlength="20" name="gSellprice"  value="<%=Global.nvlToString(goods.getGSellprice())%>">
                                    </div>
                                </div>  
                            </div>
                        </fieldset>
                        <fieldset>
                            <div class="form-group">
                                <div class="row">
                                    <div class="col-sm-12 col-md-4">
                                        <label class="control-label">库存量</label>
                                        <input type="text" class="form-control" maxlength="16" name="gAmount" value="<%=Global.nvlToString(goods.getGAmount())%>">
                                    </div>
                                    <div class="col-sm-12 col-md-4">
                                        <label class="control-label">供应商</label>
                                        <input type="text" class="form-control" maxlength="32" name="sId" value="<%=Global.nvlToString(goods.getSId())%>">
                                    </div>
                                </div>
                            </div>      
                        </fieldset>
                        <fieldset>
                            <div class="form-group">
                                <div class="row">
                                    <div class="col-sm-12 col-md-4">
                                        <label class="control-label">备注</label>
                                        <input type="text" class="form-control" maxlength="32" name="gMemo" value="<%=Global.nvlToString(goods.getGMemo())%>">
                                    </div>
                                    <div class="col-sm-12 col-md-4" >
                                        <label class="control-label">利润</label>
                                        <input type="submit" class="form-control" maxlength="16" name="gProfit" value="<%=Global.nvlToString(goods.getGProfit())%>">
                                    </div>
                                </div>
                            </div>      
                        </fieldset>
                        <div class="form-actions">
                                <div class="row">
                                    <div class="col-md-12">
                                        <button class="btn btn-default" type="submit" id="add">
                                            <i class="fa fa-eye"></i>
                                            提交
                                        </button>
                                    </div>
                                </div>
                        </div>
                    </form>
                </div>

            </div>
            <!-- end widget content -->

        </div>

    </div>
    <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
loadScript("<%=path %>/common/js/moheUtil.js"); $(document).ready(function() { pageSetUp(); $('#userForm').bootstrapValidator({ excluded:[':disabled'], feedbackIcons : { valid : 'glyphicon glyphicon-ok', invalid : 'glyphicon glyphicon-remove', validating : 'glyphicon glyphicon-refresh' }, submitHandler:function (form){ //alert(); }, fields : { 'gId' : { group : '.col-md-4', validators : { notEmpty : { message : '必填项' } } }, 'gName' : { group : '.col-md-4', validators : { notEmpty : { message : '必填项' } } }, 'gSellprice' : { group : '.col-md-4', validators : { notEmpty : { message : '必填项' } } }, 'gAmount' : { group : '.col-md-4', validators : { notEmpty : { message : '必填项' } } } } }).on('success.form.bv',function(e){ e.preventDefault(); formsubmit(); }) ; }) pageSetUp(); var addflag = "<%=isAdd?"add":"update"%>" /** *提交处理 */ function formsubmit() { var div = "<div class='loading-div'></div>"; $("#myModal").after(div); if($('#userForm').data('bootstrapValidator').isValid() == false){ return false; } var url = ''; if (addflag == 'add') { $(".modal-backdrop").remove(); url = "<%=path%>/goods/addGoods.do"; $.ajax({ type: 'post', url: url, data: $("#userForm").serialize(), cache: false, dataType: "json", success: function(data) { $(".loading-div").remove(); if (data.error_code == "0") { alert("添加成功"); queryList(); }else if(data.error_code == "20100"){ alert("商品ID已存在!"); } else { alert("数据错误,请联系管理员!"); } } }); } else { $(".modal-backdrop").remove(); url = "<%=path%>/goods/updateGoods.do"; $.ajax({ type: 'post', url: url, data: $("#userForm").serialize(), cache: false, dataType: "json", success: function(data) { $(".loading-div").remove(); if (data.error_code == "0") { queryList(); alert("修改成功"); } else { alert("数据错误,请联系管理员!"); } } }); } }

1个回答

类似这个,只是算法不同
http://blog.csdn.net/ijwddd/article/details/49419821

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问