[update] 修改bug80447
This commit is contained in:
@@ -7,7 +7,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"
|
||||
@@ -144,7 +144,15 @@ export default {
|
||||
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
|
||||
initData (data) {
|
||||
// 给表格赋值,在线编辑不知道要怎么赋值?
|
||||
this.dataSource = data.list
|
||||
this.dataSource = data.list.map(item => {
|
||||
const uidGenerator = () => {
|
||||
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
||||
}
|
||||
return {
|
||||
uid: uidGenerator(),
|
||||
...item
|
||||
}
|
||||
})
|
||||
// 给表单赋值
|
||||
this.$nextTick(() => {
|
||||
this.$refs.baseInfoForm.initData(data)
|
||||
|
||||
@@ -30,7 +30,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"
|
||||
@@ -43,10 +43,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(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>
|
||||
@@ -438,7 +438,15 @@ export default {
|
||||
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
|
||||
initData (data) {
|
||||
// 给表格赋值,在线编辑不知道要怎么赋值?
|
||||
this.dataSource = data.list
|
||||
this.dataSource = data.list.map(item => {
|
||||
const uidGenerator = () => {
|
||||
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
||||
}
|
||||
return {
|
||||
uid: uidGenerator(),
|
||||
...item
|
||||
}
|
||||
})
|
||||
const formInline = {}
|
||||
// 更改级别代号
|
||||
formInline.levelCode = data.levelCode
|
||||
@@ -532,32 +540,35 @@ export default {
|
||||
this.$refs.updateListModal.add(standardId)
|
||||
},
|
||||
// 修改单的编辑
|
||||
handleEdit (record, index) {
|
||||
handleEdit (record) {
|
||||
const standardId = this.$refs.baseInfoForm.formInline.standardId || ''
|
||||
this.$refs.updateListModal.title = this.$t('edit')
|
||||
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index
|
||||
this.$refs.updateListModal.edit(standardId, record, dataIndex)
|
||||
this.$refs.updateListModal.edit(standardId, 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