|
@@ -89,7 +89,7 @@
|
|
|
@change="handleTableChange"
|
|
|
:pagination="pagination"
|
|
|
:scroll="{ x: 2500, y: 300 }"
|
|
|
- :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
|
|
+ :rowSelection="{ onSelect: onSelect, onSelectAll: onSelectAll, selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
|
|
>
|
|
|
</a-table>
|
|
|
</a-card>
|
|
@@ -224,8 +224,8 @@
|
|
|
sm: { span: 12 },
|
|
|
});
|
|
|
const dataSource =ref([]);
|
|
|
- let selectedRowKeys = ref([]);
|
|
|
- let selectedRows = ref([]);
|
|
|
+ var selectedRowKeys = ref([]);
|
|
|
+ var selectionRows = ref([]);
|
|
|
const toggleSearchStatus = ref(false);
|
|
|
const queryParams = ref({
|
|
|
classId:'',
|
|
@@ -316,22 +316,56 @@
|
|
|
function handleToggleSearch(){
|
|
|
toggleSearchStatus.value = !toggleSearchStatus.value;
|
|
|
}
|
|
|
- function onSelectChange(keys,rows){
|
|
|
- selectedRowKeys.value = keys
|
|
|
- selectedRows.value = rows
|
|
|
+ function onSelectChange(selectedRowKeys1, selectionRows) {
|
|
|
+ var arr = selectedRowKeys.value
|
|
|
+ selectedRowKeys.value = arr.concat(selectedRowKeys1)
|
|
|
+ }
|
|
|
+ function onSelect(record, selected, selectionRows1, nativeEvent) {
|
|
|
+ if (selected) {
|
|
|
+ selectionRows.value.push(record)
|
|
|
+ // console.log(this.selectionRows)
|
|
|
+ }else{
|
|
|
+ const delIndex = selectionRows.value.findIndex((val) => {
|
|
|
+ return val.id === record.id
|
|
|
+ })
|
|
|
+ selectionRows.value.splice(delIndex, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function onSelectAll(selected, selectionRows, changeRows) {
|
|
|
+ if (selected) {
|
|
|
+ selectionRows.value = selectionRows.value.concat(changeRows)
|
|
|
+ }
|
|
|
+ if (!selected) {
|
|
|
+ let selectionRows1 = JSON.parse(JSON.stringify(selectionRows.value))
|
|
|
+ const delIndex = []
|
|
|
+ selectionRows1.forEach((item, index) => {
|
|
|
+ changeRows.forEach((val, itemIndex) => {
|
|
|
+ if (item.id === val.id) {
|
|
|
+ delIndex.push(index)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ delIndex.forEach((item) => {
|
|
|
+ delete selectionRows1[item]
|
|
|
+ })
|
|
|
+ selectionRows1 = selectionRows1.filter((item) => {
|
|
|
+ return item !== undefined
|
|
|
+ })
|
|
|
+ selectionRows.value = selectionRows1
|
|
|
+ }
|
|
|
}
|
|
|
function handleOk(){
|
|
|
if(selectedRowKeys.value.length==0){
|
|
|
message.error('请勾选数据');
|
|
|
}else{
|
|
|
- emit('selectProduct', selectedRows.value)
|
|
|
+ emit('selectProduct', selectionRows.value)
|
|
|
handleCancel()
|
|
|
}
|
|
|
}
|
|
|
function handleCancel(){
|
|
|
visible.value = false
|
|
|
selectedRowKeys.value = []
|
|
|
- selectedRows.value=[]
|
|
|
+ selectionRows.value=[]
|
|
|
pagination.value.current = 1
|
|
|
pagination.value.pageSize = 10;
|
|
|
}
|