Ajax异步传输的使用

1、jsp页面:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta charset="UTF-8">
    <%@ include file="/common.jsp"%>
<!-- 网页src -->
<link rel="stylesheet" href="<%=path %>/jslib/style/gzsywl.css"/>
<script src="<%=path %>/jslib/js/gzsywl.js"></script>
<script src="<%=path %>/jslib/js/maintenance/auditCompany/auditCompany.js"></script>
<title>审核企业详细内容</title>

<style>
        .ywl_cms_zu:hover{
            cursor: pointer;
        }
        .ywl_cms_zu1:hover{
            cursor: pointer;
        }
        table tr td:nth-child(1){
        text-align:left;
        }
        table tr td:nth-child(3){
        text-align:left;
        }
    </style>
  </head>
  
  <body>
    <!-- 右侧主体 -->
        <div class="ywl_cms_section_right">
            <div class="ywl_cms_section_right_mianbaoxie">
                <span href="#">位置</span>
                <span>></span>
                <span href="#">企业管理</span>
                <span>></span>
                <span href="#">待审核企业</span>
                <span>></span>
                <span href="#">审核企业</span>
            </div>
            <form id="from_audit" action="${path}/auditcompany/pass" method="post">
            <div class="ywl_cml_right_xinjian ywl_cms_section_right_main">
                <table class="ywl_cms_all_table" style="clear:both;float:left;">
                    <thead>
                        <tr>
                            <td style="width:100px;">企业名称</td>
                            <td style="width:380px;">${company.name}</td>
                            <td style="width:100px;">企业法人</td>
                            <td style="width:380px;">${company.legalperson}</td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>企业类型</td>
                            <td>${company.comtype}</td>
                            <td>企业邮箱</td>
                            <td>${company.email}</td>
                        </tr>
                        <tr>
                            <td>公司电话</td>
                            <td>${company.telephone}</td>
                            <td>公司传真</td>
                            <td>${company.facsimile}</td>
                        </tr>
                        <tr>
                            <td>联系人</td>
                            <td>${company.namezh}</td>
                            <td>手机号</td>
                            <td>${company.phone}</td>
                        </tr>
                        <tr>
                            <td>是否为货源企业</td>
                            <td>
                            <c:if test="${company.iscargo == 1 }">是</c:if>
                            <c:if test="${company.iscargo == 2 }">否</c:if>
                            </td>
                            <td>服务能力/范围</td>
                            <td>
                            <c:if test="${company.iscargo == 1 }">没有此项服务</c:if>
                            <c:if test="${company.iscargo == 2 }">
                            <c:if test="${company.isservice == 1 }">货源</c:if>
                            <c:if test="${company.isservice1 == 1 }">货运班次</c:if>
                            <c:if test="${company.isservice2 == 1 }">库源</c:if>
                            <c:if test="${company.isservice3 == 1 }">增值服务</c:if>
                            </c:if>
                            </td>
                        </tr>
                        <tr>
                            <td style="height:130px;">营业执照</td>
                            <td colspan="3" style="position:relative;">
                           
                        <img src="${company.filepath }" alt="" style="width:250px;height:125px;position:absolute;top:2px;left:2px;">
          
                            </td>
                        </tr>
                        <tr>
                            <td>营业执照注册号</td>
                            <td>${company.email}</td>
                            <td>对公银行</td>
                            <td>${company.bank}</td>
                        </tr>
                        <tr>
                            <td>开户行</td>
                            <td>${company.bankname}</td>
                            <td>对公账号</td>
                            <td>${company.banknum}</td>
                        </tr>
                        
                    </tbody>
                </table> 
                <div class="ywl_cml_right_xinjian ywl_cms_section_right_main" >
                    <div style="width:300px;margin:0 auto;padding-top:50px;">
                        <a id="form_audit" οnclick="auditPass('${company.id}','1')" type="button" class="ywl_cms_button text_hui">通过</a>
                        <%-- <a οnclick="noPass('${company.id}','3')" type="button" class="ywl_cms_button text_hui" style="float:right;">不通过</a> --%>
                    <a data-toggle="modal" data-target="#myModal" class="ywl_cms_button text_hui" style="margin-left:100px;">不通过</a>
                    </div>
                </div>
            </div>
        </div>
        <!-- 审核不通过--模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="height: 100%" >
