工地直转修正

This commit is contained in:
hongchao 2025-11-24 16:37:51 +08:00
parent 97645a20c3
commit d049659ab6
2 changed files with 44 additions and 9 deletions

View File

@ -277,7 +277,7 @@
:row-key="getRowKey" :row-key="getRowKey"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" :selectable="checkSelectable"/>
<el-table-column align="center" label="序号" width="55"> <el-table-column align="center" label="序号" width="55">
<template slot-scope="scope"> <template slot-scope="scope">
{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }} {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
@ -392,6 +392,8 @@ export default {
{ label: '设备编码', prop: 'maCode' }, { label: '设备编码', prop: 'maCode' },
{ label: '计量单位', prop: 'unitName' }, { label: '计量单位', prop: 'unitName' },
{ label: '在用数量', prop: 'useNum' }, { label: '在用数量', prop: 'useNum' },
{ label: '待转数量', prop: 'waitTransNum' },
{ label: '可转数量', prop:'transNum' },
{ label: '领料人', prop: 'leasePerson' }, { label: '领料人', prop: 'leasePerson' },
{ label: '领料日期', prop: 'startTime' } { label: '领料日期', prop: 'startTime' }
], ],
@ -856,6 +858,15 @@ export default {
loading.close() loading.close()
} }
}, },
checkSelectable(row) {
if(row.transNum==0){
return false
}else{
return true
}
},
// //
handleSelectionChange(currentPageSelectedRows) { handleSelectionChange(currentPageSelectedRows) {
// //
@ -886,7 +897,7 @@ export default {
currentPageSelectedRows.forEach(row => { currentPageSelectedRows.forEach(row => {
const completeRow = { const completeRow = {
...row, ...row,
directNum: row.directNum || row.useNum, directNum: row.directNum || row.transNum,
isActive: true isActive: true
} }
this.selectedDataArray.push(completeRow) this.selectedDataArray.push(completeRow)
@ -897,8 +908,8 @@ export default {
this.equipmentList.forEach(item => { this.equipmentList.forEach(item => {
const isSelected = currentPageSelectedRows.some(selectedRow => this.getRowKey(selectedRow) === this.getRowKey(item)) const isSelected = currentPageSelectedRows.some(selectedRow => this.getRowKey(selectedRow) === this.getRowKey(item))
item.isActive = isSelected item.isActive = isSelected
if (isSelected && !item.directNum && item.useNum) { if (isSelected && !item.directNum && item.transNum) {
item.directNum = item.useNum item.directNum = item.transNum
} else if (!isSelected && !this.isEdit && !this.isDetail) { } else if (!isSelected && !this.isEdit && !this.isDetail) {
item.directNum = undefined item.directNum = undefined
} }
@ -921,10 +932,10 @@ export default {
} else { } else {
row.directNum = Number(String(row.directNum).replace(/[^\d]/g, '')) row.directNum = Number(String(row.directNum).replace(/[^\d]/g, ''))
} }
if (row.directNum > row.useNum) { if (row.directNum > row.transNum) {
this.$message.error('直转数量不能大于领料数量') this.$message.error('直转数量不能大于可转数量')
this.$nextTick(() => { this.$nextTick(() => {
row.directNum = row.useNum row.directNum = row.transNum
}) })
} }

View File

@ -887,14 +887,38 @@ export default {
async getListDepart(projectName) { async getListDepart(projectName) {
try { try {
const res = await getListDepartApi({ projectName }) const res = await getListDepartApi({ projectName })
console.log('🚀 ~ res:', res)
this.departList = res.data this.departList = res.data
console.log('🚀 ~ this.departList:', this.departList)
// departList
if (this.departList && this.departList.length === 1) {
//
const autoSelectItem = this.findLeafNode(this.departList[0]);
if (autoSelectItem) {
this.form.projectUnitId = autoSelectItem.id;
// unitSelect
this.unitSelect(autoSelectItem);
}
}
} catch (error) { } catch (error) {
console.log('🚀 ~ error:', error) console.log('🚀 ~ error:', error)
} }
}, },
//
findLeafNode(node) {
// childrenchildren
if (!node.children || node.children.length === 0) {
return node;
}
//
for (const child of node.children) {
const leafNode = this.findLeafNode(child);
if (leafNode) return leafNode;
}
return null;
},
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset() this.reset()