<script>
//===================================================================*/
/* イベント
//===================================================================*/
//　F9 Excel
$(document).on("click", ".popaf03mFunc9:not('.noevent')", function (e) {
  $('#af03mExcel').trigger('printExcel');
});
//　F12 メニュー/戻る
$(document).on("click", ".popaf03mFunc12:not('.noevent')", function (e) {
  $('#af03mClose').trigger('popClose');
});

//表示
$(document).on("click", ".popup-af03m", function (e) {

    popup.openPopup("af03m", "");
    af03m.initial();
    $("#af03m").focus();
});

$("#af03mExcel").on("printExcel", function (e) {
  var errflg = false;

  if(errflg) {
    alert("エラーがあります");
  } else if( window.confirm('【得意先マスタExcel出力】をします。よろしいですか？') ){
    let param2 = { "method": "GetWseqMjan" };
    let excelid = "AF03M";
    $.ajax({
      type: "GET",
      url: "../../api/getWseq.php",
      data: param2,
      dataType: "json",
      scriptCharset: 'utf-8',
      success: function(data, status, xhr) {
        var wurl = "{$_REPORT_URL}" + "AF999JE?WSEQ=" + JSON.parse(data.data)
                + "&IREP=" + excelid
                + "&CHGCD=" + "{$_SYSTEM_NAME_EN_CHGCD}"
                + "&ACCD=" + "{$_SYSTEM_NAME_EN_ACCD}"
                + "&DBNO=" + "{$_SYSTEM_NO}"
                + "&JOKEN1=" + $("#af03mCucds").val()
                + "&JOKEN2=" + $("#af03mCucde").val();
        window.open(wurl, excelid+JSON.parse(data.data));
      }
    });
  }

});

$(document).on("focus","#af03mDummy", function(e) {
  $(".popaf03mFunc9").focus();
});

$("#af03mClose").on("popClose", function (e) {
  if (e.bubbles == false) {
    return false;
  }
  af03m.initial();
  af03m.close();
});

var af03m = {
  close: function () {
    this.initial();
    popup.closePopup("af03m");
  },

  initial: function () {
    common.clearInputData($(".af03m")); //検索画面データのクリア

    $("#af03mCucds").focus();
  },
}
</script>
