csjoz11

导航

jquery_post

$(document).ready(function() {
   codeVM = avalon.define({
      $id: 'codeCtrl',
      CODEDATA: []
   });
   
    $("#btnShopOrderInfo").click(function(e) {
       var filePath = $("input[name='ShopOrderXlsx']").val();
       if (!filePath) {
          return showErrorInfo("请选择需要上传的文件!"), false;
       }
       
       var formData = new FormData();
       formData.append("ShopOrderXlsx", document.getElementsByName("_ShopOrderXlsx")[0].files[0]);
       $.ajax({
          url: path + '/ImportAbnormalUserServlet?method=PARSE_FILE',
          type: 'POST',
          data: formData,
          contentType: false,
          processData: false,
          dataType: 'json',
          success: function (data) {
             if (data.RESULT === 'SUCCESS') {
                if (data.LIST_MAP && data.LIST_MAP.length > 0) {
                   $("#DIV_1").css("display", "block");
                   codeVM.CODEDATA = data.LIST_MAP;
                } else {
                   $("#DIV_1").css("display", "none");
                }
                
                showSuccessInfo("上传并解析文件成功,共解析到数据[" + data.LIST_MAP.length + "]条.");
             } else {
                showErrorInfo(data.MSG);
             }
          },
          error: function(data) {
             showErrorInfo(data.MSG);
          }
       });
    });
    
    $("#btnSubmit").click(function(e) {
       var trArrays = $("#TBODY_3").find("tr");
       if (trArrays.length === 0) {
          return showErrorInfo("没有要提交的数据, 请检查!"), false;
       }
       var shopOrderArr = [];
       var ABNORMAL_TYPEArr=[], GRADEArr=[],PUSH_TIMEArr=[],PUSH_USER_IDArr=[];
       for (var index = 0; index < trArrays.length; index++) {
          var trObject = trArrays[index];
          var jqObject = $(trObject);
          // 自定义字段
          ABNORMAL_TYPEArr.push(jqObject.find("input[id='ABNORMAL_TYPE']").val());
          GRADEArr.push(jqObject.find("input[id='GRADE']").val());
          PUSH_TIMEArr.push(jqObject.find("input[id='PUSH_TIME']").val());
          PUSH_USER_IDArr.push(jqObject.find("input[id='PUSH_USER_ID']").val());
       }
       
       var url = path + "/ImportAbnormalUserServlet?method=COMMIT_IMP_DATA";
       var postData = {
             ABNORMAL_TYPE: ABNORMAL_TYPEArr,
             GRADE: GRADEArr,
             PUSH_TIME: PUSH_TIMEArr,
             PUSH_USER_ID: PUSH_USER_IDArr
       };
       $.post(url, postData, function(ret) {
          if (ret.RESULT === 'SUCCESS') {
             showSuccessInfo("数据提交成功!");
          } else{
             showErrorInfo(ret.MSG);
          }
       }, 'json');
    });
});

posted on 2022-02-17 15:57  csjoz11  阅读(17)  评论(0编辑  收藏  举报