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

144 lines
3.5 KiB
Vue
Raw Normal View History

2024-05-18 11:14:53 +00:00
<template>
<el-select
multiple
filterable
clearable
ref="selectRef"
remote
:remote-method="queryData"
:loading="loading"
v-model="svalue"
:placeholder="placeholder"
style="width:100%"
2024-05-19 04:07:15 +00:00
@focus="onFocus"
2024-05-18 11:14:53 +00:00
@change="onChange">
<!-- allow-create -->
<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">
2024-05-19 04:07:15 +00:00
<el-button type="primary" size="mini" style="padding:2px 10px" @click="confirmOk">确定</el-button>
2024-05-18 11:14:53 +00:00
</div>
</div>
2024-05-19 04:07:15 +00:00
<el-option v-for="item in optionItems" :key="item.goodsName" :label="item.goodsName" :value="item.goodsName">
2024-05-18 11:14:53 +00:00
</el-option>
</el-select>
<!-- <el-checkbox-group v-model="svalue">
<el-option v-for="item in filterData" :key="item.id" :label="item.goodsName" :value="item.id">
<el-checkbox style="pointer-events: none" :label="item.goodsName"></el-checkbox>
</el-option>
</el-checkbox-group> -->
</template>
<script>
import { listSimpleEmisGoods} from "@/api/emis/emisGoods";
export default {
name: "GoodsMultiplePicker",
props: {
value: {
type: [String],
required: false
},
placeholder:{
type: [String],
required: false
},
},
data() {
return {
svalue: [],
// 搜索后的数据
optionItems:[],
itemMap:new Map(),
loading: false,
queryParams:{
pageNum: 1,
pageSize: 10,
}
};
},
watch: {
value(newVal) {
},
},
created() {
2024-05-19 04:07:15 +00:00
// if(this.value) {
// this.svalue = this.value.split(',');
// }
// this.queryData();
2024-05-18 11:14:53 +00:00
},
methods: {
2024-05-19 04:07:15 +00:00
confirmOk(){
let selIdStr="";
2024-05-18 11:14:53 +00:00
let selNameStr="";
2024-05-19 04:07:15 +00:00
let selData = [];
2024-05-18 11:14:53 +00:00
this.svalue.forEach(item=>{
let itemData=this.itemMap[item];
if(itemData!=null){
selData.push(itemData)
2024-05-19 04:07:15 +00:00
selIdStr=selIdStr+itemData.goodsName+",";
2024-05-18 11:14:53 +00:00
selNameStr=selNameStr+itemData.goodsName+",";
}
});
2024-05-19 04:07:15 +00:00
selIdStr = selIdStr.substring(0,selIdStr.length-1);
this.$emit('input', selIdStr)
2024-05-18 11:14:53 +00:00
this.$emit('onChange', selData,selNameStr)
2024-05-19 04:07:15 +00:00
this.$refs.selectRef.blur();
},
onFocus(){
this.queryData();
},
onChange(val) {
2024-05-19 19:04:49 +00:00
this.confirmOk()
2024-05-18 11:14:53 +00:00
},
queryData(queryVal) {
this.queryParams.pageNum=1;
this.queryParams.goodsName=queryVal;
listSimpleEmisGoods(this.queryParams).then(response => {
2024-05-19 04:07:15 +00:00
this.optionItems=response.rows
console.log(this.optionItems);
2024-05-18 11:14:53 +00:00
this.optionItems.forEach(item => {
2024-05-19 04:07:15 +00:00
if(!(item.goodsName in this.itemMap)){
this.itemMap[item.goodsName]=item;
2024-05-18 11:14:53 +00:00
}
});
2024-05-19 04:07:15 +00:00
2024-05-18 11:14:53 +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;
}
</style>