const commonContent = "width=device-width, initial-scale=1,maximum-scale=10,minimum-scale=0.1,user-scalable=no"; let oldCommonContent = $("#head").attr("content"); let commonIsNotSet = $(".is_not_set").html(); const commonTable = document.getElementById("table"); /*获取 密码设置*/ function getReportPasswordInfo() { return $(".report_info").html(); } if (commonTable !== null && commonTable !== undefined) { const rows = commonTable.rows.length; if (rows > 0) { const num = commonTable.rows[0].cells.length; if (num > 3) { //js添加html const html = '
' + '
' + '
' + '
' + '
'; $("body").append(html); for (let i = 0; i < num; i++) { const value = commonTable.rows[0].cells[i].innerHTML; const valueClass = commonTable.rows[0].cells[i].getAttribute("class"); const len = strLen(value); let btn_font = "btn-font"; if (len > 10) { btn_font = "btn-font-10"; } else if (len >= 6) { btn_font = "btn-font-" + len; } $(".title-content").append(''); } const yu = 4 - num % 4; if (yu > 0) { for (let x = 0; x < yu; x++) $(".title-content").append(''); } } } } else { commonIsNotSet = "1"; } //选择选项 $(".title-content .btn").click(function () { if ($(this).hasClass("checked")) { $(this).removeClass("checked"); } else { $(this).addClass("checked"); } }); //点击重置 $(".cancel").click(function () { $(".title-content .btn").each(function (i, o) { if (!$(o).hasClass("checked")) { $(o).addClass("checked"); } }); ColumnSave(); $(".condition-box").removeClass("none"); $(".title-menu").addClass("none"); }); function JumpColumn() { if (commonIsNotSet === "1") { alert("当前界面无法设置"); return; } oldCommonContent = $("#head").attr("content"); SetColumn(); $("#head").attr("content", commonContent); $(".condition-box").addClass("none"); $(".title-menu").removeClass("none"); } function SetColumn(columns) { if (columns !== null && columns !== undefined) { ColumnSave(columns.split(",")); } return columns; } function ColumnSave(columns) { const colSpans = []; const columnValues = []; let colspan_total = 0; $(".title-content .btn").each(function (i, o) { const columnValue = $(o).html(); if (columns !== null && columns !== undefined) { if (columns.indexOf(columnValue) !== -1) { $(o).removeClass("checked"); } } const valueClass = $(o).attr("class"); const useClass = valueClass.split(" "); const is_checked = $(o).hasClass("checked"); for (i = 0; i < useClass.length; i++) { if (useClass[i].indexOf("reportFormTableColumn_") === 0) { if (is_checked) { $(".condition-box ." + useClass[i] + " ").removeClass("none"); const colspan_item = $(".condition-box ." + useClass[i] + " ").attr("colspan"); if (colspan_item !== undefined) { colspan_total = colspan_total + parseInt(colspan_item); } } else { $(".condition-box ." + useClass[i] + " ").addClass("none"); columnValues.push(columnValue); } } else if (useClass[i].indexOf("reportFormTableColumnMany_") === 0) { const useManyClass = useClass[i].split("@"); if (useManyClass.length > 1) { if (!colSpans.hasOwnProperty(useManyClass[0])) { colSpans[useManyClass[0]] = 0; } if (is_checked) { const colspan = parseInt(useManyClass[1]); colSpans[useManyClass[0]] = colSpans[useManyClass[0]] + colspan; } } } } }); for (const key in colSpans) { if (colSpans[key] === 0) { $(".condition-box ." + key + " ").addClass("none"); } else { $(".condition-box ." + key + " ").attr("colspan", colSpans[key]); $(".condition-box ." + key + " ").removeClass("none"); } } const colspan_with = $(".colspan_with").html(); if (colspan_with !== undefined && colspan_with.length > 0) { const documentWidth = parseInt(colspan_total) * parseFloat(colspan_with); if (documentWidth > 100) { $("#table-box").width(documentWidth + "%"); } else { $("#table-box").width("100%"); } } return "ColumnSave@" + columnValues.join(','); } //点击保存显示 $(".save").click(function () { //判断button里面哪个含有checked; const columnValueStr = ColumnSave(); $("#head").attr("content", oldCommonContent); $(".condition-box").removeClass("none"); $(".title-menu").addClass("none"); alert(columnValueStr); }); //长按事件 // $.fn.longPress = function(fn) { // var timeout = undefined; // var $this = this; // for(var i = 0; i < $this.length; i++) { // (function(target) { // var timeout; // target.addEventListener('touchstart', function(event) { // timeout = setTimeout(function() { // //fn.apply(target); // fn(event); // }, 500); // }, false); // target.addEventListener('touchend', function(event) { // clearTimeout(timeout); // }, false); // })($this[i]); // } // }; //长按 // $("#condition,#title").longPress(function(e){ // JumpColumn(); // }); //双击头部显示 // $("#condition,#title").dblclick(function () { // JumpColumn(); // }); //获取中文 长度 function strLen(str) { let len = 0.0; for (let i = 0; i < str.length; i++) { let c = str.charCodeAt(i); //单字节加1 if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) { len += 0.5; } else { len++; } } if (len > parseInt(len)) { len++; } return len; } function getScale() { let scale = 1; const headers = {}; let content = $("#head").attr("content"); const headerArr = content.split(','); headerArr.forEach(function (item) { if (item !== '') { const index = item.indexOf('='); let key = item.slice(0, index); key = key.trim(); headers[key] = item.slice(index + 1).trim(); } }) if (headers['initial-scale'] !== null && headers['initial-scale'] !== undefined) { scale = parseFloat(headers['initial-scale']); } return scale; } $(document).ready(function () { if (commonIsNotSet === "1") { return; } const commonReportInfo = $(".report_info").html(); if (commonReportInfo !== null && commonReportInfo !== undefined && commonReportInfo !== '') { const report_info_obj = eval("(" + commonReportInfo + ")"); if (report_info_obj.hide_columns !== undefined && report_info_obj.hide_columns !== null && report_info_obj.hide_columns !== '') { ColumnSave(report_info_obj.hide_columns.split(",")); } } });