<div class="modal-dialog" style="margin-top:20%;">
<div class="modal-content" style="margin-left:0px;position:relative;width:598px;">
<div class="modal-header" style="height:30px;">
<h5 class="modal-title" id="myModalLabel">
审核不通过原因
</h5>
</div>
<div class="modal-body" style="text-align:center;height:130px;">
<textarea id="textarea"  style="width: 560px;height: 104px;resize:none;"></textarea>
</div>
<div class="modal-footer" style="height:30px;">
<button type="button" class="btn btn-default" data-dismiss="modal" style="margin-top:-27px;padding:3px 8px;">取消
</button>
<button type="button" class="btn btn-primary" οnclick="noPass('${company.id}','3');" style="margin-top:-27px;padding:3px 8px;" data-dismiss="modal">
确定
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
        </form>
        
  </body>
</html>

2、写Ajax的js(auditCompany.js):

//审核通过
function auditPass(id,status){
    var message = "";
    var OSPRFORM = 1;
    if(status == 1 || status == "1"){
    message = "确定审核通过吗?";
    }
    Modal.confirm({
       msg: message,
       btnok: '确定',
       btncl:'取消'
    }).on( function(e){
     if( e ){ 
     if( OSPRFORM == 1 ){
     OSPRFORM ++;
     $.ajax({
     url : "/auditcompany/pass",
     data : {
     companyId : id,
     status : status
     },
     async : false,
     type : 'post',
     success : function(result){
     Modal.alert({
       msg: result.msg,
    }).on(function(e){
    location.href='/auditcompany/companyList';
    });
     }
     })
     return true; 
     }
     } 
       return false; 
      });
    }
//审核不通过
function noPass(id,status){
var OSPRFORM = 1;
var v = $("#textarea").val();
 if( OSPRFORM == 1){
 OSPRFORM ++;
 $.ajax({
 url : "/auditcompany/nopass",
 data : {
 companyId : id,
 status : status,
 nopass:v
 },
 async : false,
 type : 'post',
 success : function(result){
 Modal.alert({
   msg: result.msg,
}).on(function(e){
location.href='/auditcompany/companyList';
});
 }
 })
 return true; 
 }
}

3、jfinal的controller:

//审核后通过
public void pass(){
Json j = new Json();
try {

String message = "";
String status = getPara("status");
TCompany company = TCompany.dao.findById(getPara("companyId"));
if (("1").equals(status)) {
company.set("status", 1);
message = "审核通过";
this.saveOplog("审核企业通过");
}
audit.update(company);
SendEmail.sendMessage(company.getStr("email"), "账户审核通过,已开通!", "<a href='http://www.gzswl.gov.cn'>贵州省物流公共信息服务平台</a>");
j.setSuccess(true);
j.setMsg(message);
} catch (Exception e) {
saveErrlog(e);
j.setSuccess(false);
j.setMsg("系统异常");
e.printStackTrace();
}
this.renderJson(j);
}
//审核后不通过
public void nopass(){
Json j = new Json();
try {
String str  = this.getPara("nopass");
String message = "";
String status = getPara("status");
TCompany company = TCompany.dao.findById(getPara("companyId"));
if (("3").equals(status)) {
company.set("status", 3);
message = "审核没通过";
this.saveOplog("审核企业不通过");
}
audit.update(company);
System.out.println("123"+str);
SendEmail.sendMessage(company.getStr("email"), "审核未通过,请完善相关信息!", "<a href='https://www.baidu.com'>贵州省物流云注册界面</a>");
j.setSuccess(true);
j.setMsg(message);
} catch (Exception e) {
saveErrlog(e);
j.setSuccess(false);
j.setMsg("系统异常");
e.printStackTrace();
}
this.renderJson(j);
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值