食堂原料管理

This commit is contained in:
weiwei committed 2025-05-13 11:06:14 +08:00
1 parent 7f1cfdb0e7
commit 5bd138c276
8 files changed
+169 -146

No files matched your search

@@ -0,0 +1,66 @@
<template>
<el-select
style="width: 100%"
v-model="state.selectId"
:placeholder="props.placeholder"
clearable
remote-show-suffix
filterable
remote
:remote-method="remoteSearch"
:loading="state.loading"
@visible-change="(e: boolean) => e && getOptions()"
>
<el-option v-for="v in state.options" :key="v.supplierId" :label="v.supplierName" :value="v.supplierId" />
</el-select>
</template>
<script setup lang="ts" name="SelectSupplier">
import { reactive } from "vue"
import { canteenSupplierSelect } from "/@/api/canteen/canteenSupplier"
const selectId = defineModel()
const props = withDefaults(defineProps<{ placeholder?: string }>(), {
placeholder: "请选择",
})
const queryForm = reactive<any>({
name: "",
supplierId: "",
})
const state = reactive<any>({
loading: true,
selectId: selectId,
options: [],
})
watch(
selectId,
(newVal, oldValue) => {
if (newVal == oldValue) return
state.selectId = newVal
queryForm.supplierId = newVal
getOptions()
},
{ immediate: true },
)
async function getOptions() {
try {
state.loading = true
const { data } = await canteenSupplierSelect(queryForm)
state.options = data ? data : []
} finally {
setTimeout(() => (state.loading = false), 500)
}
}
function remoteSearch(params: string) {
if (params != queryForm.name) {
queryForm.name = params
getOptions()
}
}
</script>