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

136 lines
3.4 KiB
Vue
Raw Normal View History

2025-07-01 09:37:50 +00:00
<template>
<el-select
ref="selectRef"
:disabled="disabled"
style="width:100%"
filterable
clearable
remote
:remote-method="queryData"
v-model="svalue"
:placeholder="placeholder"
@focus="onFocus"
@blur="onBlur"
@change="onChange"
@visible-change="reverseArrow"
>
2025-07-08 08:55:17 +00:00
<el-option v-for="item in optionItems" :key="item.lineCode" :label="item.lineName+((item.status==0)?'-已停用':'')" :value="item.lineCode" />
2025-07-02 06:24:37 +00:00
2025-07-01 09:37:50 +00:00
</el-select>
<!-- style="width:100%" -->
</template>
<script>
import emitter from 'element-ui/src/mixins/emitter';
import { listSimpleAllEmisTransLine } 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
},
disabled:{
type: [Boolean],
required: false
},
},
data() {
return {
optionItems: [],
svalue: this.value,
filterMap:new Map(),
queryParams: {
pageNum: 1,
pageSize: 50,
lineCode:null,
lineName:null,
country:this.countryCode,
fromCountry:this.fromCountry
}
};
},
watch: {
value(newVal) {
this.svalue = newVal;
this.queryParams.lineCode=this.svalue ;
},
countryCode(newVal) {
this.queryParams.country=this.countryCode;
this.queryData();
},
fromCountry(newVal) {
this.queryParams.fromCountry=this.fromCountry;
this.queryData();
},
},
created() {
if(this.isInitiated || this.svalue!=null){
this.queryData();
}
},
mounted(){
let rulesDom = this.$refs["selectRef"].$el.querySelector(".el-input .el-input__suffix .el-input__suffix-inner .el-input__icon"); // 找到dom
    rulesDom.classList.add("el-icon-arrow-up"); // 对dom新增class
},
methods: {
onFocus(val){
this.optionItems=[];
this.queryData();
},
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(val) {
this.queryParams.lineName=val;
listSimpleAllEmisTransLine( this.queryParams).then(response => {
this.optionItems = response.rows;
this.optionItems.forEach(item => {
this.filterMap[item.lineCode]=item;
});
});
},
reverseArrow(flag) {
let rulesDom = this.$refs["selectRef"].$el.querySelector(
".el-input .el-input__suffix .el-input__suffix-inner .el-input__icon"
); // 找到dom
if (flag) {
rulesDom.classList.add("is-reverse"); // 对dom新增class
} else {
rulesDom.classList.remove("is-reverse"); // 对dom新增class
}
},
}
};
</script>