[update] 修改bug80447
This commit is contained in:
+26
-15
@@ -29,7 +29,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"
|
||||
@@ -37,10 +37,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(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>
|
||||
@@ -125,7 +125,15 @@ export default {
|
||||
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
|
||||
initData (data) {
|
||||
// 给表格赋值,在线编辑不知道要怎么赋值?
|
||||
this.dataSource = data.advices
|
||||
this.dataSource = data.advices.map(item => {
|
||||
const uidGenerator = () => {
|
||||
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
||||
}
|
||||
return {
|
||||
uid: uidGenerator(),
|
||||
...item
|
||||
}
|
||||
})
|
||||
// 给表单赋值
|
||||
this.$nextTick(() => {
|
||||
this.$refs.baseInfoForm.initData(data)
|
||||
@@ -161,33 +169,36 @@ export default {
|
||||
this.$refs.commentModal.add(file)
|
||||
},
|
||||
// 征求意见的编辑
|
||||
handleEdit (record, index) {
|
||||
handleEdit (record) {
|
||||
// 不知道左侧要预览哪个文件
|
||||
const file = ''
|
||||
this.$refs.commentModal.title = this.$t('edit')
|
||||
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index
|
||||
this.$refs.commentModal.edit(file, record, dataIndex)
|
||||
this.$refs.commentModal.edit(file, record, record.uid)
|
||||
},
|
||||
// 征求意见的删除
|
||||
handleDelete (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)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 征求意见新增编辑完成
|
||||
modalFormOk (value, index) {
|
||||
console.log(value, index)
|
||||
if (index || index === 0) {
|
||||
modalFormOk (value, uid) {
|
||||
console.log(value, uid)
|
||||
if (uid || uid === 0) {
|
||||
// 有下标,说明是编辑
|
||||
this.dataSource.splice(index, 1, value)
|
||||
const dataIndex = this.dataSource.findIndex(item => item.uid === uid)
|
||||
this.dataSource.splice(dataIndex, 1, value)
|
||||
} else {
|
||||
// 没有下标, 是新增
|
||||
this.dataSource.push(value)
|
||||
const uidGenerator = () => {
|
||||
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
||||
}
|
||||
this.dataSource.push({ uid: uidGenerator(), ...value })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user