From 9f7095cc0c1f83ebe18e19da7733b7b0a0412632 Mon Sep 17 00:00:00 2001 From: “shentao” Date: Tue, 20 Sep 2016 18:13:00 +0800 Subject: update jquery.dataTables.js version to 1.10.11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id4763097245b4a9e1adf0b734b0ff993a2233e73 Signed-off-by: “shentao” --- .../common/thirdparty/data-tables/DT_bootstrap.css | 240 + .../common/thirdparty/data-tables/DT_bootstrap.js | 363 + .../common/thirdparty/data-tables/DataTableICT.js | 1459 ++ .../thirdparty/data-tables/DataTableSmartClient.js | 1215 ++ .../data-tables/DataTableSmartClientApp.js | 1312 ++ .../data-tables/app-test-i18n-datatable-zh-CN.json | 51 + .../app-universal-i18n-datatable-en-US.json | 89 + .../app-universal-i18n-datatable-zh-CN.json | 90 + .../common/thirdparty/data-tables/dataTable.html | 155 + .../thirdparty/data-tables/jquery.dataTables.js | 20261 +++++++++++-------- .../data-tables/jquery.dataTables.min.js | 321 +- .../thirdparty/data-tables/style-datatable.css | 154 + 12 files changed, 17008 insertions(+), 8702 deletions(-) create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DT_bootstrap.css create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DT_bootstrap.js create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableICT.js create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableSmartClient.js create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableSmartClientApp.js create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-test-i18n-datatable-zh-CN.json create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-universal-i18n-datatable-en-US.json create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-universal-i18n-datatable-zh-CN.json create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/dataTable.html create mode 100644 openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/style-datatable.css diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DT_bootstrap.css b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DT_bootstrap.css new file mode 100644 index 00000000..599fb0d8 --- /dev/null +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DT_bootstrap.css @@ -0,0 +1,240 @@ +div.dataTables_length label { + float: left; + text-align: left; +} + +div.dataTables_length label .form-control { + display: inline-block; + width: auto; + vertical-align: middle; +} + +div.dataTables_length select { + width: 75px; +} + +div.dataTables_filter label { + float: right; +} + +div.dataTables_info { + position: relative; + top:15px; +} + +div.dataTables_paginate { + float: right; + margin: 0; +} + +table.table { + clear: both; + margin-bottom: 6px !important; + max-width: none !important; +} + +table.table thead .sorting, +table.table thead .sorting_asc, +table.table thead .sorting_desc, +table.table thead .sorting_asc_disabled, +table.table thead .sorting_desc_disabled { + cursor: pointer; + *cursor: hand; +} + +table.table thead .sorting { background: url('images/sort_both.png') no-repeat center right; } +table.table thead .sorting_asc { background: url('images/sort_asc.png') no-repeat center right; } +table.table thead .sorting_desc { background: url('images/sort_desc.png') no-repeat center right; } + +table.table thead .sorting_asc_disabled { background: url('images/sort_asc_disabled.png') no-repeat center right; } +table.table thead .sorting_desc_disabled { background: url('images/sort_desc_disabled.png') no-repeat center right; } + +table.dataTable th:active { + outline: none; +} + +table.dataTable tbody { + font-size:13px; +} + +/* Scrolling */ +div.dataTables_scroll { + margin-bottom: 5px; + margin-top: 5px; +} +div.dataTables_scrollHead table { + margin-bottom: 0 !important; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +div.dataTables_scrollHead table thead tr:last-child th:first-child, +div.dataTables_scrollHead table thead tr:last-child td:first-child { + border-bottom-left-radius: 0 !important; + border-bottom-right-radius: 0 !important; +} + +div.dataTables_scrollBody table { + border-top: none; + margin-bottom: 0 !important; +} + +div.dataTables_scrollBody tbody tr:first-child th, +div.dataTables_scrollBody tbody tr:first-child td { + border-top: none; +} + +/* +div.dataTables_scrollBody tbody tr td { + padding-left: 10px !important; + padding-right: 10px !important; +} +div.dataTables_scrollHeadInner table thead tr th, +div.dataTables_scrollBody table thead tr th{ + padding-left: 10px !important; + padding-right: 18px !important; + text-align: center !important; +}*/ + +div.dataTables_scrollFoot table { + border-top: none; +} + +/* + * TableTools styles + */ + +table.DTTT_selectable tbody tr { + cursor: pointer; + *cursor: hand; +} + +div.DTTT .btn { + color: #333 !important; + font-size: 12px; +} + +div.DTTT .btn:hover { + text-decoration: none !important; +} + + +ul.DTTT_dropdown.dropdown-menu a { + color: #333 !important; /* needed only when demo_page.css is included */ +} + +ul.DTTT_dropdown.dropdown-menu li:hover a { + background-color: #0088cc; + color: white !important; +} + +/* TableTools information display */ +div.DTTT_print_info.modal { + height: 150px; + margin-top: -75px; + text-align: center; +} + +div.DTTT_print_info h6 { + font-weight: normal; + font-size: 28px; + line-height: 28px; + margin: 1em; +} + +div.DTTT_print_info p { + font-size: 14px; + line-height: 20px; +} + + + +/* + * FixedColumns styles + */ +div.DTFC_LeftHeadWrapper table, +div.DTFC_LeftFootWrapper table, +table.DTFC_Cloned tr.even { + background-color: white; +} + +div.DTFC_LeftHeadWrapper table { + margin-bottom: 0 !important; + border-top-right-radius: 0 !important; + border-bottom-left-radius: 0 !important; + border-bottom-right-radius: 0 !important; +} + +div.DTFC_LeftHeadWrapper table thead tr:last-child th:first-child, +div.DTFC_LeftHeadWrapper table thead tr:last-child td:first-child { + border-bottom-left-radius: 0 !important; + border-bottom-right-radius: 0 !important; +} + +div.DTFC_LeftBodyWrapper table { + border-top: none; + margin-bottom: 0 !important; +} + +div.DTFC_LeftBodyWrapper tbody tr:first-child th, +div.DTFC_LeftBodyWrapper tbody tr:first-child td { + border-top: none; +} + +div.DTFC_LeftFootWrapper table { + border-top: none; +} + +/*浮动的确认反确认样式 */ +td.buttonRounded { + background-color: #e5e5e5; + color: #333333; + border: 0px solid #b15a59; + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + -ms-border-radius: 0px; + -o-border-radius: 0px; + border-radius: 0px; + font-family: Arial, Verdana, sans-serif; + font-size: 12px; + /*padding: 0 3px;*/ + padding-left:5px !important; + padding-right:5px !important; + height:30px !important; +} + +td.buttonRoundedDisabled { + opacity: .65; + height:30px !important; +} + +div.buttonConfirm{ + position: absolute; left: 0px; top: 0px; width: 120px; height: 30px; z-index: 201224; overflow: visible; + font-size: 13px; +} +div.buttonUnConfirm{ + position: absolute; left: 120px; top: 0px; width: 100px; height: 30px; z-index: 201242; overflow: visible; + font-size: 13px; +} +div.buttonDelete{ + position: absolute; left: 250px; top: 0px; width: 60px; height: 30px; z-index: 201260; overflow: visible; + font-size: 13px; +} + +button.btn-confirm { + width:90px; +} + +/*** +Extended pagination +***/ +.paging_bootstrap_extended { + margin: 0 !important; + padding: 0 !important; + float: none !important; + font-size: 13px; +} + +.modal-body { + font-size: 13px; +} \ No newline at end of file diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DT_bootstrap.js b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DT_bootstrap.js new file mode 100644 index 00000000..5b95e4ac --- /dev/null +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DT_bootstrap.js @@ -0,0 +1,363 @@ +/* Set the defaults for DataTables initialisation */ + +$.extend( true, $.fn.dataTable.defaults, { + "sDom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // horizobtal scrollable datatable + //"sDom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // defaukt datatable without horizobtal scroll + "sPaginationType": "bootstrap", + "oLanguage": { + "sLengthMenu": " _MENU_ records ", + } +} ); + + +/* Default class modification */ + +$.extend( $.fn.dataTableExt.oStdClasses, { + "sWrapper": "dataTables_wrapper" +} ); + + +/* API method to get paging information */ + +$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) +{ + return { + "iStart": oSettings._iDisplayStart, + "iEnd": oSettings.fnDisplayEnd(), + "iLength": oSettings._iDisplayLength, + "iTotal": oSettings.fnRecordsTotal(), + "iFilteredTotal": oSettings.fnRecordsDisplay(), + "iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), + "iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) + }; +}; + + +/* Bootstrap style pagination control */ +$.extend( $.fn.dataTableExt.oPagination, { + "bootstrap": { + "fnInit": function( oSettings, nPaging, fnDraw ) { + var oLang = oSettings.oLanguage.oPaginate; + var fnClickHandler = function ( e ) { + e.preventDefault(); + if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { + fnDraw( oSettings ); + } + }; + + // pagination with prev, next link icons + $(nPaging).append( + '' + ); + + var els = $('a', nPaging); + $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); + $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler ); + }, + + "fnUpdate": function ( oSettings, fnDraw ) { + var iListLength = 5; + var oPaging = oSettings.oInstance.fnPagingInfo(); + var an = oSettings.aanFeatures.p; + var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); + + if ( oPaging.iTotalPages < iListLength) { + iStart = 1; + iEnd = oPaging.iTotalPages; + } + else if ( oPaging.iPage <= iHalf ) { + iStart = 1; + iEnd = iListLength; + } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { + iStart = oPaging.iTotalPages - iListLength + 1; + iEnd = oPaging.iTotalPages; + } else { + iStart = oPaging.iPage - iHalf + 1; + iEnd = iStart + iListLength - 1; + } + + for ( i=0, iLen=an.length ; i'+j+'') + .insertBefore( $('li:last', an[i])[0] ) + .bind('click', function (e) { + e.preventDefault(); + oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; + fnDraw( oSettings ); + } ); + } + + // Add / remove disabled classes from the static elements + if ( oPaging.iPage === 0 ) { + $('li:first', an[i]).addClass('disabled'); + } else { + $('li:first', an[i]).removeClass('disabled'); + } + + if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { + $('li:last', an[i]).addClass('disabled'); + } else { + $('li:last', an[i]).removeClass('disabled'); + } + } + } + } +} ); + +/* Bootstrap style full number pagination control */ +$.extend( $.fn.dataTableExt.oPagination, { + "bootstrap_full_number": { + "fnInit": function( oSettings, nPaging, fnDraw ) { + var oLang = oSettings.oLanguage.oPaginate; + var fnClickHandler = function ( e ) { + e.preventDefault(); + if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { + fnDraw( oSettings ); + } + }; + + $(nPaging).append( + '
    ' + + '' + + ''+ + '' + + '' + + '
' + ); + var els = $('a', nPaging); + $(els[0]).bind('click.DT', { action: "first" }, fnClickHandler); + $(els[1]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); + $(els[2]).bind('click.DT', { action: "next" }, fnClickHandler); + $(els[3]).bind('click.DT', { action: "last" }, fnClickHandler); + }, + + "fnUpdate": function ( oSettings, fnDraw ) { + var iListLength = 5; + var oPaging = oSettings.oInstance.fnPagingInfo(); + var an = oSettings.aanFeatures.p; + var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); + + if ( oPaging.iTotalPages < iListLength) { + iStart = 1; + iEnd = oPaging.iTotalPages; + } + else if ( oPaging.iPage <= iHalf ) { + iStart = 1; + iEnd = iListLength; + } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { + iStart = oPaging.iTotalPages - iListLength + 1; + iEnd = oPaging.iTotalPages; + } else { + iStart = oPaging.iPage - iHalf + 1; + iEnd = iStart + iListLength - 1; + } + + + + for ( i=0, iLen=an.length ; i'+j+'') + .insertBefore( $('li.next:first', an[i])[0] ) + .bind('click', function (e) { + e.preventDefault(); + oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; + fnDraw( oSettings ); + } ); + } + + // Add / remove disabled classes from the static elements + if ( oPaging.iPage === 0 ) { + $('li.prev', an[i]).addClass('disabled'); + } else { + $('li.prev', an[i]).removeClass('disabled'); + } + + if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { + $('li.next', an[i]).addClass('disabled'); + } else { + $('li.next', an[i]).removeClass('disabled'); + } + } + } + } +} ); + +/* Bootstrap style full number pagination control */ +$.extend( $.fn.dataTableExt.oPagination, { + "bootstrap_extended": { + "fnInit": function( oSettings, nPaging, fnDraw ) { + var oLang = oSettings.oLanguage.oPaginate; + var oPaging = oSettings.oInstance.fnPagingInfo(); + + var fnClickHandler = function ( e ) { + e.preventDefault(); + if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { + fnDraw( oSettings ); + } + }; + + $(nPaging).append( + '
' + oLang.sPage + ' ' + + '' + + '' + + ' ' + + oLang.sPageOf + ' ' + + '
' + ); + + var els = $('a', nPaging); + + $(els[0]).bind('click.DT', { action: "previous" }, fnClickHandler ); + $(els[1]).bind('click.DT', { action: "next" }, fnClickHandler); + + $('.pagination-panel-input', nPaging).bind('change.DT', function(e) { + var oPaging = oSettings.oInstance.fnPagingInfo(); + e.preventDefault(); + var page = parseInt($(this).val()); + if (page > 0 && page < oPaging.iTotalPages) { + if ( oSettings.oApi._fnPageChange(oSettings, page-1) ) { + fnDraw( oSettings ); + } + } else { + $(this).val(oPaging.iPage + 1); + } + }); + + $('.pagination-panel-input', nPaging).bind('keypress.DT', function(e) { + var oPaging = oSettings.oInstance.fnPagingInfo(); + if (e.which == 13) { + var page = parseInt($(this).val()); + if (page > 0 && page < oSettings.oInstance.fnPagingInfo().iTotalPages) { + if ( oSettings.oApi._fnPageChange(oSettings, page-1) ) { + fnDraw( oSettings ); + } + } else { + $(this).val(oPaging.iPage + 1); + } + e.preventDefault(); + } + }); + }, + + "fnUpdate": function ( oSettings, fnDraw ) { + var iListLength = 5; + var oPaging = oSettings.oInstance.fnPagingInfo(); + var an = oSettings.aanFeatures.p; + var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); + + if ( oPaging.iTotalPages < iListLength) { + iStart = 1; + iEnd = oPaging.iTotalPages; + } + else if ( oPaging.iPage <= iHalf ) { + iStart = 1; + iEnd = iListLength; + } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { + iStart = oPaging.iTotalPages - iListLength + 1; + iEnd = oPaging.iTotalPages; + } else { + iStart = oPaging.iPage - iHalf + 1; + iEnd = iStart + iListLength - 1; + } + + + for ( i=0, iLen=an.length ; i'+j+'') + .insertBefore( $('li.next:first', an[i])[0] ) + .bind('click', function (e) { + e.preventDefault(); + oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; + fnDraw( oSettings ); + } ); + } + + // Add / remove disabled classes from the static elements + if ( oPaging.iPage === 0 ) { + $('a.prev', an[i]).addClass('disabled'); + } else { + $('a.prev', an[i]).removeClass('disabled'); + } + + if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { + $('a.next', an[i]).addClass('disabled'); + } else { + $('a.next', an[i]).removeClass('disabled'); + } + } + } + } +} ); + +/* + * TableTools Bootstrap compatibility + * Required TableTools 2.1+ + */ +if ( $.fn.DataTable.TableTools ) { + // Set the classes that TableTools uses to something suitable for Bootstrap + $.extend( true, $.fn.DataTable.TableTools.classes, { + "container": "btn-group", + "buttons": { + "normal": "btn default", + "disabled": "btn disabled" + }, + "collection": { + "container": "DTTT_dropdown dropdown-menu", + "buttons": { + "normal": "", + "disabled": "disabled" + } + } + } ); + + // Have the collection use a bootstrap compatible dropdown + $.extend( true, $.fn.DataTable.TableTools.DEFAULTS.oTags, { + "collection": { + "container": "ul", + "button": "li", + "liner": "a" + } + } ); +} \ No newline at end of file diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableICT.js b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableICT.js new file mode 100644 index 00000000..03084e2e --- /dev/null +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableICT.js @@ -0,0 +1,1459 @@ +/*** + Wrapper/Helper Class for datagrid based on jQuery Datatable Plugin + ***/ +var DatatableICT = function () { + + var contextData; + var tableOptions; // main options + var dataTable; // datatable object + var table; // actual table jquery object + var tableContainer; // actual table container object + var tableWrapper; // actual table wrapper jquery object + var tableInitialized = false; + var ajaxParams = []; // set filter mode + var columns; + var xsHiddenColumns; + var smHiddenColumns; + var columnMaxLength = 30; + var columnsTooLong; + var hidden_xs_maxWidth = 768; + var hidden_sm_maxWidth = 991; + + var openRowFlag = false; + var rowOverFlag = false; + var rowCheckable = false; + + var aTargetsAll; + var sTotalRecordsSource; + var totalRecords; + var tableHeight; + + var requestType="GET"; + var callbackList = []; + var checkedRowDatas = []; + var currentPageData; + + var includedInXsHiddenColumns = function(columnId){ + for(var i=0;i tr > td:nth-child(1) input[type="checkbox"]:checked', table).size(); + var text = tableOptions.dataTable.oLanguage.sGroupActions; + if (selected > 0) { + $('.table-group-actions > span', tableWrapper).text(text.replace("_TOTAL_", selected)); + } else { + $('.table-group-actions > span', tableWrapper).text(""); + } + } + + var jsonObjectToArray = function(json, columns, iDraw){ + var jsonToDatatable = {aaData:[], sEcho:iDraw, iTotalRecords:0, iTotalDisplayRecords:0 }; + //获取数据的属性 + var dataField; + //性能的情况 + if(json.data){ + dataField = json.data; + } + //告警的情况 + if(json.response && json.response.data){ + dataField = json.response.data; + } + for(var i=0; i"); + } + if(openRowFlag){ + jsonToDatatable.aaData[i].push(""); + } + for(var j=0; j= hidden_xs_maxWidth && $(window).width() < hidden_sm_maxWidth && includedInSmHiddenColumns(columns[j].columnId )){ + /*隐藏pad尺寸需要隐藏的列*/ + }else if($(window).width() < hidden_xs_maxWidth && includedInXsHiddenColumns(columns[j].columnId )){ + /*隐藏手机尺寸需要隐藏的列*/ + }else{ + var currentColumnId = columns[j].columnId; + if(jQuery.inArray(currentColumnId, columnsTooLong) > -1){ + var rawText = ""; + for(var k=0;k columnMaxLength){ + jsonToDatatable.aaData[i].push(rawText.slice(0, columnMaxLength) + '...'); + }else{ + jsonToDatatable.aaData[i].push(resRowObject[currentColumnId]); + } + } else { + jsonToDatatable.aaData[i].push(resRowObject[currentColumnId]); + } + + } + } + } + jsonToDatatable.sEcho++; + //取得总行数 + var totalRow = 0; + if(requestType == "POST"){ //性能的情况单独发请求获得总行数 + totalRow = totalRecords; + }else{ + var totalRecordsSource = eval('json.' + sTotalRecordsSource); + if(totalRecordsSource && totalRecordsSource.length >0){ + totalRow = parseInt(totalRecordsSource); + } + } + if(isNaN(totalRow)){ + alert('All rows counting number got fail!'); + }else{ + jsonToDatatable.iTotalRecords = totalRow; + jsonToDatatable.iTotalDisplayRecords = totalRow; + } + return jsonToDatatable; + } + + var singleAlarmDel = function(divOverlay){ + + //根据浮动框的当前id获取需要删除的行 + var trId = divOverlay.attr('id_tr'); + tr=$('tr#' + trId); + var tds = $(tr).children(); + var tdAlarmId = ""; + if(rowCheckable){ + tdAlarmId = $(tds.eq(2)).text(); + }else{ + tdAlarmId = $(tds.eq(1)).text(); + } + + var data= { + "alarmId":[parseInt(tdAlarmId)] + }; + + var sSource = "/web/rest/web/fm/curalarms?data=" + JSON.stringify(data) + "&_operationType=remove&_dataSource=isc_PageRestDataSource_0&isc_metaDataPrefix=_&isc_dataFormat=json"; + + $.ajax( { + "dataType": 'json', + "type": "DELETE", + "url": sSource, + "data" : null, + "contentType" : 'application/json; charset=utf-8', + "success": function(json) { + if(json.response.status == 0){ + var resRowObject = json.response.data[0]; + //alert('删除成功'); + } + if(json.response.status == -1){ + //alert('删除失败'); + } + }, + "error": function() { + alert('Communication Error!'); + } + } ); + } + + var singleAlarmAckUnAck = function(divOverlay, ackType){ + + //根据浮动框的当前id获取需要确认的行 + var trId = divOverlay.attr('id_tr'); + var tr = $('tr#' + trId); + + //取得隐藏的头部表格的相应行 + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable', contextData.wrapperDivContext); + //var trHead = $('tbody > tr:nth-child(' + trId + ')', $tableHead); + var trHead = $('tr#' + trId.replace('body', 'head'), $tableHead); + var tdDivs = $('td > div', trHead); + + var tds = $(tr).children(); + var tdAlarmId = ""; + if(rowCheckable){ + tdAlarmId = $(tds.eq(2)).text(); + }else{ + tdAlarmId = $(tds.eq(1)).text(); + } + + var aoData = + { + "dataSource":"isc_PageRestDataSource_0", + "operationType":"update", + "componentId":"isc_com_zte_ums_aos_fm_view_eventview_table_AlarmTable_0", + "data":{ + "viewType":1, + "state":ackType, + "alarmId":[ + parseInt(tdAlarmId) + ] + }, + "oldValues":null + }; + + var sSource = "/web/rest/web/fm/curalarms?isc_dataFormat=json"; + + $.ajax( { + "dataType": 'json', + "type": "PUT", + "url": sSource, + "contentType": 'application/json; charset=utf-8', + "data": JSON.stringify(aoData), + "success": function(json) { + if(callbackList[1]){ + json = callbackList[1](json); + } + if(json.response.status == 0){ + var resRowObject = json.response.data[0]; + var columnsCopy = $.extend(true, [], columns); + //隐藏列的情况下需要特殊处理 + if($(window).width()>=hidden_xs_maxWidth && $(window).width() -1) { + var rawText = ""; + for(var k=0;k columnMaxLength){ + $(tds.eq(i)).html(rawText.slice(0, columnMaxLength) + '...'); + $(tdDivs.eq(i)).html(rawText.slice(0, columnMaxLength) + '...'); + }else{ + $(tds.eq(i)).html(resRowObject[currentColumnId]); + $(tdDivs.eq(i)).html(resRowObject[currentColumnId]); + } + } else { + $(tds.eq(i)).html(resRowObject[currentColumnId]); + $(tdDivs.eq(i)).html(resRowObject[currentColumnId]); + } + } + //更新缓存中的当前行数据 + for (var t = 0; t < dataTable.datas.length; t++) { + var temp = dataTable.datas[t]; + if (temp.alarmId == resRowObject['alarmId']) { + dataTable.datas[t] = resRowObject; + break; + } + } + } + if(json.response.status == -1){ + $('div#myModalConfirm' + contextData.curentDatableId).modal({ + keyboard: false, + backdrop: 'static' + }); + $('span#alarm_number' + contextData.curentDatableId).html(tdAlarmId); + //国际化信息 + if(ackType==1){ + $('span#aos_fm_alarm_opeater_ack_already').html($.i18n.prop('aos_fm_alarm_opeater_ack_already_ok').replace(/\"/g,"").replace(";", "")); + }else{ + $('span#aos_fm_alarm_opeater_ack_already').html($.i18n.prop('aos_fm_alarm_opeater_ack_already_un').replace(/\"/g,"").replace(";", "")); + } + } + }, + "error": function() { + alert('Communication Error!'); + } + } ); + } + + var addRowOverlap = function(){ + var $tableData = $('table#datatable_ajax' + contextData.curentDatableId); + //取得隐藏的头部表格的相应行 + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable', contextData.wrapperDivContext); + var trHeads = $tableHead.find('tr').get(); + $.each( trHeads, function( index, trHead ){ + $(trHead).attr('id', 'headTableTR' + index); + }); + //取得浮动div + var $divOverlay = $('div#divOverlay' + contextData.curentDatableId); + var divScrollHead = $('div.dataTables_scrollHead', contextData.wrapperDivContext); + var divRightPadding = $('div#divRightPadding' + contextData.curentDatableId); + //取表头下边沿位置 + var tableHeadBottomHeight = $(divScrollHead).position().top + $(divScrollHead).height(); + var tableBottom = $tableData.position().top + $tableData.height() + 3; + //取表格右边沿位置 + var tableRightEdgePosition = $(divRightPadding).position().left; + var trs = $tableData.find('tr').get(); + $.each( trs, function( index, tr ){ + var tdEmpty = $('td.dataTables_empty',tr); + if(!tdEmpty || tdEmpty.length ==0 ){ + $(tr).attr('id', 'bodyTableTR' + index + contextData.curentDatableId); + //$divOverlay.attr('id_tr', 'bodyTableTR' + index); + $(tr).one('hover', function(){ + var rowPos = $(tr).position(); + var currentTrTop = rowPos.top; + //var bottomLeft = rowPos.left; + $divOverlay.attr('id_tr', 'bodyTableTR' + index + contextData.curentDatableId); + $divOverlay.css({ + display: 'block', + position: 'absolute', + 'background-color': '#e5e5e5', + //opacity: 0.7, + border: 'solid 0px', + top: currentTrTop + 6, + left: tableRightEdgePosition - 308, + width: 300, + height: 30 + }); + //防止浮动框跳出表格内容区域 + if( $divOverlay.position().top < tableHeadBottomHeight || $divOverlay.position().top + $divOverlay.height() > tableBottom){ + $divOverlay.css('display', 'none'); + } + var buttonConfirm = $('div#buttonConfirm', $divOverlay); + var buttonUnConfirm = $('div#buttonUnConfirm', $divOverlay); + $(buttonConfirm).one('click', function(){ + var buttonRoundedTDsConfirm = $(buttonConfirm).find('td.buttonRounded'); + var buttonRoundedTDsUnConfirm = $(buttonUnConfirm).find('td.buttonRoundedDisabled'); + if(buttonRoundedTDsConfirm && buttonRoundedTDsConfirm.length > 0){ + $.each(buttonRoundedTDsConfirm, function(index, td){ + $(td).removeClass('buttonRounded').addClass('buttonRoundedDisabled'); + }); + $.each(buttonRoundedTDsUnConfirm, function(index, td){ + $(td).removeClass('buttonRoundedDisabled').addClass('buttonRounded'); + }); + $divOverlay.css('display', 'none'); + singleAlarmAckUnAck($divOverlay, 1); + } + }); + $(buttonUnConfirm).one('click', function(){ + var buttonRoundedTDsUnConfirm = $(buttonUnConfirm).find('td.buttonRounded'); + var buttonRoundedTDsConfirm = $(buttonConfirm).find('td.buttonRoundedDisabled'); + if(buttonRoundedTDsUnConfirm && buttonRoundedTDsUnConfirm.length > 0){ + $.each(buttonRoundedTDsUnConfirm, function(index, td){ + $(td).removeClass('buttonRounded').addClass('buttonRoundedDisabled'); + }); + $.each(buttonRoundedTDsConfirm, function(index, td){ + $(td).removeClass('buttonRoundedDisabled').addClass('buttonRounded'); + }); + $divOverlay.css('display', 'none'); + singleAlarmAckUnAck($divOverlay, 2); + } + }); + var buttonDelete = $('div#buttonDelete', $divOverlay); + $(buttonDelete).die().live('click', function(){ + //弹出删除确认对话框 + $('div#myModal' + contextData.curentDatableId).modal({ + keyboard: false, + backdrop: 'static' + }); + $('#delConfirm' + contextData.curentDatableId).die().live('click', function(){ + $divOverlay.css('display', 'none'); + dataTable.fnClose(tr); + $(tr).remove(); + //删除表头表格的相应行 + $('tr#' + $(tr).attr('id').replace('body', 'head'), $tableHead).remove(); + //删除后端数据 + singleAlarmDel($divOverlay); + //刷新表格 + dataTable.fnAdjustColumnSizing(); + }); + }); + //展开行的情况隐藏 + $('td.details > table.detailTable').on('hover', function(){ + $divOverlay.css('display', 'none'); + }); + }); + } + }); + } + + return { + + //main function to initiate the module + init: function (options, columnsDefined, xsHiddenColumnsDefined, smHiddenColumnsDefined) { + + if (!$().dataTable) { + return; + } + + var the = this; + + //记录需要禁掉默认排序的列 + var aTargets = []; + var targetsLength = columnsDefined.length; + if(rowCheckable)targetsLength++; + if(openRowFlag)targetsLength++; + for(var i=0;i<'col-md-4 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>", // datatable layout + + "aoColumnDefs" : [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column) + 'bSortable' : false, + 'aTargets' : aTargets + }], + + "bAutoWidth": false, // disable fixed width and enable fluid table + //"bSortCellsTop": true, // make sortable only the first row in thead + "sPaginationType": "bootstrap_extended", // pagination type(bootstrap, bootstrap_full_number or bootstrap_extended) + "bProcessing": true, // enable/disable display message box on record load + "bServerSide": true, // enable/disable server side ajax loading + "sAjaxSource": "", // define ajax source URL + //"sServerMethod": "GET", + + // handle ajax request + "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { + //for ICT Paging + //var startIndex = aoData[3].value;//"iDisplayStart" + //var pageLength = aoData[4].value;//"iDisplayLength" + var oPaging = oSettings.oInstance.fnPagingInfo(); + //var startIndex = oPaging.iStart; + var pageLength = oPaging.iLength; + var curPageNo = oPaging.iPage + 1; + + for(var k=aoData.length-1;k>=0;k--){ + var flag = -1; + if(aoData[k].name=='pageSize'){ + aoData[k].value=pageLength; + flag++; + } + if(aoData[k].name=='pageNo'){ + aoData[k].value=curPageNo; + flag++ + } + if(flag == 1)break; + } + + if(requestType == "POST"){ + + var postData; + for(var k=aoData.length-1;k>=0;k--){ + if(aoData[k].name=='data'){ + postData = aoData[k].value; + postData.pageSize = pageLength; + postData.pageNo = curPageNo; + break; + } + } + + oSettings.jqXHR = $.ajax( { + "dataType": 'json', + "type": "POST", + "url": sSource, + "data": JSON.stringify(postData), + "contentType": 'application/json; charset=utf-8', + "success": function(res, textStatus, jqXHR) { + if (res.sMessage) { + ZteFrameWork.alert({type: (res.sStatus == 'OK' ? 'success' : 'danger'), icon: (res.sStatus == 'OK' ? 'check' : 'warning'), message: res.sMessage, container: tableWrapper, place: 'prepend'}); + } + if ($('.group-checkable', tableContainer).size() === 1) { + $('.group-checkable', tableContainer).attr("checked", false); + $.uniform.update($('.group-checkable', tableContainer)); + } + if (tableOptions.onSuccess) { + tableOptions.onSuccess.call(the); + } + + if(callbackList[1]){ + res = callbackList[1](res); + } + + //转换返回数据给datatable + res = jsonObjectToArray(res, columns, oSettings.iDraw); + + //重绘表格 + fnCallback(res, textStatus, jqXHR); + }, + "error": function() { + if (tableOptions.onError) { + tableOptions.onError.call(the); + } + ZteFrameWork.alert({type: 'danger', icon: 'warning', message: tableOptions.dataTable.oLanguage.sAjaxRequestGeneralError, container: tableWrapper, place: 'prepend'}); + $('.dataTables_processing', tableWrapper).remove(); + } + } ); + + } else { + + oSettings.jqXHR = $.ajax( { + "dataType": 'json', + "type": "GET", + "url": sSource, + "data": aoData, + "success": function(res, textStatus, jqXHR) { + if (res.sMessage) { + ZteFrameWork.alert({type: (res.sStatus == 'OK' ? 'success' : 'danger'), icon: (res.sStatus == 'OK' ? 'check' : 'warning'), message: res.sMessage, container: tableWrapper, place: 'prepend'}); + } + if ($('.group-checkable', tableContainer).size() === 1) { + $('.group-checkable', tableContainer).attr("checked", false); + $.uniform.update($('.group-checkable', tableContainer)); + } + if (tableOptions.onSuccess) { + tableOptions.onSuccess.call(the); + } + //保存数据在dataTable对象中给行详细信息面板用 + if(res.response){ //告警的情况,返回数据在response属性里 + dataTable.datas = res.response.data; + if(res.response.status < 0){ + alert(res.response.data); + return; + } + } + + //保存当前页原始数据的备份 + currentPageData = $.extend(true, {}, res.response.data);; + + if(callbackList[1]){ + res = callbackList[1](res); + } + + //转换返回数据给datatable + res = jsonObjectToArray(res, columns, oSettings.iDraw); + + //重绘表格 + fnCallback(res, textStatus, jqXHR); + }, + "error": function() { + if (tableOptions.onError) { + tableOptions.onError.call(the); + } + ZteFrameWork.alert({type: 'danger', icon: 'warning', message: tableOptions.dataTable.oLanguage.sAjaxRequestGeneralError, container: tableWrapper, place: 'prepend'}); + $('.dataTables_processing', tableWrapper).remove(); + } + } ); + } + + }, + + // pass additional parameter + "fnServerParams": function ( aoData ) { + //here can be added an external ajax request parameters. + //for(var i in ajaxParams) { + for(var i=0; i table.dataTable', tableWrapper); + var tbodyHead = $('tbody', $tableHead); + if(tbodyHead && tbodyHead.length >0){ + $(tbodyHead).remove(); + } + + var $tableBody = $('table#datatable_ajax' + contextData.curentDatableId, tableWrapper); + var trIn = $('thead > tr:nth-child(1)', $tableHead); + var trBodyHead = $('thead > tr:nth-child(1)', $tableBody); + var tds = $(trIn).children(); + var ths = $(trBodyHead).children(); + for(var k=0;k' + tds.eq(k).html() + ''); + } + var bodyRows = $('tbody > tr', $tableBody); + for(var i=0;i' + tds.eq(j).html() + ''); + $(tds.eq(j)).height('0px'); + $(tds.eq(j)).css('padding-top','0px'); + $(tds.eq(j)).css('padding-bottom','0px'); + $(tds.eq(j)).css('border-top-width','0px'); + $(tds.eq(j)).css('border-bottom-width','0px'); + } + $(rowClone).height('0px'); + $tableHead.append($(rowClone).prop("outerHTML")); + } + + $('div.dataTables_scrollBody', tableWrapper).css('width','100%'); + $('div.dataTables_scrollHead', tableWrapper).css('width','98.5%'); + $('div.dataTables_scrollHeadInner', tableWrapper).css('padding-right', 0); + + //添加浮动确认反确认按钮 + if(rowOverFlag){ + addRowOverlap(); + } + + //设置表格本体高度 + $('div.dataTables_scrollBody', tableWrapper).css('height', tableHeight); + } + } + }, options); + + tableOptions = options; + + columns = columnsDefined; + xsHiddenColumns = xsHiddenColumnsDefined; + smHiddenColumns = smHiddenColumnsDefined; + // create table's jquery object + table = $(options.src); + tableContainer = table.parents("div#table-container" + contextData.curentDatableId); + // apply the special class that used to restyle the default datatable + + $.fn.dataTableExt.oStdClasses.sWrapper = $.fn.dataTableExt.oStdClasses.sWrapper + " dataTables_extended_wrapper"; + + // initialize a datatable + dataTable = table.dataTable(options.dataTable); + + tableWrapper = table.parents('div.dataTables_wrapper', tableContainer); + + // modify table per page dropdown input by appliying some classes + $('.dataTables_length select', tableWrapper).addClass("form-control input-xsmall input-sm"); + + // handle group checkboxes check/uncheck + $('.group-checkable', tableContainer).change(function () { + var set = $('tbody > tr > td:nth-child(1) input[type="checkbox"]', table); + var checked = $(this).is(":checked"); + $(set).each(function () { + $(this).attr("checked", checked); + }); + $.uniform.update(set); + countSelectedRecords(); + }); + + // handle row's checkbox click + table.on('change', 'tbody > tr > td:nth-child(1) input[type="checkbox"]', function(){ + countSelectedRecords(); + }); + + //if ($.browser.safari) { + // $('.table-container').css('width','100%'); + //} + //填充表头右边界 + $('div.dataTables_scrollHead', tableContainer).css('display','inline-block'); + //var dataTables_scrollHead_height = $('.dataTables_scrollHead').css( "height" ); + $("div.dataTables_scrollHead", tableContainer).after("
"); + if($.browser.mozilla){ + $('div#divRightPadding', tableContainer).css('height', '40'); + } + + //隐藏掉某些列 + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable', tableWrapper); + var $tableBody = $('table#datatable_ajax' + contextData.curentDatableId, tableWrapper); + + for(var i=0;i tr > th#' + columns[j].columnId, $tableHead).addClass('hidden-xs'); + $('thead > tr > th#' + columns[j].columnId, $tableBody).addClass('hidden-xs'); + break; + } + } + } + + for(var i=0;i tr > th#' + columns[j].columnId, $tableHead).addClass('hidden-sm'); + $('thead > tr > th#' + columns[j].columnId, $tableBody).addClass('hidden-sm'); + break; + } + } + } + },//end init------------------------------------------------------------------------------------ + + getSelectedRowsCount: function() { + return $('tbody > tr > td:nth-child(1) input[type="checkbox"]:checked', table).size(); + }, + + getSelectedRows: function() { + var rows = []; + $('tbody > tr > td:nth-child(1) input[type="checkbox"]:checked', table).each(function(){ + rows.push({rowDataNo: $(this).attr("rowDataNo"), name: $(this).attr("name"), value: $(this).val()}); + }); + + return rows; + }, + + addAjaxParam: function(name, value) { + ajaxParams.push({"name": name, "value": value}); + }, + + clearAjaxParams: function(name, value) { + ajaxParams = []; + }, + + getDataTable: function() { + return dataTable; + }, + + getTableWrapper: function() { + return tableWrapper; + }, + + gettableContainer: function() { + return tableContainer; + }, + + getTable: function() { + return table; + }, + + setOpenRowFlag: function(openRowFlagInput) { + openRowFlag = openRowFlagInput; + }, + + setRowOverFlag: function(rowOverFlagInput) { + rowOverFlag = rowOverFlagInput; + }, + + setRowCheckable: function(rowCheckableInput) { + rowCheckable = rowCheckableInput; + }, + + setColumnsTooLong: function(columnsTooLongInput) { + columnsTooLong = columnsTooLongInput; + }, + + setSTotalRecordsSource: function(sTotalRecordsSourceInput){ + sTotalRecordsSource = sTotalRecordsSourceInput; + }, + + setTotalRecords: function(totalRecordsInput){ + totalRecords = totalRecordsInput; + }, + + setTableHeight: function(tableHeightInput){ + tableHeight = tableHeightInput; + }, + + setCallbackList: function(list){ + if($.isArray(list)){ + callbackList = list; + } + }, + + getCheckedRowDatas:function(){ + checkedRowDatas = []; + $('tbody > tr > td:nth-child(1) input[type="checkbox"]:checked', table).each(function(){ + var rowNoId = $(this).attr("rowDataNo"); + var rowNoIndex = rowNoId.slice(rowNoId.indexOf("_") + 1); + checkedRowDatas.push(currentPageData[parseInt(rowNoIndex)]); + }); + return checkedRowDatas; + }, + + setRequestType: function(requestTypeInput){ + requestType = requestTypeInput; + }, + + setContextData: function(newContextData){ + contextData = newContextData; + }, + + setTotalPage: function(newTotalPage){ + $("#datatable_ajax" + contextData.curentDatableId + "_info").html(tableOptions.dataTable.oLanguage.sInfo.replace("_TOTAL_", newTotalPage + "")); + } + + }; + +}; + +var TableAjaxICT = function () { + + var contextData; + + var initPickers = function () { + //init date pickers + $('.date-picker').datepicker({ + //rtl: App.isRTL(), + autoclose: true + }); + } + + //判断a数组是否包含b数组 + function isContained(largeArray, smallArray){ + if(!(largeArray instanceof Array) || !(smallArray instanceof Array)) + return false; + if(largeArray.length < smallArray.length) + return false; + for(var i = 0; i < smallArray.length; i++){ + var flag = false; + for(j=0;j' + alarmId + ''; + sOut += '' + columns[4].columnTitle + '' + perceivedSeverity + ''; + sOut += '' + columns[9].columnTitle + '' + alarmType + ''; + sOut += '' + columns[3].columnTitle + '' + alarmRaisedTime + ''; + + sOut += '' + columns[5].columnTitle + '' + probableCauseDesc + ''; + sOut += '' + columns[15].columnTitle + '' + alarmChangedTime + ''; + sOut += '' + columns[11].columnTitle + '' + ackState + ''; + + sOut += '' + columns[12].columnTitle + '' + ackTime + ''; + sOut += '' + columns[13].columnTitle + '' + ackUserId + ''; + sOut += '' + columns[14].columnTitle + '' + ackSystemId + ''; + sOut += '' + columns[7].columnTitle + '' + neip + ''; + + sOut += '' + columns[2].columnTitle + '' + moc + ''; + sOut += '' + columns[1].columnTitle + '' + resDisplayName + ''; + + sOut += '' + columns[8].columnTitle + '' + componentname + ''; + sOut += '' + columns[16].columnTitle + '' + position1 + ''; + + sOut += '' + columns[10].columnTitle + '' + specificproblem + ''; + + sOut += '' + columns[6].columnTitle + '' + additionalText + ''; + + sOut += '' + $.i18n.prop('aos_fm_SuggestionSetting_view_DefaultSuggestionGroupTitle').replace(';', '').replace(/\"/g,'') + '' + ''; + + sOut += '' + $.i18n.prop('aos_fm_SuggestionSetting_view_SettingSuggestionGroupTitle').replace(';', '').replace(/\"/g,'') + ''; + + sOut += ''; + + /* + var systemType = 0; + var code = 0; + for (var i = 0; i < oTable.datas.length; i++) { + var temp = oTable.datas[i]; + if (temp.alarmId == oTr['alarmId'].value) { + systemType = temp.systemType; + code = temp.probableCauseCode; + } + }*/ + var data = { + "systemType" : systemType, + "code" : code + }; + var sendData = JSON.stringify(data); + $.ajax({ + "dataType" : 'json', + "type" : "GET", + "url" : "/web/rest/web/fm/Maintenance" + "?" + "data=" + sendData, + "contentType" : 'application/json; charset=utf-8', + "data" : null, + "success" : function (json) { + $('tr').find('td#defaulInfo' + id).text(json.defaulInfo); + $('tr').find('td#customInfo' + id).text(json.customInfo); + var modify = $('#customInfoModify' + id); + modify.on('click', function () { + var span = $('#modifyBtnSpan' + id); + var customInfo = $('tr').find('td#customInfo' + id); + var cancel = $('#cancelDiv' + id); + if (span['0'].className === 'fa fa-pencil-square-o') { + var value = customInfo['0'].textContent; + customInfo['0'].textContent = ''; + customInfo['0'].innerHTML = ''; + span['0'].className = 'fa fa-floppy-o'; + cancel['0'].innerHTML = ''; + $('#cancelBtn' + id).on('click', function () { + customInfo['0'].innerHTML = ''; + customInfo['0'].textContent = value; + cancel['0'].innerHTML = ''; + span['0'].className = 'fa fa-pencil-square-o'; + }); + } else { + var inputValue = $('#customInfoInput' + id)['0'].value; + customInfo['0'].innerHTML = ''; + customInfo['0'].textContent = inputValue; + span['0'].className = 'fa fa-pencil-square-o'; + cancel['0'].innerHTML = ''; + var modifyData = { + "systemType" : systemType, + "code" : code, + "defaulInfo" : json.defaulInfo, + "customInfo" : inputValue + }; + $.ajax({ + "dataType" : 'json', + "type" : "PUT", + "url" : "/web/rest/web/fm/Maintenance", + "contentType" : 'application/json; charset=utf-8', + "data" : JSON.stringify(modifyData), + "error" : function () { + alert('Modify Error!'); + } + }); + } + }); + }, + "error" : function () { + alert('Communication Error!'); + } + }); + + return sOut; + } + + var generateColumns = function(columns, openRowFlag, rowCheckable){ + var $tableData = $('table#datatable_ajax' + contextData.curentDatableId); + var theadTR = $('thead > tr', $tableData); + if(rowCheckable){ + theadTR.append(''); + } + if(openRowFlag){ + theadTR.append('  '); + } + for(var i=0;i' + columns[i].columnTitle + ''); + } + } + + var sortHandling = function(oTable, openRowFlag, rowCheckable){ + var indexSkip = -1; + if(openRowFlag&&rowCheckable){ + indexSkip = 1; + }else if(openRowFlag&&!rowCheckable||!openRowFlag&&rowCheckable){ + indexSkip = 0; + } + var $sortOrder = 0; //排序类型 1表示升序,0表示降序 + var tableWrapper = $('div.dataTables_wrapper', contextData.wrapperDivContext); + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable', tableWrapper); + var $tableData = $('table#datatable_ajax' + contextData.curentDatableId); + var clearSort = function(currentTh){ + var ths = $tableHead.find('th').get(); + var tableDataHeadTHs = $tableData.find('th').get(); + $.each( ths, function( index, th ){ + if(index > indexSkip){ + if($(th).text() != currentTh.text()){ + if($(th).is('.sorting_disabled')){ + //do nothing; + }else if($(th).is('.sorting_asc')){ + $(th).removeClass('sorting_asc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_asc').addClass('sorting_disabled'); + }else if($(th).is('.sorting_desc')){ + $(th).removeClass('sorting_desc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_desc').addClass('sorting_disabled'); + } + } + } + }); + } + + $('th', $tableHead).each(function( column ) + { + if(column>indexSkip){ + //处理三种有可能存在的排序字段,比较方法 + var findSortKey; + if( $(this).is('.sort-title') || $(this).is('.sorting_disabled') ) + { + findSortKey = function( $cell ) + { + var cellText = $cell.text(); + if(isNaN(cellText)){ + return $cell.text().toUpperCase(); + }else{ + return parseFloat(cellText); + } + //return $cell.text().toUpperCase(); + } + } + else if( $(this).is('.sort-date') ) + { + findSortKey = function( $cell ) + { + return Date.parse('1' + $cell.text()); + } + } + else if( $(this).is('.sort-price') ) + { + findSortKey = function( $cell ) + { + var key = parseFloat($cell.text().replace(/^[^\d.]*/, '')) + return isNaN(key) ? 0 : key; + } + } + + //排序 + if( findSortKey ) + { + $(this).click(function() + { + $sortOrder = $sortOrder == 0 ? 1 : 0; + var tableDataHeadTHs = $tableData.find('th').get(); + + if($sortOrder == 1){ + if($(this).is('.sorting_disabled')){ + $(this).removeClass('sorting_disabled').addClass('sorting_asc'); + $(tableDataHeadTHs[column]).removeClass('sorting_disabled').addClass('sorting_asc'); + }else if($(this).is('.sorting_asc')){ + $(this).removeClass('sorting_asc').addClass('sorting_desc'); + $(tableDataHeadTHs[column]).removeClass('sorting_asc').addClass('sorting_desc'); + }else if($(this).is('.sorting_desc')){ + $(this).removeClass('sorting_desc').addClass('sorting_asc'); + $(tableDataHeadTHs[column]).removeClass('sorting_desc').addClass('sorting_asc'); + } + }else{ + if($(this).is('.sorting_disabled')){ + $(this).removeClass('sorting_disabled').addClass('sorting_desc'); + $(tableDataHeadTHs[column]).removeClass('sorting_disabled').addClass('sorting_desc'); + }else if($(this).is('.sorting_asc')){ + $(this).removeClass('sorting_asc').addClass('sorting_desc'); + $(tableDataHeadTHs[column]).removeClass('sorting_asc').addClass('sorting_desc'); + }else if($(this).is('.sorting_desc')){ + $(this).removeClass('sorting_desc').addClass('sorting_asc'); + $(tableDataHeadTHs[column]).removeClass('sorting_desc').addClass('sorting_asc'); + } + } + clearSort($(this)); + + var rows = $tableData.find('tbody > tr').get(); + + $.each( rows, function( index, row ) + { + //先关掉所有行 + if ( oTable.fnIsOpen(row) ) + { + $(row).find('.row-details').click(); + } + }); + + //重新取得所有行,否则排序后表格显示异常 + rows = $tableData.find('tbody > tr').get(); + + $.each( rows, function( index, row ) + { + row.sortKey = findSortKey($(row).children('td').eq(column)); + }); + //排序方法 + rows.sort(function( a, b ) + { + if( $sortOrder == 1 ) + { + //升序 + if(a.sortKey < b.sortKey) return -1; + if(a.sortKey > b.sortKey) return 1; + return 0; + } + else + { + //降序 + if(a.sortKey < b.sortKey) return 1; + if(a.sortKey > b.sortKey) return -1; + return 0; + } + }); + //排序后的对象添加给$table + $.each( rows, function( index, row ) + { + $tableData.children('tbody').append(row); + row.sortKey = null; + }); + }); + } + } + }); + } + + var handleRecords = function(requestDatas, columns, xsHiddenColumns, smHiddenColumns, oLanguage, openRowFlag, rowCheckable, rowOverFlag, requestURL, requestParameters, tableHeight, columnsTooLong, sTotalRecordsSource, callbackList, totalRecords, requestType) { + + /* + jQuery.getJSON('/web/newict/framework/thirdparty/data-tables/app-universal-i18n-datatable-' + lang + '.json', + function(data) { + oLanguage = data; + }); + */ + grid = DatatableICT(); + grid.setCallbackList(callbackList); + grid.setContextData(contextData); + grid.setOpenRowFlag(openRowFlag); + grid.setRowCheckable(rowCheckable); + grid.setRowOverFlag(rowOverFlag); + grid.setColumnsTooLong(columnsTooLong); + grid.setSTotalRecordsSource(sTotalRecordsSource); + grid.setTotalRecords(totalRecords); + grid.setTableHeight(tableHeight); + grid.setRequestType(requestType); + //取得查询条件 +// if(!requestStr || requestStr.length == 0){ +// requestStr = JSON.stringify(requestAllData); +// } + grid.clearAjaxParams(); + if(requestType == "GET"){ + grid.addAjaxParam('data', JSON.stringify(requestDatas)); + }else{ + grid.addAjaxParam('data', requestDatas); + } + //取得其他参数 + for(var i=0;i table.dataTable', tableWrapper); + var ths = $tableHead.find('th').get(); + var $tableData = $('table#datatable_ajax' + contextData.curentDatableId); + var tableDataHeadTHs = $tableData.find('th').get(); + $.each( ths, function( index, th ){ + //clear all sort direction + if($(th).is('.sorting_disabled')){ + //do nothing; + }else if($(th).is('.sorting_asc')){ + $(th).removeClass('sorting_asc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_asc').addClass('sorting_disabled'); + }else if($(th).is('.sorting_desc')){ + $(th).removeClass('sorting_desc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_desc').addClass('sorting_disabled'); + } + }); + + }, + onError: function(grid) { + // execute some code on network or other general error + }, + dataTable: { + "sDom" : "tr<'row'<'col-md-6 col-sm-12'><'col-md-6 col-sm-12'pli>>", // datatable layout + "oLanguage": oLanguage, + //"bAutoWidth": true, + "sScrollY": tableHeight, + "bScrollCollapse": true, + "sScrollX": "100%", + //"sScrollXInner": "110%", + "aLengthMenu": [ + [20, 50, 100], + [20, 50, 100] // change per page values here + ], + "iDisplayLength": 100, // default record count per page + "bServerSide": true, // server side processing + "sAjaxSource": requestURL // ajax source + } + }, columns, xsHiddenColumns, smHiddenColumns, openRowFlag, rowCheckable); + } + + /* + * Insert a 'details' column to the table + */ + var insertDetails = function (oTable, columns, rowCheckable) { + + var $tableData = $('table#datatable_ajax' + contextData.curentDatableId); + + $tableData.on('click', ' tbody td .row-details', function () { + var nTr = $(this).parents('tr')[0]; + if (oTable.fnIsOpen(nTr)) { + /* This row is already open - close it */ + $(this).addClass("row-details-close").removeClass("row-details-open"); + oTable.fnClose(nTr); + } else { + /* Open this row */ + $(this).addClass("row-details-open").removeClass("row-details-close"); + oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr, columns, rowCheckable), 'details'); + } + }); + } + + return { + + //main function to initiate the module + init: function (requestDatas, lang, configPathPrefix, callbackList, newColumns, totalPage) { + + var oLanguage; + var columns; + var xsHiddenColumns; + var smHiddenColumns; + var columnsAll; + + var openRowFlag = false; + var rowOverFlag = false; + var rowCheckable = false; + var requestURL=""; + var requestAllData; + var requestParameters; + + var tableHeight; + var tableWidth; + + var columnsTooLong; + var sTotalRecordsSource=""; + var totalRecords = 0; + + var requestType = "GET"; + + //取得当前配置及国际化信息 + $.ajax({ + dataType: 'json', + url: configPathPrefix + '-' + lang + '.json', + async: false, + contentType:'application/json; charset=utf-8', + "success": function(data) { + oLanguage = data.language; + columns = data.columns; + if(newColumns){ + columns = newColumns; + } + xsHiddenColumns = data.xsHiddenColumns; + smHiddenColumns = data.smHiddenColumns; + columnsAll = data.columnsAll; + if(newColumns){ + columnsAll = newColumns; + } + openRowFlag = data.openRowFlag == 'true'? true: false; + rowOverFlag = data.rowOverFlag == 'true'? true: false; + rowCheckable = data.rowCheckable == 'true'? true: false; + requestURL = data.requestURL; + //requestAllData = data.requestAllData; + requestParameters = data.requestParameters; + tableHeight = data.tableHeight; + tableWidth = data.tableWidth; + columnsTooLong = data.columnsTooLong; + sTotalRecordsSource = data.sTotalRecordsSource; + if(data.sTotalRecords){ //性能的情况直接指定总行数 + totalRecords = parseInt(data.sTotalRecords); + } + if(totalPage){ //可以从参数指定总行数,适用于单独发请求获得总行数的场景 + totalRecords = totalPage; + } + if(data.requestType){ + requestType = data.requestType; + } + }, + "error" : function (xhr, info) { + alert('Communication Error! Error reason:' + info); + } + }); + + $('div#dataTableWrapperDiv' + contextData.curentDatableId).css('width', tableWidth); + + if(!isContained(xsHiddenColumns, smHiddenColumns) || !isContained(columns, xsHiddenColumns) || !isContained(columnsAll, columns)){ + alert('Columns claim error: (smHiddenColumns <= xsHiddenColumns <= columns <= columnsAll) Please!'); + return; + } + + generateColumns(columns, openRowFlag, rowCheckable); + //initPickers(); + handleRecords(requestDatas, columns, xsHiddenColumns, smHiddenColumns, oLanguage, openRowFlag, rowCheckable, rowOverFlag, requestURL, requestParameters, tableHeight, columnsTooLong, sTotalRecordsSource, callbackList, totalRecords, requestType); + //获得初始化完毕的DataTable对象 + var oTable = grid.getDataTable(); + if(openRowFlag){ + insertDetails(oTable, columnsAll, rowCheckable); + } + sortHandling(oTable, openRowFlag, rowCheckable); + //oTable.fnAdjustColumnSizing(true); + return oTable; + }, + + getDataGrid: function(){ + return grid; + }, + + setContextData: function(newContextData){ + contextData = newContextData; + } + + }; + +}(); + +var addTableElementsId = function(){ + + var outterDivs = $('div.dataTableWrapperDiv'); + var currentId; + + if(outterDivs && outterDivs.length > 0) { + var maxId = -1; + var divIdNo; + $.each(outterDivs, function (index, div) { + var divId = $(div).attr("id"); + divIdNo = divId.substring(20); + if (divIdNo || divIdNo.length > 0){ + if (parseInt(divIdNo) > maxId) { + maxId = parseInt(divIdNo); + } + } + }); + currentId = maxId + 1; + } + + var curentDatableId = "_" + currentId; + + var dataTableWrapperDiv = $('div#dataTableWrapperDiv');//新添加的outterDiv + $(dataTableWrapperDiv).attr("id", "dataTableWrapperDiv" + curentDatableId); + var dataTableWrapperDivContext = dataTableWrapperDiv; + $('div.table-container', dataTableWrapperDiv).attr("id", "table-container" + curentDatableId); + $('table#datatable_ajax', dataTableWrapperDiv).attr("id", "datatable_ajax" + curentDatableId); + $('div#divOverlay', dataTableWrapperDiv).attr("id", "divOverlay" + curentDatableId); + //$('div#buttonConfirm', dataTableWrapperDiv).attr("id", "buttonConfirm" + curentDatableId); + //$('div#buttonUnConfirm', dataTableWrapperDiv).attr("id", "buttonUnConfirm" + curentDatableId); + $('div#myModal', dataTableWrapperDiv).attr("id", "myModal" + curentDatableId); + $('div#myModalConfirm', dataTableWrapperDiv).attr("id", "myModalConfirm" + curentDatableId); + $('span#alarm_number', dataTableWrapperDiv).attr("id", "alarm_number" + curentDatableId); + + return { + "curentDatableId": curentDatableId, + "wrapperDivContext":dataTableWrapperDivContext + } +} + +var DataTableICT = function(requestDatas, tableDivId, tableDivPath, configPathPrefix, callbackList, newColumns, totalPage){ + + /* var requestStr = ""; + if(datas){ + requestStr = JSON.stringify(datas); + } */ + + var lang = getLanguage(); + //lang = 'en-US'; + + /**取得表格组件所需html片段 **/ + /*jQuery('div#' + tableDivId).load(tableDivPath, function() { + var contextData = addTableElementsId(); + TableAjaxICT.setContextData(contextData); + + var lang = getLanguage(); + //lang = 'en-US'; + var oTable = TableAjaxICT.init(requestStr, lang, configPathPrefix); + + //重新调节列宽以适应window resize + $(window).bind('resize', function () { + //oTable.DataTable.models.oSettings.bAjaxDataGet = false; + oTable.fnAdjustColumnSizing(); + } ); + });*/ + + /**同步取得表格组件所需html片段 **/ + $.ajax({ + async : false, + "dataType" : "html", + "type" : "GET", + "url" : tableDivPath, + "data" : null, + "success" : function (html, textStatus, jqXHR) { + $('div#' + tableDivId).html(html); + }, + "error" : function () { + alert("Communication error!"); + } + }); + + var contextData = addTableElementsId(); + TableAjaxICT.setContextData(contextData); + + var oTable = TableAjaxICT.init(requestDatas, lang, configPathPrefix, callbackList, newColumns, totalPage); + + //重新调节列宽以适应window resize + $(window).bind('resize', function () { + //oTable.DataTable.models.oSettings.bAjaxDataGet = false; + oTable.fnAdjustColumnSizing(); + } ); + + return TableAjaxICT.getDataGrid(); +} diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableSmartClient.js b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableSmartClient.js new file mode 100644 index 00000000..5f28350f --- /dev/null +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableSmartClient.js @@ -0,0 +1,1215 @@ +/*** + Wrapper/Helper Class for datagrid based on jQuery Datatable Plugin + ***/ +var DatatableICT = function () { + + var tableOptions; // main options + var dataTable; // datatable object + var table; // actual table jquery object + var tableContainer; // actual table container object + var tableWrapper; // actual table wrapper jquery object + var tableInitialized = false; + var ajaxParams = []; // set filter mode + var columns; + var xsHiddenColumns; + var smHiddenColumns; + var columnMaxLength = 30; + var columnsTooLong; + var hidden_xs_maxWidth = 768; + var hidden_sm_maxWidth = 991; + + var openRowFlag = false; + var rowOverFlag = false; + var rowCheckable = false; + + var aTargetsAll; + var sTotalRecordsSource; + var tableHeight; + + var includedInXsHiddenColumns = function(columnId){ + for(var i=0;i tr > td:nth-child(1) input[type="checkbox"]:checked', table).size(); + var text = tableOptions.dataTable.oLanguage.sGroupActions; + if (selected > 0) { + $('.table-group-actions > span', tableWrapper).text(text.replace("_TOTAL_", selected)); + } else { + $('.table-group-actions > span', tableWrapper).text(""); + } + } + + var jsonObjectToArray = function(json, columns, iDraw){ + var jsonToDatatable = {aaData:[], sEcho:iDraw, iTotalRecords:0, iTotalDisplayRecords:0 }; + for(var i=0; i"); + } + if(openRowFlag){ + jsonToDatatable.aaData[i].push(""); + } + for(var j=0; j= hidden_xs_maxWidth && $(window).width() < hidden_sm_maxWidth && includedInSmHiddenColumns(columns[j].columnId )){ + /*隐藏pad尺寸需要隐藏的列*/ + }else if($(window).width() < hidden_xs_maxWidth && includedInXsHiddenColumns(columns[j].columnId )){ + /*隐藏手机尺寸需要隐藏的列*/ + }else{ + var currentColumnId = columns[j].columnId; + if(jQuery.inArray(currentColumnId, columnsTooLong) > -1){ + var rawText = ""; + for(var k=0;k columnMaxLength){ + jsonToDatatable.aaData[i].push(rawText.slice(0, columnMaxLength) + '...'); + }else{ + jsonToDatatable.aaData[i].push(resRowObject[currentColumnId]); + } + } else { + jsonToDatatable.aaData[i].push(resRowObject[currentColumnId]); + } + + } + } + } + jsonToDatatable.sEcho++; + var totalRow = 0; + var totalRecordsSource = eval('json.' + sTotalRecordsSource); + if(totalRecordsSource && totalRecordsSource.length >0){ + totalRow = parseInt(totalRecordsSource); + } + if(isNaN(totalRow)){ + alert('All rows counting number got fail!'); + }else{ + jsonToDatatable.iTotalRecords = totalRow; + jsonToDatatable.iTotalDisplayRecords = totalRow; + } + return jsonToDatatable; + } + + var singleAlarmDel = function(divOverlay){ + + //根据浮动框的当前id获取需要删除的行 + var trId = divOverlay.attr('id_tr'); + tr=$('tr#' + trId); + var tds = $(tr).children(); + var tdAlarmId = $(tds.eq(2)).text(); + + var data= { + "alarmId":[parseInt(tdAlarmId)] + }; + + var sSource = "/web/rest/web/fm/curalarms?data=" + JSON.stringify(data) + "&_operationType=remove&_dataSource=isc_PageRestDataSource_0&isc_metaDataPrefix=_&isc_dataFormat=json"; + + $.ajax( { + "dataType": 'json', + "type": "DELETE", + "url": sSource, + "data" : null, + "contentType" : 'application/json; charset=utf-8', + "success": function(json) { + if(json.response.status == 0){ + var resRowObject = json.response.data[0]; + //alert('删除成功'); + } + if(json.response.status == -1){ + //alert('删除失败'); + } + }, + "error": function() { + alert('Communication Error!'); + } + } ); + } + + var singleAlarmAckUnAck = function(divOverlay, ackType){ + + //根据浮动框的当前id获取需要确认的行 + var trId = divOverlay.attr('id_tr'); + var tr = $('tr#' + trId); + + //取得隐藏的头部表格的相应行 + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable'); + //var trHead = $('tbody > tr:nth-child(' + trId + ')', $tableHead); + var trHead = $('tr#' + trId.replace('body', 'head'), $tableHead); + var tdDivs = $('td > div', trHead); + + var tds = $(tr).children(); + var tdAlarmId = ""; + if(rowCheckable){ + tdAlarmId = $(tds.eq(2)).text(); + }else{ + tdAlarmId = $(tds.eq(1)).text(); + } + + var aoData = + { + "dataSource":"isc_PageRestDataSource_0", + "operationType":"update", + "componentId":"isc_com_zte_ums_aos_fm_view_eventview_table_AlarmTable_0", + "data":{ + "viewType":1, + "state":ackType, + "alarmId":[ + parseInt(tdAlarmId) + ] + }, + "oldValues":null + }; + + var sSource = "/web/rest/web/fm/curalarms?isc_dataFormat=json"; + + $.ajax( { + "dataType": 'json', + "type": "PUT", + "url": sSource, + "contentType": 'application/json; charset=utf-8', + "data": JSON.stringify(aoData), + "success": function(json) { + json = AlarmLabels.transformFieldNames(json); + if(json.response.status == 0){ + var resRowObject = json.response.data[0]; + var columnsCopy = $.extend(true, [], columns); + //隐藏列的情况下需要特殊处理 + if($(window).width()>=hidden_xs_maxWidth && $(window).width() -1) { + var rawText = ""; + for(var k=0;k columnMaxLength){ + $(tds.eq(i)).html(rawText.slice(0, columnMaxLength) + '...'); + $(tdDivs.eq(i)).html(rawText.slice(0, columnMaxLength) + '...'); + }else{ + $(tds.eq(i)).html(resRowObject[currentColumnId]); + $(tdDivs.eq(i)).html(resRowObject[currentColumnId]); + } + } else { + $(tds.eq(i)).html(resRowObject[currentColumnId]); + $(tdDivs.eq(i)).html(resRowObject[currentColumnId]); + } + } + //更新缓存中的当前行数据 + for (var t = 0; t < dataTable.datas.length; t++) { + var temp = dataTable.datas[t]; + if (temp.alarmId == resRowObject['alarmId']) { + dataTable.datas[t] = resRowObject; + break; + } + } + } + if(json.response.status == -1){ + $('div#myModalConfirm').modal({ + keyboard: false, + backdrop: 'static' + }); + $('span#alarm_number').html(tdAlarmId); + //国际化信息 + if(ackType==1){ + $('span#aos_fm_alarm_opeater_ack_already').html($.i18n.prop('aos_fm_alarm_opeater_ack_already_ok')); + }else{ + $('span#aos_fm_alarm_opeater_ack_already').html($.i18n.prop('aos_fm_alarm_opeater_ack_already_un')); + } + } + }, + "error": function() { + alert('Communication Error!'); + } + } ); + } + + var addRowOverlap = function(){ + var $tableData = $('table#datatable_ajax'); + //取得隐藏的头部表格的相应行 + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable'); + var trHeads = $tableHead.find('tr').get(); + $.each( trHeads, function( index, trHead ){ + $(trHead).attr('id', 'headTableTR' + index); + }); + //取得浮动div + var $divOverlay = $('div#divOverlay'); + var divScrollHead = $('div.dataTables_scrollHead'); + var divRightPadding = $('div#divRightPadding'); + //取表头下边沿位置 + var tableHeadBottomHeight = $(divScrollHead).position().top + $(divScrollHead).height(); + var tableBottom = $tableData.position().top + $tableData.height(); + //取表格右边沿位置 + var tableRightEdgePosition = $(divRightPadding).position().left; + var trs = $tableData.find('tr').get(); + $.each( trs, function( index, tr ){ + var tdEmpty = $('td.dataTables_empty',tr); + if(!tdEmpty || tdEmpty.length ==0 ){ + $(tr).attr('id', 'bodyTableTR' + index); + //$divOverlay.attr('id_tr', 'bodyTableTR' + index); + $(tr).one('hover', function(){ + var rowPos = $(tr).position(); + var currentTrTop = rowPos.top; + //var bottomLeft = rowPos.left; + $divOverlay.attr('id_tr', 'bodyTableTR' + index); + $divOverlay.css({ + display: 'block', + position: 'absolute', + 'background-color': '#e5e5e5', + //opacity: 0.7, + border: 'solid 0px', + top: currentTrTop + 6, + left: tableRightEdgePosition - 308, + width: 300, + height: 30 + }); + //防止浮动框跳出表格内容区域 + if( $divOverlay.position().top < tableHeadBottomHeight || $divOverlay.position().top + $divOverlay.height() > tableBottom){ + $divOverlay.css('display', 'none'); + } + var buttonConfirm = $('div#buttonConfirm', $divOverlay); + var buttonUnConfirm = $('div#buttonUnConfirm', $divOverlay); + $(buttonConfirm).one('click', function(){ + var buttonRoundedTDsConfirm = $(buttonConfirm).find('td.buttonRounded'); + var buttonRoundedTDsUnConfirm = $(buttonUnConfirm).find('td.buttonRoundedDisabled'); + if(buttonRoundedTDsConfirm && buttonRoundedTDsConfirm.length > 0){ + $.each(buttonRoundedTDsConfirm, function(index, td){ + $(td).removeClass('buttonRounded').addClass('buttonRoundedDisabled'); + }); + $.each(buttonRoundedTDsUnConfirm, function(index, td){ + $(td).removeClass('buttonRoundedDisabled').addClass('buttonRounded'); + }); + $divOverlay.css('display', 'none'); + singleAlarmAckUnAck($divOverlay, 1); + } + }); + $(buttonUnConfirm).one('click', function(){ + var buttonRoundedTDsUnConfirm = $(buttonUnConfirm).find('td.buttonRounded'); + var buttonRoundedTDsConfirm = $(buttonConfirm).find('td.buttonRoundedDisabled'); + if(buttonRoundedTDsUnConfirm && buttonRoundedTDsUnConfirm.length > 0){ + $.each(buttonRoundedTDsUnConfirm, function(index, td){ + $(td).removeClass('buttonRounded').addClass('buttonRoundedDisabled'); + }); + $.each(buttonRoundedTDsConfirm, function(index, td){ + $(td).removeClass('buttonRoundedDisabled').addClass('buttonRounded'); + }); + $divOverlay.css('display', 'none'); + singleAlarmAckUnAck($divOverlay, 2); + } + }); + var buttonDelete = $('div#buttonDelete', $divOverlay); + $(buttonDelete).die().live('click', function(){ + //弹出删除确认对话框 + $('div#myModal').modal({ + keyboard: false, + backdrop: 'static' + }); + $('#delConfirm').die().live('click', function(){ + $divOverlay.css('display', 'none'); + dataTable.fnClose(tr); + $(tr).remove(); + //删除表头表格的相应行 + $('tr#' + $(tr).attr('id').replace('body', 'head'), $tableHead).remove(); + //删除后端数据 + singleAlarmDel($divOverlay); + //刷新表格 + dataTable.fnAdjustColumnSizing(); + }); + }); + //展开行的情况隐藏 + $('td.details > table.detailTable').on('hover', function(){ + $divOverlay.css('display', 'none'); + }); + }); + } + }); + } + + return { + + //main function to initiate the module + init: function (options, columnsDefined, xsHiddenColumnsDefined, smHiddenColumnsDefined) { + + if (!$().dataTable) { + return; + } + + var the = this; + + //记录需要禁掉默认排序的列 + var aTargets = []; + var targetsLength = columnsDefined.length; + if(rowCheckable)targetsLength++; + if(openRowFlag)targetsLength++; + for(var i=0;i<'col-md-4 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>", // datatable layout + + "aoColumnDefs" : [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column) + 'bSortable' : false, + 'aTargets' : aTargets + }], + + "bAutoWidth": false, // disable fixed width and enable fluid table + //"bSortCellsTop": true, // make sortable only the first row in thead + "sPaginationType": "bootstrap_extended", // pagination type(bootstrap, bootstrap_full_number or bootstrap_extended) + "bProcessing": true, // enable/disable display message box on record load + "bServerSide": true, // enable/disable server side ajax loading + "sAjaxSource": "", // define ajax source URL + //"sServerMethod": "GET", + + // handle ajax request + "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { + //for ICT Paging + //var startIndex = aoData[3].value;//"iDisplayStart" + //var pageLength = aoData[4].value;//"iDisplayLength" + var oPaging = oSettings.oInstance.fnPagingInfo(); + //var startIndex = oPaging.iStart; + var pageLength = oPaging.iLength; + var curPageNo = oPaging.iPage + 1; + + for(var k=aoData.length-1;k>=0;k--){ + var flag = -1; + if(aoData[k].name=='pageSize'){ + aoData[k].value=pageLength; + flag++; + } + if(aoData[k].name=='pageNo'){ + aoData[k].value=curPageNo; + flag++ + } + if(flag == 1)break; + } + + oSettings.jqXHR = $.ajax( { + "dataType": 'json', + "type": "GET", + "url": sSource, + "data": aoData, + "success": function(res, textStatus, jqXHR) { + if (res.sMessage) { + ZteFrameWork.alert({type: (res.sStatus == 'OK' ? 'success' : 'danger'), icon: (res.sStatus == 'OK' ? 'check' : 'warning'), message: res.sMessage, container: tableWrapper, place: 'prepend'}); + } + if ($('.group-checkable', tableContainer).size() === 1) { + $('.group-checkable', tableContainer).attr("checked", false); + $.uniform.update($('.group-checkable', tableContainer)); + } + if (tableOptions.onSuccess) { + tableOptions.onSuccess.call(the); + } + //保存数据在dataTable对象中给行详细信息面板用 + dataTable.datas = res.response.data; + if(res.response.status < 0){ + alert(res.response.data); + return; + } + + //告警字段值转换 + res = AlarmLabels.transformFieldNames(res); + + res = jsonObjectToArray(res, columns, oSettings.iDraw); + + //重绘表格 + fnCallback(res, textStatus, jqXHR); + }, + "error": function() { + if (tableOptions.onError) { + tableOptions.onError.call(the); + } + ZteFrameWork.alert({type: 'danger', icon: 'warning', message: tableOptions.dataTable.oLanguage.sAjaxRequestGeneralError, container: tableWrapper, place: 'prepend'}); + $('.dataTables_processing', tableWrapper).remove(); + } + } ); + + }, + + // pass additional parameter + "fnServerParams": function ( aoData ) { + //here can be added an external ajax request parameters. + //for(var i in ajaxParams) { + for(var i=0; i table.dataTable', tableWrapper); + var tbodyHead = $('tbody', $tableHead); + if(tbodyHead && tbodyHead.length >0){ + $(tbodyHead).remove(); + } + + var $tableBody = $('table#datatable_ajax', tableWrapper); + var trIn = $('thead > tr:nth-child(1)', $tableHead); + var trBodyHead = $('thead > tr:nth-child(1)', $tableBody); + var tds = $(trIn).children(); + var ths = $(trBodyHead).children(); + for(var k=0;k' + tds.eq(k).html() + ''); + } + var bodyRows = $('tbody > tr', $tableBody); + for(var i=0;i' + tds.eq(j).html() + ''); + $(tds.eq(j)).height('0px'); + $(tds.eq(j)).css('padding-top','0px'); + $(tds.eq(j)).css('padding-bottom','0px'); + $(tds.eq(j)).css('border-top-width','0px'); + $(tds.eq(j)).css('border-bottom-width','0px'); + } + $(rowClone).height('0px'); + $tableHead.append($(rowClone).prop("outerHTML")); + } + + $('.dataTables_scrollBody').css('width','100%'); + $('.dataTables_scrollHead').css('width','98.5%'); + $('.dataTables_scrollHeadInner').css('padding-right', 0); + + //添加浮动确认反确认按钮 + if(rowOverFlag){ + addRowOverlap(); + } + + //设置表格本体高度 + $('div.dataTables_scrollBody').css('height', tableHeight); + } + } + }, options); + + tableOptions = options; + + columns = columnsDefined; + xsHiddenColumns = xsHiddenColumnsDefined; + smHiddenColumns = smHiddenColumnsDefined; + // create table's jquery object + table = $(options.src); + tableContainer = table.parents(".table-container"); + // apply the special class that used to restyle the default datatable + + $.fn.dataTableExt.oStdClasses.sWrapper = $.fn.dataTableExt.oStdClasses.sWrapper + " dataTables_extended_wrapper"; + + // initialize a datatable + dataTable = table.dataTable(options.dataTable); + + tableWrapper = table.parents('.dataTables_wrapper'); + + // modify table per page dropdown input by appliying some classes + $('.dataTables_length select', tableWrapper).addClass("form-control input-xsmall input-sm"); + + // handle group checkboxes check/uncheck + $('.group-checkable', tableContainer).change(function () { + var set = $('tbody > tr > td:nth-child(1) input[type="checkbox"]', table); + var checked = $(this).is(":checked"); + $(set).each(function () { + $(this).attr("checked", checked); + }); + $.uniform.update(set); + countSelectedRecords(); + }); + + // handle row's checkbox click + table.on('change', 'tbody > tr > td:nth-child(1) input[type="checkbox"]', function(){ + countSelectedRecords(); + }); + + //填充表头右边界 + $('.dataTables_scrollHead').css('display','inline-block'); + //var dataTables_scrollHead_height = $('.dataTables_scrollHead').css( "height" ); + $(".dataTables_scrollHead").after("
"); + if($.browser.mozilla){ + $('#divRightPadding').css('height', '40'); + } + + //隐藏掉某些列 + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable', tableWrapper); + var $tableBody = $('table#datatable_ajax', tableWrapper); + + for(var i=0;i tr > th#' + columns[j].columnId, $tableHead).addClass('hidden-xs'); + $('thead > tr > th#' + columns[j].columnId, $tableBody).addClass('hidden-xs'); + break; + } + } + } + + for(var i=0;i tr > th#' + columns[j].columnId, $tableHead).addClass('hidden-sm'); + $('thead > tr > th#' + columns[j].columnId, $tableBody).addClass('hidden-sm'); + break; + } + } + } + },//end init------------------------------------------------------------------------------------ + + getSelectedRowsCount: function() { + return $('tbody > tr > td:nth-child(1) input[type="checkbox"]:checked', table).size(); + }, + + getSelectedRows: function() { + var rows = []; + $('tbody > tr > td:nth-child(1) input[type="checkbox"]:checked', table).each(function(){ + rows.push({name: $(this).attr("name"), value: $(this).val()}); + }); + + return rows; + }, + + addAjaxParam: function(name, value) { + ajaxParams.push({"name": name, "value": value}); + }, + + clearAjaxParams: function(name, value) { + ajaxParams = []; + }, + + getDataTable: function() { + return dataTable; + }, + + getTableWrapper: function() { + return tableWrapper; + }, + + gettableContainer: function() { + return tableContainer; + }, + + getTable: function() { + return table; + }, + + setOpenRowFlag: function(openRowFlagInput) { + openRowFlag = openRowFlagInput; + }, + + setRowOverFlag: function(rowOverFlagInput) { + rowOverFlag = rowOverFlagInput; + }, + + setRowCheckable: function(rowCheckableInput) { + rowCheckable = rowCheckableInput; + }, + + setColumnsTooLong: function(columnsTooLongInput) { + columnsTooLong = columnsTooLongInput; + }, + + setSTotalRecordsSource: function(sTotalRecordsSourceInput){ + sTotalRecordsSource = sTotalRecordsSourceInput; + }, + + setTableHeight: function(tableHeightInput){ + tableHeight = tableHeightInput; + } + + }; + +}; + +var TableAjaxICT = function () { + + var initPickers = function () { + //init date pickers + $('.date-picker').datepicker({ + //rtl: App.isRTL(), + autoclose: true + }); + } + + //判断a数组是否包含b数组 + function isContained(largeArray, smallArray){ + if(!(largeArray instanceof Array) || !(smallArray instanceof Array)) + return false; + if(largeArray.length < smallArray.length) + return false; + for(var i = 0; i < smallArray.length; i++){ + var flag = false; + for(j=0;j' + alarmId + ''; + sOut += '' + columns[4].columnTitle + '' + perceivedSeverity + ''; + sOut += '' + columns[9].columnTitle + '' + alarmType + ''; + sOut += '' + columns[3].columnTitle + '' + alarmRaisedTime + ''; + + sOut += '' + columns[5].columnTitle + '' + probableCauseDesc + ''; + sOut += '' + columns[15].columnTitle + '' + alarmChangedTime + ''; + sOut += '' + columns[11].columnTitle + '' + ackState + ''; + + sOut += '' + columns[12].columnTitle + '' + ackTime + ''; + sOut += '' + columns[13].columnTitle + '' + ackUserId + ''; + sOut += '' + columns[14].columnTitle + '' + ackSystemId + ''; + sOut += '' + columns[7].columnTitle + '' + neip + ''; + + sOut += '' + columns[2].columnTitle + '' + moc + ''; + sOut += '' + columns[1].columnTitle + '' + resDisplayName + ''; + + sOut += '' + columns[8].columnTitle + '' + componentname + ''; + sOut += '' + columns[16].columnTitle + '' + position1 + ''; + + sOut += '' + columns[10].columnTitle + '' + specificproblem + ''; + + sOut += '' + columns[6].columnTitle + '' + additionalText + ''; + + sOut += '' + $.i18n.prop('aos_fm_SuggestionSetting_view_DefaultSuggestionGroupTitle').replace(';', '').replace(/\"/g,'') + '' + ''; + + sOut += '' + $.i18n.prop('aos_fm_SuggestionSetting_view_SettingSuggestionGroupTitle').replace(';', '').replace(/\"/g,'') + ''; + + sOut += ''; + + /* + var systemType = 0; + var code = 0; + for (var i = 0; i < oTable.datas.length; i++) { + var temp = oTable.datas[i]; + if (temp.alarmId == oTr['alarmId'].value) { + systemType = temp.systemType; + code = temp.probableCauseCode; + } + }*/ + var data = { + "systemType" : systemType, + "code" : code + }; + var sendData = JSON.stringify(data); + $.ajax({ + "dataType" : 'json', + "type" : "GET", + "url" : "/web/rest/web/fm/Maintenance" + "?" + "data=" + sendData, + "contentType" : 'application/json; charset=utf-8', + "data" : null, + "success" : function (json) { + $('tr').find('td#defaulInfo' + id).text(json.defaulInfo); + $('tr').find('td#customInfo' + id).text(json.customInfo); + var modify = $('#customInfoModify' + id); + modify.on('click', function () { + var span = $('#modifyBtnSpan' + id); + var customInfo = $('tr').find('td#customInfo' + id); + var cancel = $('#cancelDiv' + id); + if (span['0'].className === 'fa fa-pencil-square-o') { + var value = customInfo['0'].textContent; + customInfo['0'].textContent = ''; + customInfo['0'].innerHTML = ''; + span['0'].className = 'fa fa-floppy-o'; + cancel['0'].innerHTML = ''; + $('#cancelBtn' + id).on('click', function () { + customInfo['0'].innerHTML = ''; + customInfo['0'].textContent = value; + cancel['0'].innerHTML = ''; + span['0'].className = 'fa fa-pencil-square-o'; + }); + } else { + var inputValue = $('#customInfoInput' + id)['0'].value; + customInfo['0'].innerHTML = ''; + customInfo['0'].textContent = inputValue; + span['0'].className = 'fa fa-pencil-square-o'; + cancel['0'].innerHTML = ''; + var modifyData = { + "systemType" : systemType, + "code" : code, + "defaulInfo" : json.defaulInfo, + "customInfo" : inputValue + }; + $.ajax({ + "dataType" : 'json', + "type" : "PUT", + "url" : "/web/rest/web/fm/Maintenance", + "contentType" : 'application/json; charset=utf-8', + "data" : JSON.stringify(modifyData), + "error" : function () { + alert('Modify Error!'); + } + }); + } + }); + }, + "error" : function () { + alert('Communication Error!'); + } + }); + + return sOut; + } + + var generateColumns = function(columns, openRowFlag, rowCheckable){ + var $tableData = $('table#datatable_ajax'); + var theadTR = $('thead > tr', $tableData); + if(rowCheckable){ + theadTR.append(''); + } + if(openRowFlag){ + theadTR.append('  '); + } + for(var i=0;i' + columns[i].columnTitle + ''); + } + } + + var sortHandling = function(oTable, openRowFlag, rowCheckable){ + var indexSkip = -1; + if(openRowFlag&&rowCheckable){ + indexSkip = 1; + }else if(openRowFlag&&!rowCheckable||!openRowFlag&&rowCheckable){ + indexSkip = 0; + } + var $sortOrder = 0; //排序类型 1表示升序,0表示降序 + var tableWrapper = $('div#datatable_ajax_wrapper'); + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable', tableWrapper); + var $tableData = $('table#datatable_ajax'); + var clearSort = function(currentTh){ + var ths = $tableHead.find('th').get(); + var tableDataHeadTHs = $tableData.find('th').get(); + $.each( ths, function( index, th ){ + if(index > indexSkip){ + if($(th).text() != currentTh.text()){ + if($(th).is('.sorting_disabled')){ + //do nothing; + }else if($(th).is('.sorting_asc')){ + $(th).removeClass('sorting_asc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_asc').addClass('sorting_disabled'); + }else if($(th).is('.sorting_desc')){ + $(th).removeClass('sorting_desc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_desc').addClass('sorting_disabled'); + } + } + } + }); + } + + $('th', $tableHead).each(function( column ) + { + if(column>indexSkip){ + //处理三种有可能存在的排序字段,比较方法 + var findSortKey; + if( $(this).is('.sort-title') || $(this).is('.sorting_disabled') ) + { + findSortKey = function( $cell ) + { + var cellText = $cell.text(); + if(isNaN(cellText)){ + return $cell.text().toUpperCase(); + }else{ + return parseFloat(cellText); + } + //return $cell.text().toUpperCase(); + } + } + else if( $(this).is('.sort-date') ) + { + findSortKey = function( $cell ) + { + return Date.parse('1' + $cell.text()); + } + } + else if( $(this).is('.sort-price') ) + { + findSortKey = function( $cell ) + { + var key = parseFloat($cell.text().replace(/^[^\d.]*/, '')) + return isNaN(key) ? 0 : key; + } + } + + //排序 + if( findSortKey ) + { + $(this).click(function() + { + $sortOrder = $sortOrder == 0 ? 1 : 0; + var tableDataHeadTHs = $tableData.find('th').get(); + + if($sortOrder == 1){ + if($(this).is('.sorting_disabled')){ + $(this).removeClass('sorting_disabled').addClass('sorting_asc'); + $(tableDataHeadTHs[column]).removeClass('sorting_disabled').addClass('sorting_asc'); + }else if($(this).is('.sorting_asc')){ + $(this).removeClass('sorting_asc').addClass('sorting_desc'); + $(tableDataHeadTHs[column]).removeClass('sorting_asc').addClass('sorting_desc'); + }else if($(this).is('.sorting_desc')){ + $(this).removeClass('sorting_desc').addClass('sorting_asc'); + $(tableDataHeadTHs[column]).removeClass('sorting_desc').addClass('sorting_asc'); + } + }else{ + if($(this).is('.sorting_disabled')){ + $(this).removeClass('sorting_disabled').addClass('sorting_desc'); + $(tableDataHeadTHs[column]).removeClass('sorting_disabled').addClass('sorting_desc'); + }else if($(this).is('.sorting_asc')){ + $(this).removeClass('sorting_asc').addClass('sorting_desc'); + $(tableDataHeadTHs[column]).removeClass('sorting_asc').addClass('sorting_desc'); + }else if($(this).is('.sorting_desc')){ + $(this).removeClass('sorting_desc').addClass('sorting_asc'); + $(tableDataHeadTHs[column]).removeClass('sorting_desc').addClass('sorting_asc'); + } + } + clearSort($(this)); + + var rows = $tableData.find('tbody > tr').get(); + + $.each( rows, function( index, row ) + { + //先关掉所有行 + if ( oTable.fnIsOpen(row) ) + { + $(row).find('.row-details').click(); + } + }); + + //重新取得所有行,否则排序后表格显示异常 + rows = $tableData.find('tbody > tr').get(); + + $.each( rows, function( index, row ) + { + row.sortKey = findSortKey($(row).children('td').eq(column)); + }); + //排序方法 + rows.sort(function( a, b ) + { + if( $sortOrder == 1 ) + { + //升序 + if(a.sortKey < b.sortKey) return -1; + if(a.sortKey > b.sortKey) return 1; + return 0; + } + else + { + //降序 + if(a.sortKey < b.sortKey) return 1; + if(a.sortKey > b.sortKey) return -1; + return 0; + } + }); + //排序后的对象添加给$table + $.each( rows, function( index, row ) + { + $tableData.children('tbody').append(row); + row.sortKey = null; + }); + }); + } + } + }); + } + + var handleRecords = function(requestStr, columns, xsHiddenColumns, smHiddenColumns, oLanguage, openRowFlag, rowCheckable, rowOverFlag, requestURL, requestParameters, tableHeight, columnsTooLong, sTotalRecordsSource) { + + /* + jQuery.getJSON('/web/newict/framework/thirdparty/data-tables/app-universal-i18n-datatable-' + lang + '.json', + function(data) { + oLanguage = data; + }); + */ + grid.setOpenRowFlag(openRowFlag); + grid.setRowCheckable(rowCheckable); + grid.setRowOverFlag(rowOverFlag); + grid.setColumnsTooLong(columnsTooLong); + grid.setSTotalRecordsSource(sTotalRecordsSource); + grid.setTableHeight(tableHeight); + //取得查询条件 +// if(!requestStr || requestStr.length == 0){ +// requestStr = JSON.stringify(requestAllData); +// } + grid.clearAjaxParams(); + grid.addAjaxParam('data', requestStr); + //取得其他参数 + for(var i=0;i table.dataTable', tableWrapper); + var ths = $tableHead.find('th').get(); + var $tableData = $('table#datatable_ajax'); + var tableDataHeadTHs = $tableData.find('th').get(); + $.each( ths, function( index, th ){ + //clear all sort direction + if($(th).is('.sorting_disabled')){ + //do nothing; + }else if($(th).is('.sorting_asc')){ + $(th).removeClass('sorting_asc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_asc').addClass('sorting_disabled'); + }else if($(th).is('.sorting_desc')){ + $(th).removeClass('sorting_desc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_desc').addClass('sorting_disabled'); + } + }); + + }, + onError: function(grid) { + // execute some code on network or other general error + }, + dataTable: { + "sDom" : "tr<'row'<'col-md-6 col-sm-12'><'col-md-6 col-sm-12'pli>>", // datatable layout + "oLanguage": oLanguage, + //"bAutoWidth": true, + "sScrollY": tableHeight, + "bScrollCollapse": true, + "sScrollX": "100%", + //"sScrollXInner": "110%", + "aLengthMenu": [ + [20, 50, 100], + [20, 50, 100] // change per page values here + ], + "iDisplayLength": 20, // default record count per page + "bServerSide": true, // server side processing + "sAjaxSource": requestURL // ajax source + } + }, columns, xsHiddenColumns, smHiddenColumns, openRowFlag, rowCheckable); + } + + /* + * Insert a 'details' column to the table + */ + var insertDetails = function (oTable, columns, rowCheckable) { + + var $tableData = $('table#datatable_ajax'); + + $tableData.on('click', ' tbody td .row-details', function () { + var nTr = $(this).parents('tr')[0]; + if (oTable.fnIsOpen(nTr)) { + /* This row is already open - close it */ + $(this).addClass("row-details-close").removeClass("row-details-open"); + oTable.fnClose(nTr); + } else { + /* Open this row */ + $(this).addClass("row-details-open").removeClass("row-details-close"); + oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr, columns, rowCheckable), 'details'); + } + }); + } + + return { + + //main function to initiate the module + init: function (requestStr, lang, configPathPrefix) { + + var oLanguage; + var columns; + var xsHiddenColumns; + var smHiddenColumns; + var columnsAll; + + var openRowFlag = false; + var rowOverFlag = false; + var rowCheckable = false; + var requestURL=""; + var requestAllData; + var requestParameters; + + var tableHeight; + var tableWidth; + + var columnsTooLong; + var sTotalRecordsSource=""; + + //取得当前配置及国际化信息 + $.ajax({ + dataType: 'json', + url: configPathPrefix + '-' + lang + '.json', + async: false, + contentType:'application/json; charset=utf-8', + "success": function(data) { + oLanguage = data.language; + columns = data.columns; + xsHiddenColumns = data.xsHiddenColumns; + smHiddenColumns = data.smHiddenColumns; + columnsAll = data.columnsAll; + openRowFlag = data.openRowFlag == 'true'? true: false; + rowOverFlag = data.rowOverFlag == 'true'? true: false; + rowCheckable = data.rowCheckable == 'true'? true: false; + requestURL = data.requestURL; + //requestAllData = data.requestAllData; + requestParameters = data.requestParameters; + tableHeight = data.tableHeight; + tableWidth = data.tableWidth; + columnsTooLong = data.columnsTooLong; + sTotalRecordsSource = data.sTotalRecordsSource; + }, + "error" : function (xhr, info) { + alert('Communication Error! Error reason:' + info); + } + }); + + $('#dataTableWrapperDiv').css('width', tableWidth); + + if(!isContained(xsHiddenColumns, smHiddenColumns) || !isContained(columns, xsHiddenColumns) || !isContained(columnsAll, columns)){ + alert('Columns claim error: (smHiddenColumns <= xsHiddenColumns <= columns <= columnsAll) Please!'); + return; + } + + generateColumns(columns, openRowFlag, rowCheckable); + //initPickers(); + handleRecords(requestStr, columns, xsHiddenColumns, smHiddenColumns, oLanguage, openRowFlag, rowCheckable, rowOverFlag, requestURL, requestParameters, tableHeight, columnsTooLong, sTotalRecordsSource); + //获得初始化完毕的DataTable对象 + var oTable = grid.getDataTable(); + if(openRowFlag){ + insertDetails(oTable, columnsAll, rowCheckable); + } + sortHandling(oTable, openRowFlag, rowCheckable); + //oTable.fnAdjustColumnSizing(true); + return oTable; + } + + }; + +}(); + +var DataTableSmartClient = function(datas, configPathPrefix){ + + var requestStr = ""; + if(datas){ + requestStr = JSON.stringify(datas); + } + + var lang = getLanguage(); + //lang = 'en-US'; + loadi18n_FM(lang); + //requestStr = ""; + var oTable = TableAjaxICT.init(requestStr, lang, configPathPrefix); + + //重新调节列宽以适应window resize + $(window).one('resize', function () { + //oTable.DataTable.models.oSettings.bAjaxDataGet = false; + oTable.fnAdjustColumnSizing(false); + } ); +} diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableSmartClientApp.js b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableSmartClientApp.js new file mode 100644 index 00000000..3a74fa95 --- /dev/null +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/DataTableSmartClientApp.js @@ -0,0 +1,1312 @@ +/*** + Wrapper/Helper Class for datagrid based on jQuery Datatable Plugin + ***/ +var DatatableICT = function () { + + var tableOptions; // main options + var dataTable; // datatable object + var table; // actual table jquery object + var tableContainer; // actual table container object + var tableWrapper; // actual table wrapper jquery object + var tableInitialized = false; + var ajaxParams = []; // set filter mode + var columns; + var xsHiddenColumns; + var smHiddenColumns; + var columnMaxLength = 30; + var columnsTooLong; + var hidden_xs_maxWidth = 768; + var hidden_sm_maxWidth = 991; + + var openRowFlag = false; + var rowOverFlag = false; + var rowCheckable = false; + + var aTargetsAll; + var sTotalRecordsSource; + var tableHeight; + + var callbackList = []; + + var includedInXsHiddenColumns = function(columnId){ + for(var i=0;i tr > td:nth-child(1) input[type="checkbox"]:checked', table).size(); + var text = tableOptions.dataTable.oLanguage.sGroupActions; + if (selected > 0) { + $('.table-group-actions > span', tableWrapper).text(text.replace("_TOTAL_", selected)); + } else { + $('.table-group-actions > span', tableWrapper).text(""); + } + } + + var jsonObjectToArray = function(json, columns, iDraw){ + var jsonToDatatable = {aaData:[], sEcho:iDraw, iTotalRecords:0, iTotalDisplayRecords:0 }; + for(var i=0; i"); + } + if(openRowFlag){ + jsonToDatatable.aaData[i].push(""); + } + for(var j=0; j= hidden_xs_maxWidth && $(window).width() < hidden_sm_maxWidth && includedInSmHiddenColumns(columns[j].columnId )){ + /*隐藏pad尺寸需要隐藏的列*/ + }else if($(window).width() < hidden_xs_maxWidth && includedInXsHiddenColumns(columns[j].columnId )){ + /*隐藏手机尺寸需要隐藏的列*/ + }else{ + var currentColumnId = columns[j].columnId; + if(jQuery.inArray(currentColumnId, columnsTooLong) > -1){ + var rawText = ""; + for(var k=0;k columnMaxLength){ + jsonToDatatable.aaData[i].push(rawText.slice(0, columnMaxLength) + '...'); + }else{ + jsonToDatatable.aaData[i].push(resRowObject[currentColumnId]); + } + } else { + jsonToDatatable.aaData[i].push(resRowObject[currentColumnId]); + } + + } + } + } + jsonToDatatable.sEcho++; + var totalRow = 0; + var totalRecordsSource = eval('json.' + sTotalRecordsSource); + if(totalRecordsSource && totalRecordsSource.length >0){ + totalRow = parseInt(totalRecordsSource); + } + if(isNaN(totalRow)){ + alert('All rows counting number got fail!'); + }else{ + jsonToDatatable.iTotalRecords = totalRow; + jsonToDatatable.iTotalDisplayRecords = totalRow; + } + return jsonToDatatable; + } + + var singleAlarmDel = function(divOverlay){ + + //根据浮动框的当前id获取需要删除的行 + var trId = divOverlay.attr('id_tr'); + tr=$('tr#' + trId); + var tds = $(tr).children(); + var tdAlarmId = ""; + if(rowCheckable){ + tdAlarmId = $(tds.eq(2)).text(); + }else{ + tdAlarmId = $(tds.eq(1)).text(); + } + + var data= { + "alarmId":[parseInt(tdAlarmId)] + }; + + var sSource = "/web/rest/web/fm/curalarms?data=" + JSON.stringify(data) + "&_operationType=remove&_dataSource=isc_PageRestDataSource_0&isc_metaDataPrefix=_&isc_dataFormat=json"; + + $.ajax( { + "dataType": 'json', + "type": "DELETE", + "url": sSource, + "data" : null, + "contentType" : 'application/json; charset=utf-8', + "success": function(json) { + if(json.response.status == 0){ + var resRowObject = json.response.data[0]; + //alert('删除成功'); + } + if(json.response.status == -1){ + //alert('删除失败'); + } + }, + "error": function() { + alert('Communication Error!'); + } + } ); + } + + var singleAlarmAckUnAck = function(divOverlay, ackType){ + + //根据浮动框的当前id获取需要确认的行 + var trId = divOverlay.attr('id_tr'); + var tr = $('tr#' + trId); + + //取得隐藏的头部表格的相应行 + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable'); + //var trHead = $('tbody > tr:nth-child(' + trId + ')', $tableHead); + var trHead = $('tr#' + trId.replace('body', 'head'), $tableHead); + var tdDivs = $('td > div', trHead); + + var tds = $(tr).children(); + var tdAlarmId = ""; + if(rowCheckable){ + tdAlarmId = $(tds.eq(2)).text(); + }else{ + tdAlarmId = $(tds.eq(1)).text(); + } + + var aoData = + { + "dataSource":"isc_PageRestDataSource_0", + "operationType":"update", + "componentId":"isc_com_zte_ums_aos_fm_view_eventview_table_AlarmTable_0", + "data":{ + "viewType":1, + "state":ackType, + "alarmId":[ + parseInt(tdAlarmId) + ] + }, + "oldValues":null + }; + + var sSource = "/web/rest/web/fm/curalarms?isc_dataFormat=json"; + + $.ajax( { + "dataType": 'json', + "type": "PUT", + "url": sSource, + "contentType": 'application/json; charset=utf-8', + "data": JSON.stringify(aoData), + "success": function(json) { + /*for(var i=0;i0){ + json = callbackList[i](json); + break; + } + }*/ + //json = AlarmLabels.transformFieldNames(json); + if(callbackList[1]){ + json = callbackList[1](json); + } + if(json.response.status == 0){ + var resRowObject = json.response.data[0]; + var columnsCopy = $.extend(true, [], columns); + //隐藏列的情况下需要特殊处理 + if($(window).width()>=hidden_xs_maxWidth && $(window).width() -1) { + var rawText = ""; + for(var k=0;k columnMaxLength){ + $(tds.eq(i)).html(rawText.slice(0, columnMaxLength) + '...'); + $(tdDivs.eq(i)).html(rawText.slice(0, columnMaxLength) + '...'); + }else{ + $(tds.eq(i)).html(resRowObject[currentColumnId]); + $(tdDivs.eq(i)).html(resRowObject[currentColumnId]); + } + } else { + $(tds.eq(i)).html(resRowObject[currentColumnId]); + $(tdDivs.eq(i)).html(resRowObject[currentColumnId]); + } + } + //更新缓存中的当前行数据 + for (var t = 0; t < dataTable.datas.length; t++) { + var temp = dataTable.datas[t]; + if (temp.alarmId == resRowObject['alarmId']) { + dataTable.datas[t] = resRowObject; + break; + } + } + } + if(json.response.status == -1){ + $('div#myModalConfirm').modal({ + keyboard: false, + backdrop: 'static' + }); + $('span#alarm_number').html(tdAlarmId); + //国际化信息 + if(ackType==1){ + $('span#aos_fm_alarm_opeater_ack_already').html($.i18n.prop('aos_fm_alarm_opeater_ack_already_ok')); + }else{ + $('span#aos_fm_alarm_opeater_ack_already').html($.i18n.prop('aos_fm_alarm_opeater_ack_already_un')); + } + } + //填充单元格颜色 + var divColor = $("div.cellBackgroundColor", tr); + $(divColor).parent().css("background", $(divColor).css("background-color")); + }, + "error": function() { + alert('Communication Error!'); + } + } ); + } + + var addRowOverlap = function(){ + var $tableData = $('table#datatable_ajax'); + //取得隐藏的头部表格的相应行 + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable'); + var trHeads = $tableHead.find('tr').get(); + $.each( trHeads, function( index, trHead ){ + $(trHead).attr('id', 'headTableTR' + index); + }); + //取得浮动div + var $divOverlay = $('div#divOverlay'); + var divScrollHead = $('div.dataTables_scrollHead'); + var divRightPadding = $('div#divRightPadding'); + //取表头下边沿位置 + var tableHeadBottomHeight = $(divScrollHead).position().top + $(divScrollHead).height(); + var tableBottom = $tableData.position().top + $tableData.height() + 3; + //取表格右边沿位置 + var tableRightEdgePosition = $(divRightPadding).position().left; + var trs = $tableData.find('tr').get(); + $.each( trs, function( index, tr ){ + var tdEmpty = $('td.dataTables_empty',tr); + if(!tdEmpty || tdEmpty.length ==0 ){ + $(tr).attr('id', 'bodyTableTR' + index); + //$divOverlay.attr('id_tr', 'bodyTableTR' + index); + $(tr).one('hover', function(){ + var rowPos = $(tr).position(); + var currentTrTop = rowPos.top; + //var bottomLeft = rowPos.left; + $divOverlay.attr('id_tr', 'bodyTableTR' + index); + $divOverlay.css({ + display: 'block', + position: 'absolute', + 'background-color': '#e5e5e5', + //opacity: 0.7, + border: 'solid 0px', + top: currentTrTop + 6, + left: tableRightEdgePosition - 308, + width: 300, + height: 30 + }); + //防止浮动框跳出表格内容区域 + if( $divOverlay.position().top < tableHeadBottomHeight || $divOverlay.position().top + $divOverlay.height() > tableBottom){ + $divOverlay.css('display', 'none'); + } + var buttonConfirm = $('div#buttonConfirm', $divOverlay); + var buttonUnConfirm = $('div#buttonUnConfirm', $divOverlay); + //初始化悬浮按钮当前行的确认反确认状态 + if($(tr).find('span.alarmAck') && $(tr).find('span.alarmAck').length >0){ + var spanAck = $(tr).find('span.alarmAck'); + var ackState = $(spanAck).attr('ack_id'); + var buttonTDsConfirm = $(buttonConfirm).find('td'); + var buttonTDsUnConfirm = $(buttonUnConfirm).find('td'); + if(ackState=="2"){ + if(buttonTDsConfirm && buttonTDsConfirm.length > 0 && buttonTDsUnConfirm && buttonTDsUnConfirm.length > 0){ + $.each(buttonTDsConfirm, function(index, td){ + $(td).removeClass('buttonRoundedDisabled').addClass('buttonRounded'); + }); + $.each(buttonTDsUnConfirm, function(index, td){ + $(td).removeClass('buttonRounded').addClass('buttonRoundedDisabled'); + }); + } + }else{ + if(buttonTDsConfirm && buttonTDsConfirm.length > 0 && buttonTDsUnConfirm && buttonTDsUnConfirm.length > 0){ + $.each(buttonTDsConfirm, function(index, td){ + $(td).removeClass('buttonRounded').addClass('buttonRoundedDisabled'); + }); + $.each(buttonTDsUnConfirm, function(index, td){ + $(td).removeClass('buttonRoundedDisabled').addClass('buttonRounded'); + }); + } + } + } + //添加确认反确认点击事件 + $(buttonConfirm).one('click', function(){ + var buttonRoundedTDsConfirm = $(buttonConfirm).find('td.buttonRounded'); + var buttonRoundedTDsUnConfirm = $(buttonUnConfirm).find('td.buttonRoundedDisabled'); + if(buttonRoundedTDsConfirm && buttonRoundedTDsConfirm.length > 0){ + $.each(buttonRoundedTDsConfirm, function(index, td){ + $(td).removeClass('buttonRounded').addClass('buttonRoundedDisabled'); + }); + $.each(buttonRoundedTDsUnConfirm, function(index, td){ + $(td).removeClass('buttonRoundedDisabled').addClass('buttonRounded'); + }); + $divOverlay.css('display', 'none'); + singleAlarmAckUnAck($divOverlay, 1); + } + }); + $(buttonUnConfirm).one('click', function(){ + var buttonRoundedTDsUnConfirm = $(buttonUnConfirm).find('td.buttonRounded'); + var buttonRoundedTDsConfirm = $(buttonConfirm).find('td.buttonRoundedDisabled'); + if(buttonRoundedTDsUnConfirm && buttonRoundedTDsUnConfirm.length > 0){ + $.each(buttonRoundedTDsUnConfirm, function(index, td){ + $(td).removeClass('buttonRounded').addClass('buttonRoundedDisabled'); + }); + $.each(buttonRoundedTDsConfirm, function(index, td){ + $(td).removeClass('buttonRoundedDisabled').addClass('buttonRounded'); + }); + $divOverlay.css('display', 'none'); + singleAlarmAckUnAck($divOverlay, 2); + } + }); + var buttonDelete = $('div#buttonDelete', $divOverlay); + $(buttonDelete).die().live('click', function(){ + $divOverlay.css('display', 'none'); + var trIdToDelete = $divOverlay.attr('id_tr'); + var toDeleteTr=$('tr#' + trIdToDelete); + $("td", toDeleteTr).addClass('dataTableTdSelected'); + //弹出删除确认对话框 + $('div#myModal').modal({ + keyboard: false, + backdrop: 'static' + }); + $('#delConfirm').die().live('click', function(){ + //$divOverlay.css('display', 'none'); + dataTable.fnClose(tr); + //删除后端数据 + singleAlarmDel($divOverlay); + //删除当前行 + $(tr).remove(); + //删除表头表格的相应行 + $('tr#' + $(tr).attr('id').replace('body', 'head'), $tableHead).remove(); + //刷新表格 + //dataTable.fnAdjustColumnSizing(); + }); + $('#myModal').on('hidden.bs.modal', function (e) { + $("td", toDeleteTr).removeClass('dataTableTdSelected'); + }) + }); + //展开行的情况隐藏 + $('td.details > table.detailTable').on('hover', function(){ + $divOverlay.css('display', 'none'); + }); + $('div#myModal').on('hover', function(){ + $divOverlay.css('display', 'none'); + }); + }); + } + }); + } + + return { + + //main function to initiate the module + init: function (options, columnsDefined, xsHiddenColumnsDefined, smHiddenColumnsDefined) { + + if (!$().dataTable) { + return; + } + + var the = this; + + //记录需要禁掉默认排序的列 + var aTargets = []; + var targetsLength = columnsDefined.length; + if(rowCheckable)targetsLength++; + if(openRowFlag)targetsLength++; + for(var i=0;i<'col-md-4 col-sm-12'<'table-group-actions pull-right'>>r><'table-scrollable't><'row'<'col-md-8 col-sm-12'pli><'col-md-4 col-sm-12'>r>>", // datatable layout + + "aoColumnDefs" : [{ // define columns sorting options(by default all columns are sortable extept the first checkbox column) + 'bSortable' : false, + 'aTargets' : aTargets + }], + + "bAutoWidth": false, // disable fixed width and enable fluid table + //"bSortCellsTop": true, // make sortable only the first row in thead + "sPaginationType": "bootstrap_extended", // pagination type(bootstrap, bootstrap_full_number or bootstrap_extended) + "bProcessing": true, // enable/disable display message box on record load + "bServerSide": true, // enable/disable server side ajax loading + "sAjaxSource": "", // define ajax source URL + //"sServerMethod": "GET", + + // handle ajax request + "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { + //for ICT Paging + //var startIndex = aoData[3].value;//"iDisplayStart" + //var pageLength = aoData[4].value;//"iDisplayLength" + var oPaging = oSettings.oInstance.fnPagingInfo(); + //var startIndex = oPaging.iStart; + var pageLength = oPaging.iLength; + var curPageNo = oPaging.iPage + 1; + + for(var k=aoData.length-1;k>=0;k--){ + var flag = -1; + if(aoData[k].name=='pageSize'){ + aoData[k].value=pageLength; + flag++; + } + if(aoData[k].name=='pageNo'){ + aoData[k].value=curPageNo; + flag++ + } + if(flag == 1)break; + } + + oSettings.jqXHR = $.ajax( { + "dataType": 'json', + "type": "GET", + "url": sSource, + "data": aoData, + "success": function(res, textStatus, jqXHR) { + if (res.sMessage) { + ZteFrameWork.alert({type: (res.sStatus == 'OK' ? 'success' : 'danger'), icon: (res.sStatus == 'OK' ? 'check' : 'warning'), message: res.sMessage, container: tableWrapper, place: 'prepend'}); + } + if ($('.group-checkable', tableContainer).size() === 1) { + $('.group-checkable', tableContainer).attr("checked", false); + $.uniform.update($('.group-checkable', tableContainer)); + } + if (tableOptions.onSuccess) { + tableOptions.onSuccess.call(the); + } + //保存数据在dataTable对象中给行详细信息面板用 + dataTable.datas = res.response.data; + if(res.response.status < 0){ + alert(res.response.data); + return; + } + + //告警字段值转换 + //res = AlarmLabels.transformFieldNames(res); + /*for(var i=0;i0){ + res = callbackList[i](res); + break; + } + }*/ + if(callbackList[1]){ + res = callbackList[1](res); + } + + res = jsonObjectToArray(res, columns, oSettings.iDraw); + + //重绘表格 + fnCallback(res, textStatus, jqXHR); + }, + "error": function() { + if (tableOptions.onError) { + tableOptions.onError.call(the); + } + ZteFrameWork.alert({type: 'danger', icon: 'warning', message: tableOptions.dataTable.oLanguage.sAjaxRequestGeneralError, container: tableWrapper, place: 'prepend'}); + $('.dataTables_processing', tableWrapper).remove(); + } + } ); + + }, + + // pass additional parameter + "fnServerParams": function ( aoData ) { + //here can be added an external ajax request parameters. + //for(var i in ajaxParams) { + for(var i=0; i table.dataTable', tableWrapper); + var tbodyHead = $('tbody', $tableHead); + if(tbodyHead && tbodyHead.length >0){ + $(tbodyHead).remove(); + } + + var $tableBody = $('table#datatable_ajax', tableWrapper); + var trIn = $('thead > tr:nth-child(1)', $tableHead); + var trBodyHead = $('thead > tr:nth-child(1)', $tableBody); + var tds = $(trIn).children(); + var ths = $(trBodyHead).children(); + for(var k=0;k' + tds.eq(k).html() + ''); + } + var bodyRows = $('tbody > tr', $tableBody); + for(var i=0;i' + tds.eq(j).html() + ''); + $(tds.eq(j)).height('0px'); + $(tds.eq(j)).css('padding-top','0px'); + $(tds.eq(j)).css('padding-bottom','0px'); + $(tds.eq(j)).css('border-top-width','0px'); + $(tds.eq(j)).css('border-bottom-width','0px'); + } + $(rowClone).height('0px'); + $tableHead.append($(rowClone).prop("outerHTML")); + } + + $('.dataTables_scrollBody').css('width','100%'); + $('.dataTables_scrollHead').css('width','98.5%'); + $('.dataTables_scrollHeadInner').css('padding-right', 0); + + //添加浮动确认反确认按钮 + if(rowOverFlag){ + addRowOverlap(); + } + + //填充单元格颜色 + var divColors = $("div.cellBackgroundColor", $tableBody); + $.each( divColors, function( index, divColor ){ + $(divColor).parent().css("background", $(divColor).css("background-color")); + }); + + //设置表格本体高度 + $('div.dataTables_scrollBody').css('height', tableHeight); + } + } + }, options); + + tableOptions = options; + + columns = columnsDefined; + xsHiddenColumns = xsHiddenColumnsDefined; + smHiddenColumns = smHiddenColumnsDefined; + // create table's jquery object + table = $(options.src); + tableContainer = table.parents(".table-container"); + // apply the special class that used to restyle the default datatable + + $.fn.dataTableExt.oStdClasses.sWrapper = $.fn.dataTableExt.oStdClasses.sWrapper + " dataTables_extended_wrapper"; + + // initialize a datatable + dataTable = table.dataTable(options.dataTable); + + tableWrapper = table.parents('.dataTables_wrapper'); + + // modify table per page dropdown input by appliying some classes + $('.dataTables_length select', tableWrapper).addClass("form-control input-xsmall input-sm"); + + // handle group checkboxes check/uncheck + $('.group-checkable', tableContainer).change(function () { + var set = $('tbody > tr > td:nth-child(1) input[type="checkbox"]', table); + var checked = $(this).is(":checked"); + $(set).each(function () { + $(this).attr("checked", checked); + }); + $.uniform.update(set); + countSelectedRecords(); + }); + + // handle row's checkbox click + table.on('change', 'tbody > tr > td:nth-child(1) input[type="checkbox"]', function(){ + countSelectedRecords(); + }); + + //填充表头右边界 + $('.dataTables_scrollHead').css('display','inline-block'); + //var dataTables_scrollHead_height = $('.dataTables_scrollHead').css( "height" ); + $(".dataTables_scrollHead").after("
"); + if($.browser.mozilla){ + $('#divRightPadding').css('height', '40'); + } + + //隐藏掉某些列 + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable', tableWrapper); + var $tableBody = $('table#datatable_ajax', tableWrapper); + + for(var i=0;i tr > th#' + columns[j].columnId, $tableHead).addClass('hidden-xs'); + $('thead > tr > th#' + columns[j].columnId, $tableBody).addClass('hidden-xs'); + break; + } + } + } + + for(var i=0;i tr > th#' + columns[j].columnId, $tableHead).addClass('hidden-sm'); + $('thead > tr > th#' + columns[j].columnId, $tableBody).addClass('hidden-sm'); + break; + } + } + } + },//end init------------------------------------------------------------------------------------ + + getSelectedRowsCount: function() { + return $('tbody > tr > td:nth-child(1) input[type="checkbox"]:checked', table).size(); + }, + + getSelectedRows: function() { + var rows = []; + $('tbody > tr > td:nth-child(1) input[type="checkbox"]:checked', table).each(function(){ + rows.push({name: $(this).attr("name"), value: $(this).val()}); + }); + + return rows; + }, + + addAjaxParam: function(name, value) { + ajaxParams.push({"name": name, "value": value}); + }, + + clearAjaxParams: function(name, value) { + ajaxParams = []; + }, + + getDataTable: function() { + return dataTable; + }, + + getTableWrapper: function() { + return tableWrapper; + }, + + gettableContainer: function() { + return tableContainer; + }, + + getTable: function() { + return table; + }, + + setOpenRowFlag: function(openRowFlagInput) { + openRowFlag = openRowFlagInput; + }, + + setRowOverFlag: function(rowOverFlagInput) { + rowOverFlag = rowOverFlagInput; + }, + + setRowCheckable: function(rowCheckableInput) { + rowCheckable = rowCheckableInput; + }, + + setColumnsTooLong: function(columnsTooLongInput) { + columnsTooLong = columnsTooLongInput; + }, + + setSTotalRecordsSource: function(sTotalRecordsSourceInput){ + sTotalRecordsSource = sTotalRecordsSourceInput; + }, + + setTableHeight: function(tableHeightInput){ + tableHeight = tableHeightInput; + }, + + setCallbackList: function(list){ + if($.isArray(list)){ + callbackList = list; + } + } + + }; + +}; + +var TableAjaxICT = function () { + + var initPickers = function () { + //init date pickers + $('.date-picker').datepicker({ + //rtl: App.isRTL(), + autoclose: true + }); + } + + //判断a数组是否包含b数组 + function isContained(largeArray, smallArray){ + if(!(largeArray instanceof Array) || !(smallArray instanceof Array)) + return false; + if(largeArray.length < smallArray.length) + return false; + for(var i = 0; i < smallArray.length; i++){ + var flag = false; + for(j=0;j 0){ + detailTableId = "alarmDetailInfo" + detailTables.length; + } + var sOut = ''; + sOut += ''; + sOut += ''; + sOut += ''; + sOut += ''; + + sOut += ''; + sOut += ''; + sOut += ''; + + sOut += ''; + sOut += ''; + sOut += ''; + sOut += ''; + + sOut += ''; + sOut += ''; + + sOut += ''; + sOut += ''; + + sOut += ''; + + sOut += ''; + + sOut += ''; + + sOut += ''; + + sOut += '
' + columns[0].columnTitle + '' + alarmId + '' + columns[4].columnTitle + '' + perceivedSeverity + '' + columns[9].columnTitle + '' + alarmType + '' + columns[3].columnTitle + '' + alarmRaisedTime + '
' + columns[5].columnTitle + '' + probableCauseDesc + '' + columns[15].columnTitle + '' + alarmChangedTime + '' + columns[11].columnTitle + '' + ackState + '
' + columns[12].columnTitle + '' + ackTime + '' + columns[13].columnTitle + '' + ackUserId + '' + columns[14].columnTitle + '' + ackSystemId + '' + columns[7].columnTitle + '' + neip + '
' + columns[2].columnTitle + '' + moc + '' + columns[1].columnTitle + '' + resDisplayName + '
' + columns[8].columnTitle + '' + componentname + '' + columns[16].columnTitle + '' + position1 + '
' + columns[10].columnTitle + '' + specificproblem + '
' + columns[6].columnTitle + '' + additionalText + '
' + $.i18n.prop('aos_fm_SuggestionSetting_view_DefaultSuggestionGroupTitle').replace(';', '').replace(/\"/g,'') + '' + '
' + $.i18n.prop('aos_fm_SuggestionSetting_view_SettingSuggestionGroupTitle').replace(';', '').replace(/\"/g,'') + '
'; + + /* + var systemType = 0; + var code = 0; + for (var i = 0; i < oTable.datas.length; i++) { + var temp = oTable.datas[i]; + if (temp.alarmId == oTr['alarmId'].value) { + systemType = temp.systemType; + code = temp.probableCauseCode; + } + }*/ + var data = { + "systemType" : systemType, + "code" : code + }; + var sendData = JSON.stringify(data); + $.ajax({ + "dataType" : 'json', + "type" : "GET", + "url" : "/web/rest/web/fm/Maintenance" + "?" + "data=" + sendData, + "contentType" : 'application/json; charset=utf-8', + "data" : null, + "success" : function (json) { + $('tr').find('td#defaulInfo' + id).text(json.defaulInfo); + $('tr').find('td#customInfo' + id).text(json.customInfo); + var modify = $('#customInfoModify' + id); + modify.on('click', function () { + var span = $('#modifyBtnSpan' + id); + var customInfo = $('tr').find('td#customInfo' + id); + var cancel = $('#cancelDiv' + id); + if (span['0'].className === 'fa fa-pencil-square-o') { + var value = customInfo['0'].textContent; + customInfo['0'].textContent = ''; + customInfo['0'].innerHTML = ''; + span['0'].className = 'fa fa-floppy-o'; + cancel['0'].innerHTML = ''; + $('#cancelBtn' + id).on('click', function () { + customInfo['0'].innerHTML = ''; + customInfo['0'].textContent = value; + cancel['0'].innerHTML = ''; + span['0'].className = 'fa fa-pencil-square-o'; + }); + } else { + var inputValue = $('#customInfoInput' + id)['0'].value; + customInfo['0'].innerHTML = ''; + customInfo['0'].textContent = inputValue; + span['0'].className = 'fa fa-pencil-square-o'; + cancel['0'].innerHTML = ''; + var modifyData = { + "systemType" : systemType, + "code" : code, + "defaulInfo" : json.defaulInfo, + "customInfo" : inputValue + }; + $.ajax({ + "dataType" : 'json', + "type" : "PUT", + "url" : "/web/rest/web/fm/Maintenance", + "contentType" : 'application/json; charset=utf-8', + "data" : JSON.stringify(modifyData), + "error" : function () { + alert('Modify Error!'); + } + }); + } + }); + }, + "error" : function () { + alert('Communication Error!'); + } + }); + + return sOut; + } + + var generateColumns = function(columns, openRowFlag, rowCheckable){ + var $tableData = $('table#datatable_ajax'); + var theadTR = $('thead > tr', $tableData); + if(rowCheckable){ + theadTR.append(''); + } + if(openRowFlag){ + theadTR.append('  '); + } + for(var i=0;i' + columns[i].columnTitle + ''); + } + } + + var sortHandling = function(oTable, openRowFlag, rowCheckable){ + var indexSkip = -1; + if(openRowFlag&&rowCheckable){ + indexSkip = 1; + }else if(openRowFlag&&!rowCheckable||!openRowFlag&&rowCheckable){ + indexSkip = 0; + } + var $sortOrder = 0; //排序类型 1表示升序,0表示降序 + var tableWrapper = $('div#datatable_ajax_wrapper'); + var $tableHead = $('div.dataTables_scrollHeadInner > table.dataTable', tableWrapper); + var $tableData = $('table#datatable_ajax'); + var clearSort = function(currentTh){ + var ths = $tableHead.find('th').get(); + var tableDataHeadTHs = $tableData.find('th').get(); + $.each( ths, function( index, th ){ + if(index > indexSkip){ + if($(th).text() != currentTh.text()){ + if($(th).is('.sorting_disabled')){ + //do nothing; + }else if($(th).is('.sorting_asc')){ + $(th).removeClass('sorting_asc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_asc').addClass('sorting_disabled'); + }else if($(th).is('.sorting_desc')){ + $(th).removeClass('sorting_desc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_desc').addClass('sorting_disabled'); + } + } + } + }); + } + + $('th', $tableHead).each(function( column ) + { + if(column>indexSkip){ + //处理三种有可能存在的排序字段,比较方法 + var findSortKey; + if( $(this).is('.sort-title') || $(this).is('.sorting_disabled') ) + { + findSortKey = function( $cell ) + { + var cellText = $cell.text(); + if(isNaN(cellText)){ + return $cell.text().toUpperCase(); + }else{ + return parseFloat(cellText); + } + //return $cell.text().toUpperCase(); + } + } + else if( $(this).is('.sort-date') ) + { + findSortKey = function( $cell ) + { + return Date.parse('1' + $cell.text()); + } + } + else if( $(this).is('.sort-price') ) + { + findSortKey = function( $cell ) + { + var key = parseFloat($cell.text().replace(/^[^\d.]*/, '')) + return isNaN(key) ? 0 : key; + } + } + + //排序 + if( findSortKey ) + { + $(this).click(function() + { + $sortOrder = $sortOrder == 0 ? 1 : 0; + var tableDataHeadTHs = $tableData.find('th').get(); + + if($sortOrder == 1){ + if($(this).is('.sorting_disabled')){ + $(this).removeClass('sorting_disabled').addClass('sorting_asc'); + $(tableDataHeadTHs[column]).removeClass('sorting_disabled').addClass('sorting_asc'); + }else if($(this).is('.sorting_asc')){ + $(this).removeClass('sorting_asc').addClass('sorting_desc'); + $(tableDataHeadTHs[column]).removeClass('sorting_asc').addClass('sorting_desc'); + }else if($(this).is('.sorting_desc')){ + $(this).removeClass('sorting_desc').addClass('sorting_asc'); + $(tableDataHeadTHs[column]).removeClass('sorting_desc').addClass('sorting_asc'); + } + }else{ + if($(this).is('.sorting_disabled')){ + $(this).removeClass('sorting_disabled').addClass('sorting_desc'); + $(tableDataHeadTHs[column]).removeClass('sorting_disabled').addClass('sorting_desc'); + }else if($(this).is('.sorting_asc')){ + $(this).removeClass('sorting_asc').addClass('sorting_desc'); + $(tableDataHeadTHs[column]).removeClass('sorting_asc').addClass('sorting_desc'); + }else if($(this).is('.sorting_desc')){ + $(this).removeClass('sorting_desc').addClass('sorting_asc'); + $(tableDataHeadTHs[column]).removeClass('sorting_desc').addClass('sorting_asc'); + } + } + clearSort($(this)); + + var rows = $tableData.find('tbody > tr').get(); + + $.each( rows, function( index, row ) + { + //先关掉所有行 + if ( oTable.fnIsOpen(row) ) + { + $(row).find('.row-details').click(); + } + }); + + //重新取得所有行,否则排序后表格显示异常 + rows = $tableData.find('tbody > tr').get(); + + $.each( rows, function( index, row ) + { + row.sortKey = findSortKey($(row).children('td').eq(column)); + }); + //排序方法 + rows.sort(function( a, b ) + { + if( $sortOrder == 1 ) + { + //升序 + if(a.sortKey < b.sortKey) return -1; + if(a.sortKey > b.sortKey) return 1; + return 0; + } + else + { + //降序 + if(a.sortKey < b.sortKey) return 1; + if(a.sortKey > b.sortKey) return -1; + return 0; + } + }); + //排序后的对象添加给$table + $.each( rows, function( index, row ) + { + $tableData.children('tbody').append(row); + row.sortKey = null; + }); + }); + } + } + }); + } + + var handleRecords = function(requestStr, columns, xsHiddenColumns, smHiddenColumns, oLanguage, openRowFlag, rowCheckable, rowOverFlag, requestURL, requestParameters, tableHeight, columnsTooLong, sTotalRecordsSource, callbackList) { + + /* + jQuery.getJSON('/web/newict/framework/thirdparty/data-tables/app-universal-i18n-datatable-' + lang + '.json', + function(data) { + oLanguage = data; + }); + */ + grid.setCallbackList(callbackList); + grid.setOpenRowFlag(openRowFlag); + grid.setRowCheckable(rowCheckable); + grid.setRowOverFlag(rowOverFlag); + grid.setColumnsTooLong(columnsTooLong); + grid.setSTotalRecordsSource(sTotalRecordsSource); + grid.setTableHeight(tableHeight); + //取得查询条件 +// if(!requestStr || requestStr.length == 0){ +// requestStr = JSON.stringify(requestAllData); +// } + grid.clearAjaxParams(); + grid.addAjaxParam('data', requestStr); + //取得其他参数 + for(var i=0;i table.dataTable', tableWrapper); + var ths = $tableHead.find('th').get(); + var $tableData = $('table#datatable_ajax'); + var tableDataHeadTHs = $tableData.find('th').get(); + $.each( ths, function( index, th ){ + //clear all sort direction + if($(th).is('.sorting_disabled')){ + //do nothing; + }else if($(th).is('.sorting_asc')){ + $(th).removeClass('sorting_asc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_asc').addClass('sorting_disabled'); + }else if($(th).is('.sorting_desc')){ + $(th).removeClass('sorting_desc').addClass('sorting_disabled'); + $(tableDataHeadTHs[index]).removeClass('sorting_desc').addClass('sorting_disabled'); + } + }); + + }, + onError: function(grid) { + // execute some code on network or other general error + }, + dataTable: { + "sDom" : "tr<'row'<'col-md-6 col-sm-12'><'col-md-6 col-sm-12'pli>>", // datatable layout + "oLanguage": oLanguage, + //"bAutoWidth": true, + "sScrollY": tableHeight, + "bScrollCollapse": true, + "sScrollX": "100%", + //"sScrollXInner": "110%", + "aLengthMenu": [ + [20, 50, 100], + [20, 50, 100] // change per page values here + ], + "iDisplayLength": 20, // default record count per page + "bServerSide": true, // server side processing + "sAjaxSource": requestURL // ajax source + } + }, columns, xsHiddenColumns, smHiddenColumns, openRowFlag, rowCheckable); + } + + /* + * Insert a 'details' column to the table + */ + var insertDetails = function (oTable, columns, rowCheckable) { + + var $tableData = $('table#datatable_ajax'); + + $tableData.on('click', ' tbody td .row-details', function () { + var nTr = $(this).parents('tr')[0]; + if (oTable.fnIsOpen(nTr)) { + /* This row is already open - close it */ + $(this).addClass("row-details-close").removeClass("row-details-open"); + oTable.fnClose(nTr); + } else { + /* Open this row */ + $(this).addClass("row-details-open").removeClass("row-details-close"); + oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr, columns, rowCheckable), 'details'); + //填充单元格颜色 + var divColor = $("div.cellBackgroundColor", $("table#" + detailTableId)); + $(divColor).parent().css("background", $(divColor).css("background-color")); + } + }); + } + + return { + + //main function to initiate the module + init: function (requestStr, lang, configPathPrefix, callbackList) { + + var oLanguage; + var columns; + var xsHiddenColumns; + var smHiddenColumns; + var columnsAll; + + var openRowFlag = false; + var rowOverFlag = false; + var rowCheckable = false; + var requestURL=""; + var requestAllData; + var requestParameters; + + var tableHeight; + var tableWidth; + + var columnsTooLong; + var sTotalRecordsSource=""; + + //取得当前配置及国际化信息 + $.ajax({ + dataType: 'json', + url: configPathPrefix + '-' + lang + '.json', + async: false, + contentType:'application/json; charset=utf-8', + "success": function(data) { + oLanguage = data.language; + columns = data.columns; + xsHiddenColumns = data.xsHiddenColumns; + smHiddenColumns = data.smHiddenColumns; + columnsAll = data.columnsAll; + openRowFlag = data.openRowFlag == 'true'? true: false; + rowOverFlag = data.rowOverFlag == 'true'? true: false; + rowCheckable = data.rowCheckable == 'true'? true: false; + requestURL = data.requestURL; + //requestAllData = data.requestAllData; + requestParameters = data.requestParameters; + tableHeight = data.tableHeight; + tableWidth = data.tableWidth; + columnsTooLong = data.columnsTooLong; + sTotalRecordsSource = data.sTotalRecordsSource; + }, + "error" : function (xhr, info) { + alert('Communication Error! Error reason:' + info); + } + }); + + $('#dataTableWrapperDiv').css('width', tableWidth); + + if(!isContained(xsHiddenColumns, smHiddenColumns) || !isContained(columns, xsHiddenColumns) || !isContained(columnsAll, columns)){ + alert('Columns claim error: (smHiddenColumns <= xsHiddenColumns <= columns <= columnsAll) Please!'); + return; + } + + generateColumns(columns, openRowFlag, rowCheckable); + //initPickers(); + handleRecords(requestStr, columns, xsHiddenColumns, smHiddenColumns, oLanguage, openRowFlag, rowCheckable, rowOverFlag, requestURL, requestParameters, tableHeight, columnsTooLong, sTotalRecordsSource, callbackList); + //获得初始化完毕的DataTable对象 + var oTable = grid.getDataTable(); + if(openRowFlag){ + insertDetails(oTable, columnsAll, rowCheckable); + } + sortHandling(oTable, openRowFlag, rowCheckable); + //oTable.fnAdjustColumnSizing(true); + return oTable; + } + + }; + +}(); + +var DataTableSmartClientApp = function(datas, configPathPrefix, callbackList){ + + var requestStr = ""; + if(datas){ + requestStr = JSON.stringify(datas); + } + + var lang = getLanguage(); + //lang = 'en-US'; + /*for(var i=0;i0){ + callbackList[i](lang); + break; + } + }*/ + if(callbackList && callbackList[0]){ + callbackList[0](lang); + } + //requestStr = ""; + var oTable = TableAjaxICT.init(requestStr, lang, configPathPrefix, callbackList); + + //重新调节列宽以适应window resize + $(window).one('resize', function () { + //oTable.DataTable.models.oSettings.bAjaxDataGet = false; + oTable.fnAdjustColumnSizing(false); + } ); +} diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-test-i18n-datatable-zh-CN.json b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-test-i18n-datatable-zh-CN.json new file mode 100644 index 00000000..fa209022 --- /dev/null +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-test-i18n-datatable-zh-CN.json @@ -0,0 +1,51 @@ +{ + "language":{ + "sProcessing": "  处理中...", + "sLengthMenu": "|每页 _MENU_ 条结果", + "sZeroRecords": "没有匹配结果", + "sInfo": "|总共找到 _TOTAL_ 条结果", + "sInfoEmpty": "共 0 项", + "sGroupActions": "_TOTAL_ 条结果被选择: ", + "sAjaxRequestGeneralError": "不能完成请求,请检查您的网络连接情况。", + "sEmptyTable": "表中数据为空", + "oPaginate": { + "sPrevious": "前页", + "sNext": "下页", + "sPage": "第", + "sPageOf": "页,总页数:" + } + }, + "columnsAll":[ + {"columnId":"0", "columnTitle":"开始时间"}, + {"columnId":"1", "columnTitle":"结束时间"}, + {"columnId":"2", "columnTitle":"查询粒度"}, + {"columnId":"3", "columnTitle":"网元位置"}, + {"columnId":"4", "columnTitle":"CPU使用率(百分比)"} + ], + "columns":[ + {"columnId":"0", "columnTitle":"开始时间"}, + {"columnId":"1", "columnTitle":"结束时间"}, + {"columnId":"2", "columnTitle":"查询粒度"}, + {"columnId":"3", "columnTitle":"网元位置"}, + {"columnId":"4", "columnTitle":"CPU使用率(百分比)"} + ], + "xsHiddenColumns":[ + ], + "smHiddenColumns":[ + ], + "columnsTooLong":["3"], + + "rowCheckable": "true", + "openRowFlag" : "false", + "rowOverFlag" : "false", + + "tableHeight":"250px", + "tableWidth":"100%", + + "requestType": "POST", + "requestURL": "/web/rest/web-pm/queryPmPageData", + "requestParameters":[ + ], + "sTotalRecordsSource":"response.extData", + "sTotalRecords":"108" +} \ No newline at end of file diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-universal-i18n-datatable-en-US.json b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-universal-i18n-datatable-en-US.json new file mode 100644 index 00000000..809daa32 --- /dev/null +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-universal-i18n-datatable-en-US.json @@ -0,0 +1,89 @@ +{ + "language":{ + "sProcessing": "  Loading...", + "sLengthMenu": "|View _MENU_ records", + "sInfo": "|Found total _TOTAL_ records", + "sInfoEmpty": "No records found to show", + "sGroupActions": "_TOTAL_ records selected: ", + "sAjaxRequestGeneralError": "Could not complete request. Please check your internet connection", + "sEmptyTable": "No data available in table", + "sZeroRecords": "No matching records found", + "oPaginate": { + "sPrevious": "Prev", + "sNext": "Next", + "sPage": "Page", + "sPageOf": "of" + } + }, + "columnsAll":[ + {"columnId":"alarmId", "columnTitle":"Alarm Id"}, + {"columnId":"resDisplayName", "columnTitle":"NE"}, + {"columnId":"moc", "columnTitle":"NE Type"}, + {"columnId":"alarmRaisedTime", "columnTitle":"Raised Time"}, + {"columnId":"perceivedSeverity", "columnTitle":"Severity"}, + {"columnId":"probableCauseDesc", "columnTitle":"Alarm Code"}, + {"columnId":"additionalText", "columnTitle":"Appendix Text"}, + {"columnId":"neip", "columnTitle":"NE IP"}, + {"columnId":"componentname", "columnTitle":"Location"}, + {"columnId":"alarmType", "columnTitle":"Alarm Type"}, + {"columnId":"specificproblem", "columnTitle":"Specific Problem"}, + {"columnId":"ackState", "columnTitle":"Acknowledged State"}, + {"columnId":"ackTime", "columnTitle":"Acknowledge Time"}, + {"columnId":"ackUserId", "columnTitle":"Acknowledge User"}, + {"columnId":"ackSystemId", "columnTitle":"Acknowledge System"}, + {"columnId":"alarmChangedTime", "columnTitle":"Changed Time"}, + {"columnId":"position1", "columnTitle":"Resource ID"} + ], + "columns":[ + {"columnId":"alarmId", "columnTitle":"Alarm Id"}, + {"columnId":"resDisplayName", "columnTitle":"NE"}, + {"columnId":"moc", "columnTitle":"NE Type"}, + {"columnId":"alarmRaisedTime", "columnTitle":"Raised Time"}, + {"columnId":"perceivedSeverity", "columnTitle":"Severity"}, + {"columnId":"probableCauseDesc", "columnTitle":"Alarm Code"}, + {"columnId":"additionalText", "columnTitle":"Appendix Text"}, + {"columnId":"neip", "columnTitle":"NE IP"}, + {"columnId":"componentname", "columnTitle":"Location"}, + {"columnId":"alarmType", "columnTitle":"Alarm Type"}, + {"columnId":"specificproblem", "columnTitle":"Specific Problem"}, + {"columnId":"ackState", "columnTitle":"Acknowledged State"}, + {"columnId":"ackTime", "columnTitle":"Acknowledge Time"}, + {"columnId":"ackUserId", "columnTitle":"Acknowledge User"}, + {"columnId":"ackSystemId", "columnTitle":"Acknowledge System"}, + {"columnId":"alarmChangedTime", "columnTitle":"Changed Time"}, + {"columnId":"position1", "columnTitle":"Resource ID"} + ], + "xsHiddenColumns":[ + {"columnId":"additionalText", "columnTitle":"Appendix Text"}, + {"columnId":"neip", "columnTitle":"NE IP"}, + {"columnId":"componentname", "columnTitle":"Location"}, + {"columnId":"position1", "columnTitle":"Resource ID"} + ], + "smHiddenColumns":[ + {"columnId":"position1", "columnTitle":"Resource ID"} + ], + "columnsTooLong":["additionalText", "moc", "componentname", "specificproblem", "position1"], + "sTotalRecordsSource":"response.extData", + + "rowCheckable": "true", + "openRowFlag" : "true", + "rowOverFlag" : "true", + + "tableHeight":"520px", + "tableWidth":"100%", + + "requestURL": "/web/rest/web/fm/curalarms", + "requestParameters":[ + {"paraId":"pageSize", "paraValue":"20"}, + {"paraId":"pageNo", "paraValue":"1"}, + {"paraId":"_operationType", "paraValue":"fetch"}, + {"paraId":"_startRow", "paraValue":"0"}, + {"paraId":"_endRow", "paraValue":"75"}, + {"paraId":"_textMatchStyle", "paraValue":"exact"}, + {"paraId":"_componentId", "paraValue":"isc_com_zte_ums_aos_fm_view_eventview_table_AlarmTable_0"}, + {"paraId":"_dataSource", "paraValue":"isc_PageRestDataSource_0"}, + {"paraId":"isc_metaDataPrefix", "paraValue":"_"}, + {"paraId":"isc_dataFormat", "paraValue":"json"} + ], + "sTotalRecordsSource":"response.extData" +} \ No newline at end of file diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-universal-i18n-datatable-zh-CN.json b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-universal-i18n-datatable-zh-CN.json new file mode 100644 index 00000000..8a270a43 --- /dev/null +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/app-universal-i18n-datatable-zh-CN.json @@ -0,0 +1,90 @@ +{ + "language":{ + "sProcessing": "  处理中...", + "sLengthMenu": "|每页 _MENU_ 条结果", + "sZeroRecords": "没有匹配结果", + "sInfo": "|总共找到 _TOTAL_ 条结果", + "sInfoEmpty": "共 0 项", + "sGroupActions": "_TOTAL_ 条结果被选择: ", + "sAjaxRequestGeneralError": "不能完成请求,请检查您的网络连接情况。", + "sEmptyTable": "表中数据为空", + "oPaginate": { + "sPrevious": "前页", + "sNext": "下页", + "sPage": "第", + "sPageOf": "页,总页数:" + } + }, + "columnsAll":[ + {"columnId":"alarmId", "columnTitle":"告警编号"}, + {"columnId":"resDisplayName", "columnTitle":"网元"}, + {"columnId":"moc", "columnTitle":"网元类型"}, + {"columnId":"alarmRaisedTime", "columnTitle":"发生时间"}, + {"columnId":"perceivedSeverity", "columnTitle":"级别"}, + {"columnId":"probableCauseDesc", "columnTitle":"告警码"}, + {"columnId":"additionalText", "columnTitle":"附加文本"}, + {"columnId":"neip", "columnTitle":"网元IP"}, + {"columnId":"componentname", "columnTitle":"网元内定位"}, + {"columnId":"alarmType", "columnTitle":"告警类型"}, + {"columnId":"specificproblem", "columnTitle":"告警原因"}, + {"columnId":"ackState", "columnTitle":"确认状态"}, + {"columnId":"ackTime", "columnTitle":"确认时间"}, + {"columnId":"ackUserId", "columnTitle":"确认用户"}, + {"columnId":"ackSystemId", "columnTitle":"确认系统"}, + {"columnId":"alarmChangedTime", "columnTitle":"修改时间"}, + {"columnId":"position1", "columnTitle":"资源ID"} + ], + "columns":[ + {"columnId":"alarmId", "columnTitle":"告警编号"}, + {"columnId":"resDisplayName", "columnTitle":"网元"}, + {"columnId":"moc", "columnTitle":"网元类型"}, + {"columnId":"alarmRaisedTime", "columnTitle":"发生时间"}, + {"columnId":"perceivedSeverity", "columnTitle":"级别"}, + {"columnId":"probableCauseDesc", "columnTitle":"告警码"}, + {"columnId":"additionalText", "columnTitle":"附加文本"}, + {"columnId":"neip", "columnTitle":"网元IP"}, + {"columnId":"componentname", "columnTitle":"网元内定位"}, + {"columnId":"alarmType", "columnTitle":"告警类型"}, + {"columnId":"specificproblem", "columnTitle":"告警原因"}, + {"columnId":"ackState", "columnTitle":"确认状态"}, + {"columnId":"ackTime", "columnTitle":"确认时间"}, + {"columnId":"ackUserId", "columnTitle":"确认用户"}, + {"columnId":"ackSystemId", "columnTitle":"确认系统"}, + {"columnId":"alarmChangedTime", "columnTitle":"修改时间"}, + {"columnId":"position1", "columnTitle":"资源ID"} + ], + "xsHiddenColumns":[ + {"columnId":"additionalText", "columnTitle":"附加文本"}, + {"columnId":"neip", "columnTitle":"网元IP"}, + {"columnId":"componentname", "columnTitle":"网元内定位"}, + {"columnId":"position1", "columnTitle":"资源ID"} + ], + "smHiddenColumns":[ + {"columnId":"position1", "columnTitle":"资源ID"} + ], + "columnsTooLong":["additionalText", "moc", "componentname", "specificproblem", "position1"], + + "rowCheckable": "true", + "openRowFlag" : "true", + "rowOverFlag" : "true", + + "tableHeight":"520px", + "tableWidth":"100%", + + "requestURL": "/web/rest/web/fm/curalarms", + "requestAllData": {"rule":{"ruleId":-1,"name":"当前告警","creator":"admin","createTime":1397439767310,"modifier":"","modifyTime":0,"description":"","state":true,"ruleType":1,"ruleSort":1,"owner":"","attrs":"","ruleData":""}}, + "requestParameters":[ + {"paraId":"pageSize", "paraValue":"20"}, + {"paraId":"pageNo", "paraValue":"1"}, + {"paraId":"_operationType", "paraValue":"fetch"}, + {"paraId":"_startRow", "paraValue":"0"}, + {"paraId":"_endRow", "paraValue":"75"}, + {"paraId":"_textMatchStyle", "paraValue":"exact"}, + {"paraId":"_componentId", "paraValue":"isc_com_zte_ums_aos_fm_view_eventview_table_AlarmTable_0"}, + {"paraId":"_dataSource", "paraValue":"isc_PageRestDataSource_0"}, + {"paraId":"isc_metaDataPrefix", "paraValue":"_"}, + {"paraId":"isc_dataFormat", "paraValue":"json"} + ], + "sTotalRecordsSource":"response.extData" +} + diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/dataTable.html b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/dataTable.html new file mode 100644 index 00000000..647866c9 --- /dev/null +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/dataTable.html @@ -0,0 +1,155 @@ + + + + + + + + + +
+
+
+
+
+ + + + + + +
+ + + + + +
+
+
+ +
+
+ + + + + + + + + + diff --git a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/jquery.dataTables.js b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/jquery.dataTables.js index 367680da..380ab1e4 100644 --- a/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/jquery.dataTables.js +++ b/openo-portal/portal-common/src/main/webapp/common/thirdparty/data-tables/jquery.dataTables.js @@ -1,7461 +1,9386 @@ +/*! DataTables 1.10.11 + * ©2008-2015 SpryMedia Ltd - datatables.net/license + */ + /** * @summary DataTables - * @description Paginate, search and sort HTML tables - * @version 1.9.4 + * @description Paginate, search and order HTML tables + * @version 1.10.11 * @file jquery.dataTables.js - * @author Allan Jardine (www.sprymedia.co.uk) + * @author SpryMedia Ltd (www.sprymedia.co.uk) * @contact www.sprymedia.co.uk/contact + * @copyright Copyright 2008-2015 SpryMedia Ltd. * - * @copyright Copyright 2008-2012 Allan Jardine, all rights reserved. + * This source file is free software, available under the following license: + * MIT license - http://datatables.net/license * - * This source file is free software, under either the GPL v2 license or a - * BSD style license, available at: - * http://datatables.net/license_gpl2 - * http://datatables.net/license_bsd - * - * This source file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * This source file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. - * + * * For details please refer to: http://www.datatables.net */ /*jslint evil: true, undef: true, browser: true */ -/*globals $, jQuery,define,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnRender,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns*/ - -(/** @lends */function( window, document, undefined ) { +/*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/ (function( factory ) { "use strict"; - // Define as an AMD module if possible - if ( typeof define === 'function' && define.amd ) - { - define( ['jquery'], factory ); + if ( typeof define === 'function' && define.amd ) { + // AMD + define( ['jquery'], function ( $ ) { + return factory( $, window, document ); + } ); } - /* Define using browser globals otherwise - * Prevent multiple instantiations if the script is loaded twice - */ - else if ( jQuery && !jQuery.fn.dataTable ) - { - factory( jQuery ); + else if ( typeof exports === 'object' ) { + // CommonJS + module.exports = function (root, $) { + if ( ! root ) { + // CommonJS environments without a window global must pass a + // root. This will give an error otherwise + root = window; + } + + if ( ! $ ) { + $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window + require('jquery') : + require('jquery')( root ); + } + + return factory( $, root, root.document ); + }; + } + else { + // Browser + factory( jQuery, window, document ); } } -(/** @lends */function( $ ) { +(function( $, window, document, undefined ) { "use strict"; - /** - * DataTables is a plug-in for the jQuery Javascript library. It is a - * highly flexible tool, based upon the foundations of progressive - * enhancement, which will add advanced interaction controls to any - * HTML table. For a full list of features please refer to - * DataTables.net. + + /** + * DataTables is a plug-in for the jQuery Javascript library. It is a highly + * flexible tool, based upon the foundations of progressive enhancement, + * which will add advanced interaction controls to any HTML table. For a + * full list of features please refer to + * [DataTables.net](href="http://datatables.net). * - * Note that the DataTable object is not a global variable but is - * aliased to jQuery.fn.DataTable and jQuery.fn.dataTable through which - * it may be accessed. + * Note that the `DataTable` object is not a global variable but is aliased + * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may + * be accessed. * * @class - * @param {object} [oInit={}] Configuration object for DataTables. Options + * @param {object} [init={}] Configuration object for DataTables. Options * are defined by {@link DataTable.defaults} - * @requires jQuery 1.3+ - * + * @requires jQuery 1.7+ + * * @example * // Basic initialisation * $(document).ready( function { * $('#example').dataTable(); * } ); - * + * * @example * // Initialisation with configuration options - in this case, disable * // pagination and sorting. * $(document).ready( function { * $('#example').dataTable( { - * "bPaginate": false, - * "bSort": false + * "paginate": false, + * "sort": false * } ); * } ); */ - var DataTable = function( oInit ) - { - - - /** - * Add a column to the list used for the table with default values - * @param {object} oSettings dataTables settings object - * @param {node} nTh The th element for this column - * @memberof DataTable#oApi - */ - function _fnAddColumn( oSettings, nTh ) - { - var oDefaults = DataTable.defaults.columns; - var iCol = oSettings.aoColumns.length; - var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, { - "sSortingClass": oSettings.oClasses.sSortable, - "sSortingClassJUI": oSettings.oClasses.sSortJUI, - "nTh": nTh ? nTh : document.createElement('th'), - "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '', - "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol], - "mData": oDefaults.mData ? oDefaults.oDefaults : iCol - } ); - oSettings.aoColumns.push( oCol ); - - /* Add a column specific filter */ - if ( oSettings.aoPreSearchCols[ iCol ] === undefined || oSettings.aoPreSearchCols[ iCol ] === null ) - { - oSettings.aoPreSearchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch ); - } - else - { - var oPre = oSettings.aoPreSearchCols[ iCol ]; - - /* Don't require that the user must specify bRegex, bSmart or bCaseInsensitive */ - if ( oPre.bRegex === undefined ) - { - oPre.bRegex = true; - } - - if ( oPre.bSmart === undefined ) - { - oPre.bSmart = true; - } - - if ( oPre.bCaseInsensitive === undefined ) - { - oPre.bCaseInsensitive = true; + var DataTable; + + + /* + * It is useful to have variables which are scoped locally so only the + * DataTables functions can access them and they don't leak into global space. + * At the same time these functions are often useful over multiple files in the + * core and API, so we list, or at least document, all variables which are used + * by DataTables as private variables here. This also ensures that there is no + * clashing of variable names and that they can easily referenced for reuse. + */ + + + // Defined else where + // _selector_run + // _selector_opts + // _selector_first + // _selector_row_indexes + + var _ext; // DataTable.ext + var _Api; // DataTable.Api + var _api_register; // DataTable.Api.register + var _api_registerPlural; // DataTable.Api.registerPlural + + var _re_dic = {}; + var _re_new_lines = /[\r\n]/g; + var _re_html = /<.*?>/g; + var _re_date_start = /^[\w\+\-]/; + var _re_date_end = /[\w\+\-]$/; + + // Escape regular expression special characters + var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' ); + + // http://en.wikipedia.org/wiki/Foreign_exchange_market + // - \u20BD - Russian ruble. + // - \u20a9 - South Korean Won + // - \u20BA - Turkish Lira + // - \u20B9 - Indian Rupee + // - R - Brazil (R$) and South Africa + // - fr - Swiss Franc + // - kr - Swedish krona, Norwegian krone and Danish krone + // - \u2009 is thin space and \u202F is narrow no-break space, both used in many + // standards as thousands separators. + var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi; + + + var _empty = function ( d ) { + return !d || d === true || d === '-' ? true : false; + }; + + + var _intVal = function ( s ) { + var integer = parseInt( s, 10 ); + return !isNaN(integer) && isFinite(s) ? integer : null; + }; + + // Convert from a formatted number with characters other than `.` as the + // decimal place, to a Javascript number + var _numToDecimal = function ( num, decimalPoint ) { + // Cache created regular expressions for speed as this function is called often + if ( ! _re_dic[ decimalPoint ] ) { + _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' ); + } + return typeof num === 'string' && decimalPoint !== '.' ? + num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) : + num; + }; + + + var _isNumber = function ( d, decimalPoint, formatted ) { + var strType = typeof d === 'string'; + + // If empty return immediately so there must be a number if it is a + // formatted string (this stops the string "k", or "kr", etc being detected + // as a formatted number for currency + if ( _empty( d ) ) { + return true; + } + + if ( decimalPoint && strType ) { + d = _numToDecimal( d, decimalPoint ); + } + + if ( formatted && strType ) { + d = d.replace( _re_formatted_numeric, '' ); + } + + return !isNaN( parseFloat(d) ) && isFinite( d ); + }; + + + // A string without HTML in it can be considered to be HTML still + var _isHtml = function ( d ) { + return _empty( d ) || typeof d === 'string'; + }; + + + var _htmlNumeric = function ( d, decimalPoint, formatted ) { + if ( _empty( d ) ) { + return true; + } + + var html = _isHtml( d ); + return ! html ? + null : + _isNumber( _stripHtml( d ), decimalPoint, formatted ) ? + true : + null; + }; + + + var _pluck = function ( a, prop, prop2 ) { + var out = []; + var i=0, ien=a.length; + + // Could have the test in the loop for slightly smaller code, but speed + // is essential here + if ( prop2 !== undefined ) { + for ( ; i