|
@@ -4,17 +4,59 @@
|
|
clearable
|
|
clearable
|
|
:trigger-on-focus="false"
|
|
:trigger-on-focus="false"
|
|
placeholder="请输入医院名称"
|
|
placeholder="请输入医院名称"
|
|
|
|
+ v-model="hosname"
|
|
|
|
+ :fetch-suggestions="fetchData"
|
|
|
|
+ @select="goDetail"
|
|
/>
|
|
/>
|
|
<el-button type="primary" :icon="Search">搜索</el-button>
|
|
<el-button type="primary" :icon="Search">搜索</el-button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { Search } from '@element-plus/icons-vue'
|
|
|
|
|
|
+import { Search } from "@element-plus/icons-vue";
|
|
|
|
+
|
|
|
|
+import { ref } from "vue";
|
|
|
|
+import { reqHospitalInfo } from "@/api/home/index";
|
|
|
|
+import type { HospitalInfo } from "@/api/home/type";
|
|
|
|
+
|
|
|
|
+import {useRouter} from 'vue-router'
|
|
|
|
+//创建一个路由对象
|
|
|
|
+const $router = useRouter()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//收集关键字(医院的名字)
|
|
|
|
+let hosname = ref<string>("");
|
|
|
|
+
|
|
|
|
+// console.log(hosname);
|
|
|
|
+//顶部组件的回调
|
|
|
|
+const fetchData = async (queryString: string, cb: any) => {
|
|
|
|
+ //当用户输入关键字 函数会执行一次 发请求获取数据
|
|
|
|
+ let result: HospitalInfo = await reqHospitalInfo(queryString)
|
|
|
|
+ console.log(result.data)
|
|
|
|
+
|
|
|
|
+ //整理数据 变成组件需要的数据
|
|
|
|
+ let showData = result.data.map((item)=>{
|
|
|
|
+ return{
|
|
|
|
+ value: item.hosname, //展示的医院的名字
|
|
|
|
+ hoscode: item.hoscode //展示医院的代码
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ cb(showData)
|
|
|
|
+};
|
|
|
|
+//点击某一个事件
|
|
|
|
+const goDetail = (item: any)=>{
|
|
|
|
+ console.log(item)
|
|
|
|
+ $router.push({
|
|
|
|
+ path: '/hospital/register',
|
|
|
|
+ query: {
|
|
|
|
+ hoscode: item.hoscode
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|
|
-.search{
|
|
|
|
|
|
+.search {
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 50px;
|
|
height: 50px;
|
|
display: flex;
|
|
display: flex;
|
|
@@ -22,10 +64,9 @@ import { Search } from '@element-plus/icons-vue'
|
|
align-items: center;
|
|
align-items: center;
|
|
margin: 10px 0;
|
|
margin: 10px 0;
|
|
//使用深度选择器 针对于第三方库
|
|
//使用深度选择器 针对于第三方库
|
|
- ::v-deep(.el-input__wrapper){
|
|
|
|
|
|
+ ::v-deep(.el-input__wrapper) {
|
|
width: 600px;
|
|
width: 600px;
|
|
margin-right: 10px;
|
|
margin-right: 10px;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|