123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- /** 跳转的代码 **/
- var jumpOldContent = $("#head").attr("content");
- var jumpcontent = "width=device-width, initial-scale=1,maximum-scale=1,minimum-scale=1";
- var report_info = $(".report_info").html();
- var pageCount = parseInt($(".get_page_count").html());
- var Page = parseInt($(".get_page").html());
- var PageInfo = $(".get_page_info").html();
- var error = ['已经是第一页了', '已经是最后一页了', '跳转页数超出的范围', '已经在当前页了无需跳转'];
- var url = "";
- if (report_info !== null && report_info !== undefined && report_info !== '') {
- var report_info_obj = eval("(" + report_info + ")");
- if (report_info_obj.url !== undefined && report_info_obj.url !== null && report_info_obj.url !== '') {
- url = report_info_obj.url;
- }
- }
- var transform = 0.84;
- var bottom = 20;
- var headers = {};
- var headerArr = jumpOldContent.split(',');
- headerArr.forEach(item => {
- if (item !== '') {
- var index = item.indexOf('=');
- var key = item.slice(0, index);
- key = key.trim();
- var value = item.slice(index + 1).trim();
- headers[key] = value;
- }
- })
- if (headers['initial-scale'] !== null && headers['initial-scale'] !== undefined) {
- var scale = parseFloat(headers['initial-scale']);
- if (scale !== 1) {
- transform = 0.84 / scale;
- bottom = 1 / scale * 20 + (1 / scale - 1) * 36 / 2;
- }
- }
- var pageDiv = ' <div class="page" style="transform:scale(' + transform + ');bottom:' + bottom + 'px;">\n' +
- ' <ul class="flex-between">\n' +
- ' <li id="prev_btn"><img src="' + url + '/reportForms/image/last_icon.png"></li>\n' +
- ' <li id="next_btn"><img src="' + url + '/reportForms/image/next_icon.png"></li>\n' +
- ' <li id="jump-phone"><img src="' + url + '/reportForms/image/tz_icon.png" id="jump-phone-img"></li>\n' +
- ' </ul>\n' +
- ' </div>';
- $(".condition-box").append(pageDiv);
- var jump_interface_page = '<div class="jump-interface jump-interface-page none">\n' +
- ' <div class="jump-box">' +
- ' <ul>' +
- ' <li class="tip">跳转</li>' +
- ' <li>' +
- PageInfo +
- ' </li>' +
- ' <li>将跳转到' +
- ' <input class="jumpNumber" id="jumpNumber" type="text"' +
- ' value="1" onkeyup="checkLen2(this)" oninput="value=value.replace(/[^\\d]/g,\'\')">' +
- ' </li>' +
- ' <li class="jump-save-box">' +
- ' <button class="jump" id="jump">跳转</button>' +
- ' <button class="cancel" id="cancel">取消</button>' +
- ' </li>' +
- ' </ul>' +
- ' </div>' +
- '</div>';
- var jump_interface_error = '<div class="jump-interface jump-interface-error none">' +
- ' <div class="jump-box">' +
- ' <ul>' +
- ' <li class="tip">错误提示</li>' +
- ' <li class="tip-content">' +
- ' <div id="tip-content-div"></div>' +
- ' </li>' +
- ' <li class="jump-save-box">' +
- ' <button class="jump" id="esure">确定</button>' +
- ' <button class="cancel" id="esure-cancel">取消</button>' +
- ' </li>' +
- ' </ul>' +
- ' </div>' +
- '</div>';
- $("body").append(jump_interface_page);
- $("body").append(jump_interface_error);
- //上一页
- document.getElementById("prev_btn").onclick = function () {
- skip(0);
- };
- //下一页
- document.getElementById("next_btn").onclick = function () {
- skip(1);
- };
- //跳转功能代码
- function skip(type) {
- var jumpNumber = Page;
- var errorBool = false;
- if (type == 0) {
- Page = Page - 1;
- if (Page < 1) {
- errorBool = true;
- }
- } else if (type == 1) {
- Page = Page + 1;
- if (Page > pageCount) {
- errorBool = true;
- }
- } else {
- var PageValue = document.getElementById("jumpNumber").value;
- if (typeof PageValue == "undefined" || PageValue == null || PageValue == "") {
- errorBool = true;
- } else {
- Page = parseInt(PageValue);
- if (Page == null || Page < 1 || Page > pageCount) {
- errorBool = true;
- }
- if (jumpNumber == Page) {
- type = 3;
- errorBool = true;
- }
- }
- }
- if (errorBool) {
- Page = jumpNumber;
- document.getElementById("tip-content-div").innerHTML = error[type];
- $(".condition-box").addClass("none");
- $("#head").attr("content", content);
- $(".jump-interface-error").removeClass("none");
- } else {
- alert("JumpPage@" + Page);
- }
- }
- //自定义键盘
- var coolInput = new CoolInput({slt: '#jumpNumber'});
- //跳转界面
- document.getElementById("jump-phone-img").onclick = function () {
- $(".condition-box").addClass("none");
- $("#head").attr("content", jumpcontent);
- $(".jump-interface-page").removeClass("none");
- coolInput.cursorT = $("#jumpNumber").offset().top;
- };
- //跳转
- document.getElementById("jump").onclick = function () {
- $(".jump-interface-page").addClass("none");
- $("#head").attr("content", jumpOldContent);
- $(".condition-box").removeClass("none");
- skip(2);
- };
- document.getElementById("cancel").onclick = function () {
- $(".jump-interface-page").addClass("none");
- $("#head").attr("content", jumpOldContent);
- $(".condition-box").removeClass("none");
- };
- document.getElementById("esure").onclick = function () {
- $(".jump-interface-error").addClass("none");
- $("#head").attr("content", jumpOldContent);
- $(".condition-box").removeClass("none");
- };
- document.getElementById("esure-cancel").onclick = function () {
- $(".jump-interface-error").addClass("none");
- $("#head").attr("content", jumpOldContent);
- $(".condition-box").removeClass("none");
- };
|