做了几个组件
This commit is contained in:
61
klp-ui/src/components/KLPService/ProductSelect/index.vue
Normal file
61
klp-ui/src/components/KLPService/ProductSelect/index.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<el-select
|
||||
v-model="selected"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
filterable
|
||||
@change="onChange"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in productOptions"
|
||||
:key="item.productId"
|
||||
:label="item.productName"
|
||||
:value="item.productId"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listProduct } from '@/api/wms/product';
|
||||
|
||||
export default {
|
||||
name: 'ProductSelect',
|
||||
props: {
|
||||
value: [String, Number],
|
||||
disabled: Boolean,
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请选择产品'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
productOptions: [],
|
||||
selected: this.value
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
this.selected = val;
|
||||
},
|
||||
selected(val) {
|
||||
this.$emit('input', val);
|
||||
this.$emit('change', val);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getProductOptions();
|
||||
},
|
||||
methods: {
|
||||
getProductOptions() {
|
||||
listProduct({ pageNum: 1, pageSize: 1000 }).then(res => {
|
||||
this.productOptions = res.rows || [];
|
||||
});
|
||||
},
|
||||
onChange(val) {
|
||||
this.$emit('change', val);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user