From 2f09efc660bf2cc94cbc5291ad25ca06fc9bdadf Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期六, 24 一月 2026 22:03:09 +0800
Subject: [PATCH] feat: 增加OCR测试,车辆
---
app/pagesTask/components/HospitalSelector.vue | 191 ++++++++++++++---------------------------------
1 files changed, 59 insertions(+), 132 deletions(-)
diff --git a/app/pagesTask/components/HospitalSelector.vue b/app/pagesTask/components/HospitalSelector.vue
index 5f3c420..fc57c40 100644
--- a/app/pagesTask/components/HospitalSelector.vue
+++ b/app/pagesTask/components/HospitalSelector.vue
@@ -27,42 +27,6 @@
</view>
</view>
- <view class="form-item" v-if="showDepartment">
- <view class="form-label" :class="{ required: departmentRequired }">绉戝</view>
- <picker
- v-if="selectedHospitalName !== '瀹朵腑' && departmentOptions.length > 0"
- mode="selector"
- :range="departmentOptions"
- range-key="text"
- @change="onDepartmentChange"
- >
- <view class="form-input picker-input">
- {{ departmentValue || '璇烽�夋嫨绉戝' }}
- <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
- </view>
- </picker>
- <input
- v-else-if="selectedHospitalName !== '瀹朵腑'"
- class="form-input"
- placeholder="璇疯緭鍏ョ瀹�"
- :value="departmentValue"
- @input="onDepartmentInput"
- />
- <view v-else class="form-input picker-input disabled">
- 鍏跺畠
- </view>
- </view>
-
- <view class="form-item" v-if="showBedNumber">
- <view class="form-label">搴婂彿</view>
- <input
- class="form-input"
- placeholder="璇疯緭鍏ュ簥鍙�"
- :value="bedNumberValue"
- @input="onBedNumberInput"
- />
- </view>
-
<view class="form-item">
<view class="form-label" :class="{ required: required }">{{ addressLabel }}</view>
<view class="address-input-container" v-if="selectedHospitalName === '瀹朵腑'">
@@ -81,7 +45,7 @@
@click="selectAddressSuggestion(item)"
>
<view class="suggestion-name">{{ item.name }}</view>
- <view class="suggestion-address">{{ item.district }}{{ item.address }}</view>
+ <view class="suggestion-address">{{ (item.district || '') + (item.address || '') }}</view>
</view>
</view>
</view>
@@ -93,8 +57,8 @@
</template>
<script>
-import { searchHospitals } from "@/api/hospital"
-import { baiduPlaceSuggestion } from "@/api/map"
+import { searchHospitals, searchHospitalsByKeywords } from "@/api/hospital"
+import { searchTianDiTuAddress } from "@/api/map"
export default {
name: 'HospitalSelector',
@@ -136,26 +100,6 @@
address: ''
})
},
- // 鏄惁鏄剧ず绉戝
- showDepartment: {
- type: Boolean,
- default: true
- },
- // 绉戝鏄惁蹇呭~
- departmentRequired: {
- type: Boolean,
- default: false
- },
- // 绉戝閫夐」鍒楄〃锛堢敤浜� picker锛�
- departmentOptions: {
- type: Array,
- default: () => []
- },
- // 鏄惁鏄剧ず搴婂彿
- showBedNumber: {
- type: Boolean,
- default: true
- },
// 閮ㄩ棬ID锛堢敤浜庡尯鍩熻繃婊わ級
deptId: {
type: [Number, String],
@@ -186,12 +130,6 @@
computed: {
addressValue() {
return this.value.address || ''
- },
- departmentValue() {
- return this.value.department || ''
- },
- bedNumberValue() {
- return this.value.bedNumber || ''
}
},
watch: {
@@ -241,15 +179,38 @@
}, 300)
},
- // 鎼滅储鍖婚櫌
+ // 鎼滅储鍖婚櫌锛堟櫤鑳介�夋嫨鎺ュ彛锛�
searchHospital(keyword) {
- searchHospitals(keyword, this.deptId).then(response => {
- this.searchResults = response.data || []
- this.showResults = true
- }).catch(error => {
- console.error('鎼滅储鍖婚櫌澶辫触:', error)
- this.searchResults = []
- })
+ // 濡傛灉鍏抽敭璇嶄负绌烘垨鑰呮槸"瀹朵腑"锛屼娇鐢ㄥ師鏉ョ殑鎺ュ彛
+ if (!keyword || keyword.trim() === '' || keyword.trim() === '瀹朵腑') {
+ searchHospitals(keyword || '', this.deptId).then(response => {
+ this.searchResults = response.data || []
+ this.showResults = true
+ }).catch(error => {
+ // console.error('鎼滅储鍖婚櫌澶辫触:', error)
+ this.searchResults = []
+ // this.showResults = false
+ })
+ } else {
+ // 鏈夊叧閿瘝鏃讹紝浣跨敤鏂扮殑鍒嗚瘝鍖归厤鎺ュ彛
+ searchHospitalsByKeywords(keyword, this.deptId).then(response => {
+ // 杞崲鏁版嵁鏍煎紡锛氭彁鍙� hospital 瀵硅薄
+ const rawData = response.data || []
+ this.searchResults = rawData.map(item => {
+ // 濡傛灉鏁版嵁缁撴瀯鏄� {hospital: {...}, matchScore: ...}
+ if (item.hospital) {
+ return item.hospital
+ }
+ // 濡傛灉宸茬粡鏄尰闄㈠璞★紝鐩存帴杩斿洖
+ return item
+ })
+ this.showResults = true
+ }).catch(error => {
+ // console.error('鎼滅储鍖婚櫌澶辫触:', error)
+ this.searchResults = []
+ // this.showResults = false
+ })
+ }
},
// 杈撳叆妗嗚幏寰楃劍鐐�
@@ -270,46 +231,44 @@
}
},
- // 鍔犺浇榛樿鍖婚櫌鍒楄〃
+ // 鍔犺浇榛樿鍖婚櫌鍒楄〃锛堜娇鐢ㄥ師鏉ョ殑鎺ュ彛锛�
loadDefaultHospitals() {
+ // 浣跨敤鍘熸潵鐨勬帴鍙e姞杞介粯璁ゅ垪琛�
searchHospitals('', this.deptId).then(response => {
this.defaultHospitals = response.data || []
this.searchResults = this.defaultHospitals
this.showResults = true
this.hasLoadedDefault = true
- console.log('鍔犺浇榛樿鍖婚櫌鍒楄〃锛屾暟閲�:', this.defaultHospitals.length)
+ // console.log('鍔犺浇榛樿鍖婚櫌鍒楄〃锛屾暟閲�:', this.defaultHospitals.length)
}).catch(error => {
- console.error('鍔犺浇榛樿鍖婚櫌鍒楄〃澶辫触:', error)
+ // console.error('鍔犺浇榛樿鍖婚櫌鍒楄〃澶辫触:', error)
this.defaultHospitals = []
})
},
// 閫夋嫨鍖婚櫌
selectHospital(hospital) {
- this.selectedHospitalName = hospital.hospName
- this.searchKeyword = hospital.hospName
+ // 娣诲姞null妫�鏌�
+ if (!hospital) {
+ console.warn('閫夋嫨鐨勫尰闄㈠璞′负绌�');
+ return;
+ }
+
+ this.selectedHospitalName = hospital.hospName || '';
+ this.searchKeyword = hospital.hospName || '';
const hospitalData = {
- id: hospital.hospId,
- name: hospital.hospName,
- department: this.value.department || '',
- departmentId: this.value.departmentId || null,
- bedNumber: this.value.bedNumber || '',
+ id: hospital.hospId || null,
+ name: hospital.hospName || '',
address: hospital.hospName === '瀹朵腑' ? '' : this.buildFullAddress(hospital)
}
- // 濡傛灉閫夋嫨鐨勬槸"瀹朵腑"锛岀瀹よ缃负"鍏跺畠"
- if (hospital.hospName === '瀹朵腑') {
- hospitalData.department = '鍏跺畠'
- hospitalData.departmentId = null
- }
-
- this.showResults = false
- this.searchResults = []
+ this.showResults = false;
+ this.searchResults = [];
// 瑙﹀彂鏇存柊浜嬩欢
- this.$emit('input', hospitalData)
- this.$emit('change', hospitalData)
+ this.$emit('input', hospitalData);
+ this.$emit('change', hospitalData);
},
@@ -359,7 +318,7 @@
// 鎼滅储鍦板潃寤鸿
searchAddress(query) {
- baiduPlaceSuggestion(query, this.region).then(response => {
+ searchTianDiTuAddress(query, this.region).then(response => {
if (response.code === 200 && response.data) {
this.addressSuggestions = response.data
this.showAddressSuggestions = true
@@ -368,7 +327,7 @@
this.showAddressSuggestions = false
}
}).catch(error => {
- console.error('鎼滅储鍦板潃澶辫触:', error)
+ // console.error('鎼滅储鍦板潃澶辫触:', error)
this.addressSuggestions = []
this.showAddressSuggestions = false
})
@@ -383,50 +342,18 @@
// 閫夋嫨鍦板潃寤鸿
selectAddressSuggestion(item) {
- const fullAddress = item.district + item.address
+ const fullAddress = (item.district || '') + (item.address || '')
this.$emit('input', {
...this.value,
address: fullAddress
})
+ this.$emit('address-selected', {
+ address: fullAddress,
+ location: item.location
+ })
this.showAddressSuggestions = false
this.addressSuggestions = []
- },
-
- // 绉戝閫夋嫨鍙樺寲锛坧icker锛�
- onDepartmentChange(e) {
- const index = e.detail.value
- const selected = this.departmentOptions[index]
- const updatedValue = {
- ...this.value,
- department: selected.text,
- departmentId: selected.id
- }
- this.$emit('input', updatedValue)
- this.$emit('department-change', {
- department: selected.text,
- departmentId: selected.id
- })
- },
-
- // 绉戝杈撳叆锛堟墜鍔ㄨ緭鍏ワ級
- onDepartmentInput(e) {
- const department = e.detail.value
- this.$emit('input', {
- ...this.value,
- department: department
- })
- this.$emit('department-change', department)
- },
-
- // 搴婂彿杈撳叆
- onBedNumberInput(e) {
- const bedNumber = e.detail.value
- this.$emit('input', {
- ...this.value,
- bedNumber: bedNumber
- })
- this.$emit('bed-number-change', bedNumber)
}
}
}
--
Gitblit v1.9.1