This commit is contained in:
parent
9714a6edf3
commit
a7b1518097
|
|
@ -13,39 +13,56 @@
|
|||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="isLoading"
|
||||
:data="tableList"
|
||||
highlight-current-row
|
||||
border
|
||||
stripe
|
||||
:max-height="650"
|
||||
style="width: 100%"
|
||||
v-loading="isLoading"
|
||||
:data="tableList"
|
||||
highlight-current-row
|
||||
border
|
||||
stripe
|
||||
:max-height="650"
|
||||
style="width: 100%"
|
||||
>
|
||||
<!-- 序号列 -->
|
||||
<el-table-column
|
||||
type="index"
|
||||
width="55"
|
||||
label="序号"
|
||||
align="center"
|
||||
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
|
||||
type="index"
|
||||
width="55"
|
||||
label="序号"
|
||||
align="center"
|
||||
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
|
||||
/>
|
||||
|
||||
<!-- 动态列 -->
|
||||
<el-table-column
|
||||
v-for="(column, index) in tableColumns"
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:width="column.width"
|
||||
:min-width="column.minWidth"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
v-for="(column, index) in tableColumns"
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:prop="column.prop"
|
||||
:width="column.width"
|
||||
:min-width="column.minWidth"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<span v-if="!column.render">{{ scope.row[column.prop] }}</span>
|
||||
<component
|
||||
v-else
|
||||
:is="{ render: (h) => column.render(h, { row: scope.row }) }"
|
||||
v-else
|
||||
:is="{ render: (h) => column.render(h, { row: scope.row }) }"
|
||||
/>
|
||||
</template>
|
||||
</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>
|
||||
|
|
@ -54,22 +71,22 @@
|
|||
<template slot-scope="scope">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:limit="3"
|
||||
:headers="upload.headers"
|
||||
:action="upload.url"
|
||||
:show-file-list="false"
|
||||
accept=".png, .jpg, .jpeg, .pdf, .doc, .docx"
|
||||
:on-success="handleFileSuccess2"
|
||||
:auto-upload="true"
|
||||
ref="upload"
|
||||
:limit="3"
|
||||
:headers="upload.headers"
|
||||
:action="upload.url"
|
||||
:show-file-list="false"
|
||||
accept=".png, .jpg, .jpeg, .pdf, .doc, .docx"
|
||||
:on-success="handleFileSuccess2"
|
||||
:auto-upload="true"
|
||||
>
|
||||
<el-button :disabled="scope.row.status && scope.row.status === '通过'" size="mini" type="text" @click="beforeFileUpload(scope.row)">上传</el-button>
|
||||
</el-upload>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
@click="picturePreview(scope.row)"
|
||||
v-if="scope.row.bmFileInfos && scope.row.bmFileInfos.length > 0"
|
||||
size="mini"
|
||||
type="text"
|
||||
@click="picturePreview(scope.row)"
|
||||
v-if="scope.row.bmFileInfos && scope.row.bmFileInfos.length > 0"
|
||||
>
|
||||
查看
|
||||
</el-button>
|
||||
|
|
@ -95,18 +112,14 @@
|
|||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
|
||||
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
|
|
@ -161,7 +174,7 @@ export default {
|
|||
{ label: '类目', prop: 'groupName' },
|
||||
{ label: '名称', prop: 'typeName' },
|
||||
{ label: '规格型号', prop: 'typeModelName' },
|
||||
{ label: '管理模式', prop: 'manageMode' },
|
||||
{ label: '管理模式', prop: 'manageMode', width: 90 },
|
||||
{ label: '设备编码', prop: 'code' },
|
||||
{ label: '维修数量', prop: 'repairNum', width: 80 },
|
||||
{
|
||||
|
|
@ -172,17 +185,30 @@ export default {
|
|||
h('el-select', {
|
||||
props: {
|
||||
value: row.isScrap || '',
|
||||
disabled: row.status === '通过' // ⭐ 状态为“通过” → 不可操作
|
||||
disabled: row.status === '通过' // ⭐ 状态为"通过" → 不可操作
|
||||
},
|
||||
on: {
|
||||
input: val => {
|
||||
this.$set(row, 'isScrap', val)
|
||||
|
||||
// 当维修是否合格字段变化时,处理退役数量逻辑
|
||||
if (val === '0') {
|
||||
// 合格:退役数量设为0且不可操作
|
||||
this.$set(row, 'reasonVal', '')
|
||||
this.$set(row, 'reasonDisabled', true)
|
||||
this.$set(row, 'retirementNum', 0)
|
||||
} else {
|
||||
// 不合格:根据管理模式设置退役数量
|
||||
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()
|
||||
},
|
||||
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) {
|
||||
|
|
@ -323,7 +386,16 @@ export default {
|
|||
this.isLoading = true
|
||||
try {
|
||||
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 **/
|
||||
if (this.$refs.addNum && this.$refs.addNum.selectedMap) {
|
||||
|
|
@ -383,6 +455,10 @@ export default {
|
|||
newRows.forEach(item => {
|
||||
if (item.manageMode === '编码管理') 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)
|
||||
})
|
||||
this.tableList = [...this.tableList, ...newRows]
|
||||
|
|
@ -409,6 +485,19 @@ export default {
|
|||
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 = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue