$(function(){
    var dataCarrier_h=$("#dataCarrier_h").val();
    getSelectArr(dataCarrier_h,'dataCarrier')

    var dataSource_h=$("#dataSource_h").val();
    getSelectArr(dataSource_h,'dataSource');

    var dataScope_h=$("#dataScope_h").val();
    getSelectArr(dataScope_h,'dataScope')

    // var dataPrecision_h=$("#dataPrecision_h").val();
    // getSelectArr(dataPrecision_h,'dataPrecision');

    var unitCharacter_h=$("#unitCharacter_h").val();
    getSelectArr(unitCharacter_h,'unitCharacter');

    var dataHandleType_h=$("#dataHandleType_h").val();
    getSelectArr(dataHandleType_h,'dataHandleType');

    var dataResult_h=$("#dataResult_h").val();
    getSelectArr(dataResult_h,'dataResult');

    var dataCrossType_h=$("#dataCrossType_h").val();
    getSelectArr(dataCrossType_h,'dataCrossType');

    var dataCrossmainType_h=$("#dataCrossmainType_h").val();
    getSelectArr(dataCrossmainType_h,'dataCrossmainType');

    var dataProportion_h=$("#dataProportion_h").val();
    getSelectArr(dataProportion_h,'dataProportion');

    //信息系统名称
    var arr1 = $("#infoSystemName_h").val().split('，');
    //信息系统类型
    var arr2 = $("#infoSystemType_h").val().split('，');
    //网络安全等级保护认定情况
    var arr3 = $("#securityCognizance_h").val().split('，');
    //通信网络安全等级防护定级备案情况
    var arr4 = $("#comSecurityCognizance_h").val().split('，');
    //是否为关键信息基础设施
    var arr5 = $("#isKetSystem_h").val().split('，');
    //信息系统Ip地址
    var arr6 = $("#infoSystemIpAddress_h").val().split('，');
    //信息系统域名
    var arr7 = $("#infoSystemDomainName_h").val().split('，');
    setInfoSystem(arr1,arr2,arr3,arr4,arr5,arr6,arr7);

});

function getSelectArr(str,nodeId){
    var arr = str.split('，');
    var strArr = new Array();
    var strdesc = '';
    for (var i = 0;i<arr.length;i++) {
        var str1 = arr[i].indexOf('#');
        if (str1 > 0) {
            var arr1 = arr[i].split('#');
            strArr[i]=arr1[0];
            strdesc+=arr1[1].trim();
        } else {
            strArr[i]=arr[i].trim();
        }
    }
    $('#'+nodeId).selectpicker('val', strArr);
    if (str.indexOf('#') > 0){
        $('#'+nodeId+'_h_des').show();
        $('#'+nodeId+'_h_des').val(strdesc);
    }
}

function setInfoSystem(arr1,arr2,arr3,arr4,arr5,arr6,arr7) {
    if(arr1.length > 1) {
        var html ='<span class="form-group">'+
            '<h3 class="col-sm-6">承载重要/核心数据的信息系统情况</h3>'+
        '</span>'
        for (var i = 0;i<arr1.length;i++) {
            html += '<div class="form-group">' +
                '<label class="col-sm-3 control-label">'+'系统'+(i+1)+'：</label>' +
                '</div>' +
                '<div class="form-group">' +
                '<label class="col-sm-3 control-label">信息系统名称：</label>' +
                '<div class="col-sm-8">' +
                    '<input readOnly id="infoSystemName'+i+'" name="infoSystemName'+i+'" value="'+arr1[i]+'"' +
                           'class="form-control"></input>' +
                '</div>' +
            '</div>' +
            '<div class="form-group">' +
                '<label class="col-sm-3 control-label">信息系统类型：</label>' +
                '<div class="col-sm-8">' +
                    '<input readOnly id="infoSystemType'+i+'" name="infoSystemType'+i+'" value="'+arr2[i]+'"' +
                           'class="form-control"></input>' +
                '</div>' +
            '</div>' +
                '<div class="form-group">' +
                '<label class="col-sm-3 control-label">信息系统IP地址：</label>' +
                '<div class="col-sm-8">' +
                '<input readOnly id="infoSystemIpAddress" name="infoSystemIpAddress" value="'+arr6[i]+'"' +
                'class="form-control"></input>' +
                '</div>' +
                '</div>' +
                '<div class="form-group">' +
                '<label class="col-sm-3 control-label">信息系统域名：</label>' +
                '<div class="col-sm-8">' +
                '<input readOnly id="infoSystemDomainName" name="infoSystemDomainName" value="'+arr7[i]+'"' +
                'class="form-control"></input>' +
                '</div>' +
                '</div>' +
            '<div class="form-group">' +
                '<label class="col-sm-3 control-label">网络安全等级保护认定情况：</label>' +
                '<div class="col-sm-8">' +
                '<label class="radio-inline">' +
                '<input field="'+ arr3[i] +'" type="radio" name="securityCognizance'+i+'" value="未开展" ';
                html += arr3[i]=="未开展"?'checked="checked"':'';
                html +=' disabled/>未开展' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr3[i] +'" type="radio" name="securityCognizance'+i+'" value="一级" ';
                html += arr3[i]=="一级"?'checked="checked"':'';
                html += ' disabled/>一级' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr3[i] +'" type="radio" name="securityCognizance'+i+'" value="二级" ';
                html += arr3[i]=="二级"?'checked="checked"':'';
                html += ' disabled/>二级' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr3[i] +'" type="radio" name="securityCognizance'+i+'" value="三级" ';
                html += arr3[i]=="三级"?'checked="checked"':'';
                html += ' disabled/>三级' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr3[i] +'" type="radio" name="securityCognizance'+i+'" value="四级" ';
                html += arr3[i]=="四级"?'checked="checked"':'';
                html += ' disabled/>四级' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr3[i] +'" type="radio" name="securityCognizance'+i+'" value="五级" ';
                html += arr3[i]=="五级"?'checked="checked"':'';
                html += ' disabled/>五级' +
                '</label>' +
                '</div>' +
                '</div>' +
                '<div class="form-group">' +
                '<label class="col-sm-3 control-label">通信网络安全等级防护定级备案情况：</label>' +
                '<div class="col-sm-8">' +
                '<label class="radio-inline">' +
                '<input field="'+ arr4[i] +'" type="radio" name="comSecurityCognizance'+i+'" value="未开展" ';
                html += arr4[i]=="未开展"?'checked="checked"':'';
                html +=' disabled/>未开展' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr4[i] +'" type="radio" name="comSecurityCognizance'+i+'" value="一级" ';
                html += arr4[i]=="一级"?'checked="checked"':'';
                html += ' disabled/>一级' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr4[i] +'" type="radio" name="comSecurityCognizance'+i+'" value="二级" ';
                html += arr4[i]=="二级"?'checked="checked"':'';
                html += ' disabled/>二级' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr4[i] +'" type="radio" name="comSecurityCognizance'+i+'" value="三级" ';
                html += arr4[i]=="三级"?'checked="checked"':'';
                html += ' disabled/>三级' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr4[i] +'" type="radio" name="comSecurityCognizance'+i+'" value="四级" ';
                html += arr4[i]=="四级"?'checked="checked"':'';
                html += ' disabled/>四级' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr4[i] +'" type="radio" name="comSecurityCognizance'+i+'" value="五级" ';
                html += arr4[i]=="五级"?'checked="checked"':'';
                html += ' disabled/>五级' +
                '</label>' +
                '</div>' +
                '</div>' +
                '<div class="form-group">' +
                '<label class="col-sm-3 control-label">是否为关键信息基础设施：</label>' +
                '<div class="col-sm-8">' +
                '<label class="radio-inline">' +
                '<input field="'+ arr5[i] +'" type="radio" name="isKetSystem'+i+'" value="是" ';
                html += arr5[i]=="是"?'checked="checked"':'';
                html += ' disabled/>是' +
                '</label>' +
                '<label class="radio-inline">' +
                '<input field="'+ arr5[i] +'" type="radio" name="isKetSystem'+i+'" value="否" ';
                html += arr5[i]=="否"?'checked="checked"':'';
                html += ' disabled/>否' +
                '</label>' +
                '</div>' +
                '</div>';
        }
        $("#infoSystem").append(html);
    } else {
        var html = '<span class="form-group">'+
            '<h3 class="col-sm-6">承载重要/核心数据的信息系统情况</h3>'+
            '</span>'+
            '<div class="form-group">' +
            '<label class="col-sm-3 control-label">信息系统名称：</label>' +
            '<div class="col-sm-8">' +
            '<input readOnly id="infoSystemName" name="infoSystemName" value="'+arr1+'"' +
            'class="form-control"></input>' +
            '</div>' +
            '</div>' +
            '<div class="form-group">' +
            '<label class="col-sm-3 control-label">信息系统类型：</label>' +
            '<div class="col-sm-8">' +
            '<input readOnly id="infoSystemType" name="infoSystemType" value="'+arr2+'"' +
            'class="form-control"></input>' +
            '</div>' +
            '</div>' +
            '<div class="form-group">' +
            '<label class="col-sm-3 control-label">信息系统IP地址：</label>' +
            '<div class="col-sm-8">' +
            '<input readOnly id="infoSystemIpAddress" name="infoSystemIpAddress" value="'+arr6+'"' +
            'class="form-control"></input>' +
            '</div>' +
            '</div>' +
            '<div class="form-group">' +
            '<label class="col-sm-3 control-label">信息系统域名：</label>' +
            '<div class="col-sm-8">' +
            '<input readOnly id="infoSystemDomainName" name="infoSystemDomainName" value="'+arr7+'"' +
            'class="form-control"></input>' +
            '</div>' +
            '</div>' +
            '<div class="form-group">' +
            '<label class="col-sm-3 control-label">网络安全等级保护认定情况：</label>' +
            '<div class="col-sm-8">' +
            '<label class="radio-inline">' +
            '<input field="'+ arr3 +'" type="radio" name="securityCognizance" value="未开展" ';
            html += arr3=="未开展"?'checked="checked"':'';
            html +=' disabled/>未开展' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr3 +'" type="radio" name="securityCognizance" value="一级" ';
            html += arr3=="一级"?'checked="checked"':'';
            html += ' disabled/>一级' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr3 +'" type="radio" name="securityCognizance" value="二级" ';
            html += arr3=="二级"?'checked="checked"':'';
            html += ' disabled/>二级' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr3 +'" type="radio" name="securityCognizance" value="三级" ';
            html += arr3=="三级"?'checked="checked"':'';
            html += ' disabled/>三级' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr3 +'" type="radio" name="securityCognizance" value="四级" ';
            html += arr3=="四级"?'checked="checked"':'';
            html += ' disabled/>四级' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr3 +'" type="radio" name="securityCognizance" value="五级" ';
            html += arr3=="五级"?'checked="checked"':'';
            html += ' disabled/>五级' +
            '</label>' +
            '</div>' +
            '</div>' +
            '<div class="form-group">' +
            '<label class="col-sm-3 control-label">通信网络安全等级防护定级备案情况：</label>' +
            '<div class="col-sm-8">' +
            '<label class="radio-inline">' +
            '<input field="'+ arr4 +'" type="radio" name="comSecurityCognizance" value="未开展" ';
            html += arr4=="未开展"?'checked="checked"':'';
            html +=' disabled/>未开展' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr4 +'" type="radio" name="comSecurityCognizance" value="一级" ';
            html += arr4=="一级"?'checked="checked"':'';
            html += ' disabled/>一级' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr4 +'" type="radio" name="comSecurityCognizance" value="二级" ';
            html += arr4=="二级"?'checked="checked"':'';
            html += ' disabled/>二级' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr4 +'" type="radio" name="comSecurityCognizance" value="三级" ';
            html += arr4=="三级"?'checked="checked"':'';
            html += ' disabled/>三级' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr4 +'" type="radio" name="comSecurityCognizance" value="四级" ';
            html += arr4=="四级"?'checked="checked"':'';
            html += ' disabled/>四级' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr4 +'" type="radio" name="comSecurityCognizance" value="五级" ';
            html += arr4=="五级"?'checked="checked"':'';
            html += ' disabled/>五级' +
            '</label>' +
            '</div>' +
            '</div>' +
            '<div class="form-group">' +
            '<label class="col-sm-3 control-label">是否为关键信息基础设施：</label>' +
            '<div class="col-sm-8">' +
            '<label class="radio-inline">' +
            '<input field="'+ arr5 +'" type="radio" name="isKetSystem" value="是" ';
            html += arr5=="是"?'checked="checked"':'';
            html += ' disabled/>是' +
            '</label>' +
            '<label class="radio-inline">' +
            '<input field="'+ arr5 +'" type="radio" name="isKetSystem" value="否" ';
            html += arr5=="否"?'checked="checked"':'';
            html += ' disabled/>否' +
            '</label>' +
            '</div>' +
            '</div>';
        $("#infoSystem").append(html);
    }

}