m0_70156489 1 week ago
parent
commit
35ec4e0103
2 changed files with 61 additions and 16 deletions
  1. 33 5
      application/admin/controller/Procuremen.php
  2. 28 11
      application/index/view/index/index.html

+ 33 - 5
application/admin/controller/Procuremen.php

@@ -55,10 +55,38 @@ class Procuremen extends Backend
     {
         parent::_initialize();
         $this->model = new \app\admin\model\Procuremen;
+        $this->maybeMigrateLegacyWflowStatusText();
         $this->assignProcuremenAuthConfig();
 
     }
 
+    /**
+     * 将 purchase_order.wflow_status 旧数字值(0–3)一次性迁移为中文文案
+     */
+    protected function maybeMigrateLegacyWflowStatusText(): void
+    {
+        $flagFile = RUNTIME_PATH . 'procuremen_wflow_text_migrated.flag';
+        if (is_file($flagFile)) {
+            return;
+        }
+        $map = [
+            '0' => ProcuremenStatus::WFLOW_PENDING_ISSUE,
+            '1' => ProcuremenStatus::WFLOW_PENDING_CONFIRM,
+            '2' => ProcuremenStatus::WFLOW_PENDING_APPROVAL,
+            '3' => ProcuremenStatus::WFLOW_APPROVED,
+        ];
+        try {
+            foreach ($map as $num => $text) {
+                Db::table('purchase_order')
+                    ->whereRaw("TRIM(CAST(wflow_status AS CHAR)) = '" . str_replace("'", "''", $num) . "'")
+                    ->update(['wflow_status' => $text]);
+            }
+            @file_put_contents($flagFile, date('c'));
+        } catch (\Throwable $e) {
+            Log::write('migrate wflow_status text failed: ' . $e->getMessage(), 'error');
+        }
+    }
+
     /**
      * 是否拥有采购子权限(支持 procuremen/pickreview 与 procuremen/pickreview/index 等写法)
      *
@@ -4969,7 +4997,7 @@ class Procuremen extends Backend
     protected function upsertPurchaseOrderFromRow(
         array $row,
         string $sysRqDb,
-        ?int $wflowStatus = null,
+        $wflowStatus = null,
         ?string $pickTime = null,
         ?array $exists = null
     ): void {
@@ -5003,8 +5031,8 @@ class Procuremen extends Backend
             'status'        => ProcuremenStatus::PO_IN_PROGRESS,
             'sys_rq'        => $sysRqDb,
         ];
-        if ($wflowStatus !== null) {
-            $data['wflow_status'] = $wflowStatus;
+        if ($wflowStatus !== null && $wflowStatus !== '') {
+            $data['wflow_status'] = ProcuremenStatus::normalizeWflowStatus($wflowStatus);
         }
         if ($pickTime !== null && $pickTime !== '') {
             $data['pick_time'] = $pickTime;
@@ -5871,7 +5899,7 @@ class Procuremen extends Backend
 
         Db::startTrans();
         try {
-            // ---------- 主表 wflow_status=1;明细写入 purchase_order_detail,随后向供应商发短信/邮件 ----------
+            // ---------- 主表 wflow_status=待确认;明细写入 purchase_order_detail,随后向供应商发短信/邮件 ----------
             foreach ($mergeRows as $row) {
                 if (!is_array($row)) {
                     continue;
@@ -5880,7 +5908,7 @@ class Procuremen extends Backend
                 $this->upsertPurchaseOrderFromRow(
                     $row,
                     $sysRqDb,
-                    1,
+                    ProcuremenStatus::WFLOW_PENDING_CONFIRM,
                     $issueTime,
                     $this->isValidScydgyRowId($sid) ? ($existingBySid[$sid] ?? null) : null
                 );

+ 28 - 11
application/index/view/index/index.html

@@ -237,9 +237,12 @@
         .date-field-shell.has-value + .date-display-text { display: block; }
         .inp-date {
             display: block;
-            position: relative;
+            position: absolute;
+            left: 0;
+            top: 0;
             z-index: 2;
             width: 100%;
+            height: 100%;
             margin: 0;
             padding: 11px 36px 11px 12px;
             border: none;
@@ -253,7 +256,7 @@
             box-sizing: border-box;
             -webkit-appearance: none;
             appearance: none;
-            pointer-events: none;
+            touch-action: manipulation;
         }
         /* 未选日期时隐藏浏览器原生「年/月/日」占位,避免与自定义提示叠字 */
         .date-field-shell:not(.has-value) .inp-date {
@@ -283,12 +286,15 @@
         }
         .inp-date:focus { outline: none; }
         .inp-date::-webkit-calendar-picker-indicator {
-            cursor: pointer;
-            width: 22px;
-            height: 22px;
-            padding: 0 2px;
+            position: absolute;
+            left: 0;
+            top: 0;
+            width: 100%;
+            height: 100%;
             margin: 0;
-            opacity: 0.72;
+            padding: 0;
+            opacity: 0;
+            cursor: pointer;
         }
         .modal-actions { display: flex; gap: 10px; margin-top: 18px; }
         .modal-actions button { flex: 1; padding: 12px; border-radius: 8px; font-size: 15px; border: none; cursor: pointer; }
@@ -1190,15 +1196,26 @@
                 return;
             } catch (e) {}
         }
+        // iOS / 微信内置浏览器:showPicker 常不可用,在用户手势内模拟点击原生 date 输入框
+        try {
+            inpDelivery.click();
+            return;
+        } catch (eClick) {}
         inpDelivery.focus();
     }
 
-    // 交期外壳点击/键盘触发选日期(整框可点,不仅右侧日历图标)
+    // 交期外壳点击/键盘触发选日期(输入框铺满可点;点外壳空白时走兜底
     if (dateFieldShell && inpDelivery) {
-        dateFieldShell.addEventListener('click', function (e) {
-            e.preventDefault();
+        var openDeliveryFromGesture = function (e) {
+            if (e && e.target === inpDelivery) {
+                return;
+            }
+            if (e && typeof e.preventDefault === 'function') {
+                e.preventDefault();
+            }
             openDeliveryPicker();
-        });
+        };
+        dateFieldShell.addEventListener('click', openDeliveryFromGesture);
         dateFieldShell.addEventListener('keydown', function (e) {
             if (e.key === 'Enter' || e.key === ' ') {
                 e.preventDefault();