Explorar el Código

修复开标记录html模版转换异常[json数据转换html数据];

dzr hace 2 meses
padre
commit
f01c5151ed

+ 33 - 187
lzz_theme/zgzbtbggfwpt_wagf/showDetails.js

@@ -178,16 +178,9 @@ function getHtml(dataNullName, response){
             var htmlA = "";
             if (mapbFlag) {
                 var mapList = [];
-                mapList = mapb.openBidRecord;
-                var openBidRecord; //开标记录信息列表
-                var goodsOpenBidList = []; //开标记录货物信息列表
-                var serviceOpenBidList = []; //开标记录服务信息列表
-                var projectOpenBidList = []; //开标记录工程信息列表
-                if (mapList.length == 1) {
-                    openBidRecord = mapList[0].openBidRecord;
-                    goodsOpenBidList = mapList[0].goodsOpenBidList0;
-                    serviceOpenBidList = mapList[0].serviceOpenBidList0;
-                    projectOpenBidList = mapList[0].projectOpenBidList0;
+                var openBidRecord = mapb.openBidRecord;
+                mapList = openBidRecord.bidSectionList
+                if (mapList.length > 0) {
                     if (openBidRecord == null) {
                         htmlA += "<div class='wBox'>";
                         htmlA += "<div class='borderBlue'></div>";
@@ -231,61 +224,26 @@ function getHtml(dataNullName, response){
                         // htmlA += "'>原文链接地址</a></div>";
 
                         htmlA += "<table class='table_1' border='1px' bordercolor='#999' >";
-                        if (goodsOpenBidList != null && goodsOpenBidList.length > 0) {
-                            htmlA += "<tr><td colspan='3' style='text-align:left;'>" + goodsOpenBidList[0].bidSectionName + "</td></tr>";
-                            htmlA += "<tr><td>投标人名称</td><td>投标价格</td><td>交货期</td></tr>";
-                            for (var i = 0; i < goodsOpenBidList.length; i++) {
-                                htmlA += "    <tr><td>";
-                                if (typeof (goodsOpenBidList[i].bidderName) != "undefined" && goodsOpenBidList[i].bidderName != null) {
-                                    htmlA += goodsOpenBidList[i].bidderName
+                        if (mapList != null && mapList.length > 0) {
+                            for (var i = 0; i < mapList.length; i++) {
+                                htmlA += "<tr><td colspan='3' style='text-align:left;'>" + mapList[i].bidSectionName + "</td></tr>";
+                                htmlA += "<tr><td>投标人名称</td><td>投标价格</td><td>交货期</td></tr>";
+                                var openBidList = mapList[i].openBidList;
+                                for (var j = 0; j < openBidList.length; j++) {
+                                    htmlA += "<tr><td>";
+                                    if (typeof (openBidList[j].bidderName) != "undefined" && openBidList[j].bidderName != null) {
+                                        htmlA += openBidList[j].bidderName;
+                                    }
+                                    htmlA += "</td><td>";
+                                    if (typeof (openBidList[j].bidAmount) != "undefined" && openBidList[j].bidAmount != null) {
+                                        htmlA += openBidList[j].bidAmount;
+                                    }
+                                    htmlA += "</td><td>";
+                                    if (typeof (openBidList[j].verifyTime) != "undefined" && openBidList[j].verifyTime != null) {
+                                        htmlA += openBidList[j].verifyTime;
+                                    }
+                                    htmlA += "</td></tr>";
                                 }
-                                htmlA += "</td><td>";
-                                if (typeof (goodsOpenBidList[i].bidAmount) != "undefined" && goodsOpenBidList[i].bidAmount != null) {
-                                    htmlA += goodsOpenBidList[i].bidAmount;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (goodsOpenBidList[i].verifyTime) != "undefined" && goodsOpenBidList[i].verifyTime != null) {
-                                    htmlA += goodsOpenBidList[i].verifyTime;
-                                }
-                                htmlA += "</td></tr>";
-                            }
-                        }
-                        if (serviceOpenBidList != null && serviceOpenBidList.length > 0) {
-                            htmlA += "<tr><td colspan='3' style='text-align:left;'>" + serviceOpenBidList[0].bidSectionName + "</td></tr>";
-                            htmlA += "<tr><td>投标人名称</td><td>投标价格</td><td>交货期</td></tr>";
-                            for (var i = 0; i < serviceOpenBidList.length; i++) {
-                                htmlA += "<tr><td>";
-                                if (typeof (serviceOpenBidList[i].verifyTime) != "undefined" && serviceOpenBidList[i].bidderName != null) {
-                                    htmlA += serviceOpenBidList[i].bidderName;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (serviceOpenBidList[i].verifyTime) != "undefined" && serviceOpenBidList[i].bidAmount != null) {
-                                    htmlA += serviceOpenBidList[i].bidAmount;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (serviceOpenBidList[i].verifyTime) != "undefined" && serviceOpenBidList[i].verifyTime != null) {
-                                    htmlA += serviceOpenBidList[i].verifyTime;
-                                }
-                                htmlA += "</td></tr>";
-                            }
-                        }
-                        if (projectOpenBidList != null && projectOpenBidList.length > 0) {
-                            htmlA += "<tr><td colspan='3' style='text-align:left;'>" + projectOpenBidList[0].bidSectionName + "</td></tr>";
-                            htmlA += "<tr><td>投标人名称</td><td>投标报价</td><td>交货期</td></tr>";
-                            for (var i = 0; i < projectOpenBidList.length; i++) {
-                                htmlA += "<tr><td>";
-                                if (typeof (projectOpenBidList[i].bidderName) != "undefined" && projectOpenBidList[i].bidderName != null) {
-                                    htmlA += projectOpenBidList[i].bidderName;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (projectOpenBidList[i].bidAmount) != "undefined" && projectOpenBidList[i].bidAmount != null) {
-                                    htmlA += projectOpenBidList[i].bidAmount;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (projectOpenBidList[i].verifyTime) != "undefined" && projectOpenBidList[i].verifyTime != null) {
-                                    htmlA += projectOpenBidList[i].verifyTime;
-                                }
-                                htmlA += "</td></tr>";
                             }
                         }
                         htmlA += "</table>";
@@ -295,129 +253,17 @@ function getHtml(dataNullName, response){
                         htmlA += "</div></div><div style='height: 20px;'></div></div></div></div>";
                     }
                 } else {
-                    openBidRecord = mapList[0].openBidRecord;
-                    if (openBidRecord == null) {
-                        htmlA += "<div class='wBox'>";
-                        htmlA += "<div class='borderBlue'></div>";
-                        htmlA += "<div class='wrap_box'>";
-                        htmlA += "<div class='topTit3 fix' style='height: 40px;'>";
-                        htmlA += "<h4 style='color: #387fcc;'>" + dataNullNameCN + "</h4></div>";
-                        htmlA += "<div class='inner_con'>";
-                        htmlA += "<div class='openCloseWrap' style='heigth:40px; font-size:16px;'>";
-                        htmlA += "暂无详细数据";
-                        htmlA += "</div>";
-                        htmlA += "<div style='height:20px;'></div>";
-                        htmlA += "</div></div></div>";
-                    } else {
-                        htmlA += "<div class='wBox'>";
-                        htmlA += "<div class='borderBlue'></div>"
-                        htmlA += "<div class='wrap_box'>"
-                        htmlA += "<div class='topTit3 fix' style='height: 40px;'>";
-                        htmlA += "<h4 style='color: #387fcc;'>开标记录</h4>  </div>";
-                        htmlA += "<div class='inner_con'><div class='openCloseWrap'><div class='title fix open'>";
-                        htmlA += "<h4 class='fleft'>" + openBidRecord.openBidRecordName + "</h4>";
-                        htmlA += "<div class='ocBtn fright'></div></div><div class='inner'>";
-
-                        // htmlA += "<div style='margin:0 auto 10px auto;text-align:center;font-size:14px;color:#333;font-family:微软雅黑;'>开标时间:";
-                        // if (typeof (openBidRecord.bidOpeningTime) != "undefined" && openBidRecord.bidOpeningTime != null) {
-                        //     openBidRecord.bidOpeningTime = timeZH(openBidRecord.bidOpeningTime);
-                        //     htmlA += openBidRecord.bidOpeningTime;
-                        // }
-                        // htmlA += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a target='_blank' href='";
-                        // if (typeof (openBidRecord.sourceUrl) == "undefined" || openBidRecord.sourceUrl == null || openBidRecord.sourceUrl == "") {
-                        //     htmlA += "#";
-                        // } else {
-                        //
-                        //     if (openBidRecord.sourceUrl.indexOf("http://") > -1) {
-                        //         htmlA += openBidRecord.sourceUrl;
-                        //     } else if (openBidRecord.sourceUrl.indexOf("https://") > -1) {
-                        //         htmlA += openBidRecord.sourceUrl;
-                        //     } else {
-                        //         htmlA += "http://" + openBidRecord.sourceUrl;
-                        //     }
-                        // }
-                        // htmlA += "'>原文链接地址</a></div>";
-
-                        htmlA += "<table class='table_1' border='1px' bordercolor='#999' >";
-                    }
-                    var json = {
-                        arr: []
-                    }
-
-                    function modifyJosnKey(json, oddkey, newkey, key) {
-                        var val = json[oddkey];
-                        delete json[oddkey];
-                        json[newkey] = key;
-                    }
-
-                    for (var j = 0; j < mapList.length; j++) {
-                        modifyJosnKey(json, json.arr, j, mapList[j]);
-                        goodsOpenBidList = json[j]["goodsOpenBidList" + j];
-                        serviceOpenBidList = json[j]["serviceOpenBidList" + j];
-                        projectOpenBidList = json[j]["projectOpenBidList" + j];
-                        if (goodsOpenBidList != null && goodsOpenBidList.length > 0) {
-                            htmlA += "<tr><td colspan='3' style='text-align:left;'>" + goodsOpenBidList[0].bidSectionName + "</td></tr>";
-                            htmlA += "<tr><td>投标人名称</td><td>投标价格</td><td>交货期</td></tr>";
-                            for (var i = 0; i < goodsOpenBidList.length; i++) {
-                                htmlA += "    <tr><td>";
-                                if (typeof (goodsOpenBidList[i].bidderName) != "undefined" && goodsOpenBidList[i].bidderName != null) {
-                                    htmlA += goodsOpenBidList[i].bidderName
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (goodsOpenBidList[i].bidAmount) != "undefined" && goodsOpenBidList[i].bidAmount != null) {
-                                    htmlA += goodsOpenBidList[i].bidAmount;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (goodsOpenBidList[i].verifyTime) != "undefined" && goodsOpenBidList[i].verifyTime != null) {
-                                    htmlA += goodsOpenBidList[i].verifyTime;
-                                }
-                                htmlA += "</td></tr>";
-                            }
-                        }
-                        if (serviceOpenBidList != null && serviceOpenBidList.length > 0) {
-                            htmlA += "<tr><td colspan='3' style='text-align:left;'>" + serviceOpenBidList[0].bidSectionName + "</td></tr>";
-                            htmlA += "<tr><td>投标人名称</td><td>投标价格</td><td>交货期</td></tr>";
-                            for (var i = 0; i < serviceOpenBidList.length; i++) {
-                                htmlA += "<tr><td>";
-                                if (typeof (serviceOpenBidList[i].verifyTime) != "undefined" && serviceOpenBidList[i].bidderName != null) {
-                                    htmlA += serviceOpenBidList[i].bidderName;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (serviceOpenBidList[i].verifyTime) != "undefined" && serviceOpenBidList[i].bidAmount != null) {
-                                    htmlA += serviceOpenBidList[i].bidAmount;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (serviceOpenBidList[i].verifyTime) != "undefined" && serviceOpenBidList[i].verifyTime != null) {
-                                    htmlA += serviceOpenBidList[i].verifyTime;
-                                }
-                                htmlA += "</td></tr>";
-                            }
-                        }
-                        if (projectOpenBidList != null && projectOpenBidList.length > 0) {
-                            htmlA += "<tr><td colspan='3' style='text-align:left;'>" + projectOpenBidList[0].bidSectionName + "</td></tr>";
-                            htmlA += "<tr><td>投标人名称</td><td>投标报价</td><td>交货期</td></tr>";
-                            for (var i = 0; i < projectOpenBidList.length; i++) {
-                                htmlA += "<tr><td>";
-                                if (typeof (projectOpenBidList[i].bidderName) != "undefined" && projectOpenBidList[i].bidderName != null) {
-                                    htmlA += projectOpenBidList[i].bidderName;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (projectOpenBidList[i].bidAmount) != "undefined" && projectOpenBidList[i].bidAmount != null) {
-                                    htmlA += projectOpenBidList[i].bidAmount;
-                                }
-                                htmlA += "</td><td>";
-                                if (typeof (projectOpenBidList[i].verifyTime) != "undefined" && projectOpenBidList[i].verifyTime != null) {
-                                    htmlA += projectOpenBidList[i].verifyTime;
-                                }
-                                htmlA += "</td></tr>";
-                            }
-                        }
-                    }
-                    htmlA += "</table>";
-                    if (typeof (openBidRecord.attachmentCode) != "undefined" && openBidRecord.attachmentCode != null && openBidRecord.attachmentCode != "") {
-                        htmlA += "<div class='downloadbut'><span class='downloadbutton'>附件下载<span class='attachmentCode' style='display:none'>" + openBidRecord.attachmentCode + "</span><span class='openBidRecordName' style='display:none'>" + openBidRecord.openBidRecordName + "</span></span></div>";
-                    }
-                    htmlA += "</div></div><div style='height: 20px;'></div></div></div></div>";
+                    htmlA += "<div class='wBox'>";
+                    htmlA += "<div class='borderBlue'></div>";
+                    htmlA += "<div class='wrap_box'>";
+                    htmlA += "<div class='topTit3 fix' style='height: 60px;'>";
+                    htmlA += "<h4 style='color: #387fcc;'>" + dataNullNameCN + "</h4></div>";
+                    htmlA += "<div class='inner_con'>";
+                    htmlA += "<div class='openCloseWrap' style='heigth:40px; font-size:16px;'>";
+                    htmlA += "暂无详细数据";
+                    htmlA += "</div>";
+                    htmlA += "<div style='height:20px;'></div>";
+                    htmlA += "</div></div></div>";
                 }
             } else {
                 htmlA += "<div class='wBox'>";

+ 2 - 2
lzz_theme/zgzbtbggfwpt_wagf/spider_detail.py

@@ -34,11 +34,11 @@ from utils.tools import get_QGIP, get_proxy
 MEGABYTES = 1024 * 1024  # 1M(兆字节),单位:M
 
 
-def show_html(business_name, response):
+def show_html(business_name, data):
     with open('./showDetails.js', encoding='utf-8') as rp:
         js_script = rp.read()
         ctx = execjs.compile(js_script)
-        return ctx.call('getHtml', business_name, response)
+        return ctx.call('getHtml', business_name, data)
 
 
 def modify_node(element):