' + columns[0].columnTitle + ' | ' + 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);
+ } );
+}
--
cgit 1.2.3-korg