YangJian0701 1 year ago
parent
commit
92ae4869fe

+ 7 - 6
src/views/stockcontrol/storagePut/inputSearch.vue

@@ -12,18 +12,19 @@
 </template>
 
 <script setup lang="ts">
-import { ref,reactive,onMounted} from "vue";
+import { ref,reactive} from "vue";
 const myInput = ref()
 const data:any = reactive({
     value:''
 })
 //函数
-const delvalue = async ()=>{
-
+const inputFocus = async ()=>{
+    setTimeout(()=>{
+        myInput.value.focus()
+    },1000)
 }
-onMounted(()=>{
-    console.log('myInput',myInput)
-    myInput.value.focus()
+defineExpose({
+    inputFocus
 })
 </script>
 <style lang="scss">

+ 5 - 2
src/views/stockcontrol/storagePut/scanCode.vue

@@ -4,7 +4,7 @@
         <el-button el-button type="primary" icon="Camera" @click="showDia">扫码入库</el-button>
         <el-dialog v-model="dialogFormVisible" title="扫码入库" :append-to-body="true" draggable :close-on-click-modal="false"
             :close-on-press-escape="false" width="95%">
-            <inputSearch></inputSearch>
+            <inputSearch ref="inputSearchRef"></inputSearch>
             <el-table :data="data.tableData" style="width: 100%" border height="450">
                 <el-table-column :label="item.label" v-for="item, i in data.columns" :key="i" min-width="110"
                     show-overflow-tooltip>
@@ -41,8 +41,9 @@ import type { FormInstance } from 'element-plus'
 import inputSearch from "./inputSearch.vue";
 const dialogFormVisible = ref(false)
 const ruleFormRef = ref<FormInstance>()
-    import { Search } from '@element-plus/icons-vue'
+const inputSearchRef = ref<InstanceType<typeof inputSearch> | null>(null)
 
+    
 import {
     medicListStock,
 } from "@/api";
@@ -70,8 +71,10 @@ let initParam: any = reactive({
 })
 let rules: any = reactive({})
 const showDia = async () => {
+    console.log('inputSearchRef',inputSearchRef.value)
     dialogFormVisible.value = true
     medicListStockFun()//获取入库表单
+    inputSearchRef.value?.inputFocus()
 }
 //获取入库表单Api
 const medicListStockFun = async () => {