emis-frontend/src/views/emis/EmisBaseTools/backup/CustomerAddressPicker.vue
2024-05-07 12:53:57 +08:00

145 lines
3.3 KiB
Vue

<template>
<section class="p-10">
<el-select
filterable
clearable
default-first-option
allow-create=""
v-el-select-loadmore="loadmore"
remote
:remote-method="remoteMethod"
:loading="loading"
:no-data-text="noDataText"
v-model="svalue"
sPlaceholder="选择"
@change="onChange">
<div class="el-s-thead">
<div style="width:20%;">名称</div>
<div style="width:20%;">电话</div>
<div style="width:20%;">公司</div>
<div style="width:40%;">地址</div>
</div>
<el-option v-for="item in filterData" :key="item.id" :label="item.name" :value="item.id">
<div class="el-data">
<div style="width:20%;">{{ item.name }}</div>
<div style="width:20%;">{{ item.phone }}</div>
<div style="width:20%;">{{ item.company }}</div>
<div style="width:40%;">{{ item.country }}</div>
</div>
</el-option>
</el-select>
</section>
</template>
<script>
import { listEmisCustomerAddress } from "@/api/emis/emisCustomerAddress";
export default {
name: "CustomerAddressPicker",
props: {
value: {
type: [String, Number],
required: false
},
countryCode: {
type: String,
required: false
},
},
data() {
return {
svalue: this.value,
sCountry:null,
code:'',
// 原始数据
data: [],
// 搜索后的数据
filterData:[],
filterMap:new Map(),
// 选中的值
sel:'',
// 输入的值转为大写后
queryVal:'',
noDataText: '无数据',
loading: false,
queryParams:{
pageNum: 1,
pageSize: 10,
}
};
},
watch: {
value(newVal) {
this.svalue = newVal;
},
svalue(newVal, oldVal) {
if (newVal !== oldVal) {
// this.$emit("input", this.svalue);
}
},
countryCode(newVal) {
this.sCountry = newVal;
this.queryData();
}
},
created() {
this.queryData();
},
methods: {
onChange(val) {
this.svalue = val;
// this.$emit("onChange");
let selData=this.filterMap[val];
console.log(selData);
this.$emit('onChange', selData)
},
remoteMethod(queryVal) {
this.queryParams.pageNum=1;
this.queryParams.name=queryVal;
this.queryData();
},
loadmore() {
this.queryParams.pageNum++;
this.queryData();
},
queryData() {
listEmisCustomerAddress(this.queryParams).then(response => {
this.filterData= response.rows
this.filterData.forEach(item => {
this.filterMap[item.id]=item;
});
});
},
}
};
</script>
<style lang="scss" scoped>
.el-s-thead{
width: 100%;
color: rgb(177 47 41);
font-size: 14px;
font-weight: 600;
display: inline-flex;
padding: 10px;
border-bottom: 1px solid #e6e3e3;
min-width: 500px;
}
.el-data{
width: 100%;
color: #000;
font-size: 14px;
font-weight: 600;
display: inline-flex;
padding: 5px;
border-bottom: 1px solid #e6e3e3;
}
</style>