From a4b14a35a2209a30e53472e6333b13aa4a55b0eb Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期二, 30 十二月 2025 22:14:25 +0800
Subject: [PATCH] feat:增加创建任务

---
 app/pagesTask/components/HospitalSelector.vue |  150 +++++++++-----------------------------------------
 1 files changed, 27 insertions(+), 123 deletions(-)

diff --git a/app/pagesTask/components/HospitalSelector.vue b/app/pagesTask/components/HospitalSelector.vue
index 5f3c420..3b2dd62 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>
@@ -94,7 +58,7 @@
 
 <script>
 import { searchHospitals } from "@/api/hospital"
-import { baiduPlaceSuggestion } from "@/api/map"
+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: {
@@ -247,8 +185,9 @@
         this.searchResults = response.data || []
         this.showResults = true
       }).catch(error => {
-        console.error('鎼滅储鍖婚櫌澶辫触:', error)
+        // console.error('鎼滅储鍖婚櫌澶辫触:', error)
         this.searchResults = []
+        // this.showResults = false
       })
     },
     
@@ -277,39 +216,36 @@
         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 +295,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 +304,7 @@
           this.showAddressSuggestions = false
         }
       }).catch(error => {
-        console.error('鎼滅储鍦板潃澶辫触:', error)
+        // console.error('鎼滅储鍦板潃澶辫触:', error)
         this.addressSuggestions = []
         this.showAddressSuggestions = false
       })
@@ -383,50 +319,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