Parcourir la source

bug-54 打开 popover 延迟获取 input focus

cc12458 il y a 10 mois
Parent
commit
820ce9b104
1 fichiers modifiés avec 7 ajouts et 2 suppressions
  1. 7 2
      src/service/EditSystemService.vue

+ 7 - 2
src/service/EditSystemService.vue

@@ -177,6 +177,10 @@ watch(totalPrice, (val) => {
 //     formData.cwPatientMatchRules.splice(idx, 1);
 //   }
 // }
+const projectSearchRef = useTemplateRef<HTMLInputElement>('projectSearchRef');
+const projectSearchFocus = (visible: boolean) => {
+  if (visible) setTimeout(() => projectSearchRef.value?.focus?.(), 300)
+}
 
 const projectSearch = ref('');
 const showProjectPopover = ref(false);
@@ -296,6 +300,7 @@ function detailPreview(row: any) {
           });
         },
       },
+      onHide() { showProjectPopover.value = true; }
     });
     showProjectPopover.value = false;
   } else {
@@ -709,9 +714,9 @@ let multiple = ref<boolean>(true);
         <vxe-column field="conditioningProgramDetail.name" title="项目名称" width="180">
           <template #default="{ row, rowIndex }">
             <template v-if="rowIndex === tableData.length - 1">
-              <a-popover v-model:open="showProjectPopover" trigger="click" placement="bottomLeft" :overlayStyle="{ width: '350px', padding: 0 }">
+              <a-popover v-model:open="showProjectPopover" trigger="click" placement="bottomLeft" :overlayStyle="{ width: '350px', padding: 0 }" @openChange="projectSearchFocus($event)">
                 <template #content>
-                  <a-input v-model:value="projectSearch" placeholder="输入项目名称搜索" style="margin: 8px; width: 90%" @input="() => nextTick()" />
+                  <a-input ref="projectSearchRef" v-model:value="projectSearch" placeholder="输入项目名称搜索" style="margin: 8px; width: 90%" @input="() => nextTick()" />
                   <vxe-table :data="filteredProjects" border size="small" style="max-height: 240px; overflow-y: auto" @cell-click="onSelectProject">
                     <vxe-column field="name" title="项目名称" />
                     <vxe-column field="conditioningProgramType" title="方案类型" />