emis-frontend/src/views/emis/EmisBaseTools/TransLinePicker.vue
2024-05-12 23:21:00 +08:00

97 lines
2.2 KiB
Vue

<template>
<el-select
style="width:100%"
filterable
clearable
v-model="svalue"
:placeholder="placeholder"
@blur="onBlur"
@change="onChange">
<el-option v-for="item in optionItems" :key="item.lineCode" :label="item.lineName" :value="item.lineCode" />
</el-select>
<!-- style="width:100%" -->
</template>
<script>
import emitter from 'element-ui/src/mixins/emitter';
import { listSimpleEmisTransLine } from "@/api/emis/emisTransLine";
export default {
name: "TransLinePicker",
mixins: [emitter],
props: {
value: {
type: String,
required: false
},
placeholder:{
type: String,
required: false
},
countryCode: {
type: String,
required: false
},
fromCountry: {
type: String,
required: false
},
isInitiated:{
type: [Boolean,String],
required: false,
default:false
}
},
data() {
return {
optionItems: [],
svalue: this.value,
filterMap:new Map(),
};
},
watch: {
value(newVal) {
this.svalue = newVal;
},
countryCode(newVal) {
this.queryData();
},
fromCountry(newVal) {
this.queryData();
},
},
created() {
if(this.isInitiated || this.svalue!=null){
this.queryData();
}
},
methods: {
onBlur(val){
this.$emit("input", this.svalue);
this.dispatch('ElFormItem', 'el.form.blur', [this.svalue]);
},
onChange() {
this.$emit("input", this.svalue);
this.$emit("onChange",this.filterMap[this.svalue]);
this.dispatch('ElFormItem', 'el.form.change', [this.svalue]);
},
queryData() {
let queryParams = {
pageNum: 1,
pageSize: 3000,
country:this.countryCode,
fromCountry:this.fromCountry
};
listSimpleEmisTransLine(queryParams).then(response => {
this.optionItems = response.rows;
this.optionItems.forEach(item => {
this.filterMap[item.lineCode]=item;
});
});
},
}
};
</script>