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

104 lines
2.3 KiB
Vue
Raw Normal View History

2024-04-22 05:35:19 +00:00
<template>
<el-select
filterable
clearable
v-model="svalue"
:placeholder="placeholder"
2024-05-07 04:53:25 +00:00
@blur="onBlur"
2024-05-18 10:19:01 +00:00
@focus="onFocus"
2024-05-07 04:53:25 +00:00
@change="onChange"
2024-05-18 10:19:01 +00:00
style="width:100%"
2024-05-07 04:53:25 +00:00
>
2024-05-10 03:42:02 +00:00
<el-option v-for="item in optionItems" :key="item.prodCode" :label="item.prodName" :value="item.prodCode" />
2024-04-22 05:35:19 +00:00
</el-select>
2024-05-18 10:19:01 +00:00
<!-- style="width:100%" multiple-->
2024-05-10 03:42:02 +00:00
2024-04-22 05:35:19 +00:00
</template>
<script>
2024-05-07 04:53:25 +00:00
import emitter from 'element-ui/src/mixins/emitter';
2024-04-22 05:35:19 +00:00
import { listSimpleEmisTransProduct } from "@/api/emis/emisTransProduct";
export default {
name: "TransProductPicker",
2024-05-07 04:53:25 +00:00
mixins: [emitter],
2024-04-22 05:35:19 +00:00
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,
2024-05-18 10:19:01 +00:00
isFistInit:true,
searchProdCode:this.value,
2024-04-22 05:35:19 +00:00
};
},
watch: {
value(newVal) {
this.svalue = newVal;
},
transLineCode(newVal) {
this.queryData();
}
},
created() {
2024-05-10 23:33:58 +00:00
this.queryData();
2024-04-22 05:35:19 +00:00
},
methods: {
2024-05-18 10:19:01 +00:00
onFocus(){
this.searchProdCode=null;
},
2024-05-07 04:53:25 +00:00
onBlur(val){
this.$emit("input", this.svalue);
this.dispatch('ElFormItem', 'el.form.blur', [this.svalue]);
},
2024-04-22 05:35:19 +00:00
onChange() {
this.$emit("input", this.svalue);
let itemData ={};
this.optionItems.forEach(item=>{
if(item.prodCode === this.svalue){
itemData = item;
}
});
this.$emit("onChange",itemData);
2024-05-07 04:53:25 +00:00
this.dispatch('ElFormItem', 'el.form.change', [this.svalue]);
2024-04-22 05:35:19 +00:00
},
queryData() {
2024-05-18 10:19:01 +00:00
if(!this.transLineCode && !this.isFistInit){
this.optionItems=[];
return;
}
2024-05-10 23:33:58 +00:00
let queryParams = {
pageNum: 1,
pageSize: 3000,
2024-05-18 10:19:01 +00:00
prodCode:this.searchProdCode,
2024-05-10 23:33:58 +00:00
transLineCode:this.transLineCode,
status:1
};
2024-04-22 05:35:19 +00:00
listSimpleEmisTransProduct(queryParams).then(response => {
this.optionItems = response.rows;
});
},
}
};
</script>