[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
@@ -25,7 +25,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -56,12 +56,12 @@
<a @click="handleLook(record, index)" class="table-ope-btn">{{ $t('lookDetail') }}</a> <a @click="handleLook(record, index)" class="table-ope-btn">{{ $t('lookDetail') }}</a>
</template> </template>
<template v-else-if="!disabled"> <template v-else-if="!disabled">
<a @click="handleEdit(record, index)" class="table-ope-btn">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a @click="handleDelete(record.id, index)" class="table-ope-btn">{{ $t('delete') }}</a> <a @click="handleDelete(record.uid)" class="table-ope-btn">{{ $t('delete') }}</a>
</template> </template>
<template v-else-if="editAndLook"> <template v-else-if="editAndLook">
<a @click="handleEdit(record, index)" class="table-ope-btn">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a @click="handleLook(record, index)" class="table-ope-btn">{{ $t('lookDetail') }}</a> <a @click="handleLook(record, index)" class="table-ope-btn">{{ $t('lookDetail') }}</a>
</template> </template>
@@ -307,7 +307,15 @@ export default {
initData (data) { initData (data) {
// 给表格赋值 // 给表格赋值
if (data && data.dataList) { 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) { modelFormOk (value) {
console.log(value, this.modalType) console.log(value, this.modalType)
if (this.modalType === 'add') { 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') { } 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.$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 { } else {
if (Array.isArray(info.file.response.result) && info.file.response.result.length > 0) { if (Array.isArray(info.file.response.result) && info.file.response.result.length > 0) {
this.messageLineFeed(this.$t('fileImportError'), info.file.response.result) this.messageLineFeed(this.$t('fileImportError'), info.file.response.result)
@@ -444,9 +464,8 @@ export default {
} }
}, },
// 编辑 // 编辑
handleEdit (record, index) { handleEdit (record) {
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index this.modalType = 'edit' + ',' + record.uid
this.modalType = 'edit' + ',' + dataIndex
this.$refs.contactEnterSendTaskModal.edit(record) this.$refs.contactEnterSendTaskModal.edit(record)
}, },
// 查看 // 查看
@@ -454,12 +473,12 @@ export default {
this.$refs.contactEnterSendTaskModal.look(record) this.$refs.contactEnterSendTaskModal.look(record)
}, },
// 删除 // 删除
handleDelete (id, index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
@@ -474,10 +493,10 @@ export default {
title: this.$t('confirmBatchDeletion'), title: this.$t('confirmBatchDeletion'),
content: this.$t('deleteAData'), content: this.$t('deleteAData'),
onOk: () => { onOk: () => {
for (let i = 0; i < this.selectedRowKeys.length; i++) { for (const i of this.selectedRowKeys) {
this.dataSource.splice(this.selectedRowKeys[i], 1, false) const dataIndex = this.dataSource.findIndex(item => item.uid === i)
this.dataSource.splice(dataIndex, 1)
} }
this.dataSource = this.dataSource.filter(item => !!item)
this.selectedRowKeys = [] this.selectedRowKeys = []
} }
}) })
@@ -29,7 +29,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -47,10 +47,10 @@
</template> </template>
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a @click="handleDelete(record.id, index)" class="table-ope-btn">{{ $t('delete') }}</a> <a @click="handleDelete(record.uid)" class="table-ope-btn">{{ $t('delete') }}</a>
</div> </div>
</j-table> </j-table>
@@ -256,7 +256,7 @@ export default {
// 不是被驳回的待办,可以设置联络人 // 不是被驳回的待办,可以设置联络人
return <user-select-by-contact v-model={row.contactUser} return <user-select-by-contact v-model={row.contactUser}
nameStr={row.contactUser_dictText} showBtn={false} nameStr={row.contactUser_dictText} showBtn={false}
filedName={(Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index} filedName={row.uid}
onNameChange={this.lineNameChange} onNameChange={this.lineNameChange}
disabled={this.disabled} type={'radio'} placeholder={this.$t('pleaseSelect')} /> disabled={this.disabled} type={'radio'} placeholder={this.$t('pleaseSelect')} />
} }
@@ -303,7 +303,15 @@ export default {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) { initData (data) {
// 给表格赋值 // 给表格赋值
this.dataSource = data this.dataSource = data.map(item => {
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
return {
uid: uidGenerator(),
...item
}
})
}, },
// 外层要获取数据 // 外层要获取数据
getData () { getData () {
@@ -346,8 +354,9 @@ export default {
}) })
}, },
// 行内联络人变化的回调 // 行内联络人变化的回调
lineNameChange (value, fieldName) { lineNameChange (value, uid) {
this.dataSource[fieldName].contactUser_dictText = value const dataIndex = this.dataSource.findIndex(item => item.uid === uid)
this.dataSource[dataIndex].contactUser_dictText = value
}, },
handleTableChange (pagination) { handleTableChange (pagination) {
this.ipagination = pagination this.ipagination = pagination
@@ -368,9 +377,13 @@ export default {
modelFormOk (value) { modelFormOk (value) {
console.log(value, this.modalType) console.log(value, this.modalType)
if (this.modalType === 'add') { 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') { } 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.$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 { } else {
if (Array.isArray(info.file.response.result) && info.file.response.result.length > 0) { if (Array.isArray(info.file.response.result) && info.file.response.result.length > 0) {
this.messageLineFeed(this.$t('fileImportError'), info.file.response.result) this.messageLineFeed(this.$t('fileImportError'), info.file.response.result)
@@ -458,9 +479,8 @@ export default {
} }
}, },
// 编辑 // 编辑
handleEdit (record, index) { handleEdit (record) {
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index this.modalType = 'edit' + ',' + record.uid
this.modalType = 'edit' + ',' + dataIndex
this.$refs.baseInfoTableModal.edit(record) this.$refs.baseInfoTableModal.edit(record)
}, },
// 查看 // 查看
@@ -468,12 +488,12 @@ export default {
this.$refs.baseInfoTableModal.look(record) this.$refs.baseInfoTableModal.look(record)
}, },
// 删除 // 删除
handleDelete (id, index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
@@ -488,10 +508,10 @@ export default {
title: this.$t('confirmBatchDeletion'), title: this.$t('confirmBatchDeletion'),
content: this.$t('deleteAData'), content: this.$t('deleteAData'),
onOk: () => { onOk: () => {
for (let i = 0; i < this.selectedRowKeys.length; i++) { for (const i of this.selectedRowKeys) {
this.dataSource.splice(this.selectedRowKeys[i], 1, false) const dataIndex = this.dataSource.findIndex(item => item.uid === i)
this.dataSource.splice(dataIndex, 1)
} }
this.dataSource = this.dataSource.filter(item => !!item)
this.selectedRowKeys = [] this.selectedRowKeys = []
} }
}) })
@@ -507,9 +527,10 @@ export default {
}, },
// 批量设置联络人选择人后的回调 // 批量设置联络人选择人后的回调
userSelectModalChange (value) { userSelectModalChange (value) {
for (const item of this.selectedRowKeys) { for (const i of this.selectedRowKeys) {
this.dataSource[item].contactUser = value const dataIndex = this.dataSource.findIndex(item => item.uid === i)
this.dataSource[item].contactUser_dictText = this.selectNames this.dataSource[dataIndex].contactUser = value
this.dataSource[dataIndex].contactUser_dictText = this.selectNames
} }
this.dataSource = JSON.parse(JSON.stringify(this.dataSource)) this.dataSource = JSON.parse(JSON.stringify(this.dataSource))
this.selectedRowKeys = [] this.selectedRowKeys = []
@@ -7,7 +7,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -144,7 +144,15 @@ export default {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) { 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.$nextTick(() => {
this.$refs.baseInfoForm.initData(data) this.$refs.baseInfoForm.initData(data)
@@ -30,7 +30,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -43,10 +43,10 @@
</template> </template>
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <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> </div>
</j-table> </j-table>
@@ -438,7 +438,15 @@ export default {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) { 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 = {} const formInline = {}
// 更改级别代号 // 更改级别代号
formInline.levelCode = data.levelCode formInline.levelCode = data.levelCode
@@ -532,32 +540,35 @@ export default {
this.$refs.updateListModal.add(standardId) this.$refs.updateListModal.add(standardId)
}, },
// 修改单的编辑 // 修改单的编辑
handleEdit (record, index) { handleEdit (record) {
const standardId = this.$refs.baseInfoForm.formInline.standardId || '' const standardId = this.$refs.baseInfoForm.formInline.standardId || ''
this.$refs.updateListModal.title = this.$t('edit') 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, record.uid)
this.$refs.updateListModal.edit(standardId, record, dataIndex)
}, },
// 修改单的删除 // 修改单的删除
handleDelete (index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
}, },
// 修改单新增编辑完成 // 修改单新增编辑完成
modalFormOk (value, index) { modalFormOk (value, uid) {
console.log(value, index) console.log(value, uid)
if (index || index === 0) { 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 { } else {
// 没有下标, 是新增 // 没有下标, 是新增
this.dataSource.push(value) const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
this.dataSource.push({ uid: uidGenerator(), ...value })
} }
}, },
// 修改前按钮点击 // 修改前按钮点击
@@ -597,7 +597,15 @@ export default {
this.formInline.projectType === ProjectType.WORK_TERMINATE.value)) { this.formInline.projectType === ProjectType.WORK_TERMINATE.value)) {
// 是完成时间变更或工作终止的变更 // 是完成时间变更或工作终止的变更
this.$nextTick(() => { 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 && } else if (this.formInline.applicationCategory === ApplicationCategory.CHANGE.value &&
(this.formInline.projectType === ProjectType.RESPONSIBLE_DEPT_CHANGE.value || (this.formInline.projectType === ProjectType.RESPONSIBLE_DEPT_CHANGE.value ||
@@ -17,7 +17,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -35,10 +35,10 @@
</template> </template>
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <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> </div>
</j-table> </j-table>
@@ -213,9 +213,13 @@ export default {
changeBaseInfoDrawerOk (value) { changeBaseInfoDrawerOk (value) {
console.log(value, this.modalType) console.log(value, this.modalType)
if (this.modalType === 'add') { 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') { } 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') this.$refs.changeBaseInfoDrawer.title = this.$t('newlyAdded')
}, },
// 编辑 // 编辑
handleEdit (record, index) { handleEdit (record) {
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index this.modalType = 'edit' + ',' + record.uid
this.modalType = 'edit' + ',' + dataIndex
this.$refs.changeBaseInfoDrawer.edit(record) this.$refs.changeBaseInfoDrawer.edit(record)
this.$refs.changeBaseInfoDrawer.title = this.$t('edit') this.$refs.changeBaseInfoDrawer.title = this.$t('edit')
}, },
// 删除 // 删除
handleDelete (id, index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
@@ -252,10 +255,10 @@ export default {
title: this.$t('confirmBatchDeletion'), title: this.$t('confirmBatchDeletion'),
content: this.$t('deleteAData'), content: this.$t('deleteAData'),
onOk: () => { onOk: () => {
for (let i = 0; i < this.selectedRowKeys.length; i++) { for (const i of this.selectedRowKeys) {
this.dataSource.splice(this.selectedRowKeys[i], 1, false) const dataIndex = this.dataSource.findIndex(item => item.uid === i)
this.dataSource.splice(dataIndex, 1)
} }
this.dataSource = this.dataSource.filter(item => !!item)
this.selectedRowKeys = [] this.selectedRowKeys = []
} }
}) })
@@ -17,7 +17,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -35,10 +35,10 @@
</template> </template>
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <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> </div>
</j-table> </j-table>
@@ -71,8 +71,8 @@ export default {
/* 分页参数 */ /* 分页参数 */
ipagination: { ipagination: {
current: 1, current: 1,
pageSize: 10, pageSize: 5,
pageSizeOptions: ['10', '30', '50', '100', '150', '200'], pageSizeOptions: ['5', '10', '30', '50', '100', '150', '200'],
showTotal: (total, range) => { showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + this.$t('total') + total + this.$t('strip') return range[0] + '-' + range[1] + ' ' + this.$t('total') + total + this.$t('strip')
}, },
@@ -170,9 +170,13 @@ export default {
jobEndBaseInfoDrawerOk (value) { jobEndBaseInfoDrawerOk (value) {
console.log(value, this.modalType) console.log(value, this.modalType)
if (this.modalType === 'add') { 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') { } 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') this.$refs.jobEndBaseInfoDrawer.title = this.$t('newlyAdded')
}, },
// 编辑 // 编辑
handleEdit (record, index) { handleEdit (record) {
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index this.modalType = 'edit' + ',' + record.uid
this.modalType = 'edit' + ',' + dataIndex
this.$refs.jobEndBaseInfoDrawer.edit(record) this.$refs.jobEndBaseInfoDrawer.edit(record)
this.$refs.jobEndBaseInfoDrawer.title = this.$t('edit') this.$refs.jobEndBaseInfoDrawer.title = this.$t('edit')
}, },
// 删除 // 删除
handleDelete (id, index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
@@ -209,10 +212,10 @@ export default {
title: this.$t('confirmBatchDeletion'), title: this.$t('confirmBatchDeletion'),
content: this.$t('deleteAData'), content: this.$t('deleteAData'),
onOk: () => { onOk: () => {
for (let i = 0; i < this.selectedRowKeys.length; i++) { for (const i of this.selectedRowKeys) {
this.dataSource.splice(this.selectedRowKeys[i], 1, false) const dataIndex = this.dataSource.findIndex(item => item.uid === i)
this.dataSource.splice(dataIndex, 1)
} }
this.dataSource = this.dataSource.filter(item => !!item)
this.selectedRowKeys = [] this.selectedRowKeys = []
} }
}) })
@@ -29,7 +29,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -37,10 +37,10 @@
@change="handleTableChange"> @change="handleTableChange">
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <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> </div>
</j-table> </j-table>
@@ -125,7 +125,15 @@ export default {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) { 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.$nextTick(() => {
this.$refs.baseInfoForm.initData(data) this.$refs.baseInfoForm.initData(data)
@@ -161,33 +169,36 @@ export default {
this.$refs.commentModal.add(file) this.$refs.commentModal.add(file)
}, },
// 征求意见的编辑 // 征求意见的编辑
handleEdit (record, index) { handleEdit (record) {
// 不知道左侧要预览哪个文件 // 不知道左侧要预览哪个文件
const file = '' const file = ''
this.$refs.commentModal.title = this.$t('edit') 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, record.uid)
this.$refs.commentModal.edit(file, record, dataIndex)
}, },
// 征求意见的删除 // 征求意见的删除
handleDelete (index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
}, },
// 征求意见新增编辑完成 // 征求意见新增编辑完成
modalFormOk (value, index) { modalFormOk (value, uid) {
console.log(value, index) console.log(value, uid)
if (index || index === 0) { 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 { } else {
// 没有下标, 是新增 // 没有下标, 是新增
this.dataSource.push(value) const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
this.dataSource.push({ uid: uidGenerator(), ...value })
} }
} }
} }
@@ -30,10 +30,10 @@
@change="handleTableChange"> @change="handleTableChange">
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <a-divider type="vertical" />
<a @click="handleDelete(index)" class="table-ope-btn" :disabled="disabled">{{ $t('delete') }}</a> <a @click="handleDelete(record.id)" class="table-ope-btn" :disabled="disabled">{{ $t('delete') }}</a>
</div> </div>
</j-table> </j-table>
@@ -197,36 +197,33 @@ export default {
this.ipagination = pagination this.ipagination = pagination
}, },
// 征求意见的编辑 // 征求意见的编辑
handleEdit (record, index) { handleEdit (record) {
// 不知道左侧要预览哪个文件 // 不知道左侧要预览哪个文件
const file = '' const file = ''
this.$refs.commentModal.title = this.$t('edit') 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, record.id)
this.$refs.commentModal.edit(file, record, dataIndex)
}, },
// 征求意见的删除 // 征求意见的删除
handleDelete (index) { handleDelete (id) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
}, },
// 征求意见新增编辑完成 // 征求意见新增编辑完成
modalFormOk (value, index) { modalFormOk (value, id) {
console.log(value, index) console.log(value, id)
if (index || index === 0) { 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[dataIndex], 'clauseNum', value.clauseNum)
this.$set(this.dataSource[index], 'clauseName', value.clauseName) this.$set(this.dataSource[dataIndex], 'clauseName', value.clauseName)
this.$set(this.dataSource[index], 'editAdvice', value.editAdvice) this.$set(this.dataSource[dataIndex], 'editAdvice', value.editAdvice)
// this.dataSource.splice(index, 1, value) // this.dataSource.splice(index, 1, value)
} else {
// 没有下标, 是新增
this.dataSource.push(value)
} }
}, },
// 选择用户得到用户名 // 选择用户得到用户名
@@ -29,7 +29,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -37,10 +37,10 @@
@change="handleTableChange"> @change="handleTableChange">
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <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> </div>
</j-table> </j-table>
@@ -132,7 +132,15 @@ export default {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) { 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.$nextTick(() => {
this.$refs.baseInfoForm.initData(data) this.$refs.baseInfoForm.initData(data)
@@ -168,36 +176,39 @@ export default {
this.$refs.commentModal.add(file) this.$refs.commentModal.add(file)
}, },
// 征求意见的编辑 // 征求意见的编辑
handleEdit (record, index) { handleEdit (record) {
// 不知道左侧要预览哪个文件 // 不知道左侧要预览哪个文件
const file = '' const file = ''
this.$refs.commentModal.title = this.$t('edit') 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, record.uid)
this.$refs.commentModal.edit(file, record, dataIndex)
}, },
// 征求意见的删除 // 征求意见的删除
handleDelete (index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
}, },
// 征求意见新增编辑完成 // 征求意见新增编辑完成
modalFormOk (value, index) { modalFormOk (value, uid) {
console.log(value, index) console.log(value, uid)
if (index || index === 0) { if (uid || uid === 0) {
// 有下标,说明是编辑 // 有下标,说明是编辑
this.$set(this.dataSource[index], 'clauseNum', value.clauseNum) const dataIndex = this.dataSource.findIndex(item => item.uid === uid)
this.$set(this.dataSource[index], 'clauseName', value.clauseName) this.$set(this.dataSource[dataIndex], 'clauseNum', value.clauseNum)
this.$set(this.dataSource[index], 'editAdvice', value.editAdvice) this.$set(this.dataSource[dataIndex], 'clauseName', value.clauseName)
this.$set(this.dataSource[dataIndex], 'editAdvice', value.editAdvice)
// this.dataSource.splice(index, 1, value) // this.dataSource.splice(index, 1, value)
} else { } else {
// 没有下标, 是新增 // 没有下标, 是新增
this.dataSource.push(value) const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
this.dataSource.push({ uid: uidGenerator(), ...value })
} }
} }
} }
@@ -29,7 +29,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -162,7 +162,11 @@ export default {
initData (data) { initData (data) {
// 给表格赋值,在线编辑不知道要怎么赋值? // 给表格赋值,在线编辑不知道要怎么赋值?
this.dataSource = data.advices.map(item => { this.dataSource = data.advices.map(item => {
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
return { return {
uid: uidGenerator(),
...item, ...item,
handleAdvice: item.handleAdvice ? item.handleAdvice : undefined handleAdvice: item.handleAdvice ? item.handleAdvice : undefined
} }
@@ -211,35 +215,38 @@ export default {
this.$refs.commentModal.add(file) this.$refs.commentModal.add(file)
}, },
// 征求意见的编辑 // 征求意见的编辑
handleEdit (record, index) { handleEdit (record) {
// 不知道左侧要预览哪个文件 // 不知道左侧要预览哪个文件
const file = '' const file = ''
this.$refs.commentModal.title = this.$t('edit') 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, record.uid)
this.$refs.commentModal.edit(file, record, dataIndex)
}, },
// 征求意见的删除 // 征求意见的删除
handleDelete (index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
}, },
// 征求意见新增编辑完成 // 征求意见新增编辑完成
modalFormOk (value, index) { modalFormOk (value, uid) {
console.log(value, index) console.log(value, uid)
if (index || index === 0) { 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 { } else {
// 没有下标, 是新增 // 没有下标, 是新增
const currentUser = Vue.ls.get(USER_INFO) const currentUser = Vue.ls.get(USER_INFO)
const currentUserId = currentUser.realname + '(' + currentUser.username + ')' 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() })
} }
} }
} }
@@ -6,7 +6,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.draftIpagination.current) - 1) * Number(this.draftIpagination.pageSize) + index }" rowKey="uid"
:columns="drafterColumns" :columns="drafterColumns"
:dataSource="drafterDataSource" :dataSource="drafterDataSource"
:pagination="draftIpagination" :pagination="draftIpagination"
@@ -137,7 +137,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -145,10 +145,10 @@
@change="handleTableChange"> @change="handleTableChange">
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <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> </div>
</j-table> </j-table>
@@ -343,8 +343,21 @@ export default {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) { initData (data) {
// 给表格赋值,在线编辑不知道要怎么赋值? // 给表格赋值,在线编辑不知道要怎么赋值?
this.drafterDataSource = data.otherDraftUserVOS const uidGenerator = () => {
this.dataSource = data.inspectContents || [] 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.formInline = Object.assign({}, data)
// 给表单赋值 // 给表单赋值
this.$nextTick(() => { this.$nextTick(() => {
@@ -463,33 +476,36 @@ export default {
this.$refs.checkContentModal.add(standardFile) this.$refs.checkContentModal.add(standardFile)
}, },
// 稽查内容的编辑 // 稽查内容的编辑
handleEdit (record, index) { handleEdit (record) {
// 编辑左侧的预览文件,还不知道要赋值哪个文件 ?? // 编辑左侧的预览文件,还不知道要赋值哪个文件 ??
const standardFile = '' const standardFile = ''
this.$refs.checkContentModal.title = this.$t('edit') 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, record.uid)
this.$refs.checkContentModal.edit(standardFile, record, dataIndex)
}, },
// 稽查内容的删除 // 稽查内容的删除
handleDelete (index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
}, },
// 稽查内容新增编辑完成 // 稽查内容新增编辑完成
checkContentOk (value, index) { checkContentOk (value, uid) {
console.log(value, index) console.log(value, uid)
if (index || index === 0) { 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 { } else {
// 没有下标, 是新增 // 没有下标, 是新增
this.dataSource.push(value) const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
this.dataSource.push({ uid: uidGenerator(), ...value })
} }
} }
} }
@@ -32,7 +32,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -40,10 +40,10 @@
@change="handleTableChange"> @change="handleTableChange">
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<a @click="handleEdit(record, index)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a> <a @click="handleEdit(record)" class="table-ope-btn" :disabled="disabled">{{ $t('edit') }}</a>
<a-divider type="vertical" /> <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> </div>
</j-table> </j-table>
@@ -72,8 +72,8 @@ export default {
/* 分页参数 */ /* 分页参数 */
ipagination: { ipagination: {
current: 1, current: 1,
pageSize: 10, pageSize: 5,
pageSizeOptions: ['10', '30', '50', '100', '150', '200'], pageSizeOptions: ['5', '10', '30', '50', '100', '150', '200'],
showTotal: (total, range) => { showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + this.$t('total') + total + this.$t('strip') return range[0] + '-' + range[1] + ' ' + this.$t('total') + total + this.$t('strip')
}, },
@@ -127,7 +127,15 @@ export default {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) { 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.$nextTick(() => {
this.$refs.baseInfoForm.initData(data) this.$refs.baseInfoForm.initData(data)
@@ -166,18 +174,17 @@ export default {
this.$refs.addEditDrafterDrawer.add() this.$refs.addEditDrafterDrawer.add()
}, },
// 编辑 // 编辑
handleEdit (record, index) { handleEdit (record) {
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index this.modalType = 'edit' + ',' + record.uid
this.modalType = 'edit' + '-' + dataIndex
this.$refs.addEditDrafterDrawer.edit(record) this.$refs.addEditDrafterDrawer.edit(record)
}, },
// 删除 // 删除
handleDelete (id, index) { handleDelete (uid) {
this.$confirm({ this.$confirm({
title: this.$t('confirmDeletion'), title: this.$t('confirmDeletion'),
content: this.$t('areYouSure'), content: this.$t('areYouSure'),
onOk: () => { 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) this.dataSource.splice(dataIndex, 1)
} }
}) })
@@ -185,10 +192,13 @@ export default {
// 新增或编辑完成 // 新增或编辑完成
modalFormOk (value) { modalFormOk (value) {
if (this.modalType === 'add') { if (this.modalType === 'add') {
this.dataSource.push(value) const uidGenerator = () => {
} else if (this.modalType && this.modalType.split('-')[0] === 'edit') { return '-' + parseInt(Math.random() * 10000 + 1, 10)
console.log(Number(this.modalType.split('-')[1]), value) }
this.dataSource.splice(Number(this.modalType.split('-')[1]), 1, value) 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)
} }
} }
} }
@@ -6,7 +6,7 @@
:can-drag="true" :can-drag="true"
:scroll="{x: '100%'}" :scroll="{x: '100%'}"
ref="table" ref="table"
:rowKey="(record, index) => { return (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index }" rowKey="uid"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
:pagination="ipagination" :pagination="ipagination"
@@ -21,10 +21,10 @@
<!--</template>--> <!--</template>-->
<!-- 操作栏 --> <!-- 操作栏 -->
<div slot="action" slot-scope="{record, index}" class="action-span-cell"> <div slot="action" slot-scope="{record}" class="action-span-cell">
<!-- 上传企标 只能上传分配给自己的上传企标,到期未上传跳过该起草人,操作列表显示- --> <!-- 上传企标 只能上传分配给自己的上传企标,到期未上传跳过该起草人,操作列表显示- -->
<a v-if="record.operateType !== '1'" <a v-if="record.operateType !== '1'"
@click="handleUploadStandard(record, index)" @click="handleUploadStandard(record)"
class="table-ope-btn" class="table-ope-btn"
:disabled="disabled" :disabled="disabled"
> >
@@ -112,7 +112,7 @@ export default {
loading: false, loading: false,
userInfo: {}, // 当前登录人信息 userInfo: {}, // 当前登录人信息
currentDate: '', currentDate: '',
uploadIndex: undefined // 正在上传企标的下标 uploadUid: undefined // 正在上传企标的行uid
} }
}, },
mounted () { mounted () {
@@ -123,7 +123,15 @@ export default {
// 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了 // 拿到外面传进来的数据初始化,因为套了几层就不在外层初始化数据了
initData (data) { initData (data) {
// 给表格赋值 // 给表格赋值
this.dataSource = data.otherDraftUserVOS this.dataSource = data.otherDraftUserVOS.map(item => {
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
return {
uid: uidGenerator(),
...item
}
})
// 给表单赋值 // 给表单赋值
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.baseInfoForm.initData(data) this.$refs.baseInfoForm.initData(data)
@@ -165,10 +173,9 @@ export default {
this.ipagination = pagination this.ipagination = pagination
}, },
// 上传企标 // 上传企标
handleUploadStandard (record, index) { handleUploadStandard (record) {
const dataIndex = (Number(this.ipagination.current) - 1) * Number(this.ipagination.pageSize) + index
this.$refs.uploadFile.open(record.fileId) this.$refs.uploadFile.open(record.fileId)
this.uploadIndex = dataIndex this.uploadUid = record.uid
}, },
// 上传企标后的回调 // 上传企标后的回调
uploadFileChange (data) { uploadFileChange (data) {
@@ -179,7 +186,8 @@ export default {
}) })
} }
/** 赋值给对应行的企标 */ /** 赋值给对应行的企标 */
this.dataSource[this.uploadIndex].fileId = attIdList.join(',') const dataIndex = this.dataSource.findIndex(item => item.uid === this.uploadUid)
this.dataSource[dataIndex].fileId = attIdList.join(',')
} }
} }
} }