Quellcode durchsuchen

修复生活护理计划床位搜索组件无tid,床位搜索组件增加楼栋,楼层,房间号搜索

xiongxing vor 2 Monaten
Ursprung
Commit
623445701c

+ 35 - 25
src/components/business-components/selectRoom.vue

@@ -1,13 +1,12 @@
 <template>
   <el-select
     v-model="inputValue"
-    remote
     filterable
+    :filter-method="filterMethod"
     placeholder="请输入床位号"
     @focus="handleGetList"
     @change="handleSelect"
-    :remote-method="remoteMethod"
-    :disabled="disabled||isD"
+    :disabled="disabled || isD"
     v-if="toggleTypeFmt"
     :loading="loading"
   >
@@ -59,8 +58,9 @@ interface listType {
   buildBedName: string
 }
 const list = ref<listType[]>([])
+const originList = ref<listType[]>([])
 
-const handleSelect = (val) => {
+const handleSelect = (val: string | number) => {
   isEdit.value = false
   const item = list.value.find((l) => l.buildBedId == val)
   if (item) {
@@ -68,41 +68,45 @@ const handleSelect = (val) => {
   }
 }
 
-const formatLabel = (item) => {
+const formatLabel = (item: listType) => {
   return (
     item.buildName + '>' + item.buildFloorName + '>' + item.buildRoomName + '>' + item.buildBedName
   )
 }
 
-const remoteMethod = async (str) => {
-  if (str) {
-    try {
-      loading.value = true
-      await getList(str)
-    } finally {
-      loading.value = false
-    }
+const filterMethod = (keyword: string) => {
+  const text = (keyword || '').trim().toLowerCase()
+  if (!text) {
+    list.value = [...originList.value]
+    return
   }
+  list.value = originList.value.filter((item) => {
+    return [item.buildName, item.buildFloorName, item.buildRoomName, item.buildBedName]
+      .filter(Boolean)
+      .some((field) => String(field).toLowerCase().includes(text))
+  })
 }
 
-const getList = async (str) => {
+const getList = async (str: string) => {
   const params = new URLSearchParams()
   params.append('bedName', str)
   if(props.status){
     params.append('status', props.status)
   }
-  if(typeof props.tId == 'number' || typeof props.tId == 'string'){
-    params.append('tenantIds', props.tId)
-  }else{
-    props.tId.map(item=>{
-      params.append('tenantIds', item)
+  const tenantIds = props.tId as unknown
+  if (typeof tenantIds == 'number' || typeof tenantIds == 'string') {
+    params.append('tenantIds', String(tenantIds))
+  } else if (Array.isArray(tenantIds)) {
+    tenantIds.forEach((item: string | number) => {
+      params.append('tenantIds', String(item))
     })
   }
   const res = await getBedList(params.toString())
-  list.value = res
+  originList.value = res || []
+  list.value = [...originList.value]
 }
 
-const fmtDict = (name) => {
+const fmtDict = (name: string | number | boolean) => {
   if (typeof name === 'number') {
     if (name === -1) return '--'
   }
@@ -134,6 +138,7 @@ watch(
   async () => {
     if (isEdit.value && props.modelValue) {
       const res = await getBedInfoById(inputValue.value)
+      originList.value = [res]
       list.value = [res]
       inputValue.value = String(inputValue.value)
       if (!toggleTypeFmt.value) fmtDict(props.modelValue)
@@ -142,13 +147,18 @@ watch(
   { deep: true, immediate: true }
 )
 
-const handleGetList = () => {
-  if (!list.value.length && !props.modelValue) {
-    getList('')
+const handleGetList = async () => {
+  if (!originList.value.length) {
+    try {
+      loading.value = true
+      await getList('')
+    } finally {
+      loading.value = false
+    }
   }
 }
 
-const selectBedById = async (bedId: string | number) => {
+const selectBedById = async (_bedId: string | number) => {
   try {
     isD.value = true
     // loading.value = true

+ 1 - 1
src/views/elderly/nursing/life-care-plan/index.vue

@@ -12,7 +12,7 @@
         <el-input @keyup.enter="handleQuery" v-model="queryParams.elderName" placeholder="请输入长者姓名" class="!w-240px" />
       </el-form-item>
       <el-form-item label="床位" prop="bedId">
-        <SelectRoom v-model="queryParams.bedId" class="!w-240px" />
+        <SelectRoom v-model="queryParams.bedId" class="!w-240px" :tId="queryParams.tenantIds" />
       </el-form-item>
       <el-form-item label="护理等级" prop="nurseLevelId">
         <TgSelect v-model="queryParams.nurseLevelId" class="!w-240px">