diff --git a/src/api/lab/lab.js b/src/api/lab/lab.js index fb6a877..f7bd0af 100644 --- a/src/api/lab/lab.js +++ b/src/api/lab/lab.js @@ -12,6 +12,9 @@ export const saveLab = data => createAPI(`/lab/save`, 'post', data) // 修改 export const updateLab = data => createAPI(`/lab/update`, 'post', data) +// 删除(仅草稿) +export const deleteLab = data => createAPI(`/lab/delete`, 'post', data) + // 下达 export const issueLab = data => createAPI(`/lab/issue`, 'post', data) diff --git a/src/views/modules/lab/labRecord.vue b/src/views/modules/lab/labRecord.vue index 506ca95..5c837cd 100644 --- a/src/views/modules/lab/labRecord.vue +++ b/src/views/modules/lab/labRecord.vue @@ -27,6 +27,7 @@ 查询 新增 + 删除 + @@ -830,6 +833,7 @@ export default { exportHeader: ['Lab记录'], exportFooter: [], resultList: [], + dataListSelections: [], dataList: [], pageIndex: 1, pageSize: 20, @@ -843,6 +847,7 @@ export default { authIssue: false, authSubmit: false, authReject: false, + authDelete: false, authFileSave: false, authFileDownLoad: false, authFileRemove: false, @@ -1736,6 +1741,7 @@ export default { this.authIssue = this.isAuth(this.menuId + ':issue') this.authSubmit = this.isAuth(this.menuId + ':submit') this.authReject = this.isAuth(this.menuId + ':reject') + this.authDelete = this.isAuth(this.menuId + ':delete') this.authFileSave = this.isAuth(this.menuId + ':fileSave') this.authFileDownLoad = this.isAuth(this.menuId + ':fileDownLoad') this.authFileRemove = this.isAuth(this.menuId + ':fileRemove') @@ -1752,6 +1758,9 @@ export default { rowStyle () { return { cursor: 'pointer' } }, + dataListSelectionChange (rows) { + this.dataListSelections = rows || [] + }, changeClickRow (row) { this.handleCurrentRowChange(row) }, @@ -1866,6 +1875,7 @@ export default { }, getDataList () { if (!this.authSearch) { + this.dataListSelections = [] this.dataList = [] this.totalPage = 0 this.currentRow = {} @@ -1878,6 +1888,7 @@ export default { this.approvalList = [] return } + this.dataListSelections = [] this.dataListLoading = true const params = { page: this.pageIndex, @@ -1911,6 +1922,7 @@ export default { } }) } else { + this.dataListSelections = [] this.dataList = [] this.totalPage = 0 this.currentRow = {} @@ -1924,6 +1936,7 @@ export default { } this.dataListLoading = false }).catch(() => { + this.dataListSelections = [] this.currentRow = {} this.currentDetailRequestId += 1 this.currentDetail = this.buildDefaultModalData() @@ -2276,6 +2289,70 @@ export default { }) }) }, + deleteHandle () { + if (!this.authDelete) { + this.$message.warning('没有删除权限') + return + } + const selectedRows = (this.dataListSelections || []).filter(item => item && item.site && item.referenceNo) + if (!selectedRows.length) { + this.$message.warning('请先勾选要删除的单据') + return + } + const nonDraftRows = selectedRows.filter(item => item.status !== '草稿') + if (nonDraftRows.length) { + const previewText = nonDraftRows.slice(0, 3).map(item => item.referenceNo).join('、') + const suffix = nonDraftRows.length > 3 ? (' 等' + nonDraftRows.length + '条') : '' + this.$message.warning('仅草稿状态的单据允许删除,当前勾选包含非草稿单据:' + previewText + suffix) + return + } + this.$confirm('确认删除选中的' + selectedRows.length + '条Lab单据?删除后会同步删除属性和附件数据。', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + const deleteTasks = selectedRows.map(item => { + return api.deleteLab({ + site: item.site, + referenceNo: item.referenceNo + }).then(({data}) => { + if (data && data.code === 0) { + return { + success: true, + site: item.site, + referenceNo: item.referenceNo + } + } + return { + success: false, + referenceNo: item.referenceNo, + msg: (data && data.msg) || '删除失败' + } + }).catch(() => { + return { + success: false, + referenceNo: item.referenceNo, + msg: '删除失败' + } + }) + }) + Promise.all(deleteTasks).then(results => { + const successRows = results.filter(item => item.success) + const failRows = results.filter(item => !item.success) + if (this.modalFlag && successRows.some(item => item.site === this.modalData.site && item.referenceNo === this.modalData.referenceNo)) { + this.modalFlag = false + } + if (!failRows.length) { + this.$message.success('删除成功,共' + successRows.length + '条') + } else if (!successRows.length) { + this.$message.error(failRows[0].msg || '删除失败') + } else { + this.$message.warning('已删除' + successRows.length + '条,失败' + failRows.length + '条') + } + this.getDataList() + }) + }).catch(() => {}) + }, getBaseList (val, type) { this.tagNo = val this.tagNo1 = type