diff --git a/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonCollectBaseInfo.vue b/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonCollectBaseInfo.vue index 54aea733..beb68d65 100644 --- a/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonCollectBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonCollectBaseInfo.vue @@ -16,12 +16,19 @@ + +
+ + + {{ $t('newlyAdded') }} + +
{{ $t('edit') }} - {{ $t('delete') }} + {{ $t('delete') }}
@@ -166,7 +173,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.formInline = Object.assign({}, data) this.onEditFile = data.onEditFile // 给表单赋值 @@ -204,34 +219,47 @@ export default { handleTableChange (pagination) { this.ipagination = pagination }, + // 新增征求意见 + handleAdd () { + // 左侧预览在线编辑的文件 + const file = this.onEditFile + this.$refs.commentModal.title = this.$t('newlyAdded') + this.$refs.commentModal.add(file) + }, // 征求意见的编辑 handleEdit (record) { // 不知道左侧要预览哪个文件 const file = this.onEditFile this.$refs.commentModal.title = this.$t('edit') - this.$refs.commentModal.edit(file, record, record.id) + this.$refs.commentModal.edit(file, record, record.uid) }, // 征求意见的删除 - handleDelete (id) { + handleDelete (uid) { this.$confirm({ title: this.$t('confirmDeletion'), content: this.$t('areYouSure'), onOk: () => { - const dataIndex = this.dataSource.findIndex(item => item.id === id) + const dataIndex = this.dataSource.findIndex(item => item.uid === uid) this.dataSource.splice(dataIndex, 1) } }) }, // 征求意见新增编辑完成 - modalFormOk (value, id) { - console.log(value, id) - if (id || id === 0) { - const dataIndex = this.dataSource.findIndex(item => item.id === id) + modalFormOk (value, uid) { + console.log(value, uid) + if (uid || uid === 0) { + const dataIndex = this.dataSource.findIndex(item => item.uid === uid) // 有下标,说明是编辑 this.$set(this.dataSource[dataIndex], 'clauseNum', value.clauseNum) this.$set(this.dataSource[dataIndex], 'clauseName', value.clauseName) this.$set(this.dataSource[dataIndex], 'editAdvice', value.editAdvice) // this.dataSource.splice(index, 1, value) + } else { + // 没有下标, 是新增 + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } + this.dataSource.push({ uid: uidGenerator(), ...value }) } }, // 选择用户得到用户名