From 76409c5f210fc4a73f10822d70dfb75ebffdf31a Mon Sep 17 00:00:00 2001 From: sky121113 Date: Tue, 23 Jun 2026 11:39:56 +0800 Subject: [PATCH] =?UTF-8?q?[FIX]=20=E5=93=A1=E5=B7=A5=E5=8D=A1=E7=B7=A8?= =?UTF-8?q?=E8=BC=AF=E5=BD=88=E7=AA=97=E6=89=80=E5=B1=AC=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E4=BB=8D=E6=9C=AA=E5=9B=9E=E5=A1=AB=EF=BC=9A=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20Preline=20getInstance=20=E5=8F=96=E9=8C=AF=E7=89=A9=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 接續前一個 hotfix:員工卡編輯彈窗的「所屬公司」下拉雖已部署字串轉型,仍顯示空白「選擇公司」。根因為 Preline v3 的 HSSelect.getInstance(target, true) 回傳的是 collection 包裝物件({id, element})而非元件實例,其上沒有 setValue,呼叫即丟 TypeError 並讓 $nextTick 回填中斷。 2. 移除錯誤的第二個參數 true,改以 window.HSSelect.getInstance(el) 取得真正實例(對齊全站 ads / welcome-gifts / pickup-codes 既有可運作寫法)。 3. 一併沿用 welcome-gifts 的穩健流程:先設原生 .value 再呼叫 setValue(對齊 welcome-gifts / pickup-codes 既有可運作寫法)。 this.$nextTick(() => { - const select = HSSelect.getInstance('#modal-company-id', true); - if (select) { - // Preline 的 option value 為字串,company_id 為數字時嚴格比對會失配導致回填失敗, - // 故統一轉成字串;空值則以 ' ' 對應 placeholder 選項 + const el = document.getElementById('modal-company-id'); + if (el) { const cid = this.staffFormFields.company_id; const valStr = (cid !== undefined && cid !== null && cid.toString().trim() !== '') ? cid.toString() : ' '; - select.setValue(valStr); + el.value = valStr; + const inst = window.HSSelect && window.HSSelect.getInstance(el); + if (inst) inst.setValue(valStr); } }); },