This commit is contained in:
parent
9714a6edf3
commit
a7b1518097
|
|
@ -50,6 +50,23 @@
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
|
<!-- 退役数量列 -->
|
||||||
|
<el-table-column label="退役数量" align="center" width="115">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input-number
|
||||||
|
v-model="scope.row.retirementNum"
|
||||||
|
:min="0"
|
||||||
|
:max="getRetirementMax(scope.row)"
|
||||||
|
:precision="0"
|
||||||
|
:disabled="isRetirementNumDisabled(scope.row)"
|
||||||
|
controls-position="right"
|
||||||
|
size="mini"
|
||||||
|
style="width: 90px"
|
||||||
|
@change="handleRetirementNumChange(scope.row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="附件" align="center" width="90" :show-overflow-tooltip="true">
|
<el-table-column label="附件" align="center" width="90" :show-overflow-tooltip="true">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||||
|
|
@ -95,10 +112,6 @@
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination
|
||||||
|
|
@ -161,7 +174,7 @@ export default {
|
||||||
{ label: '类目', prop: 'groupName' },
|
{ label: '类目', prop: 'groupName' },
|
||||||
{ label: '名称', prop: 'typeName' },
|
{ label: '名称', prop: 'typeName' },
|
||||||
{ label: '规格型号', prop: 'typeModelName' },
|
{ label: '规格型号', prop: 'typeModelName' },
|
||||||
{ label: '管理模式', prop: 'manageMode' },
|
{ label: '管理模式', prop: 'manageMode', width: 90 },
|
||||||
{ label: '设备编码', prop: 'code' },
|
{ label: '设备编码', prop: 'code' },
|
||||||
{ label: '维修数量', prop: 'repairNum', width: 80 },
|
{ label: '维修数量', prop: 'repairNum', width: 80 },
|
||||||
{
|
{
|
||||||
|
|
@ -172,17 +185,30 @@ export default {
|
||||||
h('el-select', {
|
h('el-select', {
|
||||||
props: {
|
props: {
|
||||||
value: row.isScrap || '',
|
value: row.isScrap || '',
|
||||||
disabled: row.status === '通过' // ⭐ 状态为“通过” → 不可操作
|
disabled: row.status === '通过' // ⭐ 状态为"通过" → 不可操作
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
input: val => {
|
input: val => {
|
||||||
this.$set(row, 'isScrap', val)
|
this.$set(row, 'isScrap', val)
|
||||||
|
|
||||||
|
// 当维修是否合格字段变化时,处理退役数量逻辑
|
||||||
if (val === '0') {
|
if (val === '0') {
|
||||||
|
// 合格:退役数量设为0且不可操作
|
||||||
this.$set(row, 'reasonVal', '')
|
this.$set(row, 'reasonVal', '')
|
||||||
this.$set(row, 'reasonDisabled', true)
|
this.$set(row, 'reasonDisabled', true)
|
||||||
|
this.$set(row, 'retirementNum', 0)
|
||||||
} else {
|
} else {
|
||||||
|
// 不合格:根据管理模式设置退役数量
|
||||||
this.$set(row, 'reasonDisabled', false)
|
this.$set(row, 'reasonDisabled', false)
|
||||||
|
if (row.manageMode === '编码管理') {
|
||||||
|
// 编码管理:退役数量默认为1,不可操作
|
||||||
|
this.$set(row, 'retirementNum', 1)
|
||||||
|
} else {
|
||||||
|
// 数量管理:退役数量保持原值或设为0,可操作
|
||||||
|
if (!row.retirementNum) {
|
||||||
|
this.$set(row, 'retirementNum', 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -245,6 +271,43 @@ export default {
|
||||||
this.getList()
|
this.getList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 判断退役数量字段是否禁用
|
||||||
|
// 判断退役数量字段是否禁用
|
||||||
|
isRetirementNumDisabled(row) {
|
||||||
|
// 状态为"通过"时禁用
|
||||||
|
if (row.status === '通过') return true
|
||||||
|
|
||||||
|
// 未选择维修是否合格时禁用
|
||||||
|
if (!row.isScrap && row.isScrap !== '0') return true
|
||||||
|
|
||||||
|
// 维修合格时禁用
|
||||||
|
if (row.isScrap === '0') return true
|
||||||
|
|
||||||
|
// 编码管理且维修不合格时禁用
|
||||||
|
if (row.manageMode === '编码管理' && row.isScrap === '1') return true
|
||||||
|
|
||||||
|
// 其他情况可操作(数量管理且维修不合格)
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取退役数量的最大值
|
||||||
|
getRetirementMax(row) {
|
||||||
|
// 编码管理设备最大值为1
|
||||||
|
if (row.manageMode === '编码管理') return 1
|
||||||
|
// 数量管理设备最大值为维修数量
|
||||||
|
return row.repairNum || 0
|
||||||
|
},
|
||||||
|
|
||||||
|
// 退役数量变化处理
|
||||||
|
handleRetirementNumChange(row) {
|
||||||
|
// 确保退役数量在有效范围内
|
||||||
|
if (row.retirementNum < 0) {
|
||||||
|
this.$set(row, 'retirementNum', 0)
|
||||||
|
} else if (row.retirementNum > this.getRetirementMax(row)) {
|
||||||
|
this.$set(row, 'retirementNum', this.getRetirementMax(row))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 文件上传成功处理-编码弹窗上传
|
// 文件上传成功处理-编码弹窗上传
|
||||||
// 文件上传成功处理
|
// 文件上传成功处理
|
||||||
handleFileSuccess2(response, file, fileList) {
|
handleFileSuccess2(response, file, fileList) {
|
||||||
|
|
@ -323,7 +386,16 @@ export default {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
try {
|
try {
|
||||||
const res = await getRepairDetailsList({ ...this.queryParams })
|
const res = await getRepairDetailsList({ ...this.queryParams })
|
||||||
this.tableList = res.data || []
|
this.tableList = (res.data || []).map(item => {
|
||||||
|
// 初始化退役数量为0
|
||||||
|
if (item.retirementNum === undefined || item.retirementNum === null) {
|
||||||
|
item.retirementNum = 0
|
||||||
|
}
|
||||||
|
if (item.isScrap=='0'){
|
||||||
|
item.reasonDisabled=true
|
||||||
|
}
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
|
||||||
/** ⭐ 获取列表后同步给弹窗的 selectedMap **/
|
/** ⭐ 获取列表后同步给弹窗的 selectedMap **/
|
||||||
if (this.$refs.addNum && this.$refs.addNum.selectedMap) {
|
if (this.$refs.addNum && this.$refs.addNum.selectedMap) {
|
||||||
|
|
@ -383,6 +455,10 @@ export default {
|
||||||
newRows.forEach(item => {
|
newRows.forEach(item => {
|
||||||
if (item.manageMode === '编码管理') item.repairNum = 1
|
if (item.manageMode === '编码管理') item.repairNum = 1
|
||||||
else if (!item.repairNum) item.repairNum = 1
|
else if (!item.repairNum) item.repairNum = 1
|
||||||
|
// 初始化退役数量为0
|
||||||
|
if (item.retirementNum === undefined || item.retirementNum === null) {
|
||||||
|
item.retirementNum = 0
|
||||||
|
}
|
||||||
if (this.$refs.addNum && this.$refs.addNum.selectedMap) this.$refs.addNum.selectedMap.set(item.keyId, item)
|
if (this.$refs.addNum && this.$refs.addNum.selectedMap) this.$refs.addNum.selectedMap.set(item.keyId, item)
|
||||||
})
|
})
|
||||||
this.tableList = [...this.tableList, ...newRows]
|
this.tableList = [...this.tableList, ...newRows]
|
||||||
|
|
@ -409,6 +485,19 @@ export default {
|
||||||
return this.$message.warning(`【${row.typeName}】请选择退役原因`)
|
return this.$message.warning(`【${row.typeName}】请选择退役原因`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 校验退役数量
|
||||||
|
if (row.isScrap === '1') {
|
||||||
|
// 维修不合格时校验退役数量
|
||||||
|
if (row.retirementNum === undefined || row.retirementNum === null) {
|
||||||
|
return this.$message.warning(`【${row.typeName}】退役数量不能为空`)
|
||||||
|
}
|
||||||
|
if (row.retirementNum <= 0) {
|
||||||
|
return this.$message.warning(`【${row.typeName}】退役数量必须大于0`)
|
||||||
|
}
|
||||||
|
if (row.manageMode === '数量管理' && row.retirementNum > row.repairNum) {
|
||||||
|
return this.$message.warning(`【${row.typeName}】退役数量不能大于维修数量`)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue