This commit is contained in:
parent
7dd27e57eb
commit
58a2fb721b
|
|
@ -18,6 +18,14 @@ export const addRepairData = (data = {}) => {
|
|||
})
|
||||
}
|
||||
|
||||
export const updateRepairData = (data = {}) => {
|
||||
return request({
|
||||
url: '/material-mall/repair/updateRepairData',
|
||||
method: 'POST',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 获取维修列表
|
||||
export const getRepairList = (data) => {
|
||||
return request({
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
:data="tableList"
|
||||
border stripe
|
||||
height="550px"
|
||||
:row-key="row => `${row.id}-${row.type}`"
|
||||
:row-key="row => row.keyId"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="50" :reserve-selection="true"/>
|
||||
|
|
@ -95,29 +95,12 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
openDialog(applyId, selectedRows = []) {
|
||||
openDialog(applyId) {
|
||||
this.applyId = applyId
|
||||
this.visible = true
|
||||
|
||||
// 初始化 selectedMap
|
||||
this.selectedMap.clear()
|
||||
|
||||
// 添加数据到 selectedMap
|
||||
selectedRows.forEach(row => {
|
||||
if (row.keyId) {
|
||||
this.selectedMap.set(row.keyId, {
|
||||
...row,
|
||||
repairNum: row.repairNum || (row.manageMode === '编码管理' ? 1 : 1)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
this.getList()
|
||||
this.getList() // 弹窗内部拉取完整数据并恢复勾选
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
setFixNumToTableList(row, val) {
|
||||
const index = this.tableList.findIndex(x => x.keyId === row.keyId)
|
||||
if (index !== -1) {
|
||||
|
|
@ -149,21 +132,26 @@ export default {
|
|||
const rows = res.data || []
|
||||
|
||||
this.tableList = rows.map(item => {
|
||||
const selected = item.keyId ? this.selectedMap.get(item.keyId) : null
|
||||
const key = item.keyId
|
||||
|
||||
const selected = this.selectedMap.get(key)
|
||||
const isCodeManage = item.manageMode === "编码管理"
|
||||
|
||||
return {
|
||||
...item,
|
||||
keyId: key, // ⭐ 统一 row-key 与 selectedMap key
|
||||
repairNum: selected ? selected.repairNum : isCodeManage ? 1 : ""
|
||||
}
|
||||
})
|
||||
|
||||
// 过滤 selectedMap,只保留 tableList 中存在的 keyId
|
||||
const tableKeys = new Set(this.tableList.map(r => r.keyId))
|
||||
Array.from(this.selectedMap.keys()).forEach(key => {
|
||||
if (!tableKeys.has(key)) this.selectedMap.delete(key)
|
||||
})
|
||||
this.$nextTick(() => {
|
||||
if (this.restoreSelection) this.restoreSelection()
|
||||
})
|
||||
|
||||
this.$nextTick(() => this.restoreSelection())
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
|
|
@ -172,14 +160,12 @@ export default {
|
|||
restoreSelection() {
|
||||
if (!this.$refs.multipleTable) return
|
||||
this.tableList.forEach(row => {
|
||||
if (row.keyId && this.selectedMap.has(row.keyId)) {
|
||||
if (this.selectedMap.has(row.keyId)) {
|
||||
this.$refs.multipleTable.toggleRowSelection(row, true)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
handleQuery() {
|
||||
this.getList()
|
||||
},
|
||||
|
|
@ -194,7 +180,7 @@ export default {
|
|||
if (row.keyId && !this.selectedMap.has(row.keyId)) {
|
||||
this.selectedMap.set(row.keyId, { ...row })
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
this.tableList.forEach(row => {
|
||||
if (row.keyId && !selection.some(s => s.keyId === row.keyId)) {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
:on-success="handleFileSuccess2"
|
||||
:auto-upload="true"
|
||||
>
|
||||
<el-button 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-button
|
||||
size="mini"
|
||||
|
|
@ -76,10 +76,21 @@
|
|||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="routerParams.isEdit" label="状态" align="center" prop="status" width="90">
|
||||
<template #default="scope">
|
||||
<el-tag
|
||||
:type="scope.row.status === '通过' ? 'success' : scope.row.status === '驳回' ? 'danger' : 'warning'"
|
||||
size="small"
|
||||
>
|
||||
{{ scope.row.status }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 操作列 -->
|
||||
<el-table-column label="操作" align="center" width="80px" v-if="!routerParams.isView">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" style="color: red">
|
||||
<el-button :disabled="scope.row.status && scope.row.status === '通过'"
|
||||
size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" style="color: red">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
|
@ -113,7 +124,7 @@
|
|||
import { getListByApplyIdApi, deleteToolApi, updateToolApplyApi } from '@/api/toolsManage'
|
||||
import SelectToolDialog from './SelectToolDialog.vue'
|
||||
import { getToken } from "@/utils/auth";
|
||||
import {addRepairData} from "@/api/equipmentRepair";
|
||||
import {addRepairData, getRepairDetailsList, updateRepairData} from "@/api/equipmentRepair";
|
||||
|
||||
export default {
|
||||
name: 'AddEditTools',
|
||||
|
|
@ -128,7 +139,7 @@ export default {
|
|||
pageSize: 10,
|
||||
parentTypeName: null,
|
||||
typeName: null,
|
||||
manageType: null,
|
||||
manageMode: null,
|
||||
applyId: null,
|
||||
},
|
||||
typeList: [
|
||||
|
|
@ -150,12 +161,7 @@ export default {
|
|||
{ label: '类目', prop: 'groupName' },
|
||||
{ label: '名称', prop: 'typeName' },
|
||||
{ label: '规格型号', prop: 'typeModelName' },
|
||||
{
|
||||
label: '管理模式',
|
||||
prop: 'manageType',
|
||||
width: '80',
|
||||
render: (h, { row }) => h('span', {}, row.manageType === '0' ? '数量管理' : '编码管理')
|
||||
},
|
||||
{ label: '管理模式', prop: 'manageMode' },
|
||||
{ label: '设备编码', prop: 'code' },
|
||||
{ label: '维修数量', prop: 'repairNum', width: 80 },
|
||||
{
|
||||
|
|
@ -163,28 +169,28 @@ export default {
|
|||
prop: 'isScrap',
|
||||
width: '120',
|
||||
render: (h, { row }) =>
|
||||
h('el-select', {
|
||||
props: { value: row.isScrap || '' },
|
||||
on: {
|
||||
input: val => {
|
||||
this.$set(row, 'isScrap', val)
|
||||
h('el-select', {
|
||||
props: {
|
||||
value: row.isScrap || '',
|
||||
disabled: row.status === '通过' // ⭐ 状态为“通过” → 不可操作
|
||||
},
|
||||
on: {
|
||||
input: val => {
|
||||
this.$set(row, 'isScrap', val)
|
||||
|
||||
// === 新增:处理退役原因禁用/清空 ===
|
||||
if (val === '0') {
|
||||
// 选“是” → 清空并禁用退役原因
|
||||
this.$set(row, 'reasonVal', '')
|
||||
this.$set(row, 'reasonDisabled', true)
|
||||
} else {
|
||||
// 选“否” → 允许填写
|
||||
this.$set(row, 'reasonDisabled', false)
|
||||
}
|
||||
if (val === '0') {
|
||||
this.$set(row, 'reasonVal', '')
|
||||
this.$set(row, 'reasonDisabled', true)
|
||||
} else {
|
||||
this.$set(row, 'reasonDisabled', false)
|
||||
}
|
||||
},
|
||||
style: 'width: 90px'
|
||||
}, [
|
||||
h('el-option', { props: { label: '是', value: '0' } }),
|
||||
h('el-option', { props: { label: '否', value: '1' } }),
|
||||
])
|
||||
}
|
||||
},
|
||||
style: 'width: 90px'
|
||||
}, [
|
||||
h('el-option', { props: { label: '是', value: '0' } }),
|
||||
h('el-option', { props: { label: '否', value: '1' } })
|
||||
])
|
||||
},
|
||||
{
|
||||
label: '维修日期',
|
||||
|
|
@ -196,9 +202,12 @@ export default {
|
|||
type: 'date',
|
||||
placeholder: '选择日期',
|
||||
format: 'yyyy-MM-dd',
|
||||
'value-format': 'yyyy-MM-dd'
|
||||
'value-format': 'yyyy-MM-dd',
|
||||
disabled: row.status === '通过' // ⭐ 禁用
|
||||
},
|
||||
on: {
|
||||
input: val => this.$set(row, 'repairTime', val)
|
||||
},
|
||||
on: { input: val => this.$set(row, 'repairTime', val) },
|
||||
style: 'width: 140px'
|
||||
})
|
||||
},
|
||||
|
|
@ -207,17 +216,19 @@ export default {
|
|||
prop: 'reasonVal',
|
||||
width: '120',
|
||||
render: (h, { row }) =>
|
||||
h('el-select', {
|
||||
props: {
|
||||
value: row.reasonVal || '',
|
||||
disabled: row.reasonDisabled === true // ⭐ 根据维修是否合格禁用
|
||||
},
|
||||
on: { input: val => this.$set(row, 'reasonVal', val) },
|
||||
style: 'width: 90px'
|
||||
}, [
|
||||
h('el-option', { props: { label: '人为', value: '人为' } }),
|
||||
h('el-option', { props: { label: '自然', value: '自然' } })
|
||||
])
|
||||
h('el-select', {
|
||||
props: {
|
||||
value: row.reasonVal || '',
|
||||
disabled: row.reasonDisabled === true || row.status === '通过' // ⭐ 禁用条件合并
|
||||
},
|
||||
on: {
|
||||
input: val => this.$set(row, 'reasonVal', val)
|
||||
},
|
||||
style: 'width: 90px'
|
||||
}, [
|
||||
h('el-option', { props: { label: '人为', value: '人为' } }),
|
||||
h('el-option', { props: { label: '自然', value: '自然' } })
|
||||
])
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
@ -225,10 +236,10 @@ export default {
|
|||
created() {
|
||||
this.routerParams = this.$route.query
|
||||
let title = '新增维修'
|
||||
if (this.routerParams.isView) title = '查看工具'
|
||||
else if (this.routerParams.isEdit) title = '编辑工具'
|
||||
if (this.routerParams.isView) title = '维修查看'
|
||||
else if (this.routerParams.isEdit) title = '维修编辑'
|
||||
|
||||
this.queryParams.applyId = this.routerParams.applyId || ''
|
||||
this.queryParams.id = this.routerParams.applyId || ''
|
||||
const obj = Object.assign({}, this.$route, { title })
|
||||
this.$tab.updatePage(obj)
|
||||
this.getList()
|
||||
|
|
@ -253,6 +264,8 @@ export default {
|
|||
if (!targetRow.bmFileInfos) {
|
||||
this.$set(targetRow, 'bmFileInfos', [])
|
||||
}
|
||||
//先清空bmFileInfos
|
||||
targetRow.bmFileInfos=[]
|
||||
// 将文件对象添加到 bmFileInfos 中
|
||||
targetRow.bmFileInfos.push(obj)
|
||||
this.$message.success('文件上传成功')
|
||||
|
|
@ -287,7 +300,12 @@ export default {
|
|||
const file = row.bmFileInfos[row.bmFileInfos.length - 1]
|
||||
console.log('预览文件:', file)
|
||||
this.dialogImageUrl = file.fileUrl.replaceAll('#', '%23')
|
||||
const parts = file.fileName.split('.')
|
||||
// 从URL中提取文件名
|
||||
const urlParts = file.fileUrl.split('/');
|
||||
const fileNameWithParams = urlParts[urlParts.length - 1];
|
||||
// 去除URL参数,获取纯文件名
|
||||
const fileName = fileNameWithParams.split('?')[0];
|
||||
const parts = fileName.split('.')
|
||||
const extension = parts.pop().toLowerCase()
|
||||
if (['doc', 'docx', 'pdf'].includes(extension)) {
|
||||
const windowName = file.fileName
|
||||
|
|
@ -304,10 +322,31 @@ export default {
|
|||
async getList() {
|
||||
this.isLoading = true
|
||||
try {
|
||||
const res = await getListByApplyIdApi({ ...this.queryParams })
|
||||
this.tableList = res.rows || []
|
||||
this.total = res.total || 0
|
||||
} finally { this.isLoading = false }
|
||||
const res = await getRepairDetailsList({ ...this.queryParams })
|
||||
this.tableList = res.data || []
|
||||
|
||||
/** ⭐ 获取列表后同步给弹窗的 selectedMap **/
|
||||
if (this.$refs.addNum && this.$refs.addNum.selectedMap) {
|
||||
const dialog = this.$refs.addNum
|
||||
// 清空旧的
|
||||
dialog.selectedMap.clear()
|
||||
// 将 tableList 里的所有 keyId 放入 selectedMap
|
||||
this.tableList.forEach(row => {
|
||||
dialog.selectedMap.set(row.keyId, row)
|
||||
})
|
||||
// 如果弹窗内还有 tableList,需要保持一致
|
||||
dialog.tableList = [...this.tableList]
|
||||
|
||||
// 让弹窗恢复勾选状态(如果有 restoreSelection 方法)
|
||||
dialog.$nextTick(() => {
|
||||
if (dialog.restoreSelection) dialog.restoreSelection()
|
||||
})
|
||||
}
|
||||
|
||||
this.total = this.tableList.length
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
handleDelete(row) {
|
||||
this.$confirm('确定删除该条数据?', '提示', { type: 'warning' }).then(() => {
|
||||
|
|
@ -322,7 +361,7 @@ export default {
|
|||
this.$message.success('删除成功')
|
||||
})
|
||||
},
|
||||
handleNumDialog() { if (this.$refs.addNum) this.$refs.addNum.openDialog(this.queryParams.applyId, this.tableList) },
|
||||
handleNumDialog() { if (this.$refs.addNum) this.$refs.addNum.openDialog(this.queryParams.applyId) },
|
||||
handleAddFromDialog(rows) {
|
||||
if (!rows || rows.length === 0) return
|
||||
const existingKeys = new Set(this.tableList.map(item => item.keyId))
|
||||
|
|
@ -359,6 +398,7 @@ export default {
|
|||
}
|
||||
|
||||
const payload = {
|
||||
changeId:this.routerParams.applyId,
|
||||
toBeRepairList: this.tableList
|
||||
}
|
||||
|
||||
|
|
@ -366,7 +406,12 @@ export default {
|
|||
|
||||
this.isLoading = true
|
||||
try {
|
||||
const res = await addRepairData(payload)
|
||||
let res;
|
||||
if (this.routerParams.isEdit){
|
||||
res = await updateRepairData(payload)
|
||||
} else {
|
||||
res = await addRepairData(payload)
|
||||
}
|
||||
if (res.code ==200){
|
||||
this.$message.success('操作成功!')
|
||||
this.$tab.closeOpenPage({ path: './repairList' })
|
||||
|
|
|
|||
|
|
@ -72,18 +72,12 @@
|
|||
:prop="column.prop"
|
||||
align="center"
|
||||
>
|
||||
<!-- <!– 插槽 –>-->
|
||||
<!-- <template v-slot="{ row }" v-if="column.prop == 'status'">-->
|
||||
<!-- <el-tag v-if="row.status == '0'" type="info">草稿</el-tag>-->
|
||||
<!-- <el-tag v-if="row.status == '1'" type="warning">审批中</el-tag>-->
|
||||
<!-- <el-tag v-if="row.status == '2'" type="success">已审批</el-tag>-->
|
||||
<!-- </template>-->
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button v-if="row.status != '已驳回'" size="mini" type="text" icon="el-icon-zoom-in" @click="handleView(row)">查看</el-button>
|
||||
<el-button v-if="row.status == '已驳回'" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button v-if="row.status == '已驳回'" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(row)" style="color: red"
|
||||
<el-button size="mini" type="text" icon="el-icon-zoom-in" @click="handleView(row)">查看</el-button>
|
||||
<el-button v-if="row.status == '驳回待处理' || row.status == '全部驳回'" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button v-if="row.status == '待审核' || row.status == '全部驳回'" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(row)" style="color: red"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
|
|
@ -122,9 +116,11 @@ export default {
|
|||
endTime: null,
|
||||
},
|
||||
statusList: [
|
||||
{ label: '待审核', value: '待审核' },
|
||||
{ label: '审核中', value: '审核中' },
|
||||
{ label: '已审核', value: '已审核' },
|
||||
{ label: '已驳回', value: '已驳回' },
|
||||
{ label: '驳回待处理', value: '驳回待处理' },
|
||||
{ label: '全部通过', value: '全部通过' },
|
||||
{ label: '全部驳回', value: '全部驳回' },
|
||||
],
|
||||
total: 0, // 总条数
|
||||
// 表头
|
||||
|
|
@ -185,7 +181,7 @@ export default {
|
|||
},
|
||||
// 编辑
|
||||
handleEdit(row) {
|
||||
this.$router.push({ path: '/toolsManage/addTools', query: { applyId: row.id, isEdit: true } })
|
||||
this.$router.push({ path: './addRepair', query: { applyId: row.id, isEdit: true } })
|
||||
},
|
||||
// 删除
|
||||
handleDelete(row) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button size="mini" type="text" icon="el-icon-zoom-in" @click="handleView(row)">查看</el-button>
|
||||
<el-button v-if="row.status == '审核中'" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">审核</el-button>
|
||||
<el-button v-if="row.status == '待审核' || row.status == '审核中'" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">审核</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
@ -109,9 +109,11 @@ export default {
|
|||
endTime: null,
|
||||
},
|
||||
statusList: [
|
||||
{ label: '待审核', value: '待审核' },
|
||||
{ label: '审核中', value: '审核中' },
|
||||
{ label: '已审核', value: '已审核' },
|
||||
{ label: '已驳回', value: '已驳回' },
|
||||
{ label: '驳回待处理', value: '驳回待处理' },
|
||||
{ label: '全部通过', value: '全部通过' },
|
||||
{ label: '全部驳回', value: '全部驳回' },
|
||||
],
|
||||
total: 0, // 总条数
|
||||
// 表头
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ export default {
|
|||
if (res.code == 200) {
|
||||
this.$message.success('通过成功!')
|
||||
} else {
|
||||
this.$message.error(res.msg || '通过失败')
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
} catch (error) {
|
||||
this.$message.error('通过失败')
|
||||
|
|
|
|||
Loading…
Reference in New Issue