2024-04-22 05:35:19 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
<el-select
|
2024-05-25 09:36:22 +00:00
|
|
|
|
style="width:100%"
|
|
|
|
|
|
ref="selectRef"
|
2024-04-22 05:35:19 +00:00
|
|
|
|
filterable
|
2024-05-25 09:36:22 +00:00
|
|
|
|
clearable
|
|
|
|
|
|
remote
|
|
|
|
|
|
:remote-method="queryData"
|
|
|
|
|
|
v-model="svalue"
|
|
|
|
|
|
:placeholder="placeholder"
|
|
|
|
|
|
|
|
|
|
|
|
no-data-text=""
|
|
|
|
|
|
|
|
|
|
|
|
@blur="onBlur"
|
|
|
|
|
|
@change="onChange"
|
|
|
|
|
|
@click.native="onClick"
|
|
|
|
|
|
@visible-change="reverseArrow"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option v-for="item in optionItems" :key="item.siteCode" :label="item.siteName" :value="item.siteCode" ></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- filterable
|
2024-04-22 05:35:19 +00:00
|
|
|
|
clearable
|
2024-05-07 04:53:25 +00:00
|
|
|
|
autocomplete="false"
|
2024-05-18 10:19:01 +00:00
|
|
|
|
ref="selectRef"
|
2024-04-22 05:35:19 +00:00
|
|
|
|
v-model="svalue"
|
2024-05-07 04:53:25 +00:00
|
|
|
|
remote
|
|
|
|
|
|
:remote-method="queryData"
|
2024-04-22 05:35:19 +00:00
|
|
|
|
:placeholder="placeholder"
|
|
|
|
|
|
style="width: 100%;"
|
2024-05-07 04:53:25 +00:00
|
|
|
|
@focus="onFocus"
|
|
|
|
|
|
class="remote-select"
|
|
|
|
|
|
@change="onChange"
|
|
|
|
|
|
@clear="onClear"
|
2024-04-22 05:35:19 +00:00
|
|
|
|
|
2024-05-25 09:36:22 +00:00
|
|
|
|
no-data-text=""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@visible-change="reverseArrow"
|
|
|
|
|
|
@mouseleave.native="onMouseleave" -->
|
2024-05-07 04:53:25 +00:00
|
|
|
|
|
2024-04-22 05:35:19 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2024-05-25 09:36:22 +00:00
|
|
|
|
import emitter from 'element-ui/src/mixins/emitter';
|
2024-05-07 04:53:25 +00:00
|
|
|
|
import { listSimpleEmisSite } from "@/api/emis/emisSite";
|
2024-04-22 05:35:19 +00:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "EmisSiteSimplePicker",
|
2024-05-25 09:36:22 +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-11 03:13:13 +00:00
|
|
|
|
siteType:{
|
|
|
|
|
|
type: [String,Number],
|
|
|
|
|
|
required: false
|
|
|
|
|
|
},
|
2024-06-05 02:18:20 +00:00
|
|
|
|
parentSiteCode:{
|
2024-06-05 02:14:36 +00:00
|
|
|
|
type: [String],
|
|
|
|
|
|
required: false,
|
2024-06-05 02:18:20 +00:00
|
|
|
|
defaultValue:null
|
|
|
|
|
|
},
|
|
|
|
|
|
blIncludeChildSite:{
|
2024-06-05 21:06:07 +00:00
|
|
|
|
type: [String,Number],
|
2024-06-05 02:18:20 +00:00
|
|
|
|
required: false,
|
|
|
|
|
|
defaultValue:null
|
2024-06-05 02:14:36 +00:00
|
|
|
|
},
|
2024-04-22 05:35:19 +00:00
|
|
|
|
disabled:{
|
|
|
|
|
|
type: [Boolean,String],
|
|
|
|
|
|
required: false
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
loading:false,
|
2024-05-25 09:36:22 +00:00
|
|
|
|
|
2024-04-22 05:35:19 +00:00
|
|
|
|
svalue: this.value,
|
2024-05-25 09:36:22 +00:00
|
|
|
|
optionItems: [],
|
|
|
|
|
|
// 缺省值
|
|
|
|
|
|
defaultItems: null,
|
|
|
|
|
|
itemMap:new Map(),
|
|
|
|
|
|
|
2024-05-07 04:53:25 +00:00
|
|
|
|
queryParams:{
|
|
|
|
|
|
pageNum:1,
|
2024-05-18 10:19:01 +00:00
|
|
|
|
pageSize:10,
|
2024-05-11 03:13:13 +00:00
|
|
|
|
siteType:this.siteType,
|
2024-05-07 04:53:25 +00:00
|
|
|
|
countryCode:this.countryCode,
|
2024-05-25 09:36:22 +00:00
|
|
|
|
siteCode:null,
|
2024-06-05 02:14:36 +00:00
|
|
|
|
siteName:null,
|
2024-06-05 03:31:04 +00:00
|
|
|
|
parentSiteCode:this.parentSiteCode,
|
2024-06-05 02:14:36 +00:00
|
|
|
|
params:{
|
2024-06-05 03:31:04 +00:00
|
|
|
|
blIncludeChildSite:this.blIncludeChildSite
|
2024-06-05 02:14:36 +00:00
|
|
|
|
}
|
2024-05-07 04:53:25 +00:00
|
|
|
|
}
|
2024-04-22 05:35:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
2024-05-25 09:36:22 +00:00
|
|
|
|
value(newVal,oldVal) {
|
|
|
|
|
|
// 逻辑 有初始值先查询初值
|
|
|
|
|
|
if(this.value!=null){
|
|
|
|
|
|
this.svalue=this.value;
|
|
|
|
|
|
this.queryData(null,this.svalue);
|
|
|
|
|
|
}
|
2024-04-22 05:35:19 +00:00
|
|
|
|
},
|
2024-05-07 04:53:25 +00:00
|
|
|
|
siteType(newVal, oldVal) {
|
2024-05-25 09:36:22 +00:00
|
|
|
|
if(newVal!=oldVal){
|
|
|
|
|
|
this.queryParams.siteType=newVal
|
|
|
|
|
|
this.defaultItems=null;
|
|
|
|
|
|
}
|
2024-05-07 04:53:25 +00:00
|
|
|
|
},
|
2024-04-22 05:35:19 +00:00
|
|
|
|
countryCode(newVal, oldVal) {
|
2024-05-25 09:36:22 +00:00
|
|
|
|
if(newVal!=oldVal){
|
|
|
|
|
|
this.queryParams.countryCode=newVal
|
|
|
|
|
|
this.defaultItems=null;
|
|
|
|
|
|
}
|
2024-04-22 05:35:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-05-18 10:19:01 +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-05-07 04:53:25 +00:00
|
|
|
|
},
|
2024-05-18 10:19:01 +00:00
|
|
|
|
created() {
|
2024-05-25 09:36:22 +00:00
|
|
|
|
if(this.svalue!=null){
|
|
|
|
|
|
this.queryData(null,this.svalue);
|
|
|
|
|
|
}
|
2024-04-22 05:35:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2024-05-25 09:36:22 +00:00
|
|
|
|
onClick(){
|
|
|
|
|
|
// 第一次点击时需要初始化
|
|
|
|
|
|
if(!this.defaultItems){
|
|
|
|
|
|
this.queryData(null,null);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this.optionItems = [...this.defaultItems];
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-04-22 05:35:19 +00:00
|
|
|
|
onChange() {
|
|
|
|
|
|
this.$emit("input", this.svalue);
|
2024-05-25 09:36:22 +00:00
|
|
|
|
let itemData = this.optionItems.find(item => item.siteCode == this.svalue);
|
2024-04-22 05:35:19 +00:00
|
|
|
|
this.$emit("onChange",itemData);
|
|
|
|
|
|
},
|
2024-05-07 04:53:25 +00:00
|
|
|
|
onClear(){
|
2024-05-15 11:05:34 +00:00
|
|
|
|
this.$emit("input", this.svalue);
|
2024-05-25 09:36:22 +00:00
|
|
|
|
this.$emit("onChange",null);
|
2024-05-07 04:53:25 +00:00
|
|
|
|
},
|
2024-05-25 09:36:22 +00:00
|
|
|
|
onBlur(val){
|
|
|
|
|
|
this.$emit("input", this.svalue);
|
|
|
|
|
|
this.dispatch('ElFormItem', 'el.form.blur');
|
2024-05-07 04:53:25 +00:00
|
|
|
|
},
|
2024-05-25 09:36:22 +00:00
|
|
|
|
queryData(val,key) {
|
2024-05-18 10:19:01 +00:00
|
|
|
|
this.optionItems=[];
|
|
|
|
|
|
|
2024-05-25 09:36:22 +00:00
|
|
|
|
this.queryParams.siteCode=key;
|
2024-05-18 10:19:01 +00:00
|
|
|
|
this.queryParams.siteName=val;
|
2024-05-25 09:36:22 +00:00
|
|
|
|
|
2024-05-07 04:53:25 +00:00
|
|
|
|
listSimpleEmisSite(this.queryParams).then(response => {
|
2024-05-18 10:19:01 +00:00
|
|
|
|
this.optionItems=response.rows;
|
2024-05-25 09:36:22 +00:00
|
|
|
|
// 初始值存储
|
|
|
|
|
|
if(key==null && val==null){
|
|
|
|
|
|
this.defaultItems=[...this.optionItems]
|
2024-05-18 10:19:01 +00:00
|
|
|
|
}
|
2024-05-25 09:36:22 +00:00
|
|
|
|
});
|
2024-05-18 10:19:01 +00:00
|
|
|
|
},
|
2024-05-07 04:53:25 +00:00
|
|
|
|
reverseArrow(flag) {
|
2024-05-18 10:19:01 +00:00
|
|
|
|
let rulesDom = this.$refs["selectRef"].$el.querySelector(
|
2024-05-07 04:53:25 +00:00
|
|
|
|
".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-07 04:53:25 +00:00
|
|
|
|
rulesDom.classList.remove("is-reverse"); // 对dom新增class
|
2024-04-22 05:35:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|
2024-05-07 04:53:25 +00:00
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
// right: 30px;
|
|
|
|
|
|
// cursor: pointer;
|
|
|
|
|
|
:deep .el-select.remote-select{
|
|
|
|
|
|
.el-select__caret::before{
|
|
|
|
|
|
content: '\e6e1';
|
|
|
|
|
|
}
|
|
|
|
|
|
.is-focus{
|
|
|
|
|
|
.el-select__caret{
|
|
|
|
|
|
transform: rotateZ(0deg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|