[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
@@ -32,7 +32,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"
@@ -40,10 +40,10 @@
@change="handleTableChange">
<!-- 操作栏 -->
<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>
@@ -72,8 +72,8 @@ export default {
/* 分页参数 */
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '30', '50', '100', '150', '200'],
pageSize: 5,
pageSizeOptions: ['5', '10', '30', '50', '100', '150', '200'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + this.$t('total') + total + this.$t('strip')
},
@@ -127,7 +127,15 @@ export default {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) {
// 给表格赋值,在线编辑不知道要怎么赋值?
this.dataSource = data.otherDraftUserVOS || []
this.dataSource = data.otherDraftUserVOS && data.otherDraftUserVOS.length > 0 ? data.otherDraftUserVOS.map(item => {
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
return {
uid: uidGenerator(),
...item
}
}) : []
// 给表单赋值
this.$nextTick(() => {
this.$refs.baseInfoForm.initData(data)
@@ -166,18 +174,17 @@ export default {
this.$refs.addEditDrafterDrawer.add()
},
// 编辑
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.addEditDrafterDrawer.edit(record)
},
// 删除
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)
}
})
@@ -185,10 +192,13 @@ export default {
// 新增或编辑完成
modalFormOk (value) {
if (this.modalType === 'add') {
this.dataSource.push(value)
} else if (this.modalType && this.modalType.split('-')[0] === 'edit') {
console.log(Number(this.modalType.split('-')[1]), value)
this.dataSource.splice(Number(this.modalType.split('-')[1]), 1, 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') {
const dataIndex = this.dataSource.findIndex(item => item.uid === this.modalType.split(',')[1])
this.dataSource.splice(dataIndex, 1, value)
}
}
}