处理取消行选择仍可以删除信息的问题

This commit is contained in:
renpy 2023-07-28 18:57:27 +08:00
parent 2a6ff43f0b
commit ab4961b3a4
4 changed files with 21 additions and 9 deletions

View File

@ -72,19 +72,20 @@ export default {
class: this.innerSelectedRowKeys.includes(key) ? 'ant-table-row-selected' : '', class: this.innerSelectedRowKeys.includes(key) ? 'ant-table-row-selected' : '',
on: { on: {
click: () => { click: () => {
this.$emit("rowClick",record)
if(!this.canSelect) { if(!this.canSelect) {
return return
} }
if (this.innerSelectedRowKeys.includes(key)) { if (this.innerSelectedRowKeys.includes(key)) {
const findIndex = this.innerSelectedRowKeys.findIndex(k => k == key) const findIndex = this.innerSelectedRowKeys.findIndex(k => k == key)
this.innerSelectedRowKeys.splice(findIndex, 1) this.innerSelectedRowKeys.splice(findIndex, 1)
this.$emit("cancleRowClick")
} else { } else {
if(this.multiple) { if(this.multiple) {
this.innerSelectedRowKeys.push(key) this.innerSelectedRowKeys.push(key)
} }
else { else {
this.innerSelectedRowKeys = [key] this.innerSelectedRowKeys = [key]
this.$emit("selectRowClick",record)
} }
} }
}, },

View File

@ -38,7 +38,8 @@
:list="dataSource" :list="dataSource"
:loading="loading" :loading="loading"
:pagination="false" :pagination="false"
@rowClick="onRowClick" @selectRowClick="selectRow"
@cancleRowClick="cancelRow"
@rowDbclick="onRowDbclick" @rowDbclick="onRowDbclick"
> >
<template slot="status" slot-scope="{record}"> <template slot="status" slot-scope="{record}">
@ -346,9 +347,12 @@ export default {
this.$message.info("Please select a piece of data") this.$message.info("Please select a piece of data")
} }
}, },
onRowClick(record) { selectRow(record) {
this.currentId = record.id this.currentId = record.id
}, },
cancelRow() {
this.currentId = ""
},
onSave() { onSave() {
this.form.validateFields((err, values) => { this.form.validateFields((err, values) => {
if (!err) { if (!err) {

View File

@ -38,7 +38,8 @@
:list="dataSource" :list="dataSource"
:loading="loading" :loading="loading"
:pagination="false" :pagination="false"
@rowClick="onRowClick" @selectRowClick="selectRow"
@cancleRowClick="cancelRow"
@rowDbclick="onRowDbclick" @rowDbclick="onRowDbclick"
> >
<template slot="status" slot-scope="{record}"> <template slot="status" slot-scope="{record}">
@ -368,10 +369,12 @@ export default {
this.$message.info("Please select a piece of data") this.$message.info("Please select a piece of data")
} }
}, },
onRowClick(record) { selectRow(record) {
console.log(record);
this.currentId = record.id this.currentId = record.id
}, },
cancelRow() {
this.currentId = ""
},
onSave() { onSave() {
this.form.validateFields((err, values) => { this.form.validateFields((err, values) => {
if (!err) { if (!err) {

View File

@ -38,7 +38,8 @@
:list="dataSource" :list="dataSource"
:pagination="false" :pagination="false"
:loading="loading" :loading="loading"
@rowClick="onRowClick" @selectRowClick="selectRow"
@cancleRowClick="cancelRow"
@rowDbclick="onRowDbclick" @rowDbclick="onRowDbclick"
> >
<template slot="status" slot-scope="{text,record}"> <template slot="status" slot-scope="{text,record}">
@ -280,9 +281,12 @@ export default {
this.$message.info("Please select a piece of data") this.$message.info("Please select a piece of data")
} }
}, },
onRowClick(record) { selectRow(record) {
this.currentId = record.id this.currentId = record.id
}, },
cancelRow() {
this.currentId = ""
},
onSave() { onSave() {
this.form.validateFields((err, values) => { this.form.validateFields((err, values) => {
if (!err) { if (!err) {