emis-frontend/src/views/emis/EmisBaseTools/TransProductPicker.vue

80 lines
1.7 KiB
Vue
Raw Normal View History

2024-04-22 05:35:19 +00:00
<template>
<el-select
style="width:100%"
filterable
clearable
v-model="svalue"
:placeholder="placeholder"
@change="onChange">
<el-option v-for="item in optionItems" :key="item.prodCode" :label="item.prodCode+'-'+item.prodName" :value="item.prodCode" />
</el-select>
</template>
<script>
import { listSimpleEmisTransProduct } from "@/api/emis/emisTransProduct";
export default {
name: "TransProductPicker",
props: {
value: {
type: [String, Number],
required: false
},
transLineCode: {
type: String,
required: false
},
placeholder:{
type: String,
required: false
},
isInitiated:{
type: [Boolean,String],
required: false,
default:false
}
},
data() {
return {
optionItems: [],
svalue: this.value,
};
},
watch: {
value(newVal) {
this.svalue = newVal;
},
svalue(newVal, oldVal) {
this.$emit("input", this.svalue);
},
transLineCode(newVal) {
this.queryData();
}
},
created() {
if(this.isInitiated || this.svalue!=null){
this.queryData();
}
},
methods: {
onChange() {
this.$emit("input", this.svalue);
let itemData ={};
this.optionItems.forEach(item=>{
if(item.prodCode === this.svalue){
itemData = item;
}
});
this.$emit("onChange",itemData);
},
queryData() {
let queryParams = {transLineCode:this.transLineCode,status:1};
listSimpleEmisTransProduct(queryParams).then(response => {
this.optionItems = response.rows;
});
},
}
};
</script>