This commit is contained in:
zlwu committed 2026-06-21 12:41:39 +08:00
1 parent 299609706c
commit e46c0480d4
87 files changed
+11975 -15543

No files matched your search

@@ -0,0 +1,79 @@
<template>
<el-select
v-model="model"
:placeholder="placeholder"
filterable
remote
:remote-method="loadOptions"
:loading="loading"
clearable
style="width: 100%"
@focus="handleFocus"
>
<el-option
v-for="item in displayOptions"
:key="item.id"
:label="item.licensePlate"
:value="item.licensePlate"
/>
</el-select>
</template>
<script setup lang="ts">
import { vehicleApi, type Vehicle } from '@/api/pl'
import { pickBxList } from '@/utils/http/bx'
defineOptions({ name: 'PlVehicleSelect' })
const model = defineModel<string>({ default: '' })
withDefaults(
defineProps<{
placeholder?: string
}>(),
{
placeholder: '请选择车牌号'
}
)
const loading = ref(false)
const options = ref<Vehicle[]>([])
const loadOptions = async (keyword: string) => {
loading.value = true
try {
const res = await vehicleApi.list(keyword.trim() ? { q: keyword.trim() } : undefined)
options.value = pickBxList<Vehicle>(res)
} catch (error) {
console.error('加载运输车辆列表失败', error)
options.value = []
} finally {
loading.value = false
}
}
const handleFocus = () => {
if (options.value.length === 0) {
loadOptions('')
}
}
/** 编辑态回显:历史出入库单中的车牌若不在运输车辆库,仍展示只读选项 */
const displayOptions = computed(() => {
const current = model.value?.trim()
if (!current) return options.value
if (options.value.some((item) => item.licensePlate === current)) {
return options.value
}
return [
{
id: `legacy-${current}`,
licensePlate: current,
vehicleType: '',
vehicleStatus: '',
createTime: ''
},
...options.value
]
})
</script>