Files
klp-oa/klp-ui/src/components/KLPService/RawMaterialSelect/index.vue

85 lines
1.6 KiB
Vue
Raw Normal View History

2025-07-18 17:22:56 +08:00
<template>
<el-select
v-model="selected"
:placeholder="placeholder"
filterable
clearable
@change="onChange"
style="width: 100%"
2025-07-21 10:56:50 +08:00
:value-key="'rawMaterialId'"
2025-07-18 17:22:56 +08:00
>
<el-option
v-for="item in options"
:key="item.rawMaterialId"
2025-07-21 10:56:50 +08:00
:label="`${item.rawMaterialName}${item.rawMaterialCode}`"
2025-07-18 17:22:56 +08:00
:value="item.rawMaterialId"
2025-07-21 10:56:50 +08:00
>
<div class="option-label">
<span class="material-name">{{ item.rawMaterialName }}</span>
<span class="material-code">{{ item.rawMaterialCode }}</span>
</div>
</el-option>
2025-07-18 17:22:56 +08:00
</el-select>
</template>
<script>
import { listRawMaterial } from "@/api/wms/rawMaterial";
export default {
name: "RawMaterialSelect",
props: {
2025-07-21 10:56:50 +08:00
value: [String, null],
2025-07-18 17:22:56 +08:00
placeholder: {
type: String,
default: "请选择原材料"
}
},
data() {
return {
options: [],
selected: this.value
};
},
watch: {
value(val) {
this.selected = val;
2025-07-21 10:56:50 +08:00
},
selected(val) {
this.$emit("input", val);
this.$emit("change", val);
2025-07-18 17:22:56 +08:00
}
},
mounted() {
this.fetchOptions();
},
methods: {
fetchOptions() {
listRawMaterial({ pageNum: 1, pageSize: 1000 }).then(res => {
this.options = res.rows || [];
});
},
onChange(val) {
this.$emit("input", val);
this.$emit("change", val);
}
}
};
</script>
2025-07-21 10:56:50 +08:00
<style scoped>
.option-label {
display: flex;
justify-content: space-between;
align-items: center;
}
.material-name {
font-size: 14px;
color: #333;
}
.material-code {
font-size: 12px;
color: #999;
margin-left: 10px;
}
</style>