This commit is contained in:
parent
9714a6edf3
commit
a7b1518097
|
|
@ -13,39 +13,56 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
v-loading="isLoading"
|
v-loading="isLoading"
|
||||||
:data="tableList"
|
:data="tableList"
|
||||||
highlight-current-row
|
highlight-current-row
|
||||||
border
|
border
|
||||||
stripe
|
stripe
|
||||||
:max-height="650"
|
:max-height="650"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<!-- 序号列 -->
|
<!-- 序号列 -->
|
||||||
<el-table-column
|
<el-table-column
|
||||||
type="index"
|
type="index"
|
||||||
width="55"
|
width="55"
|
||||||
label="序号"
|
label="序号"
|
||||||
align="center"
|
align="center"
|
||||||
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
|
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 动态列 -->
|
<!-- 动态列 -->
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-for="(column, index) in tableColumns"
|
v-for="(column, index) in tableColumns"
|
||||||
:key="index"
|
:key="index"
|
||||||
:label="column.label"
|
:label="column.label"
|
||||||
:prop="column.prop"
|
:prop="column.prop"
|
||||||
:width="column.width"
|
:width="column.width"
|
||||||
:min-width="column.minWidth"
|
:min-width="column.minWidth"
|
||||||
align="center"
|
align="center"
|
||||||
show-overflow-tooltip
|
show-overflow-tooltip
|
||||||
>
|
>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span v-if="!column.render">{{ scope.row[column.prop] }}</span>
|
<span v-if="!column.render">{{ scope.row[column.prop] }}</span>
|
||||||
<component
|
<component
|
||||||
v-else
|
v-else
|
||||||
:is="{ render: (h) => column.render(h, { row: scope.row }) }"
|
: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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -54,22 +71,22 @@
|
||||||
<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">
|
||||||
<el-upload
|
<el-upload
|
||||||
ref="upload"
|
ref="upload"
|
||||||
:limit="3"
|
:limit="3"
|
||||||
:headers="upload.headers"
|
:headers="upload.headers"
|
||||||
:action="upload.url"
|
:action="upload.url"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
accept=".png, .jpg, .jpeg, .pdf, .doc, .docx"
|
accept=".png, .jpg, .jpeg, .pdf, .doc, .docx"
|
||||||
:on-success="handleFileSuccess2"
|
:on-success="handleFileSuccess2"
|
||||||
:auto-upload="true"
|
:auto-upload="true"
|
||||||
>
|
>
|
||||||
<el-button :disabled="scope.row.status && scope.row.status === '通过'" size="mini" type="text" @click="beforeFileUpload(scope.row)">上传</el-button>
|
<el-button :disabled="scope.row.status && scope.row.status === '通过'" size="mini" type="text" @click="beforeFileUpload(scope.row)">上传</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
@click="picturePreview(scope.row)"
|
@click="picturePreview(scope.row)"
|
||||||
v-if="scope.row.bmFileInfos && scope.row.bmFileInfos.length > 0"
|
v-if="scope.row.bmFileInfos && scope.row.bmFileInfos.length > 0"
|
||||||
>
|
>
|
||||||
查看
|
查看
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -95,18 +112,14 @@
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination
|
||||||
v-show="total > 0"
|
v-show="total > 0"
|
||||||
:total="total"
|
:total="total"
|
||||||
:page.sync="queryParams.pageNum"
|
:page.sync="queryParams.pageNum"
|
||||||
:limit.sync="queryParams.pageSize"
|
:limit.sync="queryParams.pageSize"
|
||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
|
@ -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