【update】-来款企业可以多选查询

This commit is contained in:
fengchenchen
2023-05-17 14:16:25 +08:00
parent 368f980b8b
commit a652c6fe71
4 changed files with 71 additions and 13 deletions
+32 -3
View File
@@ -35,7 +35,7 @@
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: 'radio'}"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: isMultiple ? 'checkbox' : 'radio'}"
@change="handleTableChange"
class="j-table-force-nowrap">
<template slot="htmlSlot" slot-scope="text">
@@ -71,6 +71,12 @@ export default {
memberNature: {
type: Number,
default: null
},
// 是否多选-默认false
isMultiple: {
type:Boolean,
required:false,
default:false
}
},
data() {
@@ -134,7 +140,6 @@ export default {
if (res.result.total) {
this.ipagination.total = res.result.total
//清空列表选中
this.onClearSelected()
} else {
this.ipagination.total = 0
}
@@ -158,10 +163,29 @@ export default {
close() {
this.visible = false
this.selectedCompany = {}
if (this.isMultiple) {
this.selectedCompany = []
}
this.onClearSelected()
},
onSelectChange(selectedRowKeys, selectionRows) {
this.selectedCompany = selectionRows[0]
console.log('---this.selectedCompany----', selectedRowKeys, selectionRows)
if(!this.isMultiple) {
this.selectedCompany = selectionRows[0]
} else {
// selectionRows只会返回当前页数据的返回,所以多选的时候需要比对各个数据是否存在,不存在的话就从当前数据中查询推入selectedCompany中
let resultArr = []
selectionRows.forEach(row => {
let ele = this.selectedCompany.find(ele => ele.id === row.id)
if(!ele) {
resultArr.push(row)
}
})
this.selectedCompany = [...this.selectedCompany, ...resultArr]
// this.selectedCompany = selectionRows
}
this.selectedRowKeys = selectedRowKeys
},
/*
* 重写一下查询 之前调用的是混入的查询
@@ -175,6 +199,11 @@ export default {
this.queryParam = {}
this.loadData(1)
}
},
created() {
if (this.isMultiple) {
this.selectedCompany = []
}
}
}
</script>
+24 -5
View File
@@ -2,14 +2,14 @@
<div class="company-select">
<a-row>
<a-col :span="20">
<a-input @click="chooseBusiness" :value="value[valueKey]" v-bind="$attrs" :readOnly="true" unselectable="on"></a-input>
<a-input @click="chooseBusiness" :title="value[valueKey]" :value="value[valueKey]" v-bind="$attrs" :readOnly="true" unselectable="on"></a-input>
</a-col>
<a-col :span="4" class="form-btn" v-if="canAdd">
<a-button v-bind="$attrs" icon="plus" @click="addCompany"></a-button>
</a-col>
</a-row>
<business-select ref="businessSelect" @ok="handleOk" v-bind="$attrs"></business-select>
<business-select ref="businessSelect" @ok="handleOk" v-bind="$attrs" :is-multiple="isMultiple"></business-select>
<business-management-module ref="businessAdd" @ok="addCompanyOk"></business-management-module>
</div>
</template>
@@ -50,6 +50,12 @@ export default {
type:Boolean,
required:false,
default:false
},
// 是否多选-默认false
isMultiple: {
type:Boolean,
required:false,
default:false
}
},
methods: {
@@ -71,9 +77,22 @@ export default {
* @param value
*/
handleOk(value) {
let company = {
id: value.id,
companyName: value.companyName
console.log('--------value---------', 'value')
let company = {id: undefined, companyName: undefined}
// 多选的时候 全部放在一起,以逗号分隔
if (this.isMultiple) {
if(value.length > 0) {
let ids = [], nameArr = []
value.forEach(item => {
ids.push(item.id)
nameArr.push(item.companyName)
})
company.id = ids.join()
company.companyName= nameArr.join()
}
} else {
company.id = value.id
company.companyName= value.companyName
}
this.$emit('change', company)
},