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

183 lines
4.1 KiB
Vue
Raw Normal View History

2025-06-11 00:15:54 +00:00
<template>
<el-select
multiple
filterable
2025-06-12 02:56:29 +00:00
2025-06-11 00:15:54 +00:00
clearable
ref="selectRef"
remote
:remote-method="queryData"
:loading="loading"
v-model="svalue"
:placeholder="placeholder"
style="width:100%"
@focus="onFocus"
2025-06-12 00:44:30 +00:00
2025-06-11 00:15:54 +00:00
class="mutiSelect"
2025-06-12 02:56:29 +00:00
@change="onChange"
@visible-change="reverseArrow"
2025-06-11 00:15:54 +00:00
>
2025-06-12 00:44:30 +00:00
<!-- @change="onChange" -->
2025-06-11 00:15:54 +00:00
<!-- collapse-tags -->
<div style="padding: 0px 8px 0 20px;width:100%;line-height:34px;display:inline-flex; border-bottom: 1px solid #e7e7e7;">
<div style="width:50%">
<span style="font-size: 13px;font-weight: 600;">选择供应商</span>
</div>
<div style="width:50%;text-align:right">
<el-button type="primary" size="mini" style="padding:2px 10px" @click="confirmOk">确定</el-button>
</div>
</div>
2025-06-12 02:56:29 +00:00
<el-option v-for="item in optionItems.filter(el=> !svalue.includes(el.code) )" :key="item.id" :label="item.name" :value="item.code">
2025-06-11 00:15:54 +00:00
</el-option>
</el-select>
</template>
<script>
import { listSimpleEmisSupplier } from "@/api/emis/emisSupplier";
import emitter from 'element-ui/src/mixins/emitter';
export default {
name: "EmisSupplierMultiplePicker",
mixins: [emitter],
props: {
value: {
type: [String],
required: false
},
placeholder:{
type: [String],
required: false
},
},
data() {
return {
svalue: [],
// 搜索后的数据
optionItems:[],
itemMap:new Map(),
loading: false,
queryParams:{
pageNum: 1,
pageSize: 50,
2025-06-11 11:08:15 +00:00
code:this.value,
name:null
2025-06-11 00:15:54 +00:00
}
};
},
watch: {
value(newVal) {
2025-06-12 00:44:30 +00:00
if(this.value) {
this.svalue = this.value.split(',');
2025-06-12 02:56:29 +00:00
// this.queryData(null,this.value,this.value);
2025-06-12 00:44:30 +00:00
}
// this.queryParams.sortCodeStr=this.value;
// console.log("xxxx===>xxx2:",this.queryParams)
// this.queryData(null);
2025-06-11 00:15:54 +00:00
},
},
created() {
if(this.value) {
this.svalue = this.value.split(',');
2025-06-12 00:44:30 +00:00
this.queryData(null,this.value,this.value);
2025-06-11 00:15:54 +00:00
}
},
methods: {
confirmOk(){
2025-06-11 11:08:15 +00:00
let selCodeStr="";
2025-06-11 00:15:54 +00:00
if(this.svalue&&this.svalue.length>0){
selCodeStr=this.svalue.join(',');
}
2025-06-12 00:44:30 +00:00
console.log("===>==1=>》:",this.svalue,selCodeStr);
2025-06-11 00:15:54 +00:00
this.$emit('input', selCodeStr)
this.$emit('onChange',selCodeStr)
2025-06-12 00:44:30 +00:00
// this.dispatch('ElFormItem', 'el.form.blur', [this.svalue]);
2025-06-11 00:15:54 +00:00
this.$refs.selectRef.blur();
},
onFocus(){
2025-06-12 02:56:29 +00:00
let selCodeStr=null;
2025-06-12 00:44:30 +00:00
if(this.svalue&&this.svalue.length>0){
2025-06-12 02:56:29 +00:00
selCodeStr=this.svalue.join(',');
2025-06-12 00:44:30 +00:00
}
2025-06-12 02:56:29 +00:00
this.queryData(null,null,selCodeStr);
2025-06-11 00:15:54 +00:00
},
onChange(val) {
2025-06-12 02:56:29 +00:00
let selCodeStr="";
if(this.svalue&&this.svalue.length>0){
selCodeStr=this.svalue.join(',');
}
// this.queryData(null,null,selCodeStr);
this.$emit('input', selCodeStr)
this.$emit('onChange',selCodeStr)
2025-06-11 00:15:54 +00:00
},
2025-06-12 00:44:30 +00:00
queryData(val,key,sortCodeStr) {
2025-06-11 00:15:54 +00:00
this.queryParams.pageNum=1;
2025-06-12 00:44:30 +00:00
this.queryParams.name=val;
this.queryParams.code=key;
this.queryParams.sortCodeStr=sortCodeStr;
2025-06-11 00:15:54 +00:00
console.log("xxxx===>xxx2:",this.queryParams)
listSimpleEmisSupplier(this.queryParams).then(response => {
this.optionItems=response.rows
this.optionItems.forEach(item => {
if(!(item.code in this.itemMap)){
this.itemMap[item.code]=item;
}
});
});
},
2025-06-12 02:56:29 +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
}
},
2025-06-11 00:15:54 +00:00
}
};
</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: 300px;
}
.el-data{
width: 100%;
color: #000;
font-size: 14px;
font-weight: 600;
display: inline-flex;
padding: 5px;
border-bottom: 1px solid #e6e3e3;
}
.el-tag.el-tag--info {
background-color: #f4f4f5;
border-color: #e9e9eb;
color: #000000;
font-weight: 600;
}
.mutiSelect :deep .el-select-dropdown.is-multiple .el-select-dropdown__item.selected::after {
display: none;
}
</style>