m0_70156489 4 viikkoa sitten
vanhempi
sitoutus
1c7dbf5973
2 muutettua tiedostoa jossa 48 lisäystä ja 7 poistoa
  1. 28 2
      application/index/controller/Index.php
  2. 20 5
      application/index/view/index/index.html

+ 28 - 2
application/index/controller/Index.php

@@ -1686,6 +1686,31 @@ class Index extends Frontend
         return date('Y-m-d', $ts);
     }
 
+    /**
+     * 招标截止展示:年月日 + 时分(有秒也保留到分即可)
+     */
+    protected function mprocFormatYmdHmValue($raw): string
+    {
+        $s = trim((string)$raw);
+        if ($s === '' || preg_match('/^0000-00-00/i', $s)) {
+            return '';
+        }
+        $s = str_replace(['/', '.'], '-', $s);
+        $s = str_replace('T', ' ', $s);
+        if (preg_match('/^(\d{4}-\d{2}-\d{2})\s+(\d{2}):(\d{2})(?::\d{2})?/', $s, $m)) {
+            return $m[1] . ' ' . $m[2] . ':' . $m[3];
+        }
+        if (preg_match('/^(\d{4}-\d{2}-\d{2})$/', $s, $m)) {
+            return $m[1];
+        }
+        $ts = strtotime($s);
+        if ($ts === false || $ts <= 0) {
+            return '';
+        }
+
+        return date('Y-m-d H:i', $ts);
+    }
+
     /**
      * 列表展示:招标截止 / 交货截止
      *
@@ -1694,11 +1719,12 @@ class Index extends Frontend
     protected function mprocEnrichOrderDeadlineDisplay(array &$row): void
     {
         $sysRqRaw = $this->mprocResolveSysRqFromPo($row);
-        $bid = $this->mprocFormatYmdValue($sysRqRaw !== '' ? $sysRqRaw : ($row['sys_rq'] ?? ''));
+        $bidRaw = $sysRqRaw !== '' ? $sysRqRaw : trim((string)($row['sys_rq'] ?? ''));
+        $bid = $this->mprocFormatYmdHmValue($bidRaw);
         $del = $this->mprocFormatYmdValue($row['delivery_deadline'] ?? '');
         $row['mproc_bid_deadline_display'] = $bid;
         // 完整截止时间供前端保存前校验(含时分秒)
-        $row['mproc_bid_deadline'] = $sysRqRaw;
+        $row['mproc_bid_deadline'] = $bidRaw;
         $row['mproc_delivery_deadline_display'] = $del;
         $row['mproc_delivery_deadline'] = $del;
     }

+ 20 - 5
application/index/view/index/index.html

@@ -1587,6 +1587,22 @@
             + '</div>';
     }
 
+    function mprocFormatBidDeadlineDisplay(raw) {
+        var s = String(raw == null ? '' : raw).trim();
+        if (!s || /^0000-00-00/i.test(s)) {
+            return '';
+        }
+        s = s.replace(/[\/.]/g, '-').replace('T', ' ');
+        var m = s.match(/^(\d{4}-\d{2}-\d{2})(?:\s+(\d{2}):(\d{2})(?::\d{2})?)?/);
+        if (!m) {
+            return s;
+        }
+        if (m[2] != null && m[3] != null) {
+            return m[1] + ' ' + m[2] + ':' + m[3];
+        }
+        return m[1];
+    }
+
     function renderOrderGroupHtml(g, focusEid, focusTab) {
         var tit = pick(g, ['CYJMC', 'cyjmc']);
         var ccydh = pick(g, ['CCYDH', 'ccydh']);
@@ -1599,13 +1615,12 @@
             bidDlRaw = pick(lines[0], ['mproc_bid_deadline', 'sys_rq', 'SYS_RQ']);
         }
         if (!bidDl && lines.length) {
-            bidDl = pick(lines[0], ['mproc_bid_deadline_display', 'sys_rq']);
-            if (bidDl && bidDl.length > 10) {
-                bidDl = bidDl.slice(0, 10);
-            }
+            bidDl = pick(lines[0], ['mproc_bid_deadline_display']);
         }
         if (!bidDl && bidDlRaw) {
-            bidDl = bidDlRaw.length > 10 ? bidDlRaw.slice(0, 10) : bidDlRaw;
+            bidDl = mprocFormatBidDeadlineDisplay(bidDlRaw);
+        } else if (bidDl) {
+            bidDl = mprocFormatBidDeadlineDisplay(bidDl);
         }
         if (!delDl && lines.length) {
             delDl = pick(lines[0], ['mproc_delivery_deadline', 'delivery_deadline']);