Browse Source

2026-06-17

Lab优化
master
fengyuan_yang 14 hours ago
parent
commit
094868e7f1
  1. 3
      src/api/lab/lab.js
  2. 77
      src/views/modules/lab/labRecord.vue

3
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)

77
src/views/modules/lab/labRecord.vue

@ -27,6 +27,7 @@
<el-form-item :label="' '">
<el-button v-if="authSearch" @click="getDataList">查询</el-button>
<el-button v-if="authUpdate" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="authDelete" type="danger" @click="deleteHandle()">删除</el-button>
<download-excel
v-if="authSearch"
:fields="exportFieldMap"
@ -55,8 +56,10 @@
:row-style="rowStyle"
@row-click="changeClickRow"
@current-change="currentChange"
@selection-change="dataListSelectionChange"
v-loading="dataListLoading"
style="width: 100%;">
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
<el-table-column prop="referenceNo" header-align="center" align="center" label="序列号" width="180"></el-table-column>
<el-table-column prop="status" header-align="center" align="center" label="单据状态" width="110"></el-table-column>
<el-table-column prop="nodeName" header-align="center" align="center" label="当前节点" width="140"></el-table-column>
@ -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

Loading…
Cancel
Save