|
@@ -1,13 +1,12 @@
|
|
|
<template>
|
|
<template>
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="inputValue"
|
|
v-model="inputValue"
|
|
|
- remote
|
|
|
|
|
filterable
|
|
filterable
|
|
|
|
|
+ :filter-method="filterMethod"
|
|
|
placeholder="请输入床位号"
|
|
placeholder="请输入床位号"
|
|
|
@focus="handleGetList"
|
|
@focus="handleGetList"
|
|
|
@change="handleSelect"
|
|
@change="handleSelect"
|
|
|
- :remote-method="remoteMethod"
|
|
|
|
|
- :disabled="disabled||isD"
|
|
|
|
|
|
|
+ :disabled="disabled || isD"
|
|
|
v-if="toggleTypeFmt"
|
|
v-if="toggleTypeFmt"
|
|
|
:loading="loading"
|
|
:loading="loading"
|
|
|
>
|
|
>
|
|
@@ -59,8 +58,9 @@ interface listType {
|
|
|
buildBedName: string
|
|
buildBedName: string
|
|
|
}
|
|
}
|
|
|
const list = ref<listType[]>([])
|
|
const list = ref<listType[]>([])
|
|
|
|
|
+const originList = ref<listType[]>([])
|
|
|
|
|
|
|
|
-const handleSelect = (val) => {
|
|
|
|
|
|
|
+const handleSelect = (val: string | number) => {
|
|
|
isEdit.value = false
|
|
isEdit.value = false
|
|
|
const item = list.value.find((l) => l.buildBedId == val)
|
|
const item = list.value.find((l) => l.buildBedId == val)
|
|
|
if (item) {
|
|
if (item) {
|
|
@@ -68,41 +68,45 @@ const handleSelect = (val) => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const formatLabel = (item) => {
|
|
|
|
|
|
|
+const formatLabel = (item: listType) => {
|
|
|
return (
|
|
return (
|
|
|
item.buildName + '>' + item.buildFloorName + '>' + item.buildRoomName + '>' + item.buildBedName
|
|
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()
|
|
const params = new URLSearchParams()
|
|
|
params.append('bedName', str)
|
|
params.append('bedName', str)
|
|
|
if(props.status){
|
|
if(props.status){
|
|
|
params.append('status', 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())
|
|
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 (typeof name === 'number') {
|
|
|
if (name === -1) return '--'
|
|
if (name === -1) return '--'
|
|
|
}
|
|
}
|
|
@@ -134,6 +138,7 @@ watch(
|
|
|
async () => {
|
|
async () => {
|
|
|
if (isEdit.value && props.modelValue) {
|
|
if (isEdit.value && props.modelValue) {
|
|
|
const res = await getBedInfoById(inputValue.value)
|
|
const res = await getBedInfoById(inputValue.value)
|
|
|
|
|
+ originList.value = [res]
|
|
|
list.value = [res]
|
|
list.value = [res]
|
|
|
inputValue.value = String(inputValue.value)
|
|
inputValue.value = String(inputValue.value)
|
|
|
if (!toggleTypeFmt.value) fmtDict(props.modelValue)
|
|
if (!toggleTypeFmt.value) fmtDict(props.modelValue)
|
|
@@ -142,13 +147,18 @@ watch(
|
|
|
{ deep: true, immediate: true }
|
|
{ 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 {
|
|
try {
|
|
|
isD.value = true
|
|
isD.value = true
|
|
|
// loading.value = true
|
|
// loading.value = true
|