2024-04-22 05:35:19 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
<el-select
|
2024-05-11 08:32:24 +00:00
|
|
|
|
style="width:100%"
|
2024-05-16 22:28:20 +00:00
|
|
|
|
ref="selectRef"
|
2024-04-22 05:35:19 +00:00
|
|
|
|
filterable
|
|
|
|
|
|
clearable
|
2024-05-16 22:28:20 +00:00
|
|
|
|
remote
|
|
|
|
|
|
:remote-method="queryData"
|
2024-04-22 05:35:19 +00:00
|
|
|
|
v-model="svalue"
|
|
|
|
|
|
:placeholder="placeholder"
|
2024-05-07 04:53:25 +00:00
|
|
|
|
@blur="onBlur"
|
|
|
|
|
|
@change="onChange"
|
2024-05-16 22:28:20 +00:00
|
|
|
|
@focus="onFocus"
|
|
|
|
|
|
@visible-change="reverseArrow"
|
2024-05-07 04:53:25 +00:00
|
|
|
|
>
|
2024-05-13 06:10:38 +00:00
|
|
|
|
<el-option v-for="item in optionItems" :key="item.code" :label="item.name+'('+item.nameEn+')'" :value="item.code" ></el-option>
|
2024-04-22 05:35:19 +00:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</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 { listSimpleEmisCountry} from "@/api/emis/emisCountry";
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "CountryPicker",
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
optionItems: [],
|
|
|
|
|
|
svalue: this.value,
|
2024-05-16 22:28:20 +00:00
|
|
|
|
countryCode:null,
|
2024-04-22 05:35:19 +00:00
|
|
|
|
countryMap:new Map(),
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
value(newVal) {
|
|
|
|
|
|
this.svalue = newVal;
|
2024-05-16 22:28:20 +00:00
|
|
|
|
if(this.svalue!=null) {
|
|
|
|
|
|
this.countryCode=this.svalue;
|
|
|
|
|
|
}
|
2024-04-22 05:35:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
created() {
|
2024-05-16 22:28:20 +00:00
|
|
|
|
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
|
2024-04-22 05:35:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2024-05-16 22:28:20 +00:00
|
|
|
|
onFocus(){
|
|
|
|
|
|
this.countryCode=null;
|
|
|
|
|
|
this.queryData();
|
|
|
|
|
|
},
|
2024-05-07 04:53:25 +00:00
|
|
|
|
onBlur(val){
|
|
|
|
|
|
this.$emit("input", this.svalue);
|
2024-05-16 22:28:20 +00:00
|
|
|
|
this.dispatch('ElFormItem', 'el.form.blur');
|
2024-05-07 04:53:25 +00:00
|
|
|
|
},
|
2024-04-22 05:35:19 +00:00
|
|
|
|
onChange() {
|
2024-05-16 22:28:20 +00:00
|
|
|
|
if(this.svalue!=null){
|
|
|
|
|
|
this.$emit("input", this.svalue);
|
|
|
|
|
|
let itemData ={};
|
|
|
|
|
|
this.optionItems.forEach(item=>{
|
|
|
|
|
|
if(item.code === this.svalue){
|
|
|
|
|
|
itemData = item;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
this.$emit("change",itemData);
|
|
|
|
|
|
this.$emit("onChange",itemData);
|
|
|
|
|
|
this.dispatch('ElFormItem', 'el.form.change', [this.svalue]);
|
|
|
|
|
|
}
|
2024-04-22 05:35:19 +00:00
|
|
|
|
},
|
2024-05-16 22:28:20 +00:00
|
|
|
|
queryData(val) {
|
|
|
|
|
|
let queryParams = {
|
|
|
|
|
|
code:this.countryCode,
|
|
|
|
|
|
name:val
|
|
|
|
|
|
};
|
2024-04-22 05:35:19 +00:00
|
|
|
|
listSimpleEmisCountry(queryParams).then(response => {
|
2024-05-16 22:28:20 +00:00
|
|
|
|
this.optionItems =response.rows;
|
2024-04-22 05:35:19 +00:00
|
|
|
|
});
|
|
|
|
|
|
},
|
2024-05-16 22:28:20 +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
|
2024-04-22 05:35:19 +00:00
|
|
|
|
} else {
|
2024-05-16 22:28:20 +00:00
|
|
|
|
rulesDom.classList.remove("is-reverse"); // 对dom新增class
|
2024-04-22 05:35:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|