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

135 lines
3.4 KiB
Vue
Raw Normal View History

2024-04-22 05:35:19 +00:00
<template>
<el-select
2024-07-02 09:09:39 +00:00
ref="selectRef"
2024-07-03 23:52:30 +00:00
:disabled="disabled"
2024-05-11 08:36:58 +00:00
style="width:100%"
2024-04-22 05:35:19 +00:00
filterable
clearable
2024-07-02 09:09:39 +00:00
remote
:remote-method="queryData"
2024-04-22 05:35:19 +00:00
v-model="svalue"
:placeholder="placeholder"
2024-06-11 11:49:02 +00:00
@focus="onFocus"
2024-05-07 04:53:25 +00:00
@blur="onBlur"
2024-07-02 09:09:39 +00:00
@change="onChange"
@visible-change="reverseArrow"
>
2024-05-10 03:42:02 +00:00
<el-option v-for="item in optionItems" :key="item.lineCode" :label="item.lineName" :value="item.lineCode" />
2024-04-22 05:35:19 +00:00
</el-select>
2024-05-10 03:42:02 +00:00
<!-- style="width:100%" -->
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 { listSimpleEmisTransLine } from "@/api/emis/emisTransLine";
export default {
name: "TransLinePicker",
2024-05-07 04:53:25 +00:00
mixins: [emitter],
2024-04-22 05:35:19 +00:00
props: {
value: {
type: String,
required: false
},
placeholder:{
type: String,
required: false
},
countryCode: {
type: String,
required: false
},
2024-05-12 15:21:00 +00:00
fromCountry: {
type: String,
required: false
},
2024-04-22 05:35:19 +00:00
isInitiated:{
type: [Boolean,String],
required: false,
default:false
2024-07-03 23:52:30 +00:00
},
disabled:{
type: [Boolean],
required: false
},
2024-04-22 05:35:19 +00:00
},
data() {
return {
optionItems: [],
svalue: this.value,
2024-05-07 04:53:25 +00:00
filterMap:new Map(),
2024-06-11 11:49:02 +00:00
queryParams: {
pageNum: 1,
2024-06-19 13:44:25 +00:00
pageSize: 50,
2024-07-02 09:09:39 +00:00
lineCode:null,
lineName:null,
2024-06-11 11:49:02 +00:00
country:this.countryCode,
fromCountry:this.fromCountry
}
2024-04-22 05:35:19 +00:00
};
},
watch: {
value(newVal) {
this.svalue = newVal;
2024-07-02 09:10:58 +00:00
this.queryParams.lineCode=this.svalue ;
2024-04-22 05:35:19 +00:00
},
countryCode(newVal) {
2024-06-11 11:49:02 +00:00
this.queryParams.country=this.countryCode;
2024-04-22 05:35:19 +00:00
this.queryData();
2024-05-12 15:21:00 +00:00
},
fromCountry(newVal) {
2024-06-11 11:49:02 +00:00
this.queryParams.fromCountry=this.fromCountry;
2024-05-12 15:21:00 +00:00
this.queryData();
},
2024-04-22 05:35:19 +00:00
},
created() {
if(this.isInitiated || this.svalue!=null){
this.queryData();
}
},
2024-07-02 09:09:39 +00:00
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
},
2024-04-22 05:35:19 +00:00
methods: {
2024-06-11 11:49:02 +00:00
onFocus(val){
this.optionItems=[];
this.queryData();
},
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);
2024-05-07 04:53:25 +00:00
this.$emit("onChange",this.filterMap[this.svalue]);
this.dispatch('ElFormItem', 'el.form.change', [this.svalue]);
2024-04-22 05:35:19 +00:00
},
2024-07-02 09:09:39 +00:00
queryData(val) {
this.queryParams.lineName=val;
2024-06-11 11:49:02 +00:00
listSimpleEmisTransLine( this.queryParams).then(response => {
2024-04-22 05:35:19 +00:00
this.optionItems = response.rows;
2024-05-07 04:53:25 +00:00
this.optionItems.forEach(item => {
this.filterMap[item.lineCode]=item;
});
2024-04-22 05:35:19 +00:00
});
},
2024-07-02 09:09:39 +00:00
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
}
},
2024-04-22 05:35:19 +00:00
}
};
</script>