[update] 修改bug80447

This commit is contained in:
lideqin
2024-01-16 14:23:26 +08:00
parent 5954525a32
commit 424e49aa92
14 changed files with 321 additions and 188 deletions
@@ -17,7 +17,7 @@
:can-drag="true"
:scroll="{x: '100%'}"
ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }"
rowKey="uid"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
@@ -35,10 +35,10 @@
</template>
<!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" />
<a @click="handleDelete(record.id, index)" class="table-ope-btn" :disabled="disabled">{{ $t('delete') }}</a>
<a @click="handleDelete(record.uid)" class="table-ope-btn" :disabled="disabled">{{ $t('delete') }}</a>
</div>
</j-table>
@@ -213,9 +213,13 @@ export default {
changeBaseInfoDrawerOk (value) {
console.log(value, this.modalType)
if (this.modalType === 'add') {
this.dataSource.push(value)
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
this.dataSource.push({ uid: uidGenerator(), ...value })
} else if (this.modalType && this.modalType.split(',')[0] === 'edit') {
this.dataSource.splice(Number(this.modalType.split(',')[1]), 1, value)
const dataIndex = this.dataSource.findIndex(item => item.uid === this.modalType.split(',')[1])
this.dataSource.splice(dataIndex, 1, value)
}
},
// 新增
@@ -225,19 +229,18 @@ export default {
this.$refs.changeBaseInfoDrawer.title = this.$t('newlyAdded')
},
// 编辑
handleEdit (record, index) {
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index
this.modalType = 'edit' + ',' + dataIndex
handleEdit (record) {
this.modalType = 'edit' + ',' + record.uid
this.$refs.changeBaseInfoDrawer.edit(record)
this.$refs.changeBaseInfoDrawer.title = this.$t('edit')
},
// 删除
handleDelete (id, index) {
handleDelete (uid) {
this.$confirm({
title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'),
onOk: () => {
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index
const dataIndex = this.dataSource.findIndex(item => item.uid === uid)
this.dataSource.splice(dataIndex, 1)
}
})
@@ -252,10 +255,10 @@ export default {
title: this.$t('confirmBatchDeletion'),
content: this.$t('deleteAData'),
onOk: () => {
for (let i = 0; i < this.selectedRowKeys.length; i++) {
this.dataSource.splice(this.selectedRowKeys[i], 1, false)
for (const i of this.selectedRowKeys) {
const dataIndex = this.dataSource.findIndex(item => item.uid === i)
this.dataSource.splice(dataIndex, 1)
}
this.dataSource = this.dataSource.filter(item => !!item)
this.selectedRowKeys = []
}
})