zoukankan      html  css  js  c++  java
  • ajax报告申请添加

                      function reportApplyAddFun(){
                          $("#dlg").dialog("open").dialog("center").dialog("setTitle",'');// ''(二级页面标题)
                        $("#fm").form("clear");
                        $.ajax({// 加载报告申请基础数据
                            type : "post",
                            url : "reportApplyBase",
                            data:{"flag":"1"},
                            cache : false,
                            async : false,
                            dataType : "json",
                            success : function(data){
                                var str = "<select class='' style=' 210px;' autocomplete='off'>"
                                var itemStr = "";
                                $.each(data, function(index,value){
                                    var itemName = data[index].name;
                                    alert(itemName);
                                    itemStr += "<option value='0' selected='selected'>" + itemName + "</option>"
                                    str += itemStr;
                                })
                                str + "</select>";
                                document.getElementById("companyNature").innerHTML = str;
                            } , error:function(data){
                                    alert("加载数据失败!" + data);
                            }
                        });
                      }
    /**
         * 获取字典数据
         * @param request
         * @param response
         * @param map
         * @return
         */
        /*@RequestMapping("reportApplyBase")
        public String saveInfo(HttpServletRequest request, HttpServletResponse response) {
            String flag = request.getParameter("flag");
            log.info(flag);
            List<ReportApplyBase> reportApplyBaseList = new ArrayList<ReportApplyBase>();
            String json = null;
            try {
                Class.forName("com.mysql.jdbc.Driver");
                con = DriverManager.getConnection(DB_URL, USER, PASS);
                stmt = con.createStatement();
                rs = stmt.executeQuery("select * from test");
                while (rs.next()) {
                    ReportApplyBase reportApply = new ReportApplyBase();
    //                reportApply.setId(rs.getInt(Integer.parseInt("id")));
                    reportApply.setName(rs.getString("name"));
                    reportApply.setAddress(rs.getString("address"));
                    reportApplyBaseList.add(reportApply);
                }
                // list转为json传入前端
                json = JSON.toJSONString(reportApplyBaseList);
                log.info(json);
                // 取得流向JSP传递数据
                response.setContentType("text/html;charset=UTF-8");
                response.getWriter().println(json);
                response.reset();
            } catch (Exception e) {
                log.info(e.getMessage());
                e.printStackTrace();
            } finally {
                try {
                    con.close();
                    stmt.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            return json;
        }*/
    index.html <div th:replace="reportApplyList :: header"></div>
    index.js

    function load(){
    $('.main').html('<div th:replace="reportApplyList :: header"></div>');
    catalog(id);
    }

    /** 提交报告申请基本信息 **/
    				function reportApplySubmitFun() {
    					var projectNumber = $("#projectNumber").val();// 项目编号
    					var checkMonad = $("#checkMonad").val();// 受检单位
    					var monadNature = $("#monadNature option:selected").val();// 单位性质
    					var ascriptionArea = $("#ascriptionArea option:selected").val();// 所属区域
    					var checkType = $("#checkType option:selected").val();// 检测类型
    					var money = $("#money").val();// 金额
    					$.ajax({// 加载报告申请基础数据
                            type : "post",
                            url : "saveReportApply",
                            data:{"projectNumber":projectNumber, "checkMonad":checkMonad, "monadNature":monadNature, "ascriptionArea":ascriptionArea, "checkType":checkType, "money":money},
                            cache : false,
                            async : false,
                            dataType : "text",
                            success : function(data){
                                if(data=="ok"){
                                	alert("提交成功!");
                                } else if(data=="no"){
                                	alert("提交失败!");
                                }
                            }
                        });
    				}
    

      

        /**
         * 保存附件(缴费通知、合同登记【word】)
         */
        public void saveReportApplyWord(HttpServletRequest request, HttpServletResponse response) {
            FileSaver fs = new FileSaver(request, response);
            FlIndex flIndex = new FlIndex();
            flIndex.setXmbh(fs.getFormField("projectNumber"));// 项目编号
            flIndex.setSjdw(fs.getFormField("checkMonad")); // 受检单位
            flIndex.setDwxz(fs.getFormField("monadNature"));// 单位性质
            flIndex.setSsqy(fs.getFormField("ascriptionArea"));// 所属区域
            flIndex.setJclx(fs.getFormField("checkType"));// 检测类型
            flIndex.setJe(fs.getFormField("money"));// 金额
            String typeId = request.getParameter("typeId");
            String flag = "";
            try {
                DocTable docTable = new DocTable();
                if (typeId.equals("1")) {// 缴费通知
                    docTable.setJftzd(new SerialBlob(fs.getFileBytes()));// 文件内容
                } else if (typeId.equals("2")) {// 合同登记
                    docTable.setHtlr(new SerialBlob(fs.getFileBytes()));
                }
                flIndex.setDoc(docTable);
                reportApplyDao.persistReportApply(flIndex);
                flag = "ok";
            } catch (Exception e) {
                flag = "on";
                log.info("保存附件(缴费通知、合同登记【word】)失败");
                e.printStackTrace();
            } finally {
                fs.setCustomSaveResult(flag);
                fs.close();
            }
        }
  • 相关阅读:
    Linux第七周学习总结——可执行程序的装载
    《深入理解计算机系统》第七章读书笔记
    《Linux内核设计与实现》第三章读书笔记
    《Linux内核设计与实现》第十八章读书笔记
    Linux第六周学习总结——进程额管理和进程的创建
    Linux第五周学习总结——扒开系统调用的三层皮(下
    《Linux内核设计与实现》第五章读书笔记
    #Linux第四周学习总结——扒开系统调用的三层皮(上)
    《Linux内核设计与实现》第一二章读书笔记
    Linux第三周学习总结——构造一个简单的Linux系统MenuOS
  • 原文地址:https://www.cnblogs.com/hongwei2085/p/9070305.html
Copyright © 2011-2022 走看看