From 424e49aa924f754ac09eb2d944d78f5ff539904c Mon Sep 17 00:00:00 2001 From: lideqin <694785430@qq.com> Date: Tue, 16 Jan 2024 14:23:26 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20=E4=BF=AE=E6=94=B9bug80447?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/OnlyTableForm.vue | 51 ++++++++++----- .../modules/EngineerInitBaseInfo.vue | 65 ++++++++++++------- .../modules/ApproveBaseInfo.vue | 12 +++- .../modules/MainDrafterInitBaseInfo.vue | 41 +++++++----- .../PlanApprovalChangeFlow.vue | 10 ++- .../modules/FinishTimeChangeBaseInfo.vue | 31 +++++---- .../modules/JobEndBaseInfo.vue | 35 +++++----- .../modules/CommentObjectEnterBaseInfo.vue | 41 +++++++----- .../modules/DepartLiaisonCollectBaseInfo.vue | 31 ++++----- .../DepartLiaisonLeaderApproveBaseInfo.vue | 45 ++++++++----- .../modules/MainDrafterCollectBaseInfo.vue | 29 +++++---- ...MainDrafterCollectUploadMinuteBaseInfo.vue | 50 +++++++++----- .../modules/MainDrafterSentBaseInfo.vue | 42 +++++++----- .../OtherDrafterUploadStandardBaseInfo.vue | 26 +++++--- 14 files changed, 321 insertions(+), 188 deletions(-) diff --git a/src/views/workCenter/annualRevisionPlanActivelyReport/modules/OnlyTableForm.vue b/src/views/workCenter/annualRevisionPlanActivelyReport/modules/OnlyTableForm.vue index 8829aac0..3d6d46d5 100644 --- a/src/views/workCenter/annualRevisionPlanActivelyReport/modules/OnlyTableForm.vue +++ b/src/views/workCenter/annualRevisionPlanActivelyReport/modules/OnlyTableForm.vue @@ -25,7 +25,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" @@ -56,12 +56,12 @@ {{ $t('lookDetail') }} @@ -307,7 +307,15 @@ export default { initData (data) { // 给表格赋值 if (data && data.dataList) { - this.dataSource = data.dataList + this.dataSource = data.dataList.map(item => { + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } + return { + uid: uidGenerator(), + ...item + } + }) } }, // 外层要获取数据 @@ -354,9 +362,13 @@ export default { modelFormOk (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) } }, // 新增 @@ -409,7 +421,15 @@ export default { this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`) } // 推入表格中 - this.dataSource = info.file.response.result + this.dataSource = info.file.response.result.map(item => { + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } + return { + uid: uidGenerator(), + ...item + } + }) } else { if (Array.isArray(info.file.response.result) && info.file.response.result.length > 0) { this.messageLineFeed(this.$t('fileImportError'), info.file.response.result) @@ -444,9 +464,8 @@ export default { } }, // 编辑 - 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.contactEnterSendTaskModal.edit(record) }, // 查看 @@ -454,12 +473,12 @@ export default { this.$refs.contactEnterSendTaskModal.look(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) } }) @@ -474,10 +493,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 = [] } }) diff --git a/src/views/workCenter/annualRevisionPlanStandardizationInit/modules/EngineerInitBaseInfo.vue b/src/views/workCenter/annualRevisionPlanStandardizationInit/modules/EngineerInitBaseInfo.vue index 7efd69ff..288785e5 100644 --- a/src/views/workCenter/annualRevisionPlanStandardizationInit/modules/EngineerInitBaseInfo.vue +++ b/src/views/workCenter/annualRevisionPlanStandardizationInit/modules/EngineerInitBaseInfo.vue @@ -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" @@ -47,10 +47,10 @@ -
- {{ $t('edit') }} +
+ {{ $t('edit') }} - {{ $t('delete') }} + {{ $t('delete') }}
@@ -256,7 +256,7 @@ export default { // 不是被驳回的待办,可以设置联络人 return } @@ -303,7 +303,15 @@ export default { // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 initData (data) { // 给表格赋值 - this.dataSource = data + this.dataSource = data.map(item => { + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } + return { + uid: uidGenerator(), + ...item + } + }) }, // 外层要获取数据 getData () { @@ -346,8 +354,9 @@ export default { }) }, // 行内联络人变化的回调 - lineNameChange (value, fieldName) { - this.dataSource[fieldName].contactUser_dictText = value + lineNameChange (value, uid) { + const dataIndex = this.dataSource.findIndex(item => item.uid === uid) + this.dataSource[dataIndex].contactUser_dictText = value }, handleTableChange (pagination) { this.ipagination = pagination @@ -368,9 +377,13 @@ export default { modelFormOk (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) } }, // 新增 @@ -423,7 +436,15 @@ export default { this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`) } // 推入表格中 - this.dataSource = info.file.response.result + this.dataSource = info.file.response.result.map(item => { + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } + return { + uid: uidGenerator(), + ...item + } + }) } else { if (Array.isArray(info.file.response.result) && info.file.response.result.length > 0) { this.messageLineFeed(this.$t('fileImportError'), info.file.response.result) @@ -458,9 +479,8 @@ export default { } }, // 编辑 - 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.baseInfoTableModal.edit(record) }, // 查看 @@ -468,12 +488,12 @@ export default { this.$refs.baseInfoTableModal.look(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) } }) @@ -488,10 +508,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 = [] } }) @@ -507,9 +527,10 @@ export default { }, // 批量设置联络人选择人后的回调 userSelectModalChange (value) { - for (const item of this.selectedRowKeys) { - this.dataSource[item].contactUser = value - this.dataSource[item].contactUser_dictText = this.selectNames + for (const i of this.selectedRowKeys) { + const dataIndex = this.dataSource.findIndex(item => item.uid === i) + this.dataSource[dataIndex].contactUser = value + this.dataSource[dataIndex].contactUser_dictText = this.selectNames } this.dataSource = JSON.parse(JSON.stringify(this.dataSource)) this.selectedRowKeys = [] diff --git a/src/views/workCenter/enterpriseStandardChange/modules/ApproveBaseInfo.vue b/src/views/workCenter/enterpriseStandardChange/modules/ApproveBaseInfo.vue index 64b45025..83c7954d 100644 --- a/src/views/workCenter/enterpriseStandardChange/modules/ApproveBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardChange/modules/ApproveBaseInfo.vue @@ -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) diff --git a/src/views/workCenter/enterpriseStandardChange/modules/MainDrafterInitBaseInfo.vue b/src/views/workCenter/enterpriseStandardChange/modules/MainDrafterInitBaseInfo.vue index 85be2af7..564c85af 100644 --- a/src/views/workCenter/enterpriseStandardChange/modules/MainDrafterInitBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardChange/modules/MainDrafterInitBaseInfo.vue @@ -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 @@ -
- {{ $t('edit') }} + @@ -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 }) } }, // 修改前按钮点击 diff --git a/src/views/workCenter/enterpriseStandardInitChange/PlanApprovalChangeFlow.vue b/src/views/workCenter/enterpriseStandardInitChange/PlanApprovalChangeFlow.vue index 2630942f..5b9eeefc 100644 --- a/src/views/workCenter/enterpriseStandardInitChange/PlanApprovalChangeFlow.vue +++ b/src/views/workCenter/enterpriseStandardInitChange/PlanApprovalChangeFlow.vue @@ -597,7 +597,15 @@ export default { this.formInline.projectType === ProjectType.WORK_TERMINATE.value)) { // 是完成时间变更或工作终止的变更 this.$nextTick(() => { - this.$refs.changeBaseInfo.dataSource = JSON.parse(JSON.stringify(this.model.dataList)) + this.$refs.changeBaseInfo.dataSource = JSON.parse(JSON.stringify(this.model.dataList)).map(item => { + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } + return { + uid: uidGenerator(), + ...item + } + }) }) } else if (this.formInline.applicationCategory === ApplicationCategory.CHANGE.value && (this.formInline.projectType === ProjectType.RESPONSIBLE_DEPT_CHANGE.value || diff --git a/src/views/workCenter/enterpriseStandardInitChange/modules/FinishTimeChangeBaseInfo.vue b/src/views/workCenter/enterpriseStandardInitChange/modules/FinishTimeChangeBaseInfo.vue index 1f6decb5..207ca369 100644 --- a/src/views/workCenter/enterpriseStandardInitChange/modules/FinishTimeChangeBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardInitChange/modules/FinishTimeChangeBaseInfo.vue @@ -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 @@ -
- {{ $t('edit') }} + @@ -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 = [] } }) diff --git a/src/views/workCenter/enterpriseStandardInitChange/modules/JobEndBaseInfo.vue b/src/views/workCenter/enterpriseStandardInitChange/modules/JobEndBaseInfo.vue index 74032eff..8f11237b 100644 --- a/src/views/workCenter/enterpriseStandardInitChange/modules/JobEndBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardInitChange/modules/JobEndBaseInfo.vue @@ -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 @@ -
- {{ $t('edit') }} + @@ -71,8 +71,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') }, @@ -170,9 +170,13 @@ export default { jobEndBaseInfoDrawerOk (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) } }, // 新增 @@ -182,19 +186,18 @@ export default { this.$refs.jobEndBaseInfoDrawer.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.jobEndBaseInfoDrawer.edit(record) this.$refs.jobEndBaseInfoDrawer.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) } }) @@ -209,10 +212,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 = [] } }) diff --git a/src/views/workCenter/enterpriseStandardRevision/modules/CommentObjectEnterBaseInfo.vue b/src/views/workCenter/enterpriseStandardRevision/modules/CommentObjectEnterBaseInfo.vue index 2eafa487..002398c6 100644 --- a/src/views/workCenter/enterpriseStandardRevision/modules/CommentObjectEnterBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardRevision/modules/CommentObjectEnterBaseInfo.vue @@ -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"> -
- {{ $t('edit') }} + @@ -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 }) } } } diff --git a/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonCollectBaseInfo.vue b/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonCollectBaseInfo.vue index 596a293b..0d44f0e4 100644 --- a/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonCollectBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonCollectBaseInfo.vue @@ -30,10 +30,10 @@ @change="handleTableChange"> -
- {{ $t('edit') }} + @@ -197,36 +197,33 @@ export default { this.ipagination = pagination }, // 征求意见的编辑 - 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.id) }, // 征求意见的删除 - handleDelete (index) { + handleDelete (id) { 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.id === id) this.dataSource.splice(dataIndex, 1) } }) }, // 征求意见新增编辑完成 - modalFormOk (value, index) { - console.log(value, index) - if (index || index === 0) { + modalFormOk (value, id) { + console.log(value, id) + if (id || id === 0) { + const dataIndex = this.dataSource.findIndex(item => item.id === id) // 有下标,说明是编辑 - this.$set(this.dataSource[index], 'clauseNum', value.clauseNum) - this.$set(this.dataSource[index], 'clauseName', value.clauseName) - this.$set(this.dataSource[index], 'editAdvice', value.editAdvice) + 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 { - // 没有下标, 是新增 - this.dataSource.push(value) } }, // 选择用户得到用户名 diff --git a/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonLeaderApproveBaseInfo.vue b/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonLeaderApproveBaseInfo.vue index e09fd8af..44126f9a 100644 --- a/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonLeaderApproveBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardRevision/modules/DepartLiaisonLeaderApproveBaseInfo.vue @@ -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"> -
- {{ $t('edit') }} + @@ -132,7 +132,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) @@ -168,36 +176,39 @@ 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.$set(this.dataSource[index], 'clauseNum', value.clauseNum) - this.$set(this.dataSource[index], 'clauseName', value.clauseName) - this.$set(this.dataSource[index], 'editAdvice', value.editAdvice) + 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 { // 没有下标, 是新增 - this.dataSource.push(value) + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } + this.dataSource.push({ uid: uidGenerator(), ...value }) } } } diff --git a/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectBaseInfo.vue b/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectBaseInfo.vue index 9bd1265e..5b4620e4 100644 --- a/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectBaseInfo.vue @@ -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" @@ -162,7 +162,11 @@ export default { initData (data) { // 给表格赋值,在线编辑不知道要怎么赋值? this.dataSource = data.advices.map(item => { + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } return { + uid: uidGenerator(), ...item, handleAdvice: item.handleAdvice ? item.handleAdvice : undefined } @@ -211,35 +215,38 @@ 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 { // 没有下标, 是新增 const currentUser = Vue.ls.get(USER_INFO) const currentUserId = currentUser.realname + '(' + currentUser.username + ')' - this.dataSource.push({ ...value, createUserId_dictText: currentUserId }) + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } + this.dataSource.push({ ...value, createUserId_dictText: currentUserId, uid: uidGenerator() }) } } } diff --git a/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectUploadMinuteBaseInfo.vue b/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectUploadMinuteBaseInfo.vue index 3517a338..859f9820 100644 --- a/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectUploadMinuteBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterCollectUploadMinuteBaseInfo.vue @@ -6,7 +6,7 @@ :can-drag="true" :scroll="{x: '100%'}" ref="table" - :rowKey="(record, index) => { return (Number(this.draftIpagination.current) - 1) * Number(this.draftIpagination.pageSize) + index }" + rowKey="uid" :columns="drafterColumns" :dataSource="drafterDataSource" :pagination="draftIpagination" @@ -137,7 +137,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" @@ -145,10 +145,10 @@ @change="handleTableChange"> -
- {{ $t('edit') }} + @@ -343,8 +343,21 @@ export default { // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 initData (data) { // 给表格赋值,在线编辑不知道要怎么赋值? - this.drafterDataSource = data.otherDraftUserVOS - this.dataSource = data.inspectContents || [] + const uidGenerator = () => { + return '-' + parseInt(Math.random() * 10000 + 1, 10) + } + this.drafterDataSource = data.otherDraftUserVOS.map(item => { + return { + uid: uidGenerator(), + ...item + } + }) + this.dataSource = data.inspectContents && data.inspectContents.length > 0 ? data.inspectContents.map(item => { + return { + uid: uidGenerator(), + ...item + } + }) : [] this.formInline = Object.assign({}, data) // 给表单赋值 this.$nextTick(() => { @@ -463,33 +476,36 @@ export default { this.$refs.checkContentModal.add(standardFile) }, // 稽查内容的编辑 - handleEdit (record, index) { + handleEdit (record) { // 编辑左侧的预览文件,还不知道要赋值哪个文件 ?? const standardFile = '' this.$refs.checkContentModal.title = this.$t('edit') - const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index - this.$refs.checkContentModal.edit(standardFile, record, dataIndex) + this.$refs.checkContentModal.edit(standardFile, 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) } }) }, // 稽查内容新增编辑完成 - checkContentOk (value, index) { - console.log(value, index) - if (index || index === 0) { + checkContentOk (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 }) } } } diff --git a/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterSentBaseInfo.vue b/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterSentBaseInfo.vue index 315453c8..5bccab0e 100644 --- a/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterSentBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardRevision/modules/MainDrafterSentBaseInfo.vue @@ -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"> -
- {{ $t('edit') }} + @@ -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) } } } diff --git a/src/views/workCenter/enterpriseStandardRevision/modules/OtherDrafterUploadStandardBaseInfo.vue b/src/views/workCenter/enterpriseStandardRevision/modules/OtherDrafterUploadStandardBaseInfo.vue index a9955ac0..18e3d71c 100644 --- a/src/views/workCenter/enterpriseStandardRevision/modules/OtherDrafterUploadStandardBaseInfo.vue +++ b/src/views/workCenter/enterpriseStandardRevision/modules/OtherDrafterUploadStandardBaseInfo.vue @@ -6,7 +6,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" @@ -21,10 +21,10 @@ -