自动填入单位

This commit is contained in:
砂糖
2025-07-22 11:49:48 +08:00
parent 3b408fade9
commit 633f81727d
4 changed files with 226 additions and 141 deletions

View File

@@ -4,8 +4,6 @@
:placeholder="placeholder"
filterable
clearable
remote
:remote-method="debouncedRemoteMethod"
:loading="loading"
@change="onChange"
style="width: 100%"
@@ -67,25 +65,19 @@ export default {
this.fetchOptions("");
},
methods: {
fetchOptions(keyword) {
fetchOptions() {
this.loading = true;
listRawMaterial({ pageNum: 1, pageSize: 10, rawMaterialName: keyword }).then(res => {
listRawMaterial({ pageNum: 1, pageSize: 9999 }).then(res => {
this.options = res.rows || [];
this.loading = false;
}).catch(() => {
this.loading = false;
});
},
remoteMethod(keyword) {
this.fetchOptions(keyword);
async onChange(val) {
const rawMaterial = this.options.find(p => p.rawMaterialId === val);
this.$emit('change', rawMaterial);
},
debouncedRemoteMethod: debounce(function(keyword) {
this.remoteMethod(keyword);
}, 400),
onChange(val) {
this.$emit("input", val);
this.$emit("change", val);
}
}
};
</script>