renderings
1. Use iframe to introduce the page
area_qysyb2: function() { $("#_result").css('width', '100%'); $("#_result").css('height', '100%'); var page = ` <div style="width:100%; height:100%"> <iframe frameborder="no" scrolling-y="yes" allowtransparency="yes" src="../business/ak_business/html/ak_xmtj/ak_qysybtj.html?type=${ak_right. type2}" style="list-style:none;width:100%;height:100%;"></iframe> </div>`; $('#_result').html(page); var docuWidth = $(document).width(); _slipWin.upws(docuWidth * 0.27); _slipWin.show(); },
2.html page
Write an hrml page introduced by iframe
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <link rel="stylesheet" type="text/css" href="../../css/rightPage_common.css" /> </head> <body class="page-header-fixed page-sidebar-closed-hide-logo page-sidebar-closed-hide-logo" style="background-color: rgba(0,0,0,0);"> <!--#include virtual="../../common/head_global.html"--> <!--#include virtual="../../common/head_theme.html"--> <!-- Statistics on the number of national institutions of joint-stock institutions --> <div class="panel-heading"> <span id="head_title"></span> <!-- <img id="imgSlide" src="../../../build/slipWin/up.png"> --> <!-- <span id="head_total"></span> --> </div> <div class="panel-body" id="slide_body" style="display: none;"> <form id="formSearch" class="form-horizontal"> <div class="form-group" style="margin-top:3px;opacity: 0.7;"> <!-- Continents --> <div class="col-md-2"> <input type="text" class="form-control" id="startTime" placeholder="Statistical start time" autocomplete="off"> </div> <!-- Country --> <div class="col-md-2"> <input type="text" class="form-control" id="endTime" placeholder="Statistical end time" autocomplete="off"> </div> </div> <div class="form-group" style="margin-top:3px;opacity: 0.7;"> <div class="col-md-3" style="width: 93%"> <select id="projectStatus" class="form-control" data-size="3" multiple="multiple: true"></select> </div> </div> <div class="form-group" style="margin-top:3px;margin-bottom: 0;justify-content: start;"> <div class="col-md-3" style="margin-left: 8px;"> <button type="button" id="btn_query" class="btn btn-primary" style="margin-left:5px;background-color: #1a4264;">Query</button> <button type="button" id="btn_reset" class="btn btn-primary" style="margin-left:5px;background-color: #1a4264;">Reset</button> </div> </div> </form> </div> <div id="body"></div> <!-- Interestingly, the bottom.html file will only take effect if it is created in the html directory. --> <!--#include virtual="../../common/bottom.html"--> <script src="../../common/assets/global/plugins/bootstrap/js/bootstrap-paginator.js" type="text/javascript" charset="utf-8"></script> </body> <script type="text/javascript" src="../../js/ak_xmtj/ak_qysybtj_gjtj.js"></script> <script type="text/javascript"> jQuery(document).ready(function() { ak_qysybtj_gjtj.init(); }); </script> </html>
3.Script
Initialize list parameters first
init: function() { ak_qysybtj_gjtj.areaId = ak_qysybtj_gjtj.getQuery(window.location.search, 'areaId'); // Regional business unit id ak_qysybtj_gjtj.projectstatus = ak_qysybtj_gjtj.getQuery(window.location.search, 'projectstatus'); //Construction status ak_qysybtj_gjtj.startTime = ak_qysybtj_gjtj.getQuery(window.location.search, 'startTime'); // Statistics start time ak_qysybtj_gjtj.endTime = ak_qysybtj_gjtj.getQuery(window.location.search, 'endTime'); // Statistics end time if(ak_qysybtj_gjtj.projectstatus !== 'null') { // Process construction status parameter format let status = ak_qysybtj_gjtj.projectstatus; status = status.split(",").join("','"); status = "'" + status + "'"; ak_qysybtj_gjtj.projectstatus = status; } // console.log(ak_qysybtj_gjtj.projectstatus) console.log(ak_qysybtj_gjtj.startTime) console.log(ak_qysybtj_gjtj.endTime) \t\t $("#head_title").text("Regional Division National Statistics"); // Title // this.initSelect(); // Initialize the drop-down box this.ButtonInit(); // Initialize Button's click event // this.initDatepicker(); // Initialize time control // this.initSlide(); // Initialization conditions for sliding and sliding out ak_qysybtj_gjtj.initSearch(); // Receive requested parameters },
Receive the parameters of the request and call the request backend interface method
initSearch: function() { this.offset = this.pagesize * (this.page - 1); ak_qysybtj_gjtj.temp = { Authorization: akglobe_config.token, areaId:ak_qysybtj_gjtj.areaId, // Regional business unit id projectstatus: ak_qysybtj_gjtj.projectstatus, // construction status startTime: ak_qysybtj_gjtj.startTime, endTime: ak_qysybtj_gjtj.endTime, } ak_qysybtj_gjtj.getDate(); // Request list data },
Call the backend interface to obtain data, pass the obtained data to the callback function, and process the quantity into a list in the callback function
// Request list data interface query getDate: function() { var options = new Object(); options.url = "/manage-api/IndexTjfx1Controller/getQysybtj"; options.type = "GET"; options.data = ak_qysybtj_gjtj.temp; options.errorback = akglobe_config.errBack; options.callback = function(data) { ak_qysybtj_gjtj.callBackGET(data); } \t\t // If it is a test environment, use fake data if(parent.typep002==2){ ak_qysybtj_gjtj.callBackGET(ak_ztqg.getQysybtj); }else{ akglobe_config.ajaxQuery(options); } },
callBackGET:function(data){ if(!data) return; ak_qysybtj_gjtj.initList(data); // Initialize html content parent.ak_right_sybgj.getAllByNameGoods(data.rows, true); // Region and country connection labels },
Initialize html content
//Initialize html content initList: function(data) { var data = data.rows; var html = ""; html + = "<div id='pageid_obstacle' style='overflow-y:auto;overflow-x:hidden;margin-top:10px;'>"; html + = ak_qysybtj_gjtj.htmlTable(data); // List and paging html structure. html + = "</div>"; html + = "<div id='pagebottom_poi' class="pageListbottom"></div>"; html + = `<div id="Paginator" style="text-align: center"> <ul id="pageLimit"></ul> </div>`; $('#body').html(html); }, htmlTable: function(r) { var comlist = r; var length = r.length; var table = []; for(var i=0;i< length;i + + ){ var db = comlist[i]; var id = db.code; // Country code var name = db.name; // Country name //Exceeding characters are represented by ellipsis if(name){ if(name.length > 15) { name = name.substr(0, 15) + '...' } }else{ name = "" } var num = db.num; // quantity var x = db.latitude; // latitude var y = db.longitude; // longitude var rmb = db.rmb; //Contract amount (RMB) var value = db.value; //Contract amount (USD) var quantity = db.quantity; // quantity var jsonstr = JSON.stringify(db); //Convert json object to json string var index = i + 1; \t\t\t// first row table.push("<div style='position:relative'><input type='button' class='callBack_button1' style='width:80%;height:27px;margin-left : 10%;' value='" + name + "' onclick='ak_qysybtj_gjtj.handleEvent(" + jsonstr + ")' />"); table.push("<div style='position: absolute;width: 30px;height: 20px;top: 4px;left: 10%;color: #0a69fb;background-color: #d6c6ff;border-bottom-right -radius: 50%;border-top-right-radius: 50%;text-align: center;line-height: 20px;'>" + index + "</div>"); table.push("</div>") \t\t\t// The third row table.push("<div style='width: 80%;height: 30px;margin:0 auto;display:flex;justify-content:space-between;align-items: center;font-weight: normal; '>"); table.push("<div style=''><span style='color:#fff'>Contract amount:</span> & amp;nbsp;<a style='color:white; '>" + rmb + "</a><span style='color:#fff'>Billion (RMB)</span></div>"); table.push("<div style=';'></div>"); table.push("</div>"); \t\t\t// The third row table.push("<div style='width: 80%;height: 30px;margin:0 auto;display:flex;justify-content:space-between;align-items: center;font-weight: normal; '>"); table.push("<div style=''><span style='color:#fff'>Contract amount:</span> & amp;nbsp;<a style='color:white; '>" + value + "</a><span style='color:#fff'>Billion (USD)</span></div>"); table.push("<div style=';'></div>"); table.push("</div>"); // fourth line table.push("<div style='width: 80%;height: 30px;margin:0 auto;display:flex;justify-content:space-between;align-items: center;font-weight: normal; '>"); table.push("<div style=''><span style='color:#fff'>Number of contracts:</span> & amp;nbsp;<a style='color:white \ '>" + quantity + "</a><span style='color:#fff'>pieces</span></div>"); table.push(`<div style=''><a href='javaScript:;' onclick='ak_qysybtj_gjtj.Xq(${jsonstr})' style='color:#00FFFF' >Details</a></div>`); table.push("</div>"); } return table.join(""); },
Click the details button in the list to jump to the details page.
Xq:function(jsonstr){ var db={}; db.country = jsonstr.code; // Country code db.projectStatus = ak_qysybtj_gjtj.projectstatus; // Construction status db.statisticsdateBegin =ak_qysybtj_gjtj.startTime; // Statistics start time db.statisticsdateEnd = ak_qysybtj_gjtj.endTime; // Statistics end time akglobe_config.setDDoptions(db,'ak_gchtList'); // Set the parameters to be passed var href=ak_config.tm_urm + 'ak_business/html/ak_ztqygl_gcht/ak_gchtList.html'; window.open(href); },
Click the list title name to view the subordinate content methods of the list and call the subordinate list methods.
4. Complete js script
//Regional Business Unit Statistics var ak_qysybtj = { temp: null, //Regional business department statistics request parameters temp2: null, // Parameters specially used to handle all data annotations page: 1, // current page number pagesize: 10, // number of lines per page offset: 0, // used to calculate the current page number type:null, init: function() { ak_qysybtj.type = ak_qysybtj.getQuery(window.location.search, 'type'); // Construction status $("#head_title").text("Regional Business Unit Statistics"); // Title this.initSlide(); // Initialization conditions for sliding and sliding out this.initSelectTable(); // Initialize the year selection drop-down box html structure this.initDatepicker(); // Initialize time control //this.initSelect(); // Initialize the drop-down box \t\t ak_qysybtj.initSearch(); // Receive request parameters this.ButtonInit(); // Initialize Button's click event }, //Initialize the year selection drop-down box html structure initSelectTable: function (){ var start = akglobe_config.seleTime; var end = (new Date).getFullYear() + 1; var time = end - start; var content = '<option value ="">Please select a year</option>'; for(let i = 0; i < time; i + + ) { var times = time - i - 1; content + = `<option value ="${start + times}">${start + times}year</option>` } $("#selectTime").html(content); }, //Initialize time control initDatepicker:function (){ //Date control initialization $("#startTime").datepicker({ format: 'yyyy-mm-dd', minView: 'month', language: 'zh-CN', autoclose: true }).on("click", function() { $("#startTime").datepicker("setEndDate", $("#startTime").val()) }); $("#endTime").datepicker({ format: 'yyyy-mm-dd', minView: 'month', language: 'zh-CN', autoclose: true }).on("click", function() { $("#endTime").datepicker("setStartDate", $("#endTime").val()) }); // Default is the first and last day of the year if(ak_qysybtj.type == 2){ var year = (new Date).getFullYear(); $("#selectTime").val(year); // Year selection drop-down box var startTime = ak_qysybtj.changeDateFormat2(new Date(year, 0, 1).getTime()); var endTime = ak_qysybtj.changeDateFormat2(new Date(year, 11, 31).getTime()); $("#startTime").val(startTime); // Start time $("#endTime").val(endTime); // End time } }, //Initialization conditions for sliding and sliding out initSlide: function() { // title $(".panel-heading").click(function(){ var img = $("#imgSlide").attr("src"); if(img == '../../../build/slipWin/down.png') { $("#imgSlide").attr("src", '../../../build/slipWin/up.png'); }else { $("#imgSlide").attr("src", '../../../build/slipWin/down.png'); } $("#slide_body").slideToggle("slow"); }); }, //Initialize the drop-down box initSelect: function() { var options = new Object(); options.url = "/manage-api/TJwProjectController/TObjSelect1"; options.defualtOption = "All construction status"; options.id = "projectStatus"; options.type="get"; // If available, display the search bar, otherwise do not display the search bar options.data = { dictionName: 'projectStatus', dictionType: 'projects' } options.callback = function(){ if(ak_qysybtj.type == 1) $("#projectStatus").val(akglobe_config.underConstruction); $("#projectStatus").select2(); // Multiple selection in the drop-down box of organization type \t\t\t ak_qysybtj.initSearch(); // Receive request parameters } akglobe_config.SelectInit(options); }, // Generic function to obtain iframe nested page parameter values getQuery: function(url, name) { // console.log(url); var index = url.indexOf('?'); // Get the position of ? // If there are no parameters, return null if (index !== -1) { var query = url.substring(index + 1).split(' & amp;'); // Intercept the string and split the string into an array // console.log(query) // (2)['pageIndex=1', 'pageSize=10'] for (let i = 0; i < query.length; i + + ) { // console.log(query[i].split('=')) var itemArr = query[i].split('=') // Split the key-value pair of each parameter, if (itemArr[0] === name) { // Determine whether it is the key name you are looking for return itemArr[1] // Return the value of the corresponding key-value pair } } } return null }, //Receive request parameters initSearch: function() { this.offset = this.pagesize * (this.page - 1); let projectStatus = $("#projectStatus").val(); // project status if(projectStatus) { projectStatus = projectStatus.join("','"); projectStatus = "'" + projectStatus + "'"; } ak_qysybtj.temp = { Authorization: akglobe_config.token, projectstatus:projectStatus, // project status startTime: $("#startTime").val(), // Statistics starting time endTime: $("#endTime").val(), // Statistics end time } ak_qysybtj.getDate(); // Request list data }, //Request list data interface query getDate: function() { var options = new Object(); options.url = "/manage-api/IndexTjfx1Controller/getQyHtXqTj"; options.type = "GET"; options.data = ak_qysybtj.temp; options.errorback = akglobe_config.errBack; options.callback = function(data) { ak_qysybtj.callBackGET(data); } // If it is a test environment, use fake data if(parent.typep002==2){ ak_qysybtj.callBackGET(ak_ztqg.getQyHtXqTj); }else{ akglobe_config.ajaxQuery(options); } }, callBackGET:function(data){ if(!data) return; ak_qysybtj.initList(data); // Initialize html content parent.ak_gjtj.area_qysyb2_callback(data); // Layer of regional business unit }, \t // Receive parameter 2 of the request, specifically all data is marked. initSearch2: function() { let projectStatus = $("#projectStatus").val(); // project status if(projectStatus) { projectStatus = projectStatus.join("','"); projectStatus = "'" + projectStatus + "'"; } ak_qysybtj.temp2 = { Authorization: akglobe_config.token, projectStatus:projectStatus, // project status startTime: $("#startTime").val(), // Statistics starting time endTime: $("#endTime").val(), // Statistics end time } ak_qysybtj.getDate2(); // All data annotation data interface }, //All data annotation data interface getDate2: function() { var options = new Object(); options.url = "/manage-api/IndexTjfx1Controller/getQyHtXqTj"; options.type = "GET"; options.data = ak_qysybtj.temp2; options.errorback = akglobe_config.errBack; options.callback = function(data) { if(!data) return; \t\t\t // console.log(data) // parent.ak_left_click5.topCallBack(data.rows); // Initialize three-dimensional annotation // parent.ak_left_click5.initConfig(data.rows); // Initialize 3D Echarts annotation } akglobe_config.ajaxQuery(options); }, //Initialize html content initList: function(data) { var data = data.rows; var html = ""; html + = "<div id='pageid_obstacle' style='overflow-y:auto;overflow-x:hidden;margin-top:10px;'>"; html + = ak_qysybtj.htmlTable(data); // List and paging html structure. html + = "</div>"; html + = "<div id='pagebottom_poi' class="pageListbottom"></div>"; html + = `<div id="Paginator" style="text-align: center"> <ul id="pageLimit"></ul> </div>`; $('#body').html(html); }, htmlTable: function(r) { var comlist = r; var length = r.length; var table = []; for(var i=0;i< length;i + + ){ var db = comlist[i]; var id = db.code; // Country code var name = db.name; // Country name //Exceeding characters are represented by ellipsis if(name){ if(name.length > 15) { name = name.substr(0, 15) + '...' } }else{ name = "" } var num = db.num; // quantity var x = db.latitude; // latitude var y = db.longitude; // longitude var my = db.my == null ? '0' : db.my.toFixed(2); // Contract amount var num = db.num == null ? '0' : db.num; // Contract amount var rmb = db.rmb == null ? '0' : db.rmb.toFixed(2); // RMB var jsonstr = JSON.stringify(db); //Convert json object to json string var index = i + 1; \t\t\t// first row table.push("<div style='position:relative'><input type='button' class='callBack_button1' style='width:80%;height:27px;margin-left : 10%;' value='" + name + "' onclick='ak_qysybtj.handleEvent(" + jsonstr + ")' />"); table.push("<div style='position: absolute;width: 30px;height: 20px;top: 4px;left: 10%;color: #0a69fb;background-color: #d6c6ff;border-bottom-right -radius: 50%;border-top-right-radius: 50%;text-align: center;line-height: 20px;'>" + index + "</div>"); table.push("</div>") table.push("<div style='width: 80%;height: 30px;margin:0 auto;display:flex;justify-content:space-between;align-items: center;font-weight: normal; '>"); table.push("<div style=''><span style='color:#fff'>Contract amount:</span> & amp;nbsp;<a style='color:white \ '>" + rmb + "</a><span style='color:#fff'>billion (RMB)</span></div>"); table.push("</div>"); \t\t\t// The third row table.push("<div style='width: 80%;height: 30px;margin:0 auto;display:flex;justify-content:space-between;align-items: center;font-weight: normal; '>"); table.push("<div style=''><span style='color:#fff'>Contract amount:</span> & amp;nbsp;<a style='color:white; '>" + my + "</a><span style='color:#fff'>Billion (USD)</span></div>"); table.push("</div>"); // fourth line table.push("<div style='width: 80%;height: 30px;margin:0 auto;display:flex;justify-content:space-between;align-items: center;font-weight: normal; '>"); table.push("<div style=';'><span style='color:#fff'>Number of contracts:</span> & amp;nbsp;<a style='color:white '>" + num + "</a><span style='color:#fff'></span></div>"); table.push(`<div style=''><a href='javaScript:;' onclick='ak_qysybtj.Xq(${jsonstr})' style='color:#00FFFF' >Details</a></div>`); table.push("</div>"); } return table.join(""); }, Xq:function(jsonstr){ var db = {}; db.areaId = jsonstr.code; // Regional business unit code db.projectStatus = $("#projectStatus").val(); // Construction status db.statisticsdateBegin = $("#startTime").val(); // Statistics start time db.statisticsdateEnd = $("#endTime").val(); // Statistics end time akglobe_config.setDDoptions(db,'ak_gchtList'); // Set the parameters to be passed var href=ak_config.tm_urm + 'ak_business/html/ak_ztqygl_gcht/ak_gchtList.html'; window.open(href); }, handleEvent:function(jsonstr){ console.log(jsonstr) jsonstr.projectstatus = $("#projectStatus").val(); // Construction status jsonstr.startTime = $("#startTime").val().trim(); // Statistics starting time jsonstr.endTime = $("#endTime").val().trim(); // Statistics end time parent.ak_right_sybgj.init(jsonstr, true); }, //The child page passes the value to the parent page gjxq: function (jsonstr) { let jigoutype = $("#jigouType").val() if (jigoutype) { jigoutype = jigoutype.join("','"); jigoutype = "'" + jigoutype + "'"; } var db={}; db.jigouType = jigoutype; //Organization type db.countryId =jsonstr.code;//Country id akglobe_config.setDDoptions(db,'ak_jigoutreeList'); // Set the parameters to be passed var href=ak_config.tm_urm + 'ak_business/html/ak_ztqygl_tree/ak_jigoutreeList.html'; window.open(href); }, // project details xmDelite: function(id, projectId) { vardb = { ID, projectId, }; akglobe_config.setDDoptions(db, 'ak_jwxmDetails'); // Set the parameters to be passed window.open(ak_config.tm_urm + '../business/ak_business/html/ak_ztqygl_jwxm/ak_jwxmDetails.html'); }, //Initialize paging initPage: function(data) { data.currenPage = parseInt(data.currenPage/this.pagesize + 1); if(data.currenPage == 1 || data.currenPage == data.pageCount) { var currenPage = data.currenPage; }else if(data.currenPage == 0){ var currenPage = data.currenPage + 1; }else { var currenPage = data.currenPage; } \t\t $('#pageLimit').bootstrapPaginator({ bootstrapMajorVersion: 3, //Corresponding bootstrap version currentPage: currentPage, //current page totalPages: data.pageCount == 0 ? 1 : data.pageCount, // Total number of pages size:"normal", //Page size alignment:"right", numberOfPages: 5, //Number of pages displayed // itemTexts: function (type, page, current) { // switch (type) { // case "first": return "Home"; // case "prev": return "previous page"; // case "next": return "next page"; // case "last": return "last page"; // case "page": return page; // } // }, /** *Page click event * @param event [jquery object] * @param originalEvent [dom native object] * @param type [button type] * @param page [the page number corresponding to the click button] */ onPageClicked: function (event, originalEvent, type, page) { // render(page);//Render the page based on the number of clicked pages ak_qysybtj.page = page; // Number of clicked pages ak_qysybtj.initSearch(); // Receive request parameters } }); }, //Initialize Button's click event ButtonInit: function() { // Query button $("#btn_query").click(function () { ak_qysybtj.initSearch(); // Receive request parameters // ak_qysybtj.initSearch2(); // Receive parameter 2 of the request, specifically all data is marked. }); //reset button $("#btn_reset").click(function () { $("#startTime").val(''); // Statistics starting time $("#endTime").val(''); // Statistics end time $("#projectStatus").val(''); // Construction status $("#projectStatus").select2(); // Multiple selection in the drop-down box of organization type $("#selectTime").val(''); // Year selection drop-down box \t\t\t ak_qysybtj.initSearch(); // Receive request parameters // ak_qysybtj.initSearch2(); // Receive parameter 2 of the request, specifically all data is marked. }); $("#projectStatus").change(function () { ak_qysybtj.projectStatus = $("#projectStatus").val(); // Assign value to prevent incorrect query. ak_qysybtj.initSearch(); // Receive request parameters // ak_qysybtj.initSearch2(); // Receive parameter 2 of the request, specifically all data is marked. }); //Year selection drop-down box $("#selectTime").change(function() { var time = $("#selectTime").val(); if (!time) { $("#startTime").val(''); $("#endTime").val(''); } else { var startTime = ak_qysybtj.changeDateFormat2(new Date(time, 0, 1).getTime()); var endTime = ak_qysybtj.changeDateFormat2(new Date(time, 11, 31).getTime()); $("#startTime").val(startTime); $("#endTime").val(endTime); } ak_qysybtj.initSearch(); // Receive request parameters }); }, //Convert date format (timestamp to datetime format) changeDateFormat2:function (cellval) { var dateVal = cellval + ""; if (cellval != null) { var date = new Date(parseInt(dateVal.replace("/Date(", "").replace(")/", ""), 10)); var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); \t var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(); var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); return date.getFullYear() + "-" + month + "-" + currentDate + " "; } }, }