工地直转修正
This commit is contained in:
parent
97645a20c3
commit
d049659ab6
|
|
@ -277,7 +277,7 @@
|
|||
:row-key="getRowKey"
|
||||
@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">
|
||||
<template slot-scope="scope">
|
||||
{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
|
||||
|
|
@ -392,6 +392,8 @@ export default {
|
|||
{ label: '设备编码', prop: 'maCode' },
|
||||
{ label: '计量单位', prop: 'unitName' },
|
||||
{ label: '在用数量', prop: 'useNum' },
|
||||
{ label: '待转数量', prop: 'waitTransNum' },
|
||||
{ label: '可转数量', prop:'transNum' },
|
||||
{ label: '领料人', prop: 'leasePerson' },
|
||||
{ label: '领料日期', prop: 'startTime' }
|
||||
],
|
||||
|
|
@ -856,6 +858,15 @@ export default {
|
|||
loading.close()
|
||||
}
|
||||
},
|
||||
|
||||
checkSelectable(row) {
|
||||
if(row.transNum==0){
|
||||
return false
|
||||
}else{
|
||||
return true
|
||||
}
|
||||
},
|
||||
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(currentPageSelectedRows) {
|
||||
// 如果正在恢复选中状态,忽略此事件
|
||||
|
|
@ -886,7 +897,7 @@ export default {
|
|||
currentPageSelectedRows.forEach(row => {
|
||||
const completeRow = {
|
||||
...row,
|
||||
directNum: row.directNum || row.useNum,
|
||||
directNum: row.directNum || row.transNum,
|
||||
isActive: true
|
||||
}
|
||||
this.selectedDataArray.push(completeRow)
|
||||
|
|
@ -897,8 +908,8 @@ export default {
|
|||
this.equipmentList.forEach(item => {
|
||||
const isSelected = currentPageSelectedRows.some(selectedRow => this.getRowKey(selectedRow) === this.getRowKey(item))
|
||||
item.isActive = isSelected
|
||||
if (isSelected && !item.directNum && item.useNum) {
|
||||
item.directNum = item.useNum
|
||||
if (isSelected && !item.directNum && item.transNum) {
|
||||
item.directNum = item.transNum
|
||||
} else if (!isSelected && !this.isEdit && !this.isDetail) {
|
||||
item.directNum = undefined
|
||||
}
|
||||
|
|
@ -921,10 +932,10 @@ export default {
|
|||
} else {
|
||||
row.directNum = Number(String(row.directNum).replace(/[^\d]/g, ''))
|
||||
}
|
||||
if (row.directNum > row.useNum) {
|
||||
this.$message.error('直转数量不能大于领料数量')
|
||||
if (row.directNum > row.transNum) {
|
||||
this.$message.error('直转数量不能大于可转数量')
|
||||
this.$nextTick(() => {
|
||||
row.directNum = row.useNum
|
||||
row.directNum = row.transNum
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -887,14 +887,38 @@ export default {
|
|||
async getListDepart(projectName) {
|
||||
try {
|
||||
const res = await getListDepartApi({ projectName })
|
||||
console.log('🚀 ~ res:', res)
|
||||
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) {
|
||||
console.log('🚀 ~ error:', error)
|
||||
}
|
||||
},
|
||||
|
||||
// 辅助方法:查找树形结构中的叶子节点
|
||||
findLeafNode(node) {
|
||||
// 如果节点没有children或children为空,则认为是叶子节点
|
||||
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() {
|
||||
this.reset()
|
||||
|
|
|
|||
Loading…
Reference in New Issue