This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-ntc/src/main/webapp/static/pages/scripts/importExcel.js

278 lines
9.0 KiB
JavaScript

$(function(){
//打开导入modal
$(".import").click(function(){
$("#import_modal").modal({
backdrop:"static",
keyboard:false,
show:true
});
});
$("#appIdId").on("change",function(){
ajaxBehaviour($(this).val());
});
switchService();
$("input[name='serviceDictId']").click(function(){
switchService();
});
$("input[name='regionDictIds']").click(function(){
});
if($(".requestIdSel").hasClass("hidden")){
$(".attributeSel").addClass("hidden");
$(".classifySel").addClass("hidden");
$("select[name='requestId']").empty();
if($(".appSelDiv").length == 0){
// 新增文件div上移
var fileDiv = $(".fileSelDiv").clone();
$(".fileSelDiv").remove();
$(".requestIdSel").after(fileDiv);
}else{
// 去除多余<br>
$(".modal-body").find("br").each(function(){
if($(this).prev("div").hasClass("hidden")){
$(this).remove();
}
});
}
}
if($("#functionId").val() == 215){
profileChange($("input[name='manipulatType']:checked").val());
$("input[name='manipulatType']").click(function(){
profileChange($(this).val());
});
}
// 分组配置导入 隐藏是否下发选项
if($("#functionId").val() == 605 || $("#functionId").val() == 606 || $("#functionId").val() == 607 || $("#functionId").val() == 608){
$(".isSendDiv").hide();
}
});
/**
* action动作切换
*/
function switchService(){
var functionId=$("#functionId").val();
if(functionId==5){//IP配置特殊处理
var cfgRegionCodeS=$("input[name='serviceDictId']:checked").attr("cfgRegionCodeS");
var cfgRegionCode=cfgRegionCodeS.split(",")[0];
$("input[name='regionDictIds'][cfgRegionCodeR!='"+cfgRegionCode+"']").prop("checked",false);
$("input[name='regionDictIds'][cfgRegionCodeR!='"+cfgRegionCode+"']").parents(".radio-inline").addClass("hidden");
$("input[name='regionDictIds'][cfgRegionCodeR='"+cfgRegionCode+"']").prop("checked",true);
$("input[name='regionDictIds'][cfgRegionCodeR='"+cfgRegionCode+"']").parents(".radio-inline").removeClass("hidden");
if(cfgRegionCodeS.split(",").length <=1 ){
$(".region").addClass("hidden");
}else{
$(".region").removeClass("hidden");
}
}else{
if($("input[name='regionDictIds']").length <=1){
$(".region").addClass("hidden");
}else{
$(".region").removeClass("hidden");
}
}
if($("input[name='serviceDictId']").length <=1){
$(".service").addClass("hidden");
}else{
$(".service").removeClass("hidden");
}
// App Identify -> RateLimit隐藏SubscribeID
if(functionId == 63){
var action = $("input[name='serviceDictId']:checked").attr("action");
var label = $(".region").find("input[configservicetype='subscribe_id']").parents("label:first");
if(action == 64){
$("input[name='regionDictIds'][regiontype='1']").prop("checked",true);
$(label).hide();
}else{
$(label).show();
}
}
}
/**
* 模板下载
* TODO 后期修改为传入regionDictId
* */
function downLoadTemplate(path){
var obj={
"regionDictId":$("input[name='regionDictIds']:checked").val(),
"serviceDictId":$("input[name='serviceDictId']:checked").val(),
"requestId":$("select[name='requestId']").val(),
"manipulatType":$("input[name='manipulatType']:checked").val()
};
var params = $.param(obj);
document.location.href = path+'/ntc/iplist/import/template?' + params;
}
var ajaxBehaviour=function(val){
var pathName=window.document.location.pathname.substring(0,window.document.location.pathname.indexOf("/nis")+4);
var request=$.ajax({
type:'post',
url:pathName+'/specific/specificServiceCfg/childrenList',
data:{"parent":val},
dataType:'json',
async:true,
success:function(data,textStatus){//处理返回结果
if(textStatus=="success"){
var html='<select name="behaviorId" data-live-search="true" class="selectpicker form-control">'
+'<option value=""><spring:message code="select"/></option>';
if(data.length>0){
for(i=0;i<data.length;i++){
html+='<option value="'+data[i].code+'"';
html+='>'+data[i].name+'</option>';
}
html+='</select>';
$("#behaviorId").html(html);
$("[name='behaviorId']").selectpicker("refresh");
$("[name='behaviorId']").selectpicker("render");
}else{
html+='</select>';
$("#behaviorId").html(html);
$("[name='behaviorId']").selectpicker("refresh");
$("[name='behaviorId']").selectpicker("render");
}
}
},
complete:function(XMLHttpRequest,status){//超时设置
if(status=="timeout"){
var html='<select name="behaviorId" data-live-search="true" class="selectpicker form-control">'
+'<option value=""><spring:message code="select"/></option></select>';
$("#behaviorId").html(html);
$("[name='behaviorId']").selectpicker("refresh");
$("[name='behaviorId']").selectpicker("render");
}
}
});
}
//导入配置
var importCfg=function(){
if($("#serviceId").val()==""){
alert("请选择action");
return ;
}
var appFlag=true;
if(($("#functionId").val() == 63)||($("#functionId").val() == 408)||($("#functionId").val() == 407)||
($("#functionId").val() == 402)||($("#functionId").val() == 403)||($("#functionId").val() == 405)
||($("#functionId").val() == 563)||($("#functionId").val() == 565)||($("#functionId").val() == 564)||($("#functionId").val() == 566)){
var appIdValue=$("#appIdName").val();
if(appIdValue == null || appIdValue =='' || typeof(appIdValue) == "undefined"){
appFlag=false;
}
}
var fileName = $(".fileupload-preview", $("#importForm1")).text();
var $error = $('.alert-error', $("#importForm1"));
if(!appFlag){
$("span",$error).html($("#appError").val());
$error.removeClass("hide");
$error.addClass("show");
return false;
}
// 代理-操控业务Profile Info
var manipulateType = $("input[name='manipulatType']:checked").val();
if(manipulateType == 85 || manipulateType == 90 || manipulateType == 16){
if($("#profileSelId").val() == "" || $("#profileSelId").val() == null){
$("span",$error).html($("#noneProfileTip").val());
$error.removeClass("hide");
$error.addClass("show");
return false;
}
}
if(fileName==""){
$("span",$error).html($("#noneFileTip").val());
$error.removeClass("hide");
$error.addClass("show");
return false;
}else if(fileName.lastIndexOf("\.")==-1/*||fileName.substring(fileName.lastIndexOf("\.")+1).toLowerCase()!='xls'*/ ||fileName.substring(fileName.lastIndexOf("\.")+1).toLowerCase()!='xlsx'){
$("span",$error).html($("#fileVersionErrorTip").val());
$error.removeClass("hide");
$error.addClass("show");
return false;
}
$("#import_modal").modal('hide');//导入文件隐藏
$("#importForm1").submit();
}
// 代替data-dismiss=""属性(关闭错误信息)
var closeTip = function(){
var $error = $('.alert-error', $("#importForm1"));
$error.removeClass("show");
$error.addClass("hide");
}
function profileChange(val){
if(typeof val == 'undefined'){
return false;
}
$(".region").find("label[class='radio-inline']").each(function(){
$(this).show();
});
var reqHdrInput = $(".region").find("input[regionvalue='PXY_CTRL_HTTP_REQ_HDR']");
var resBodyInput = $(".region").find("input[regionvalue='PXY_CTRL_HTTP_RES_BODY']");
var reqBodyInput = $(".region").find("input[regionvalue='PXY_CTRL_HTTP_REQ_BODY']");
// 根据动作隐藏配置域,若该域隐藏前已被选中则默认选中首个
var resetFlag = false;
if(val == 48){
if($(resBodyInput).prop("checked") == true){
resetFlag = true;
}
$(resBodyInput).parents("label:first").hide();
}else if(val == 80){
if($(reqBodyInput).prop("checked") == true || $(resBodyInput).prop("checked") == true){
resetFlag = true;
}
$(reqBodyInput).parents("label:first").hide();
$(resBodyInput).parents("label:first").hide();
}else if(val == 85 || val == 90){
if($(reqHdrInput).prop("checked") == true || $(reqBodyInput).prop("checked") == true || $(resBodyInput).prop("checked") == true){
resetFlag = true;
}
$(reqHdrInput).parents("label:first").hide();
$(reqBodyInput).parents("label:first").hide();
$(resBodyInput).parents("label:first").hide();
}
if(resetFlag){
$("input[name='regionDictIds']:first").prop("checked",true);
}
if(val == 48 || val == 80){ // 重定向和替换动作无Profile属性
$(".profileInfo").addClass("hidden");
}else{
$(".profileInfo").removeClass("hidden");
// Get Policy Profile Info
var pathName = window.document.location.pathname.substring(0,window.document.location.pathname.lastIndexOf("/nis")+4);
$.ajax({
type:'get',
url:pathName+'/proxy/control/manipulatPolicy/ajaxGetProfileInfo?source='+val,
dataType:'json',
success:function(data){
if(data != null){
$("#profileSelId").empty();
$.each(data, function(i, n){
var option = new Option(data[i].cfgDesc, data[i].compileId);
$("#profileSelId")[0].options.add(option);
});
$("#profileSelId").selectpicker("refresh");
}
}
});
}
}